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