Skip to content

Commit

Permalink
Update CMake file for including tbb and cuda
Browse files Browse the repository at this point in the history
  • Loading branch information
sbaldu committed Mar 18, 2024
1 parent ff27074 commit 6407aa8
Showing 1 changed file with 54 additions and 50 deletions.
104 changes: 54 additions & 50 deletions profiling/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,60 +51,64 @@ target_compile_options(
target_compile_options(serial.out PRIVATE -pg)
target_link_options(serial.out PRIVATE -pg)

# find_package(TBB)

# # CPU TBB
# if(TBB_FOUND)
# # compile cpu tbb module
# add_executable(tbb.out main.cc)
# target_link_libraries(tbb.out PRIVATE ${Boost_LIBRARIES})
# target_include_directories(tbb.out PRIVATE ${Boost_PATH})
# target_compile_options(
# tbb.out
# PRIVATE -ltbb -DALPAKA_ACC_CPU_B_TBB_T_SEQ_PRESENT
# -DALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLED
# -DALPAKA_ACC_CPU_B_TBB_T_SEQ_ASYNC_BACKEND)
# target_link_libraries(tbb.out PRIVATE TBB::tbb)
# endif()

# # check if CUDA is available
# include(CheckLanguage)
# check_language(CUDA)
find_package(TBB)

# CPU TBB
if(TBB_FOUND)
# compile cpu tbb module
add_executable(tbb.out main.cc)
target_link_libraries(tbb.out PRIVATE ${Boost_LIBRARIES})
target_include_directories(tbb.out PRIVATE ${Boost_PATH})
target_compile_options(
tbb.out
PRIVATE -ltbb -DALPAKA_ACC_CPU_B_TBB_T_SEQ_PRESENT
-DALPAKA_ACC_CPU_B_TBB_T_SEQ_ENABLED
-DALPAKA_ACC_CPU_B_TBB_T_SEQ_ASYNC_BACKEND)
target_link_libraries(tbb.out PRIVATE TBB::tbb)
target_compile_options(serial.out PRIVATE -pg)
target_link_options(serial.out PRIVATE -pg)
endif()

# # GPU CUDA
# if(CMAKE_CUDA_COMPILER)
# # enable CUDA
# enable_language(CUDA)
# set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CUDA_COMPILER})
# check if CUDA is available
include(CheckLanguage)
check_language(CUDA)

# # set the CUDA standard
# if(NOT DEFINED CMAKE_CUDA_STANDARD)
# set(CMAKE_CUDA_STANDARD 17)
# set(CMAKE_CUDA_STANDARD_REQUIRED ON)
# endif()
# GPU CUDA
if(CMAKE_CUDA_COMPILER)
# enable CUDA
enable_language(CUDA)
set(CMAKE_CUDA_HOST_COMPILER ${CMAKE_CUDA_COMPILER})

# set(CMAKE_CUDA_FLAGS "-Wall -Wextra -g -O2")
# set the CUDA standard
if(NOT DEFINED CMAKE_CUDA_STANDARD)
set(CMAKE_CUDA_STANDARD 17)
set(CMAKE_CUDA_STANDARD_REQUIRED ON)
endif()

# # compile the file with .cc extension using nvcc
# set_source_files_properties(main.cc PROPERTIES LANGUAGE CUDA)
# # compile gpu cuda module
# add_executable(cuda.out main.cc)
# # link boost
# target_link_libraries(cuda.out PRIVATE ${Boost_LIBRARIES})
# target_include_directories(cuda.out PRIVATE ${Boost_PATH})
# # set the cuda architectures
# set_target_properties(cuda.out PROPERTIES CUDA_ARCHITECTURES
# "50;60;61;62;70")
# # alpaka build flags
# target_compile_options(
# cuda.out
# PRIVATE -DALPAKA_ACC_GPU_CUDA_PRESENT -DALPAKA_ACC_GPU_CUDA_ENABLED
# -DALPAKA_ACC_GPU_CUDA_ASYNC_BACKEND)
# # nvcc compilation flags
# target_compile_options(
# cuda.out PRIVATE --expt-relaxed-constexpr -gencode
# arch=compute_61,code=[sm_61,compute_61])
# endif()
set(CMAKE_CUDA_FLAGS "-Wall -Wextra -g -O2")

# compile the file with .cc extension using nvcc
set_source_files_properties(main.cc PROPERTIES LANGUAGE CUDA)
# compile gpu cuda module
add_executable(cuda.out main.cc)
# link boost
target_link_libraries(cuda.out PRIVATE ${Boost_LIBRARIES})
target_include_directories(cuda.out PRIVATE ${Boost_PATH})
# set the cuda architectures
set_target_properties(cuda.out PROPERTIES CUDA_ARCHITECTURES
"50;60;61;62;70")
# alpaka build flags
target_compile_options(
cuda.out
PRIVATE -DALPAKA_ACC_GPU_CUDA_PRESENT -DALPAKA_ACC_GPU_CUDA_ENABLED
-DALPAKA_ACC_GPU_CUDA_ASYNC_BACKEND)
# nvcc compilation flags
target_compile_options(
cuda.out PRIVATE --expt-relaxed-constexpr -gencode
arch=compute_61,code=[sm_61,compute_61])
target_compile_options(cuda.out PRIVATE -pg -G)
target_link_options(cuda.out PRIVATE -pg -G)
endif()

# # GPU HIP check if HIP is available
# check_language(HIP)
Expand Down

0 comments on commit 6407aa8

Please sign in to comment.