-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCMakeLists.txt
56 lines (49 loc) · 2.04 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
cmake_minimum_required(VERSION 3.21 FATAL_ERROR)
project(bilinear CXX)
find_package(OpenMP REQUIRED)
add_library(easybmp EasyBMP/EasyBMP.cpp)
target_include_directories(easybmp PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/EasyBMP)
add_executable(bilinear_cpu bilinear.cpp)
target_compile_features(bilinear_cpu PUBLIC cxx_std_11)
target_link_libraries(bilinear_cpu easybmp OpenMP::OpenMP_CXX)
include(CheckLanguage)
check_language(CUDA)
if (CMAKE_CUDA_COMPILER)
message(STATUS "Using CUDA")
enable_language(CUDA)
set(GPU_ARCHITECTURES "50;86")
else()
check_language(HIP)
if (CMAKE_HIP_COMPILER)
message(STATUS "Using HIP")
enable_language(HIP)
set(GPU_ARCHITECTURES "gfx900")
if(NOT DEFINED HIP_PATH)
if(NOT DEFINED ENV{HIP_PATH})
set(HIP_PATH "/opt/rocm/hip" CACHE PATH "Path to which HIP has been installed")
else()
set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed")
endif()
endif()
set(CMAKE_MODULE_PATH "${HIP_PATH}/cmake" ${CMAKE_MODULE_PATH})
find_package(HIP REQUIRED)
else()
message(STATUS "Could not find CUDA or HIP, skipping GPU support")
endif()
endif()
if (CMAKE_CUDA_COMPILER OR CMAKE_HIP_COMPILER)
foreach (NAME_SUFFIX "unoptimized" "coalescing" "no_fp64")
add_executable(bilinear_gpu_${NAME_SUFFIX} ${NAME_SUFFIX}/bilinear.cu)
if (CMAKE_HIP_COMPILER)
set_source_files_properties(${NAME_SUFFIX}/bilinear.cu PROPERTIES LANGUAGE HIP)
set_target_properties(bilinear_gpu_${NAME_SUFFIX} PROPERTIES HIP_ARCHITECTURES "${GPU_ARCHITECTURES}")
set_target_properties(bilinear_gpu_${NAME_SUFFIX} PROPERTIES HIP_RUNTIME_LIBRARY Shared)
else()
set_target_properties(bilinear_gpu_${NAME_SUFFIX} PROPERTIES CUDA_ARCHITECTURES "${GPU_ARCHITECTURES}")
set_target_properties(bilinear_gpu_${NAME_SUFFIX} PROPERTIES CUDA_RUNTIME_LIBRARY Shared)
endif()
target_compile_features(bilinear_gpu_${NAME_SUFFIX} PUBLIC cxx_std_11)
target_include_directories(bilinear_gpu_${NAME_SUFFIX} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(bilinear_gpu_${NAME_SUFFIX} easybmp)
endforeach()
endif()