|
4 | 4 |
|
5 | 5 | cmake_minimum_required(VERSION 3.16.0) |
6 | 6 |
|
7 | | - |
8 | 7 | ################################################################################ |
9 | 8 | # Project |
10 | 9 | ################################################################################ |
11 | 10 |
|
| 11 | +include(CheckLanguage) # check for CUDA/HIP language support |
| 12 | + |
12 | 13 | project(CUDA_memtest LANGUAGES CXX) |
13 | 14 |
|
14 | 15 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) |
@@ -70,15 +71,26 @@ else() |
70 | 71 | # Find HIP |
71 | 72 | ################################################################################ |
72 | 73 | # supported HIP version range |
73 | | - set(CUDA_MEMTEST_HIP_MIN_VER 4.0) |
74 | | - set(CUDA_MEMTEST_HIP_MAX_VER 5.0) |
75 | | - find_package(hip "${CUDA_MEMTEST_HIP_MAX_VER}") |
76 | | - if(NOT TARGET hip) |
77 | | - message(STATUS "Could not find HIP ${CUDA_MEMTEST_HIP_MAX_VER}. Now searching for HIP ${CUDA_MEMTEST_HIP_MIN_VER}") |
78 | | - find_package(hip "${CUDA_MEMTEST_HIP_MIN_VER}") |
79 | | - endif() |
| 74 | + check_language(HIP) |
| 75 | + |
| 76 | + if(CMAKE_HIP_COMPILER) |
| 77 | + enable_language(HIP) |
| 78 | + find_package(hip REQUIRED) |
| 79 | + |
| 80 | + set(CUDA_MEMTEST_HIP_MIN_VER 5.2) |
| 81 | + set(CUDA_MEMTEST_HIP_MAX_VER 6.1) |
80 | 82 |
|
81 | | - if(NOT TARGET hip) |
| 83 | + # construct hip version only with major and minor level |
| 84 | + # cannot use hip_VERSION because of the patch level |
| 85 | + # 6.0 is smaller than 6.0.1234, so CUDA_MEMTEST_HIP_MAX_VER would have to be defined with a large patch level or |
| 86 | + # the next minor level, e.g. 6.1, would have to be used. |
| 87 | + set(_hip_MAJOR_MINOR_VERSION "${hip_VERSION_MAJOR}.${hip_VERSION_MINOR}") |
| 88 | + |
| 89 | + if(${_hip_MAJOR_MINOR_VERSION} VERSION_LESS ${CUDA_MEMTEST_HIP_MIN_VER} OR ${_hip_MAJOR_MINOR_VERSION} VERSION_GREATER ${CUDA_MEMTEST_HIP_MAX_VER}) |
| 90 | + message(WARNING "HIP ${_hip_MAJOR_MINOR_VERSION} is not official supported by cuda_memtest. Supported versions: ${CUDA_MEMTEST_HIP_MIN_VER} - ${CUDA_MEMTEST_HIP_MAX_VER}") |
| 91 | + endif() |
| 92 | + |
| 93 | + else() |
82 | 94 | message(FATAL_ERROR "Optional alpaka dependency HIP could not be found!") |
83 | 95 | endif() |
84 | 96 | endif() |
@@ -135,6 +147,7 @@ if(CUDA_MEMTEST_BACKEND STREQUAL "cuda") |
135 | 147 | else() |
136 | 148 | target_link_libraries(cuda_memtest PRIVATE hip::host) |
137 | 149 | target_link_libraries(cuda_memtest PRIVATE hip::device) |
| 150 | + target_compile_definitions(cuda_memtest PRIVATE "$<$<COMPILE_LANGUAGE:CXX>:-D__HIP_PLATFORM_AMD__>") |
138 | 151 | target_compile_definitions(cuda_memtest PRIVATE "ENABLE_NVML=0") |
139 | 152 | endif() |
140 | 153 |
|
|
0 commit comments