Cannot simulate the geant4 problem with multi-threads


Can anyone help me to solve my problem when I run my simulation?
I have fully set up multithreading but when running the CPUs say “D” as shown in the image. I don’t know how to do it.
Please help me to point out the error.

D state code means that the process is in uninterruptible sleep, usually this is due to I/O.

Did you code any output to disk yourself in your application? Usually the geant4-way to collect data and write to disk is more efficient: Analysis Manager Classes — Book For Application Developers 10.7 documentation

Thank you for your help. I don’t understand what you are saying. But I used mesh scorer (Built-in scoring commands) to get particle fux in the mesh.
When I run my simulation on my laptop without multi-threads mode or with multi-threads (2 CPUs, 3 CPUs, and 4 CPUs). I saw that all of the situations also run with full cores (4 CPUs).
Is there a problem with my input file.
This is my input files: GEANT4_Simulation – Google Drive. Could you check the errors for me?

in your opening post, you point out that processes are in “D” state. This state typically indicates that processes are waiting for disc access (input/output, “I/O”), presumably multiple threads try to access the same file and thereby block each other. more threads → more blocking

what exactly is the problem you are observing? do your processes stay forever in D-state until reboot? will the simulation run as expected for 4 cores on the 36 core machine?

GammaKnife is one of the advanced examples, I would assume that the original code runs without issues on your system? can you highlight the changes you made?

I tried to run the gammaknife example in the advanced example folder. I have seen that it has the same problem as shown in the attached image. After that, I modified this example. I changed the DetectorContruction file to change into my geometry. I added an option to permit a user to choose the number of threads that they wanted as in the basic example4 folder.

I can confirm: when I change the simulation.mac content to run 1000 particles with 16 threads, I also find the gammaknife threads in D state. However, it is not stuck, just takes a lot of time (100 times more than for 10?). So I don’t know if that is a problem.

For 4 threads and 10, as in the original file, it seems to run smooth, with no issues. How many particles do you simulate?