I want to rebuild Geant4 code to make it simpler

I want to remove all the extra packages leaving only the main computation modules to learn how Geant4 to build the computation code. After that, I want to translate this sample code making it can run at GPU.Do somebody can give me some advise to help me finishing this work, thank you very much.

If you’re interested in simulation on GPU, I’d strongly encourage looking at the current AdePT and Celeritas projects that are investigating particle transport simulation on GPU. These are already considering some of the aspects you note, and would welcome contributors/interest.

In general a straight conversion of the current Geant4 “kernel” to run on GPU will not work - hence the above R&D projects. A good overview, though there has been development since, is here, and here.

1 Like

Thank you very much for your help, it is real helpful for me and I will look at the AdePT and Celerias projects urgently. At end, I have to reiterate that your response was a huge help to me.

Dear Mr.Morgen:
I’m jimbook_tian at Geant4 forum, have you still remembered me? I feel very glad about your reply, it’s really helpful for me. So I should say thank you again here.
After looking at your reply, I went to see the two project you mentioned, and try to install and build them. There were some problems when I tried to install software dependencies. I happened to find that you are one of the developers of VecGeom, so I take the liberty to consult you. I’d appreciate it if you could spare some time from your busy schedule and give me some help.
The problems I met are below:
1.UME::SIMD: When I cmake the VecCore with argument -UMESIMD=ON after I installed UME::SIMD(which is depended by VecCore) by following its install tutorial, it raise an error like this:

 CMake Error at /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
   Could NOT find UMESIMD (missing: UMESIMD_INCLUDE_DIRS) (Required is at
   least version "0.8.1")
 Call Stack (most recent call first):
   /usr/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
   cmake/FindUMESIMD.cmake:63 (find_package_handle_standard_args)
   cmake/Builtins.cmake:14 (_find_package)
   CMakeLists.txt:51 (find_package)

Then I try using cmake && make &&make install in the UME::SIMD folder to add UME::SIMD to cmake module, but it doesn’t work.Below is how I install UME::SIMD:

$ mkdir ~/software/ume
$ cd ~/software/ume
$ git clone https://github.com/edanor/umesimd.git
$ cd umesimd
$ git checkout tags/v0.8.1
$ cd ..
$ pwd
/home/jimbook/software/ume
$ export CPLUS_INCLUDE_PATH=$CPLUS_INCLUDE_PATH:/home/jimbook/software/ume
$ echo  "#export the UME::SIMD library directory" >> ~/.bachrc
$ echo  "export CPLUS_INCLUDE_PATH=\$CPLUS_INCLUDE_PATH:/home/jimbook/software/ume" >> ~/.bachrc
$ mkdir build
$ cd build
$ cmake ..
$ make && sudo make install

2.VecGeom: When I cmake VecGeom with argument -VECGEOM_ENABLE_CUDA=ON, it raise error like this:

CMake Error in /home/jimbook/software/VecGeom/build/CMakeFiles/CMakeTmp/CMakeLists.txt:
   Target "cmTC_6561b" requires the language dialect "CUDA17" , but CMake does
   not know the compile flags to use to enable it.
CMake Error at /usr/share/cmake-3.16/Modules/FindCUDA/select_compute_arch.cmake:114 (try_run):
   Failed to generate test project build system.
 Call Stack (most recent call first):
   /usr/share/cmake-3.16/Modules/FindCUDA/select_compute_arch.cmake:173 (CUDA_DETECT_INSTALLED_GPUS)
   CMakeLists.txt:354 (cuda_select_nvcc_arch_flags)

Maybe cuda evironment infomation of my PC is also important that you want to know.
first, cuda that cmake find is here:

 Configuring with Scalar backend
 Found CUDA: /usr/local/cuda (found suitable version "11.8", minimum required is "7.5") 
 Compiling for SSE2 SIMD architecture
 Found CUDA: /usr/local/cuda (found suitable version "11.8", minimum required is "11")

second, the system is WSL2 Ubuntu, info of nvidia-smi is here

+-----------------------------------------------------------------------------+
| NVIDIA-SMI 515.76.02    Driver Version: 517.48       CUDA Version: 11.7     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  On   | 00000000:01:00.0 Off |                  N/A |
| N/A   62C    P8    N/A /  N/A |      0MiB /  2048MiB |      0%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A        24      G   /Xwayland                       N/A      |
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A        24      G   /Xwayland                       N/A      |
+-----------------------------------------------------------------------------+ 

and nvcc version is here:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Wed_Sep_21_10:33:58_PDT_2022
Cuda compilation tools, release 11.8, V11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0

In the end, I want to show my appriciate for you again.

I may found the solution of the second problem.
I check below error infomation at Google and cmake doc:

CMake Error in /home/jimbook/software/VecGeom/build/CMakeFiles/CMakeTmp/CMakeLists.txt:
   Target "cmTC_6561b" requires the language dialect "CUDA17" , but CMake does
   not know the compile flags to use to enable it.

Then I found an anwser say if cmake version below 3.18, this error will be raised. And default version of cmake at Ubuntu is 3.16, which caused the problem. After I updated the cmake to 3.24, this problem was solved.

Maybe the CMakeList.txt should be modified from cmake_minimum_required(VERSION 3.16...3.22) to cmake_minimum_required(VERSION 3.18...3.22)