hipify CMakeLists.txt

This commit is contained in:
Gregor Weiss 2024-04-25 07:13:54 +00:00
parent b5244d2817
commit fdb313b0bf
2 changed files with 41 additions and 2 deletions

View file

@ -140,6 +140,44 @@ if("${CMAKE_BUILD_TYPE}" STREQUAL "Release")
endif()
endif()
#----------------------------------------------------------#
# Setup GPU runtime (works for HIP) #
#----------------------------------------------------------#
if (NOT CMAKE_GPU_RUNTIME)
set(GPU_RUNTIME "ROCM" CACHE STRING "Switches between ROCM and CUDA")
else (NOT CMAKE_GPU_RUNTIME)
set(GPU_RUNTIME "${CMAKE_GPU_RUNTIME}" CACHE STRING "Switches between ROCM and CUDA")
endif (NOT CMAKE_GPU_RUNTIME)
# Really should only be ROCM or CUDA, but allowing HIP because it is the currently built-in option
set(GPU_RUNTIMES "ROCM" "CUDA" "HIP")
if(NOT "${GPU_RUNTIME}" IN_LIST GPU_RUNTIMES)
set(ERROR_MESSAGE "GPU_RUNTIME is set to \"${GPU_RUNTIME}\".\nGPU_RUNTIME must be either HIP, ROCM, or CUDA.")
message(FATAL_ERROR ${ERROR_MESSAGE})
endif()
# GPU_RUNTIME for AMD GPUs should really be ROCM, if selecting AMD GPUs
# so manually resetting to HIP if ROCM is selected
if (${GPU_RUNTIME} MATCHES "ROCM")
set(GPU_RUNTIME "HIP")
endif (${GPU_RUNTIME} MATCHES "ROCM")
set_property(CACHE GPU_RUNTIME PROPERTY STRINGS ${GPU_RUNTIMES})
enable_language(${GPU_RUNTIME})
set(CMAKE_${GPU_RUNTIME}_EXTENSIONS OFF)
set(CMAKE_${GPU_RUNTIME}_STANDARD_REQUIRED ON)
if (DEFINED ENV{HIP_PATH})
set(HIP_PATH $ENV{HIP_PATH})
else (DEFINED ENV{HIP_PATH})
execute_process(COMMAND hipconfig --path OUTPUT_VARIABLE HIP_PATH ERROR_QUIET)
endif (DEFINED ENV{HIP_PATH})
set(ROCMCC_FLAGS "${ROCMCC_FLAGS} -munsafe-fp-atomics")
if (${GPU_RUNTIME} MATCHES "HIP")
set(HIPCC_FLAGS "${ROCMCC_FLAGS}")
else (${GPU_RUNTIME} MATCHES "HIP")
set(HIPCC_FLAGS "${CUDACC_FLAGS} -I/${HIP_PATH}/include")
endif (${GPU_RUNTIME} MATCHES "HIP")
#----------------------------------------------------------#
# Add all necessary compiler warnings for debugging. #
#----------------------------------------------------------#

View file

@ -79,6 +79,7 @@ add_library(bwclib ${BWC_LINK} bitstream.c
libbwc.c
codestream.c
dwt.c
dwt.hip
mq.c
tier1.c
tier2.c