Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixing cmake charm++ and charm4py build with cuda #3836

Merged
merged 5 commits into from
Oct 4, 2024

Conversation

mayantaylor
Copy link
Collaborator

Previously, attempting to build with the cuda option using the cmake build resulted in the following error (on Delta):

> -- Found CUDAToolkit: /sw/spack/deltas11-2023-03/apps/linux-rhel8-zen3/gcc-11.4.0/cuda-11.8.0-vfixfmc/include (found version "11.8.89") 
> -- The CUDA compiler identification is GNU 11.4.0
> -- Detecting CUDA compiler ABI info
> -- Detecting CUDA compiler ABI info - failed
> -- Check for working CUDA compiler: /sw/spack/deltas11-2023-03/apps/linux-rhel8-zen3/gcc-11.4.0/cuda-11.8.0-vfixfmc/bin/nvcc
> -- Check for working CUDA compiler: /sw/spack/deltas11-2023-03/apps/linux-rhel8-zen3/gcc-11.4.0/cuda-11.8.0-vfixfmc/bin/nvcc - broken
> CMake Error at /usr/share/cmake/Modules/CMakeTestCUDACompiler.cmake:52 (message):
>   The CUDA compiler
> 
>     "/sw/spack/deltas11-2023-03/apps/linux-rhel8-zen3/gcc-11.4.0/cuda-11.8.0-vfixfmc/bin/nvcc"
> 
>   is not able to compile a simple test program.
> 
>   It fails with the following output:
> 
>     Change Dir: /u/mtaylor2/software/charm/mpi-linux-x86_64-cuda/CMakeFiles/CMakeTmp
>     
>     Run Build Command(s):/usr/bin/gmake -f Makefile cmTC_4c559/fast && /usr/bin/gmake  -f CMakeFiles/cmTC_4c559.dir/build.make CMakeFiles/cmTC_4c559.dir/build
>     gmake[1]: Entering directory '/u/mtaylor2/software/charm/mpi-linux-x86_64-cuda/CMakeFiles/CMakeTmp'
>     Building CUDA object CMakeFiles/cmTC_4c559.dir/main.cu.o
>     /sw/spack/deltas11-2023-03/apps/linux-rhel8-zen3/gcc-11.4.0/cuda-11.8.0-vfixfmc/bin/nvcc      -c /u/mtaylor2/software/charm/mpi-linux-x86_64-cuda/CMakeFiles/CMakeTmp/main.cu -o CMakeFiles/cmTC_4c559.dir/main.cu.o
>     Linking CUDA executable cmTC_4c559
>     /usr/bin/cmake -E cmake_link_script CMakeFiles/cmTC_4c559.dir/link.txt --verbose=1
>     "" CMakeFiles/cmTC_4c559.dir/main.cu.o -o cmTC_4c559 
>     Error running link command: No such file or directory
>     gmake[1]: *** [CMakeFiles/cmTC_4c559.dir/build.make:99: cmTC_4c559] Error 2
>     gmake[1]: Leaving directory '/u/mtaylor2/software/charm/mpi-linux-x86_64-cuda/CMakeFiles/CMakeTmp'
>     gmake: *** [Makefile:127: cmTC_4c559/fast] Error 2

The issue: the cuda library is referenced via the variable CUDA, and the cmake script introduces an option also named CUDA. This introduces confusion when cmake tries to find cuda: enable_language(CUDA).

This PR fixes the issue by renaming the CUDA option as BUILD_CUDA. The existing cmake structure requires that there still exists an option named CUDA for the conv-mach-cuda.h discovery, so I pushed the creation of the CUDA option to after all cuda library setup.

This PR also links in the necessary cuda and HAPI libraries to charmlib.so, for use in charm4py.

Copy link
Contributor

@matthiasdiener matthiasdiener left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@ritvikrao ritvikrao enabled auto-merge (squash) October 4, 2024 16:30
@ritvikrao ritvikrao merged commit d17744e into main Oct 4, 2024
23 checks passed
@mayantaylor mayantaylor deleted the maya/cmake-cuda-build branch October 30, 2024 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants