Message: Re: G4-MT and ROOT Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Feedback Re: G4-MT and ROOT 

Forum: Multithreading
Re: Question G4-MT and ROOT (Andrea Di Simone)
Date: 21 Nov, 2012
From: Andrea Dotti <Andrea Dotti>

Hello Andrea, I've some experience with G4MT & ROOT since I'm porting an application we use to perform G4 validation to the MT version. I can give here my notes and experience. Please consider these are not yet final.

I am having too all kind of crashes with ROOT and MT applications. To better understand the issues I've created a stand-alone MT application that is NOT using G4 at all, but spawns threads. Each thread opens a ROOT file, books an histogram and a TTree. Then fills the two and it closes the file. I get crashes in this application for more than one thread. Thus I can say that there are pieces of code in ROOT that seems not thread safe. If needed I can send you this code so you can test yourself the ROOT classes you need in a MT application.

In particular in my test I've noticed that the following operations are not thread safe: 1- Using a constructor of TH* and TTree objects (this mean objects created on the stack or on the heap are both non-thread safe) 2- TTree::Fill seems to be non thread-safe if the tree contains branches of type "std::vector", in my test if it contains only simple data (bools/doubles/etc) I could run smoothly without crashes. I did not have problems with TH*::Fill 3- Destructors. This implies that also operations like TFile::Close are not thread-safe

For me the problem was solved using a mutex for the non thread-safe parts of the code to make the thread work sequentially. My solution is the same used in ROOT tutorials on the subject:

If you are starting your project from scratch, I suggest you to take a look at the relatively new g4tools package that gives tuple and histogramming facility with ROOT writers (example basic B4 available from 9.5 on how to use it).

Hope this helps, Andrea

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

1 More: Re: G4-MT and ROOT   (Andrea Di Simone - 21 Nov, 2012)
1 Feedback: Re: G4-MT and ROOT   (Andrea Dotti - 21 Nov, 2012)
2 None: Re: G4-MT and ROOT   (Andrea Di Simone - 21 Nov, 2012)
 Add Message Add Message
to: "Re: G4-MT and ROOT"

 Subscribe Subscribe

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