diff --git a/CMakeLists.txt b/CMakeLists.txt index d0d4735..6559284 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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. # #----------------------------------------------------------# @@ -198,4 +236,4 @@ install( FILES "${PROJECT_BINARY_DIR}/bwc-config.cmake" install( EXPORT bwc-targets NAMESPACE bwc:: - DESTINATION ${CMAKE_INSTALL_CMAKEDIR}) \ No newline at end of file + DESTINATION ${CMAKE_INSTALL_CMAKEDIR}) diff --git a/src/library/CMakeLists.txt b/src/library/CMakeLists.txt index 549453e..ad118b9 100755 --- a/src/library/CMakeLists.txt +++ b/src/library/CMakeLists.txt @@ -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 @@ -126,4 +127,4 @@ install( TARGETS bwclib #----------------------------------------------------------# # Define the output name for the BigWhoop library. # #----------------------------------------------------------# -set_property(TARGET bwclib PROPERTY OUTPUT_NAME bwc) \ No newline at end of file +set_property(TARGET bwclib PROPERTY OUTPUT_NAME bwc)