Message: Re: How to split file reading between cores Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Re: How to split file reading between cores 

Forum: Multithreading
Re: Question How to split file reading between cores (Volodymyr Rodin)
Re: Feedback Re: How to split file reading between cores (Jonathan Madsen)
Date: Feb 15, 14:52
From: Volodymyr Rodin <Volodymyr Rodin>

Hi Jonathan

> One possible way to do this would be to read all the parameters into
> memory on the master thread and in your primary generator action, just
> have each event either pop a "beam parameter" out of the global list
> (use a mutex) or increment an index that tells the threads which "beam
> parameter" index to use (use an atomic)

Unfortunately, the problem still remains. My beam parameters were originally stored in a global vector. I have defined an index in PrimaryGenerator header.

 std::atomic<G4int> file_pos;

And a function:

G4int increment(){
    	   file_pos++;
    	   return file_pos.load();
       }

And in GeneratePrimaries() called it as:

 increment(); 

Probably it doesn't work because Geant4 creates a separate copy of PrimaryGenerator for each core.

Thanks for the help,

Volodymyr

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Feedback: Re: How to split file reading between cores   (Jonathan Madsen - Feb 15, 15:59)
(_ Feedback: Re: How to split file reading between cores   (Volodymyr Rodin - Feb 15, 17:22)
(_ Ok: Re: How to split file reading between cores   (Volodymyr Rodin - Feb 16, 10:18)
(_ Question: Re: How to split file reading between cores   (Michael H. Kelsey - Feb 17, 10:22)
1 Ok: Re: How to split file reading between cores   (Volodymyr Rodin - Feb 18, 04:06)
1 Feedback: Re: How to split file reading between cores   (Jonathan Madsen - Feb 18, 07:24)
2 Feedback: Re: How to split file reading between cores   (Jonathan Madsen - Feb 18, 07:57)
 Add Message Add Message
to: "Re: How to split file reading between cores"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews