Warning, /geant4/examples/README.HowToRunMT is written in an unsupported language. File is not indexed.
0001 -------------------------------------------------------------------
0002
0003 =========================================================
0004 Geant4 - an Object-Oriented Toolkit for Simulation in HEP
0005 =========================================================
0006
0007 Tips how to run an example in multi-threading mode
0008 --------------------------------------------------
0009
0010 Only migrated examples or user applications can be run in multi-threading (MT) mode.
0011 The instructions for migrating user applications can be found in Geant4 documentation guides
0012 and a short howto is available here:
0013
0014 https://twiki.cern.ch/twiki/bin/view/Geant4/QuickMigrationGuideForGeant4V10
0015
0016 In this file, we give just useful tips for running already migrated examples
0017 (or user applications).
0018
0019 1) RUN EXAMPLE IN MULTI-THREADING MODE
0020
0021 No special steps are needed to build an example in multi-threading (MT) mode.
0022 The examples which has been migrated to multi-threading will automatically
0023 run in MT when they are built against the Geant4 libraries built with MT mode
0024 activated, otherwise they will run in sequential mode.
0025 Not migrated examples will run in sequential mode even when built against
0026 Geant4 libraries built with MT mode activated.
0027
0028 The examples which do NOT support MT can be easily recognized by the following line
0029 of code in main ():
0030
0031 G4RunManager* runManager = new G4RunManager;
0032
0033 or
0034
0035 auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::SerialOnly);
0036
0037 2) SET NUMBER OF THREADS
0038
0039 When the number of threads is not selected in the application, the default number
0040 (which is actually 2) will be used. Another number of threads can be set in several
0041 ways:
0042
0043 - in the code
0044
0045 auto* runManager = ...;
0046 runManager->SetNumberOfThreads(4);
0047
0048 - in a macro file via UI command added just before /run/initialize
0049
0050 /run/numberOfThreads 4
0051
0052 - by setting the environment variable
0053
0054 export G4FORCENUMBEROFTHREADS = 4
0055 or
0056 setenv G4FORCENUMBEROFTHREADS 4
0057
0058 The environment variable value is forced and it cannot be changed from a code
0059 call or a macro. A warning is issued in such situation.
0060
0061 3) OUTPUT FROM THREADS
0062
0063 In MT processing each worker produces its output and these messages are interlayed
0064 on the screen. The messeges from threads are preceded with a predefined string
0065 G4WTi> where i is the thread number. Users can change this default behaviour
0066 and choose
0067
0068 - to limit the output from threads to one selected thread only:
0069
0070 /control/cout/ignoreThreadsExcept 0
0071
0072 - to redirect the output from threads in a file:
0073
0074 /control/cout/setCoutFile coutFileName
0075 /control/cout/setCerrFile cerrFileName
0076
0077 - to buffer the output from each thread at a time, so that the output of each
0078 thread is grouped and printed at the end of the job
0079
0080 /control/cout/useBuffer true|false