Skip to content

Commit ca3a9ba

Browse files
Fix build issues for V100 target
1 parent ed630ad commit ca3a9ba

File tree

3 files changed

+25
-34
lines changed

3 files changed

+25
-34
lines changed

CMakeLists.txt

+22-26
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ cmake_minimum_required(VERSION 3.21)
2828
cmake_policy(VERSION 3.21...3.27)
2929

3030
# C Language is needed in order to verify Fortran compiler is C-interoperable
31-
# HIP language is needed to properly find "hip" package
3231
project(SELF VERSION 1.0.0
3332
DESCRIPTION "Spectral Element Library in Fortran"
34-
LANGUAGES Fortran C HIP)
33+
LANGUAGES Fortran C)
3534

3635
option(SELF_ENABLE_MULTITHREADING "Option to enable CPU multithreading for `do concurrent` loop blocks." OFF)
3736
option(SELF_ENABLE_TESTING "Option to enable build of tests. (Default On)" ON)
@@ -47,13 +46,6 @@ if(SELF_ENABLE_MULTITHREADING)
4746
set(SELF_MULITHREADING_NTHREADS "4" CACHE STRING "Number of threads to use for `do concurrent` loop blocks. This option is only used with GNU compilers. Other compilers use OMP_NUM_THREADS environment variable at runtime.")
4847
endif()
4948

50-
if(NOT DEFINED ROCM_PATH)
51-
if(NOT DEFINED ENV{ROCM_PATH})
52-
set(ROCM_PATH "/opt/rocm/" CACHE PATH "Path to which ROCm has been installed")
53-
else()
54-
set(ROCM_PATH $ENV{ROCM_PATH} CACHE PATH "Path to which ROCm has been installed")
55-
endif()
56-
endif()
5749

5850

5951
# Fortran compiler requirements
@@ -202,25 +194,29 @@ if(SELF_ENABLE_GPU)
202194
message( FATAL_ERROR "MPI installation is not GPU-aware" )
203195
endif()
204196
else()
205-
# CUDA (Optional)
206-
find_package(cuda)
207-
if(cuda_FOUND)
208-
if(MPI_HAS_QUERY_CUDA_SUPPORT)
209-
message("-- CUDA found. Enabling CUDA language.")
210-
enable_language(CUDA)
211-
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -DHAVE_CUDA" )
212-
set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -DHAVE_CUDA" )
213-
set( CMAKE_Fortran_FLAGS_COVERAGE "${CMAKE_Fortran_FLAGS_COVERAGE} -DHAVE_CUDA")
214-
set( CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS_PROFILE} -DHAVE_CUDA")
215-
set( CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -DHAVE_CUDA" )
216-
217-
218-
# TO DO - need cuda libraries and hipblas libraries
219-
else()
220-
message( FATAL_ERROR "MPI installation is not GPU-aware" )
197+
# CUDA
198+
find_package(CUDAToolkit REQUIRED)
199+
message("-- CUDA found. Enabling CUDA language.")
200+
enable_language(CUDA)
201+
if(MPI_HAS_QUERY_CUDA_SUPPORT)
202+
set( CMAKE_Fortran_FLAGS "${CMAKE_Fortran_FLAGS} -DHAVE_CUDA" )
203+
set( CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -DHAVE_CUDA" )
204+
set( CMAKE_Fortran_FLAGS_COVERAGE "${CMAKE_Fortran_FLAGS_COVERAGE} -DHAVE_CUDA")
205+
set( CMAKE_Fortran_FLAGS_PROFILE "${CMAKE_Fortran_FLAGS_PROFILE} -DHAVE_CUDA")
206+
set( CMAKE_Fortran_FLAGS_RELEASE "${CMAKE_Fortran_FLAGS_RELEASE} -DHAVE_CUDA" )
207+
208+
if(SELF_ENABLE_DOUBLE_PRECISION)
209+
set( CMAKE_CUDA_FLAGS "${CMAKE_CUDA_FLAGS} -DDOUBLE_PRECISION" )
210+
set( CMAKE_CUDA_FLAGS_DEBUG "${CMAKE_CUDA_FLAGS_DEBUG} -DDOUBLE_PRECISION" )
211+
set( CMAKE_CUDA_FLAGS_COVERAGE "${CMAKE_CUDA_FLAGS_COVERAGE} -DDOUBLE_PRECISION")
212+
set( CMAKE_CUDA_FLAGS_PROFILE "${CMAKE_CUDA_FLAGS_PROFILE} -DDOUBLE_PRECISION")
213+
set( CMAKE_CUDA_FLAGS_RELEASE "${CMAKE_CUDA_FLAGS_RELEASE} -DDOUBLE_PRECISION" )
221214
endif()
215+
216+
set( BACKEND_LIBRARIES CUDA::cuda_driver CUDA::cudart CUDA::cublas)
217+
222218
else()
223-
message( FATAL_ERROR "Enabling GPU support requires either HIP or CUDA." )
219+
message( FATAL_ERROR "MPI installation is not GPU-aware" )
224220
endif()
225221
endif()
226222
endif()

src/CMakeLists.txt

+2-8
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,10 @@ file(GLOB SELF_FSRC "${CMAKE_CURRENT_SOURCE_DIR}/*.f*")
2929
if(SELF_ENABLE_GPU)
3030
file(GLOB SELF_BACKEND_FSRC "${CMAKE_CURRENT_SOURCE_DIR}/gpu/*.f*")
3131
file(GLOB SELF_BACKEND_CPPSRC "${CMAKE_CURRENT_SOURCE_DIR}/gpu/*.cpp*")
32-
# Note : [email protected] (Oct. 1 2024)
33-
# Ultimately, we want to be able to use the language support for HIP/CUDA
34-
# rather than bringing in HIP/CUDA through `find_package`. At the moment
35-
# we are doing a hack overrided the CXX compiler with either hipcc or nvcc
36-
# The reason we're doing it this way (hacky) at the moment is that we get
37-
# segmentation faults on our AMD GPU tests when using the HIP language support
38-
# via Cmake, for some yet unknown reason.
32+
3933
if(hip_FOUND)
4034
set_source_files_properties(${SELF_BACKEND_CPPSRC} PROPERTIES LANGUAGE HIP)
41-
elseif(cuda_FOUND)
35+
else()
4236
set_source_files_properties(${SELF_BACKEND_CPPSRC} PROPERTIES LANGUAGE CUDA)
4337
endif()
4438
else()

src/gpu/SELF_GPU_Macros.h

+1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ static void check(const hipError_t err, const char *const file, const int line)
3131
#else
3232

3333
#include <cuda_runtime.h>
34+
#include <stdint.h> // required to provide uint32_t
3435

3536
#define hipLaunchKernelGGL(F,G,B,M,S,...) F<<<G,B,M,S>>>(__VA_ARGS__)
3637

0 commit comments

Comments
 (0)