Geant4 Cross Reference |
1 ---------------------------------------------- 1 ------------------------------------------------------------------- 2 2 3 ========================================= 3 ========================================================= 4 Geant4 - an Object-Oriented Toolkit for S 4 Geant4 - an Object-Oriented Toolkit for Simulation in HEP 5 ========================================= 5 ========================================================= 6 6 7 Tips how to run an example in multi-th 7 Tips how to run an example in multi-threading mode 8 -------------------------------------- 8 -------------------------------------------------- 9 9 10 Only migrated examples or user applications c 10 Only migrated examples or user applications can be run in multi-threading (MT) mode. 11 The instructions for migrating user applicati 11 The instructions for migrating user applications can be found in Geant4 documentation guides 12 and a short howto is available here: 12 and a short howto is available here: 13 13 14 https://twiki.cern.ch/twiki/bin/view/Geant4/Q 14 https://twiki.cern.ch/twiki/bin/view/Geant4/QuickMigrationGuideForGeant4V10 15 15 16 In this file, we give just useful tips for ru 16 In this file, we give just useful tips for running already migrated examples 17 (or user applications). 17 (or user applications). 18 18 19 1) RUN EXAMPLE IN MULTI-THREADING MODE 19 1) RUN EXAMPLE IN MULTI-THREADING MODE 20 20 21 No special steps are needed to build an examp 21 No special steps are needed to build an example in multi-threading (MT) mode. 22 The examples which has been migrated to multi 22 The examples which has been migrated to multi-threading will automatically 23 run in MT when they are built against the Gea 23 run in MT when they are built against the Geant4 libraries built with MT mode 24 activated, otherwise they will run in sequent 24 activated, otherwise they will run in sequential mode. 25 Not migrated examples will run in sequential 25 Not migrated examples will run in sequential mode even when built against 26 Geant4 libraries built with MT mode activated 26 Geant4 libraries built with MT mode activated. 27 27 28 The examples which do NOT support MT can be e 28 The examples which do NOT support MT can be easily recognized by the following line 29 of code in main (): 29 of code in main (): 30 30 31 G4RunManager* runManager = new G4RunManager 31 G4RunManager* runManager = new G4RunManager; 32 32 33 or 33 or 34 34 35 auto* runManager = G4RunManagerFactory::Cre 35 auto* runManager = G4RunManagerFactory::CreateRunManager(G4RunManagerType::SerialOnly); 36 36 37 2) SET NUMBER OF THREADS 37 2) SET NUMBER OF THREADS 38 38 39 When the number of threads is not selected in 39 When the number of threads is not selected in the application, the default number 40 (which is actually 2) will be used. Another n 40 (which is actually 2) will be used. Another number of threads can be set in several 41 ways: 41 ways: 42 42 43 - in the code 43 - in the code 44 44 45 auto* runManager = ...; 45 auto* runManager = ...; 46 runManager->SetNumberOfThreads(4); 46 runManager->SetNumberOfThreads(4); 47 47 48 - in a macro file via UI command added just b 48 - in a macro file via UI command added just before /run/initialize 49 49 50 /run/numberOfThreads 4 50 /run/numberOfThreads 4 51 51 52 - by setting the environment variable 52 - by setting the environment variable 53 53 54 export G4FORCENUMBEROFTHREADS = 4 54 export G4FORCENUMBEROFTHREADS = 4 55 or 55 or 56 setenv G4FORCENUMBEROFTHREADS 4 56 setenv G4FORCENUMBEROFTHREADS 4 57 57 58 The environment variable value is forced and 58 The environment variable value is forced and it cannot be changed from a code 59 call or a macro. A warning is issued in such 59 call or a macro. A warning is issued in such situation. 60 60 61 3) OUTPUT FROM THREADS 61 3) OUTPUT FROM THREADS 62 62 63 In MT processing each worker produces its out 63 In MT processing each worker produces its output and these messages are interlayed 64 on the screen. The messeges from threads are 64 on the screen. The messeges from threads are preceded with a predefined string 65 G4WTi> where i is the thread number. Users c 65 G4WTi> where i is the thread number. Users can change this default behaviour 66 and choose 66 and choose 67 67 68 - to limit the output from threads to one sel 68 - to limit the output from threads to one selected thread only: 69 69 70 /control/cout/ignoreThreadsExcept 0 70 /control/cout/ignoreThreadsExcept 0 71 71 72 - to redirect the output from threads in a fi 72 - to redirect the output from threads in a file: 73 73 74 /control/cout/setCoutFile coutFileName 74 /control/cout/setCoutFile coutFileName 75 /control/cout/setCerrFile cerrFileName 75 /control/cout/setCerrFile cerrFileName 76 76 77 - to buffer the output from each thread at a 77 - to buffer the output from each thread at a time, so that the output of each 78 thread is grouped and printed at the end of 78 thread is grouped and printed at the end of the job 79 79 80 /control/cout/useBuffer true|false 80 /control/cout/useBuffer true|false