LLNL / Kripke

Kripke is a simple, scalable, 3D Sn deterministic particle transport code
BSD 3-Clause "New" or "Revised" License
36 stars 37 forks source link

Instructions for building with CUDA? #54

Closed vsoch closed 6 months ago

vsoch commented 6 months ago

Hi! Could you add some basic documentation for building with CUDA? I'm trying to build into a container, and using the issues/docs on the site but running into trouble:

cmake -DENABLE_CUDA=true ../
-- Build files have been written to: /opt/Kripke/build
root@248e2a50a9d0:/opt/Kripke/build# make 
[  1%] Building CXX object tpl/raja/tpl/camp/CMakeFiles/camp.dir/src/errors.cpp.o
[  2%] Linking CXX static library ../../../../lib/libcamp.a
[  2%] Built target camp
[  2%] Building CUDA object tpl/raja/CMakeFiles/RAJA.dir/src/AlignedRangeIndexSetBuilders.cpp.o
[  3%] Building CUDA object tpl/raja/CMakeFiles/RAJA.dir/src/DepGraphNode.cpp.o
[  4%] Building CUDA object tpl/raja/CMakeFiles/RAJA.dir/src/LockFreeIndexSetBuilders.cpp.o
[  4%] Building CUDA object tpl/raja/CMakeFiles/RAJA.dir/src/MemUtils_CUDA.cpp.o
[  5%] Building CUDA object tpl/raja/CMakeFiles/RAJA.dir/src/MemUtils_HIP.cpp.o
[  6%] Building CUDA object tpl/raja/CMakeFiles/RAJA.dir/src/MemUtils_SYCL.cpp.o
[  7%] Building CUDA object tpl/raja/CMakeFiles/RAJA.dir/src/PluginStrategy.cpp.o
[  7%] Linking CXX static library ../../lib/libRAJA.a
[  7%] Built target RAJA
[  8%] Building CUDA object CMakeFiles/kripke.dir/src/Kripke/Core/BaseVar.cpp.o
[  8%] Building CUDA object CMakeFiles/kripke.dir/src/Kripke/Core/DataStore.cpp.o
[  9%] Building CUDA object CMakeFiles/kripke.dir/src/Kripke/Core/DomainVar.cpp.o
[ 10%] Building CUDA object CMakeFiles/kripke.dir/src/Kripke/Generate.cpp.o
[ 10%] Building CUDA object CMakeFiles/kripke.dir/src/Kripke/Generate/Data.cpp.o
[ 11%] Building CUDA object CMakeFiles/kripke.dir/src/Kripke/Generate/Decomp.cpp.o
[ 12%] Building CUDA object CMakeFiles/kripke.dir/src/Kripke/Generate/Energy.cpp.o
[ 13%] Building CUDA object CMakeFiles/kripke.dir/src/Kripke/Generate/Quadrature.cpp.o
[ 13%] Building CUDA object CMakeFiles/kripke.dir/src/Kripke/Generate/Space.cpp.o
[ 14%] Building CUDA object CMakeFiles/kripke.dir/src/Kripke/InputVariables.cpp.o
[ 15%] Building CUDA object CMakeFiles/kripke.dir/src/Kripke/Kernel/LPlusTimes.cpp.o
/opt/Kripke/src/Kripke/Kernel/LPlusTimes.cpp(55): error: __host__ or __device__ annotation on lambda requires --extended-lambda nvcc flag
                       (Direction d, Moment nm, Group g, Zone z) {
                       ^

1 error detected in the compilation of "/opt/Kripke/src/Kripke/Kernel/LPlusTimes.cpp".
make[2]: *** [CMakeFiles/kripke.dir/build.make:216: CMakeFiles/kripke.dir/src/Kripke/Kernel/LPlusTimes.cpp.o] Error 2
make[1]: *** [CMakeFiles/Makefile2:404: CMakeFiles/kripke.dir/all] Error 2
make: *** [Makefile:136: all] Error 2

If you could add some notes / updates to the README or share here, it would be greatly appreciated. I'm fairly new to building with CUDA outside of, for example, Python libraries. Thank you!

rhornung67 commented 6 months ago

To fix this build error, you need to add --expt-extended-lambda to CMAKE_CUDA_FLAGS.

vsoch commented 6 months ago

That worked great - thank you!

rhornung67 commented 6 months ago

I don't work on Kripke, but I think adding some build recipes in the docs is a good idea.