Message: How to correctly (most efficiently) collect thread local data? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question How to correctly (most efficiently) collect thread local data? 

Forum: Multithreading
Date: 01 Jul, 2016
From: <nirpshah>

Hey Geant users,

I'm building a simulation that's basically a gamma source (662 keV) and a detector. The detector is a sensitive detector so I can gather hit information like the position of interaction, energy deposited, etc. The non-MT version, to the best of my knowledge, works fine and runs a million particles in a few minutes. When I MT on my desktop to 15 workers + 1 master (8 core hyperthreaded intel processor), I get a similar speed: 1 million particles in a few minutes. I would expect the speed to be 10x faster but it isn't.

So my question is, how do I collect the thread local hit data when I'm multithreading? Are there any examples I should look at?

Thank you,

Niral

More information:

I'm very new to Geant4 and fairly new to c++ so I lack a lot of knowledge. I used B5 as a guild to build my simulation.

I've tried two methods to collect the event specific hit data. The first was to directly append it to a file in EndOfEventAction (that is, all of the threads write to one file). This method worked but had similar performance and at the time I wasn't using any Mutex locks so I was concerned about data integrity. I thought maybe the writing was slowing Geant4, so then I built a DataCollector class that I construct in main() and pass through as a pointer to EndOfEventAction. DataCollector has a bunch of deques that hold all the data I want and at the end of main() I dump them all to a file. This time, I am using Mutex locks so only one thread is writing to the DataCollector at a time. Again, I saw no increase in speed. I am assuming this is because the Mutex locks are preventing the threads from working too fast.

The last idea I have is to run multiple non-MT Geant4 simulations with multiple output files and tie them together at the end.

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

1 None: Re: How to correctly (most efficiently) collect thread local data?   (Makoto Asai - 01 Jul, 2016)
1 None: Re: How to correctly (most efficiently) collect thread local data?   (nirpshah - 01 Jul, 2016)
(_ None: Re: How to correctly (most efficiently) collect thread local data?   (Makoto Asai - 01 Jul, 2016)
1 Question: Re: How to correctly (most efficiently) collect thread local data?   (nirpshah - 01 Jul, 2016)
... 1 Message(s)
2 None: Re: How to correctly (most efficiently) collect thread local data?   (nirpshah - 01 Jul, 2016)
2 News: Re: How to correctly (most efficiently) collect thread local data?   (nirpshah - 12 Jul, 2016)
1 Warning: Re: How to correctly (most efficiently) collect thread local data?   (Andrea Dotti - 12 Jul, 2016)
 Add Message Add Message
to: "How to correctly (most efficiently) collect thread local data?"

 Subscribe Subscribe

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