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

Rebase of the CMSSW_7_1_THREADED_X branch on top of CMSSW_7_1_X #3461

Merged
merged 50 commits into from Apr 28, 2014

Commits on Apr 24, 2014

  1. The variable remainingEvents_ may be read by multiple threads simulta…

    …nously so must be atomic
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    20c7b96 View commit details
    Browse the repository at this point in the history
  2. First version to actually process multiple events concurrently

    This version uses a TBB task per Stream to process Events with a mutex used to protect the Source in a critical section. This is sufficient to test the thread safety of the framework internals.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    4dc580d View commit details
    Browse the repository at this point in the history
  3. Propagate exceptions thrown during processing to the main thread

    The EventProcessor now uses the new C++11 std::exception_ptr, std::current_exception() and std:rethrow_exception() to capture a thrown exception in a thread processing an event and then transfer that exception to the main thread to be rethrown. We use an std::atomic to provide thread safe update of the std::exception_ptr member data in the case of multiple processing threads having an exception. In such a case, only one of the exceptions will be kept.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    7c80d45 View commit details
    Browse the repository at this point in the history
  4. Added classes to managed resources shared by multiple modules

    The SharedResourcesRegistry is the centralized place where resources are registered and where the framework can get SharedResourcesAcquirer instances. These two classes work together to allow safe sharing of non-thread safe resources between modules. A unit test is included to test the two classes.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    af13a91 View commit details
    Browse the repository at this point in the history
  5. Switched to using recursive_mutex and moved SharedResourcesAcquirer.h…

    … to interface
    
    In order to more easily accommodate unscheduled execution, I switched from using a mutex to a recursive_mutex. This will be less performant since the locks will be held longer than might be needed but it is easier to implement initially. A more performant way would be to release the locks temporarily while we are doing a ‘edm::Event::getBy*’ call.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    4c388eb View commit details
    Browse the repository at this point in the history
  6. Made legacy modules thread safe

    Now uses a std::mutex to guarantee a module instance is only processing one event at a time. Also uses a edm::SharedResourcesAcquirer to get the legacy resource and therefore guarantee only one legacy module is running at a time.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    26ba0da View commit details
    Browse the repository at this point in the history
  7. Use the SharedResourcesAcquirer when a ‘one’ type module declares a S…

    …haredResource
    
    All ‘one’ style base classes now hold a SharedResourcesAcquirer and use a new virtual function ‘createAcquirer()’ which by default returns an empty SharedResourcesAcquirer instance. If the module declares the use of a ‘SharedResource’ then the ‘createAcquirer()’ method will be overridden and return an instance with the needed resources. To facility this, edm::one::imll::SharedResourcesUser had to be changed to a templated class.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    fa25861 View commit details
    Browse the repository at this point in the history
  8. Need to explicitly instantiate the SharedResourcesUser templated class

    The SharedResourcesUser class was just changed to a template. As with the other implementor types, this needs to be explicitly instantiated.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    7212d2b View commit details
    Browse the repository at this point in the history
  9. Added missing mutex includes

    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    969d359 View commit details
    Browse the repository at this point in the history
  10. commented out debug printouts

    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    b91697d View commit details
    Browse the repository at this point in the history
  11. Make access to EventSetup thread safe

    Use a global mutex to serialize access to all EventSetup modules and sources. This is overkill but guarantees that if any two modules/sources are sharing a non-thread safe resource we don’t have a problem.  Changed two of the mutable to std::atomics since they are read/written outside of the critical section guarded by the mutex.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    03bd5b5 View commit details
    Browse the repository at this point in the history
  12. Configuration menu
    Copy the full SHA
    16d250c View commit details
    Browse the repository at this point in the history
  13. Added a special resource for DelayedReader

    To allow a DelayedReader to synchronize with itself we want to use a SharedResourcesAcquirer. However, the normal procedure of declaring a resource and then only after all resources have been declared do we get an acquirer isn’t appropriate for this case. Therefore we provide a special resource just for this case.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    e46dbe0 View commit details
    Browse the repository at this point in the history
  14. DelayedReader can now use a SharedResourcesAcquirer

    If a DelayedReader needs to synchronize with itself (and possibly with the Source) the inheriting class can override the sharedResources_() method. The method is used when data products are requested from the DelayedReader.
    If the Source also needs to synchronize with the DelayedReader the inheriting class can override resourceSharedWithDelayedReader_() and return a SharedResourcesAcquirer which uses the same resource as the DelayedReader. The EventProcessor will acquire the resource before calling methods on the Source.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    541d15f View commit details
    Browse the repository at this point in the history
  15. Use new InputSource and DelayedReader APIs to synchronize

    Given that we can’t be reading from the InputSource at the same time as we fill a branch via the RootDelayedReader, we implement the new APIs to allow both the PoolSource and the RootDelayedReader to share a ‘resource’.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    d509d5a View commit details
    Browse the repository at this point in the history
  16. clear the event selector in a thread safe manner

    Moved the sentry used to clear the event selector at the end of each event processing to be within the mutex. This makes sure all updates on that object are done in the same critical section.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    00c920b View commit details
    Browse the repository at this point in the history
  17. Have delayed reading of provenance synchronize with all other reads f…

    …rom PoolSource
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    a05c90d View commit details
    Browse the repository at this point in the history
  18. Tell ROOT we are going to use multiple threads

    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.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    45d32b4 View commit details
    Browse the repository at this point in the history
  19. Configuration menu
    Copy the full SHA
    00f5984 View commit details
    Browse the repository at this point in the history
  20. Classes inheriting from TClassStreamer must implement the Generate me…

    …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.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    cf9a21a View commit details
    Browse the repository at this point in the history
  21. ROOT requires a dummy TThread object be instantiated in each thread

    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.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    092fffe View commit details
    Browse the repository at this point in the history
  22. Have InitRootHandlers handle setting up ROOT for threading

    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.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    22bc087 View commit details
    Browse the repository at this point in the history
  23. Do not fast copy ROOT files if using multiple threads

    Disabled fast copying of ROOT files when we have multiple threads and multiple Streams. This must be done since fast copying requires the output file to record all the events from the input in the same order as stored in the input. This is not guaranteed when we do multiple threads.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    7daf72d View commit details
    Browse the repository at this point in the history
  24. Fail at run time if Service uses an obsolete signal.

    The threaded framework requires Services to switch to a new collection
    of signals. To allow easier migration, the obsolete signals have been
    replaced with a class which causes an Exception to be thrown if their
    connect method is called.
    Had to change one unit test which was making use of the old signals.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    d7db4bb View commit details
    Browse the repository at this point in the history
  25. RandomNumberGeneratorService Threaded

    Modifications to make the random number generator
    service work with the multithreaded Framework.
    The interface now requires a StreamID or
    LuminosityBlockIndex argument to the getEngine
    function. For each module, there will an
    engine for each stream and also each concurrent
    luminosity block instead of being just one
    per module. This is necessary to prevent data races.
    The service now uses the new callbacks for the
    threaded Framework. This required extensive revisions
    to the internals of the service and also to
    the related unit tests. If all modules use
    the new getEngine interface, the service
    will support multiple threads, forking
    (but not multiple threads and forking in the
    same job), and replay.
    
    Temporarily the old interface still works while clients
    are transitioned to the new interface. But modules
    using the old interface must be ONE or LEGACY
    type modules (not GLOBAL OR STREAM). If any modules
    use the old interface, then both replay and
    multiprocess forking will be broken.
    wddgit authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    693abf7 View commit details
    Browse the repository at this point in the history
  26. fix InputSource after automatic merging of cms-sw#1575 in the THREADE…

    …D branch
    fwyzard authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    abb7059 View commit details
    Browse the repository at this point in the history
  27. Fix unit tests for Random Numbers. This is for the threaded

    branch only. Affects unit tests only. Reference files needed
    updating plus minor cleanup. The change that caused this problem
    was cleanly merged from the 7_0_X branch, but I did not notice
    the unit test reference files needed to be different on the
    threaded branch. One conflicted and the other did not exist
    in 7_0_X.
    wddgit authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    1bd77d2 View commit details
    Browse the repository at this point in the history
  28. Don't use obsolete signals

    wmtan authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    2bc2f92 View commit details
    Browse the repository at this point in the history
  29. Modify behavior of modules using shared resources

    With this change, modules that use the no argument
    form of the usesResource function will not run
    at the same time as any other module that has
    declared any shared resource or used the no argument
    usesResource function.
    wddgit authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    8e09348 View commit details
    Browse the repository at this point in the history
  30. Optimize registerSharedResource function

    Replace a linear search for legacy resources
    by a data member that counts them. Also use
    the std::make_shared function instead of new.
    wddgit authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    943bb42 View commit details
    Browse the repository at this point in the history
  31. Updated file to newer ROOT format

    The file contains one histogram used during reconstruction. Unfortunately, the file was
    written so long ago that ROOT's schema for the classes has changed. This is a problem for the
    threaded framework since ROOT 5 updates schema in a thread-unsafe manner when it opens
    a file and sees a new-to-it schema. By creating a new file containing the same information
    we can successfully preload the new class schemas (since they match the C++ code) at job
    initialization time.
    ROOT 6 is supposed to fix this problem.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    c5aff1c View commit details
    Browse the repository at this point in the history
  32. Configuration menu
    Copy the full SHA
    ca3185b View commit details
    Browse the repository at this point in the history
  33. Force creating of ROOT Streamers at begin of job

    The code which constructs ROOT Streamers is not thread safe. Unfortunately,
    Streamers normally get created the first time they are needed which would
    be too late for our case. This change forces all Streamers to be created,
    even if we do not need them for this job.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    325de45 View commit details
    Browse the repository at this point in the history
  34. Force creation of TStreamerInfos at TFile open time

    The global container of TStreamerInfos is not thread-safe. Therefore the ROOT team advised to create all TStreamerInfos needed for a job up front. We already create all TStreamerInfos for schemas corresponding to the present class layouts. However, a TFile can contain old schemas and will wants to create their TStreamerInfos the first time the class is read from the file. For our purposes, that is too late and therefore we need to force ROOT to create them at file open time.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    d74bf3e View commit details
    Browse the repository at this point in the history
  35. Fix unit test failure. In test diff ignore text some class is printing

    std::out in its constructor.
    wddgit authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    81cf685 View commit details
    Browse the repository at this point in the history
  36. Fix tab vs space issues in code

    Changed all tabs to be spaces to avoid problems between editors.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    82e2ce0 View commit details
    Browse the repository at this point in the history
  37. Use ROOT’s Cint Mutex to protect access to CINT structures

    When requested to load a dictionary, we have to manipulate some Cint data structures to say what file it comes from. When used in a threaded environment, ROOT requires a lock be taken before accessing these structures.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    8fa9cd1 View commit details
    Browse the repository at this point in the history
  38. Keep ROOT from optimizing Streamers

    ROOT will optimize Streamers such that adjoining member data of the same basic type are written/read
    together. Sometimes ROOT decides this optimization should not be applied and de-optimizes the Streamer.
    Unfortunately, the decision to de-optimize comes very late and can happen during the event loop and cause
    a data race. Therefore we tell ROOT, for now, to never optimize.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    6fb4009 View commit details
    Browse the repository at this point in the history
  39. Fix merge problem

    Fix problem when 7_1_X was merged into 7_1_THREADED_X.
    There was a conflict and some necessary changes were
    not merged. This is causing compilation to fail in
    7_1_THREADED_X.
    wddgit authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    4f7a373 View commit details
    Browse the repository at this point in the history
  40. Ignore new ROOT error message about TH1 nbins <=0

    When we switched to ROOT 5.34.17 a new warning message appeared
    when TH1 is passed nbins <= 0. Since ROOT already sets the value
    to nbins=1 we can ignore this warning.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    ed60a83 View commit details
    Browse the repository at this point in the history
  41. Remove getEngine() function from random service

    In the random number generator service, remove the
    getEngine function which takes no arguments. This function
    is replaced by new getEngine functions that take either
    a StreamID or a LuminosityBlockIndex as an argument. This
    comes after a long migration of all clients to the new
    interface. The new interace is designed to work with
    the multithreaded Framework.
    
    (Note that this also fixes a compilation error that resulted
    after a similar pull request was automatically merged from
    7_1_X)
    wddgit authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    ac16f5f View commit details
    Browse the repository at this point in the history
  42. Ignore new nbinsy warning from ROOT

    ROOT 5.34.17 has added additional warnings which we convert to exceptions. The warning about nbinsy <=0 is irrelevant since ROOT has a reasonable behavior in this case. Therefore, we want to ignore this warning.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    5459475 View commit details
    Browse the repository at this point in the history
  43. No longer force all Streamers to exist early

    The new thread-safety changes to ROOT make the need to try to force
    all Streamers into existence early unnecessary.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    9c66691 View commit details
    Browse the repository at this point in the history
  44. Forced to take ROOT internal mutex lock to avoid deadlock

    ROOT locks the same mutex before loading a shared library and in
    statics embedded in shared libaries. In the middle the operating
    system takes a lock to protect the shared library data structures.
    Therefore to avoid deadlock problems we must take the same ROOT lock
    before loading any shared libraries since we do not know apriori
    if the shared library being loaded links to a library which will
    take the lock at load time.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    56a7570 View commit details
    Browse the repository at this point in the history
  45. Use R__LOCKGUARD2 instead of R__LOCKGUARD

    To avoid having the first lock order incorrect because the Cint lock
    is not yet created when PluginManager first calls R__LOCKGUARD, I
    switched to R__LOCKGUARD2 which will create that Cint lock if ROOT
    has decided that locks should be made but hasn't yet made them.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    7fa242a View commit details
    Browse the repository at this point in the history
  46. Do not force creation of StreamerInfos at ROOT file opening

    Forcing the creating of StreamerInfos at file open is no longer needed
    and it causes problems when we have done a 'drop on input' for a file
    and the items dropped can not be schema evolved. In that case the original
    code would cause an exception and it would kill the job. This change
    allows us to properly handle 'drop on input'.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    99f8c49 View commit details
    Browse the repository at this point in the history
  47. Removed TrackPropagation/Geant4e from Threaded branch

    The Geant4e based propagator is not presently thread safe. To avoid
    problems with the static analyzer we are removing it from the threaded
    branch. If the code is made thread safe, we will add it back.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    de76e6b View commit details
    Browse the repository at this point in the history
  48. Removed PolyFit3DParametrizedMagneticField from Threaded branch

    The PolyFit3DParametrizedMagneticField is not presently thread safe. To avoid
    problems with the static analyzer we are removing it from the threaded
    branch. If the code is made thread safe, we will add it back.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    a725a99 View commit details
    Browse the repository at this point in the history
  49. Remove DQM service from configurations

    The DQM service is not thread-safe and must be removed from
    configurations until it is changed.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    f2c4969 View commit details
    Browse the repository at this point in the history
  50. removed use of TkDetMap from configurations

    The TkDetMap service is not thread-safe and violates CMSSW coding
    rules and must be removed from configurations until it is changed.
    Modules dependent upon TkDetMap have also been removed from configurations.
    Dr15Jones authored and ktf committed Apr 24, 2014
    Configuration menu
    Copy the full SHA
    fa306b4 View commit details
    Browse the repository at this point in the history