Multithreading in CMSSW
Documentation about how to do multithreading in the CMSSW framework can be found at the following twikis:
- Types of Modules in the Threaded Framework
- C++ Interface Description for Stream Modules (typically used for EDProducer and EDFilter)
- C++ Interface Description for Global Modules (typically used for EDAnalyzer and OutputModule)
- C++ Interface Description for One Modules
- Framework and Event Data Model Offline Guide
The rule of thumb is that EDProducer or EDFilters should probably be a Stream module, while EDAnalyzers and OutputModules should probably be a Global module. A One module basically exists as a fallback to single-threaded processing.
From the discussion in this pull request, one could use Clang Static Analyzer within the CMSSW framework to check for thread safety. To do that, first check out the Utilities/StaticAnalyzers
package.
git cms-addpkg Utilities/StaticAnalyzers
Then, call scram b
with certain environment variables.
export USER_CXXFLAGS="-DEDM_ML_DEBUG -w"
export USER_LLVM_CHECKERS="-enable-checker threadsafety -enable-checker optional.ClassChecker -enable-checker cms -disable-checker cms.FunctionDumper"
scram b -k -j $(nproc) checker
The static analyzer results can be viewed in a web browser. See also: https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideStaticAnalyzer.