Loading CMakeLists.txt +11 −8 Original line number Diff line number Diff line Loading @@ -18,6 +18,10 @@ option(BUILD_SHARED_LIBS "Build using shared libraries" ON) # Since it depends on the code structure, it should not be a user-configurable option. set(GPU_SEPARABLE_COMPILATION OFF) ############ Package dependencies ############### find_package(OpenMP 3.0 REQUIRED) find_package(MPI REQUIRED) if(CMAKE_CUDA_ARCHITECTURES) set(ENABLE_GPU TRUE) include(setup_cuda) Loading @@ -26,24 +30,23 @@ elseif(CMAKE_HIP_ARCHITECTURES) include(setup_hip) else() set(ENABLE_GPU FALSE) set(GPU_LIBRARIES "") include(setup_cpu) endif() find_package(MPI REQUIRED) ########## TARGETS ################################################ add_library(mpiwrap src/wrapper.cc) gpu_runtime_link(mpiwrap) gpu_blas_link(mpiwrap) runtime_link(mpiwrap) blas_link(mpiwrap) add_executable(mpitest src/allreduce.cc) gpu_runtime_link(mpitest) runtime_link(mpitest) ##################################################################### # configured header file stashing options configure_file(include/config.hh.in include/config.hh) target_compile_features(mpiwrap PUBLIC cxx_std_17) target_link_libraries(mpiwrap PUBLIC MPI::MPI_CXX) target_link_libraries(mpiwrap PUBLIC OpenMP::OpenMP_CXX MPI::MPI_CXX) target_include_directories(mpiwrap PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include> Loading cmake/setup_cpu.cmake 0 → 100644 +9 −0 Original line number Diff line number Diff line #link the correct runtime libraries (no-op for CPU) function(runtime_link target_name) endfunction() function(blas_link target_name) endfunction() function(device_link target_name) endfunction() cmake/setup_cuda.cmake +3 −4 Original line number Diff line number Diff line Loading @@ -7,22 +7,21 @@ enable_language(CUDA) message(STATUS "Setting up CUDA") find_package(CUDAToolkit REQUIRED) #set(GPU_LIBRARIES CUDA::cudart CUDA::cublas) # Note: Technically, C++17 is only supported by cmake 3.18+ set(CMAKE_CUDA_STANDARD 17) #link the correct gpu runtime library function(gpu_runtime_link target_name) function(runtime_link target_name) target_link_libraries(${target_name} PUBLIC CUDA::cudart) endfunction() #link the correct gpu runtime library function(gpu_blas_link target_name) function(blas_link target_name) target_link_libraries(${target_name} PUBLIC CUDA::cublas) endfunction() function(gpu_device_link target_name) function(device_link target_name) if(GPU_SEPARABLE_COMPILATION) set_target_properties( ${target_name} PROPERTIES CUDA_SEPARABLE_COMPILATION ON) Loading cmake/setup_hip.cmake +3 −4 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ set(CMAKE_MODULE_PATH "${ROCM_ROOT}/hip/cmake" ${CMAKE_MODULE_PATH}) find_package(HIP REQUIRED) find_package(hipblas REQUIRED) #find_package(rocsolver REQUIRED) #set(GPU_LIBRARIES hip::host roc::hipblas) set(CMAKE_HIP_STANDARD 17) Loading @@ -20,20 +19,20 @@ if(GPU_SEPARABLE_COMPILATION) endif() #link the correct gpu runtime library function(gpu_runtime_link target_name) function(runtime_link target_name) target_include_directories(${target_name} PRIVATE ${CMAKE_SOURCE_DIR}/include/cuda2hip) target_link_libraries(${target_name} PUBLIC hip::host) endfunction() #link the correct gpu runtime library function(gpu_blas_link target_name) function(blas_link target_name) target_include_directories(${target_name} PRIVATE ${CMAKE_SOURCE_DIR}/include/cuda2hip) target_link_libraries(${target_name} PUBLIC roc::hipblas) endfunction() function(gpu_device_link target_name) function(device_link target_name) target_include_directories(${target_name} PRIVATE ${CMAKE_SOURCE_DIR}/include/cuda2hip) set_target_properties(${target_name} PROPERTIES Loading Loading
CMakeLists.txt +11 −8 Original line number Diff line number Diff line Loading @@ -18,6 +18,10 @@ option(BUILD_SHARED_LIBS "Build using shared libraries" ON) # Since it depends on the code structure, it should not be a user-configurable option. set(GPU_SEPARABLE_COMPILATION OFF) ############ Package dependencies ############### find_package(OpenMP 3.0 REQUIRED) find_package(MPI REQUIRED) if(CMAKE_CUDA_ARCHITECTURES) set(ENABLE_GPU TRUE) include(setup_cuda) Loading @@ -26,24 +30,23 @@ elseif(CMAKE_HIP_ARCHITECTURES) include(setup_hip) else() set(ENABLE_GPU FALSE) set(GPU_LIBRARIES "") include(setup_cpu) endif() find_package(MPI REQUIRED) ########## TARGETS ################################################ add_library(mpiwrap src/wrapper.cc) gpu_runtime_link(mpiwrap) gpu_blas_link(mpiwrap) runtime_link(mpiwrap) blas_link(mpiwrap) add_executable(mpitest src/allreduce.cc) gpu_runtime_link(mpitest) runtime_link(mpitest) ##################################################################### # configured header file stashing options configure_file(include/config.hh.in include/config.hh) target_compile_features(mpiwrap PUBLIC cxx_std_17) target_link_libraries(mpiwrap PUBLIC MPI::MPI_CXX) target_link_libraries(mpiwrap PUBLIC OpenMP::OpenMP_CXX MPI::MPI_CXX) target_include_directories(mpiwrap PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/include> Loading
cmake/setup_cpu.cmake 0 → 100644 +9 −0 Original line number Diff line number Diff line #link the correct runtime libraries (no-op for CPU) function(runtime_link target_name) endfunction() function(blas_link target_name) endfunction() function(device_link target_name) endfunction()
cmake/setup_cuda.cmake +3 −4 Original line number Diff line number Diff line Loading @@ -7,22 +7,21 @@ enable_language(CUDA) message(STATUS "Setting up CUDA") find_package(CUDAToolkit REQUIRED) #set(GPU_LIBRARIES CUDA::cudart CUDA::cublas) # Note: Technically, C++17 is only supported by cmake 3.18+ set(CMAKE_CUDA_STANDARD 17) #link the correct gpu runtime library function(gpu_runtime_link target_name) function(runtime_link target_name) target_link_libraries(${target_name} PUBLIC CUDA::cudart) endfunction() #link the correct gpu runtime library function(gpu_blas_link target_name) function(blas_link target_name) target_link_libraries(${target_name} PUBLIC CUDA::cublas) endfunction() function(gpu_device_link target_name) function(device_link target_name) if(GPU_SEPARABLE_COMPILATION) set_target_properties( ${target_name} PROPERTIES CUDA_SEPARABLE_COMPILATION ON) Loading
cmake/setup_hip.cmake +3 −4 Original line number Diff line number Diff line Loading @@ -10,7 +10,6 @@ set(CMAKE_MODULE_PATH "${ROCM_ROOT}/hip/cmake" ${CMAKE_MODULE_PATH}) find_package(HIP REQUIRED) find_package(hipblas REQUIRED) #find_package(rocsolver REQUIRED) #set(GPU_LIBRARIES hip::host roc::hipblas) set(CMAKE_HIP_STANDARD 17) Loading @@ -20,20 +19,20 @@ if(GPU_SEPARABLE_COMPILATION) endif() #link the correct gpu runtime library function(gpu_runtime_link target_name) function(runtime_link target_name) target_include_directories(${target_name} PRIVATE ${CMAKE_SOURCE_DIR}/include/cuda2hip) target_link_libraries(${target_name} PUBLIC hip::host) endfunction() #link the correct gpu runtime library function(gpu_blas_link target_name) function(blas_link target_name) target_include_directories(${target_name} PRIVATE ${CMAKE_SOURCE_DIR}/include/cuda2hip) target_link_libraries(${target_name} PUBLIC roc::hipblas) endfunction() function(gpu_device_link target_name) function(device_link target_name) target_include_directories(${target_name} PRIVATE ${CMAKE_SOURCE_DIR}/include/cuda2hip) set_target_properties(${target_name} PROPERTIES Loading