How to set the number of Geant4 Working Threads (G4WT´s) in the User Interface?)

In some examples included in the Geant4 toolkit (in Multithreading mode) I have seen that when I open the executable, in the User Interface there are 4 Geant4 Working Threads (G4WT’s); In other examples, when I open the executable, in the user interface I notice that there is only one Working Thread; and in one example I observed that there are up to 10 Working Threads; Based on the above, I would like to know how I can set (with a command or commands in the Geant4 User Interface) the number of Working Threads?

_Geant4 Version:_11.2.1
_Operating System:_Windows 10
_Compiler/Version:_Visual Studio 2022
_CMake Version:_3.29.0-rc2

/run/numberOfThreads N

Thanks for the reply. Using the TestEm6 example, I typed the command /run/numberOfThreads 10 (before typing the /run/initialize command) and the User Iinterface returns the following message: “/run/numberOfThreads command is issued in sequential mode. The command is ignored” . What can I do about it?

You either built your Geant4 with MT turned off, or possibly the TestEm6 example is hardcoded to use the sequential (single threaded) RunManager. Follow the instructions in the Installation Guide if you need to rebuild G4 setting the MT flag back to ON. You can read about the different RunManagers in the Application Users Guide.

Ok, thanks for the information. I add that I built with the Multithreading turned On. Based on what I just said, I have the following doubt: if I built with Multithreading turned On, does that mean that in general I will be able to use the /run/numberOfThreads command in the Geant4 examples?

Almost, but not quite. If you build G4 with MT, then you can use the multithreaded RunManager. if you code uses

#include "G4RunManager.hh"

explicitly, then you’re getting the old sequential run manager. If you use

#include "G4RunMangerMT.hh"

then you get the multithreaded run manager. With G4 11-series, you can also use G4RunManagerFactory to get the appropriate RM for your build.

1 Like

Thanks for the information. It has been a great help. I just add that unlike the TestEm6 example, using the B1 example I was able to use the /run/numberOfThreads command (before using the /run/initialize command).

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.