Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use threads with ROOT #1103

Merged
merged 5 commits into from
Oct 18, 2013
Merged

Conversation

Dr15Jones
Copy link
Contributor

Use InitRootHandlers to make all the necessary calls to ROOT to enable ROOT's "thread safe" mode. This includes telling ROOT early that we will be using threads and then on each thread creating a dummy instance of TThread. The actual order of calling is handled by EventProcessor by calling through to the appropriate virtual function of RootHandlers. Also, all classes which inherit from TClassStreamer need to have a proper Generate() method since it is now called to create a copy of that class for each thread.

For ROOT 5 we must load all plugins before starting the threaded event processing. Therefore I added an option to turn on loading of all dictionaries up front. Also, ROOT requires us to call TThread::Initialize() in order to get ROOT to use internal mutexes.
…thod

If you tell ROOT that it needs to be thread safe, it then expects all classes inheriting from TClassStreamer to implement the Generate() method. The method simply uses the copy constructor of the object to return a ‘new’ed version of the object.
We must follow ROOT’s rule which requires a dummy TThread instance be created in each operating system thread in order to create their own thread local storage. Given that we don’t know what thread a TBB task will be run, for right now we create a thread local static TThread on the function which is called from both the main thread and by TBB tasks in order to process events.
Instead of spreading around the different calls needed to setup ROOT for threading, all the methods are concentrated in InitRootHandlers. The EventProcessor then calls the correct virtual methods of the base class RootHandlers Service interface to handle the setup.
@cmsbuild
Copy link
Contributor

A new Pull Request was created by @Dr15Jones (Chris Jones) for CMSSW_7_0_THREADED_X.

Use threads with ROOT

It involves the following packages:

FWCore/Utilities
FWCore/Services
DataFormats/Streamer
DataFormats/Common
FWCore/Framework

@smuzaffar, @Dr15Jones, @ktf, @nclopezo can you please review it and eventually sign? Thanks.
@wmtan this is something you requested to watch as well.
You can sign-off by replying to this message having '+1' in the first line of your reply.
You can reject by replying to this message having '-1' in the first line of your reply.

@Dr15Jones
Copy link
Contributor Author

+1

Passes all framework unit tests. Plus when combined with all other recent thread-safety commits and the recent ROOT fixes, helgrind does not find any 'true' race conditions when applied to a test which reads from one ROOT file and writes to another ROOT file while using 2 streams and 2 threads.

@cmsbuild
Copy link
Contributor

This pull request is fully signed and it will be integrated in one of the next IBs unless changes or unless it breaks tests.

ktf added a commit that referenced this pull request Oct 18, 2013
Multi-threaded fixes -- Use threads with ROOT
@ktf ktf merged commit 0639b14 into cms-sw:CMSSW_7_0_THREADED_X Oct 18, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants