diff --git a/projects/hip-tests/samples/0_Intro/bit_extract/CMakeLists.txt b/projects/hip-tests/samples/0_Intro/bit_extract/CMakeLists.txt index bffb2f1abe..166a8ccb79 100644 --- a/projects/hip-tests/samples/0_Intro/bit_extract/CMakeLists.txt +++ b/projects/hip-tests/samples/0_Intro/bit_extract/CMakeLists.txt @@ -26,12 +26,16 @@ if(NOT DEFINED __HIP_ENABLE_PCH) set(__HIP_ENABLE_PCH ON CACHE BOOL "enable/disable pre-compiled hip headers") endif() +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + if(${__HIP_ENABLE_PCH}) add_definitions(-D__HIP_ENABLE_PCH) endif() # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/0_Intro/bit_extract/Makefile b/projects/hip-tests/samples/0_Intro/bit_extract/Makefile index 023259d24f..612c18ce3c 100644 --- a/projects/hip-tests/samples/0_Intro/bit_extract/Makefile +++ b/projects/hip-tests/samples/0_Intro/bit_extract/Makefile @@ -20,7 +20,8 @@ #Dependencies : [MYHIP]/bin must be in user's path. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/0_Intro/module_api/CMakeLists.txt b/projects/hip-tests/samples/0_Intro/module_api/CMakeLists.txt index 2e389e210b..cefe6e2c79 100644 --- a/projects/hip-tests/samples/0_Intro/module_api/CMakeLists.txt +++ b/projects/hip-tests/samples/0_Intro/module_api/CMakeLists.txt @@ -22,8 +22,12 @@ project(module_api) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/0_Intro/module_api/Makefile b/projects/hip-tests/samples/0_Intro/module_api/Makefile index b1baa1849c..ad78c1fd56 100644 --- a/projects/hip-tests/samples/0_Intro/module_api/Makefile +++ b/projects/hip-tests/samples/0_Intro/module_api/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/0_Intro/module_api_global/CMakeLists.txt b/projects/hip-tests/samples/0_Intro/module_api_global/CMakeLists.txt index c4a8b01347..c3b147c60c 100644 --- a/projects/hip-tests/samples/0_Intro/module_api_global/CMakeLists.txt +++ b/projects/hip-tests/samples/0_Intro/module_api_global/CMakeLists.txt @@ -22,8 +22,12 @@ project(modile_api_global) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/0_Intro/module_api_global/Makefile b/projects/hip-tests/samples/0_Intro/module_api_global/Makefile index 212bbae5ec..3d186d3fb0 100644 --- a/projects/hip-tests/samples/0_Intro/module_api_global/Makefile +++ b/projects/hip-tests/samples/0_Intro/module_api_global/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/0_Intro/square/CMakeLists.txt b/projects/hip-tests/samples/0_Intro/square/CMakeLists.txt index 4bcc2ec158..104f828698 100644 --- a/projects/hip-tests/samples/0_Intro/square/CMakeLists.txt +++ b/projects/hip-tests/samples/0_Intro/square/CMakeLists.txt @@ -24,11 +24,15 @@ project(square) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # create square.cpp -execute_process(COMMAND sh -c "/opt/rocm/hip/bin/hipify-perl ../square.cu > ../square.cpp") +execute_process(COMMAND sh -c "${ROCM_PATH}/hip/bin/hipify-perl ../square.cu > ../square.cpp") # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/0_Intro/square/Makefile b/projects/hip-tests/samples/0_Intro/square/Makefile index 3cefbe6d25..ec35c87e72 100644 --- a/projects/hip-tests/samples/0_Intro/square/Makefile +++ b/projects/hip-tests/samples/0_Intro/square/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/1_Utils/hipBusBandwidth/CMakeLists.txt b/projects/hip-tests/samples/1_Utils/hipBusBandwidth/CMakeLists.txt index 5ec0c2ff50..bfebb89e56 100644 --- a/projects/hip-tests/samples/1_Utils/hipBusBandwidth/CMakeLists.txt +++ b/projects/hip-tests/samples/1_Utils/hipBusBandwidth/CMakeLists.txt @@ -22,8 +22,12 @@ project(hipBusBandwidth) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/1_Utils/hipBusBandwidth/Makefile b/projects/hip-tests/samples/1_Utils/hipBusBandwidth/Makefile index 8a45e5f130..8fa0b829fc 100644 --- a/projects/hip-tests/samples/1_Utils/hipBusBandwidth/Makefile +++ b/projects/hip-tests/samples/1_Utils/hipBusBandwidth/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/1_Utils/hipCommander/CMakeLists.txt b/projects/hip-tests/samples/1_Utils/hipCommander/CMakeLists.txt index d071a84c40..2719619f36 100644 --- a/projects/hip-tests/samples/1_Utils/hipCommander/CMakeLists.txt +++ b/projects/hip-tests/samples/1_Utils/hipCommander/CMakeLists.txt @@ -22,8 +22,12 @@ project(hipCommander) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/1_Utils/hipCommander/Makefile b/projects/hip-tests/samples/1_Utils/hipCommander/Makefile index 55dc844d1d..bb38a1f2b7 100644 --- a/projects/hip-tests/samples/1_Utils/hipCommander/Makefile +++ b/projects/hip-tests/samples/1_Utils/hipCommander/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/1_Utils/hipDispatchLatency/CMakeLists.txt b/projects/hip-tests/samples/1_Utils/hipDispatchLatency/CMakeLists.txt index 096edae9bc..d0a453f1d5 100644 --- a/projects/hip-tests/samples/1_Utils/hipDispatchLatency/CMakeLists.txt +++ b/projects/hip-tests/samples/1_Utils/hipDispatchLatency/CMakeLists.txt @@ -22,8 +22,12 @@ project(hipDispatchLatency) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/1_Utils/hipDispatchLatency/Makefile b/projects/hip-tests/samples/1_Utils/hipDispatchLatency/Makefile index 969557ae84..b93a530056 100644 --- a/projects/hip-tests/samples/1_Utils/hipDispatchLatency/Makefile +++ b/projects/hip-tests/samples/1_Utils/hipDispatchLatency/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/1_Utils/hipInfo/CMakeLists.txt b/projects/hip-tests/samples/1_Utils/hipInfo/CMakeLists.txt index 2cfc0cb6ce..4314467527 100644 --- a/projects/hip-tests/samples/1_Utils/hipInfo/CMakeLists.txt +++ b/projects/hip-tests/samples/1_Utils/hipInfo/CMakeLists.txt @@ -22,8 +22,12 @@ project(hipInfo) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/1_Utils/hipInfo/Makefile b/projects/hip-tests/samples/1_Utils/hipInfo/Makefile index d8cdf32188..09f717c7c2 100644 --- a/projects/hip-tests/samples/1_Utils/hipInfo/Makefile +++ b/projects/hip-tests/samples/1_Utils/hipInfo/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt index 6d12e24dc0..ae4735c1ae 100644 --- a/projects/hip-tests/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt @@ -22,8 +22,12 @@ project(MatrixTranspose) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/2_Cookbook/0_MatrixTranspose/Makefile b/projects/hip-tests/samples/2_Cookbook/0_MatrixTranspose/Makefile index f691f5003e..4e829bde28 100644 --- a/projects/hip-tests/samples/2_Cookbook/0_MatrixTranspose/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/0_MatrixTranspose/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/10_inline_asm/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/10_inline_asm/CMakeLists.txt index e4a8a4eb87..ac4e586772 100644 --- a/projects/hip-tests/samples/2_Cookbook/10_inline_asm/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/10_inline_asm/CMakeLists.txt @@ -22,8 +22,12 @@ project(inline_asm) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/2_Cookbook/10_inline_asm/Makefile b/projects/hip-tests/samples/2_Cookbook/10_inline_asm/Makefile index fcdb849c87..516a120612 100644 --- a/projects/hip-tests/samples/2_Cookbook/10_inline_asm/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/10_inline_asm/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/11_texture_driver/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/11_texture_driver/CMakeLists.txt index d8475b9c2f..f93b2e791e 100644 --- a/projects/hip-tests/samples/2_Cookbook/11_texture_driver/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/11_texture_driver/CMakeLists.txt @@ -22,8 +22,12 @@ project(texture2dDrv) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/2_Cookbook/11_texture_driver/Makefile b/projects/hip-tests/samples/2_Cookbook/11_texture_driver/Makefile index ea284a8e1f..68d4d7f28c 100644 --- a/projects/hip-tests/samples/2_Cookbook/11_texture_driver/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/11_texture_driver/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt index 04d327efc7..32f190b58f 100644 --- a/projects/hip-tests/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt @@ -19,10 +19,13 @@ # THE SOFTWARE. cmake_minimum_required(VERSION 2.8.3) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () 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") + set(HIP_PATH "${ROCM_PATH}/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() @@ -36,7 +39,7 @@ find_package(HIP QUIET) if(HIP_FOUND) message(STATUS "Found HIP: " ${HIP_VERSION}) else() - message(FATAL_ERROR "Could not find HIP. Ensure that HIP is either installed in /opt/rocm/hip or the variable HIP_PATH is set to point to the right location.") + message(FATAL_ERROR "Could not find HIP. Ensure that HIP is either installed in ${ROCM_PATH}/hip or the variable HIP_PATH is set to point to the right location.") endif() set(MY_SOURCE_FILES MatrixTranspose.cpp) @@ -50,7 +53,7 @@ set_source_files_properties(${MY_SOURCE_FILES} PROPERTIES HIP_SOURCE_PROPERTY_FO hip_add_executable(${MY_TARGET_NAME} ${MY_SOURCE_FILES} HIPCC_OPTIONS ${MY_HIPCC_OPTIONS} HCC_OPTIONS ${MY_HCC_OPTIONS} CLANG_OPTIONS ${MY_CLANG_OPTIONS} NVCC_OPTIONS ${MY_NVCC_OPTIONS}) # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH ${HIP_PATH} /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${HIP_PATH} ${ROCM_PATH}) find_package(hip QUIET) if(TARGET hip::host) message(STATUS "Found hip::host at ${hip_DIR}") diff --git a/projects/hip-tests/samples/2_Cookbook/13_occupancy/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/13_occupancy/CMakeLists.txt index d69c22fd9b..481cf58b26 100644 --- a/projects/hip-tests/samples/2_Cookbook/13_occupancy/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/13_occupancy/CMakeLists.txt @@ -22,8 +22,12 @@ project(occupancy) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/2_Cookbook/13_occupancy/Makefile b/projects/hip-tests/samples/2_Cookbook/13_occupancy/Makefile index bb19856d12..bfd5a8bb30 100644 --- a/projects/hip-tests/samples/2_Cookbook/13_occupancy/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/13_occupancy/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt index 58c2f372d3..084f273096 100644 --- a/projects/hip-tests/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt @@ -22,8 +22,12 @@ project(gpuarch) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/2_Cookbook/14_gpu_arch/Makefile b/projects/hip-tests/samples/2_Cookbook/14_gpu_arch/Makefile index eebb86d7ce..2e898a9e02 100644 --- a/projects/hip-tests/samples/2_Cookbook/14_gpu_arch/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/14_gpu_arch/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/15_static_library/README.md b/projects/hip-tests/samples/2_Cookbook/15_static_library/README.md index 3a347d2cf7..bf0123573d 100644 --- a/projects/hip-tests/samples/2_Cookbook/15_static_library/README.md +++ b/projects/hip-tests/samples/2_Cookbook/15_static_library/README.md @@ -74,7 +74,8 @@ hipcc hipMain1.cpp -L. -lHipOptLibrary -o test_emit_static_hipcc_linker.out ``` Using g++: ``` -g++ hipMain1.cpp -L. -lHipOptLibrary -L/opt/rocm/hip/lib -lamdhip64 -o test_emit_static_host_linker.out +ROCM_PATH is the path where ROCM is installed. default path is /opt/rocm. +g++ hipMain1.cpp -L. -lHipOptLibrary -L/hip/lib -lamdhip64 -o test_emit_static_host_linker.out ``` ## Static libraries with device functions diff --git a/projects/hip-tests/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt index f73ba6766e..30a5928389 100644 --- a/projects/hip-tests/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt @@ -2,8 +2,12 @@ project(static_lib) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip REQUIRED) @@ -23,7 +27,7 @@ add_library(HipDevice STATIC ${CPP_SOURCES}) target_compile_options(HipDevice PRIVATE -fgpu-rdc) target_link_libraries(HipDevice PRIVATE -fgpu-rdc) -target_include_directories(HipDevice PRIVATE /opt/rocm/hsa/include) +target_include_directories(HipDevice PRIVATE ${ROCM_PATH}/hsa/include) # Create test executable that uses libHipDevice.a set(TEST_SOURCES ${CMAKE_SOURCE_DIR}/hipMain2.cpp) diff --git a/projects/hip-tests/samples/2_Cookbook/15_static_library/device_functions/Makefile b/projects/hip-tests/samples/2_Cookbook/15_static_library/device_functions/Makefile index 26c9ed122f..74bade6359 100644 --- a/projects/hip-tests/samples/2_Cookbook/15_static_library/device_functions/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/15_static_library/device_functions/Makefile @@ -1,4 +1,5 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt index bbb738f0f1..347171ed9d 100644 --- a/projects/hip-tests/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt @@ -2,8 +2,12 @@ project(static_lib) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip REQUIRED) diff --git a/projects/hip-tests/samples/2_Cookbook/15_static_library/host_functions/Makefile b/projects/hip-tests/samples/2_Cookbook/15_static_library/host_functions/Makefile index 4945075cad..645b26fbb1 100644 --- a/projects/hip-tests/samples/2_Cookbook/15_static_library/host_functions/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/15_static_library/host_functions/Makefile @@ -1,4 +1,5 @@ -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/16_assembly_to_executable/Makefile b/projects/hip-tests/samples/2_Cookbook/16_assembly_to_executable/Makefile index f8117ffbf0..5732f37d01 100644 --- a/projects/hip-tests/samples/2_Cookbook/16_assembly_to_executable/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/16_assembly_to_executable/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/16_assembly_to_executable/README.md b/projects/hip-tests/samples/2_Cookbook/16_assembly_to_executable/README.md index ef11329924..6a2ce15a10 100644 --- a/projects/hip-tests/samples/2_Cookbook/16_assembly_to_executable/README.md +++ b/projects/hip-tests/samples/2_Cookbook/16_assembly_to_executable/README.md @@ -1,3 +1,4 @@ +ROCM_PATH is the path where ROCM is installed. default path is /opt/rocm. # Compile to assembly and create an executable from modified asm This sample shows how to generate the assembly code for a simple HIP source application, then re-compiling it and generating a valid HIP executable. @@ -7,8 +8,8 @@ This sample uses a previous HIP application sample, please see [0_Intro/square]( ## Compiling the HIP source into assembly Using HIP flags `-c -S` will help generate the host x86_64 and the device AMDGCN assembly code when paired with `--cuda-host-only` and `--cuda-device-only` respectively. In this sample we use these commands: ``` -/opt/rocm/hip/bin/hipcc -c -S --cuda-host-only -target x86_64-linux-gnu -o square_host.s square.cpp -/opt/rocm/hip/bin/hipcc -c -S --cuda-device-only --offload-arch=gfx900 --offload-arch=gfx906 square.cpp +/hip/bin/hipcc -c -S --cuda-host-only -target x86_64-linux-gnu -o square_host.s square.cpp +/hip/bin/hipcc -c -S --cuda-device-only --offload-arch=gfx900 --offload-arch=gfx906 square.cpp ``` The device assembly will be output into two separate files: @@ -22,22 +23,22 @@ You may modify `--offload-arch` flag to build other archs and choose to enable o ## Compiling the assembly into a valid HIP executable If valid, the modified host and device assembly may be compiled into a HIP executable. The host assembly can be compiled into an object using this command: ``` -/opt/rocm/hip/bin/hipcc -c square_host.s -o square_host.o +/hip/bin/hipcc -c square_host.s -o square_host.o ``` However, the device assembly code will require a few extra steps. The device assemblies needs to be compiled into device objects, then offload-bundled into a HIP fat binary using the clang-offload-bundler, then llvm-mc embeds the binary inside of a host object using the MC directives provided in `hip_obj_gen.mcin`. The output is a host object with an embedded device object. Here are the steps for device side compilation into an object: ``` -/opt/rocm/hip/../llvm/bin/clang -target amdgcn-amd-amdhsa -mcpu=gfx900 square-hip-amdgcn-amd-amdhsa-gfx900.s -o square-hip-amdgcn-amd-amdhsa-gfx900.o -/opt/rocm/hip/../llvm/bin/clang -target amdgcn-amd-amdhsa -mcpu=gfx906 square-hip-amdgcn-amd-amdhsa-gfx906.s -o square-hip-amdgcn-amd-amdhsa-gfx906.o -/opt/rocm/llvm/bin/clang-offload-bundler -type=o -bundle-align=4096 -targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa-gfx900,hip-amdgcn-amd-amdhsa-gfx906 -inputs=/dev/null,square-hip-amdgcn-amd-amdhsa-gfx900.o,square-hip-amdgcn-amd-amdhsa-gfx906.o -outputs=offload_bundle.hipfb -/opt/rocm/llvm/bin/llvm-mc -triple x86_64-unknown-linux-gnu hip_obj_gen.mcin -o square_device.o --filetype=obj +/hip/../llvm/bin/clang -target amdgcn-amd-amdhsa -mcpu=gfx900 square-hip-amdgcn-amd-amdhsa-gfx900.s -o square-hip-amdgcn-amd-amdhsa-gfx900.o +/hip/../llvm/bin/clang -target amdgcn-amd-amdhsa -mcpu=gfx906 square-hip-amdgcn-amd-amdhsa-gfx906.s -o square-hip-amdgcn-amd-amdhsa-gfx906.o +/llvm/bin/clang-offload-bundler -type=o -bundle-align=4096 -targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa-gfx900,hip-amdgcn-amd-amdhsa-gfx906 -inputs=/dev/null,square-hip-amdgcn-amd-amdhsa-gfx900.o,square-hip-amdgcn-amd-amdhsa-gfx906.o -outputs=offload_bundle.hipfb +/llvm/bin/llvm-mc -triple x86_64-unknown-linux-gnu hip_obj_gen.mcin -o square_device.o --filetype=obj ``` **Note:** Using option `-bundle-align=4096` only works on ROCm 4.0 and newer compilers. Also, the architecture must match the same arch as when compiling to assembly. Finally, using the system linker, hipcc, or clang, link the host and device objects into an executable: ``` -/opt/rocm/hip/bin/hipcc square_host.o square_device.o -o square_asm.out +/hip/bin/hipcc square_host.o square_device.o -o square_asm.out ``` If you haven't modified the GPU archs, this executable should run on both `gfx900` and `gfx906`. diff --git a/projects/hip-tests/samples/2_Cookbook/17_llvm_ir_to_executable/Makefile b/projects/hip-tests/samples/2_Cookbook/17_llvm_ir_to_executable/Makefile index 722248a853..6299094b20 100644 --- a/projects/hip-tests/samples/2_Cookbook/17_llvm_ir_to_executable/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/17_llvm_ir_to_executable/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/17_llvm_ir_to_executable/README.md b/projects/hip-tests/samples/2_Cookbook/17_llvm_ir_to_executable/README.md index 4b1ea11dd5..45cd0cb7df 100644 --- a/projects/hip-tests/samples/2_Cookbook/17_llvm_ir_to_executable/README.md +++ b/projects/hip-tests/samples/2_Cookbook/17_llvm_ir_to_executable/README.md @@ -1,3 +1,4 @@ +ROCM_PATH is the path where ROCM is installed. default path is /opt/rocm. # Compile to LLVM IR and create an executable from modified IR This sample shows how to generate the LLVM IR for a simple HIP source application, then re-compiling it and generating a valid HIP executable. @@ -7,8 +8,8 @@ This sample uses a previous HIP application sample, please see [0_Intro/square]( ## Compiling the HIP source into LLVM IR Using HIP flags `-c -emit-llvm` will help generate the host x86_64 and the device LLVM bitcode when paired with `--cuda-host-only` and `--cuda-device-only` respectively. In this sample we use these commands: ``` -/opt/rocm/hip/bin/hipcc -c -emit-llvm --cuda-host-only -target x86_64-linux-gnu -o square_host.bc square.cpp -/opt/rocm/hip/bin/hipcc -c -emit-llvm --cuda-device-only --offload-arch=gfx900 --offload-arch=gfx906 square.cpp +/hip/bin/hipcc -c -emit-llvm --cuda-host-only -target x86_64-linux-gnu -o square_host.bc square.cpp +/hip/bin/hipcc -c -emit-llvm --cuda-device-only --offload-arch=gfx900 --offload-arch=gfx906 square.cpp ``` The device LLVM IR bitcode will be output into two separate files: - square-hip-amdgcn-amd-amdhsa-gfx900.bc @@ -18,8 +19,8 @@ You may modify `--offload-arch` flag to build other archs and choose to enable o To transform the LLVM bitcode into human readable LLVM IR, use these commands: ``` -/opt/rocm/llvm/bin/llvm-dis square-hip-amdgcn-amd-amdhsa-gfx900.bc -o square-hip-amdgcn-amd-amdhsa-gfx900.ll -/opt/rocm/llvm/bin/llvm-dis square-hip-amdgcn-amd-amdhsa-gfx906.bc -o square-hip-amdgcn-amd-amdhsa-gfx906.ll +/llvm/bin/llvm-dis square-hip-amdgcn-amd-amdhsa-gfx900.bc -o square-hip-amdgcn-amd-amdhsa-gfx900.ll +/llvm/bin/llvm-dis square-hip-amdgcn-amd-amdhsa-gfx906.bc -o square-hip-amdgcn-amd-amdhsa-gfx906.ll ``` **Warning:** We cannot ensure any compiler besides the ROCm hipcc and clang will be compatible with this process. Also, there is no guarantee that the starting IR produced with `-x cl` will run with HIP runtime. Experimenting with other compilers or starting IR will be the responsibility of the developer. @@ -32,25 +33,25 @@ At this point, you may evaluate the LLVM IR and make modifications if you are fa ## Compiling the LLVM IR into a valid HIP executable If valid, the modified host and device IR may be compiled into a HIP executable. First, the readable IR must be compiled back in LLVM bitcode. The host IR can be compiled into an object using this command: ``` -/opt/rocm/llvm/bin/llvm-as square_host.ll -o square_host.bc -/opt/rocm/hip/bin/hipcc -c square_host.bc -o square_host.o +/llvm/bin/llvm-as square_host.ll -o square_host.bc +/hip/bin/hipcc -c square_host.bc -o square_host.o ``` However, the device IR will require a few extra steps. The device bitcodes needs to be compiled into device objects, then offload-bundled into a HIP fat binary using the clang-offload-bundler, then llvm-mc embeds the binary inside of a host object using the MC directives provided in `hip_obj_gen.mcin`. The output is a host object with an embedded device object. Here are the steps for device side compilation into an object: ``` -/opt/rocm/hip/../llvm/bin/llvm-as square-hip-amdgcn-amd-amdhsa-gfx900.ll -o square-hip-amdgcn-amd-amdhsa-gfx900.bc -/opt/rocm/hip/../llvm/bin/llvm-as square-hip-amdgcn-amd-amdhsa-gfx906.ll -o square-hip-amdgcn-amd-amdhsa-gfx906.bc -/opt/rocm/hip/../llvm/bin/clang -target amdgcn-amd-amdhsa -mcpu=gfx900 square-hip-amdgcn-amd-amdhsa-gfx900.bc -o square-hip-amdgcn-amd-amdhsa-gfx900.o -/opt/rocm/hip/../llvm/bin/clang -target amdgcn-amd-amdhsa -mcpu=gfx906 square-hip-amdgcn-amd-amdhsa-gfx906.bc -o square-hip-amdgcn-amd-amdhsa-gfx906.o -/opt/rocm/hip/../llvm/bin/clang-offload-bundler -type=o -bundle-align=4096 -targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa-gfx900,hip-amdgcn-amd-amdhsa-gfx906 -inputs=/dev/null,square-hip-amdgcn-amd-amdhsa-gfx900.o,square-hip-amdgcn-amd-amdhsa-gfx906.o -outputs=offload_bundle.hipfb -/opt/rocm/llvm/bin/llvm-mc hip_obj_gen.mcin -o square_device.o --filetype=obj +/hip/../llvm/bin/llvm-as square-hip-amdgcn-amd-amdhsa-gfx900.ll -o square-hip-amdgcn-amd-amdhsa-gfx900.bc +/hip/../llvm/bin/llvm-as square-hip-amdgcn-amd-amdhsa-gfx906.ll -o square-hip-amdgcn-amd-amdhsa-gfx906.bc +/hip/../llvm/bin/clang -target amdgcn-amd-amdhsa -mcpu=gfx900 square-hip-amdgcn-amd-amdhsa-gfx900.bc -o square-hip-amdgcn-amd-amdhsa-gfx900.o +/hip/../llvm/bin/clang -target amdgcn-amd-amdhsa -mcpu=gfx906 square-hip-amdgcn-amd-amdhsa-gfx906.bc -o square-hip-amdgcn-amd-amdhsa-gfx906.o +/hip/../llvm/bin/clang-offload-bundler -type=o -bundle-align=4096 -targets=host-x86_64-unknown-linux,hip-amdgcn-amd-amdhsa-gfx900,hip-amdgcn-amd-amdhsa-gfx906 -inputs=/dev/null,square-hip-amdgcn-amd-amdhsa-gfx900.o,square-hip-amdgcn-amd-amdhsa-gfx906.o -outputs=offload_bundle.hipfb +/llvm/bin/llvm-mc hip_obj_gen.mcin -o square_device.o --filetype=obj ``` **Note:** Using option `-bundle-align=4096` only works on ROCm 4.0 and newer compilers. Also, the architecture must match the same arch as when compiling to LLVM IR. Finally, using the system linker, hipcc, or clang, link the host and device objects into an executable: ``` -/opt/rocm/hip/bin/hipcc square_host.o square_device.o -o square_ir.out +/hip/bin/hipcc square_host.o square_device.o -o square_ir.out ``` If you haven't modified the GPU archs, this executable should run on both `gfx900` and `gfx906`. diff --git a/projects/hip-tests/samples/2_Cookbook/1_hipEvent/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/1_hipEvent/CMakeLists.txt index f4b6029943..9ac1aba1ca 100644 --- a/projects/hip-tests/samples/2_Cookbook/1_hipEvent/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/1_hipEvent/CMakeLists.txt @@ -22,8 +22,12 @@ project(hipEvent) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/2_Cookbook/1_hipEvent/Makefile b/projects/hip-tests/samples/2_Cookbook/1_hipEvent/Makefile index 563702e6fb..01655bde5b 100644 --- a/projects/hip-tests/samples/2_Cookbook/1_hipEvent/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/1_hipEvent/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/3_shared_memory/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/3_shared_memory/CMakeLists.txt index 41fdd78250..f2f5196373 100644 --- a/projects/hip-tests/samples/2_Cookbook/3_shared_memory/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/3_shared_memory/CMakeLists.txt @@ -22,8 +22,12 @@ project(sharedMemory) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/2_Cookbook/3_shared_memory/Makefile b/projects/hip-tests/samples/2_Cookbook/3_shared_memory/Makefile index 7227b9b9a6..ef8727c5ea 100644 --- a/projects/hip-tests/samples/2_Cookbook/3_shared_memory/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/3_shared_memory/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/4_shfl/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/4_shfl/CMakeLists.txt index d0fd286ffe..394d5852fb 100644 --- a/projects/hip-tests/samples/2_Cookbook/4_shfl/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/4_shfl/CMakeLists.txt @@ -22,8 +22,12 @@ project(shfl) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/2_Cookbook/4_shfl/Makefile b/projects/hip-tests/samples/2_Cookbook/4_shfl/Makefile index 1b470f1d57..76559c1cd2 100644 --- a/projects/hip-tests/samples/2_Cookbook/4_shfl/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/4_shfl/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/5_2dshfl/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/5_2dshfl/CMakeLists.txt index 1fc362dedb..d0ab52859d 100644 --- a/projects/hip-tests/samples/2_Cookbook/5_2dshfl/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/5_2dshfl/CMakeLists.txt @@ -22,8 +22,12 @@ project(2dshfl) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/2_Cookbook/5_2dshfl/Makefile b/projects/hip-tests/samples/2_Cookbook/5_2dshfl/Makefile index 9e67c3e589..57240697ee 100644 --- a/projects/hip-tests/samples/2_Cookbook/5_2dshfl/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/5_2dshfl/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt index 8dba51a666..73c4fe621b 100644 --- a/projects/hip-tests/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt @@ -22,8 +22,12 @@ project(dynamic_shared) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/2_Cookbook/6_dynamic_shared/Makefile b/projects/hip-tests/samples/2_Cookbook/6_dynamic_shared/Makefile index f35de1d0ec..71d4f135ab 100644 --- a/projects/hip-tests/samples/2_Cookbook/6_dynamic_shared/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/6_dynamic_shared/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/7_streams/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/7_streams/CMakeLists.txt index 9aa963f870..2d95541905 100644 --- a/projects/hip-tests/samples/2_Cookbook/7_streams/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/7_streams/CMakeLists.txt @@ -22,8 +22,12 @@ project(stream) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/2_Cookbook/7_streams/Makefile b/projects/hip-tests/samples/2_Cookbook/7_streams/Makefile index dcf679f9b8..814341b5c5 100644 --- a/projects/hip-tests/samples/2_Cookbook/7_streams/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/7_streams/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/8_peer2peer/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/8_peer2peer/CMakeLists.txt index abcb2b7afd..ad34ee44df 100644 --- a/projects/hip-tests/samples/2_Cookbook/8_peer2peer/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/8_peer2peer/CMakeLists.txt @@ -22,8 +22,12 @@ project(peer2peer) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/2_Cookbook/8_peer2peer/Makefile b/projects/hip-tests/samples/2_Cookbook/8_peer2peer/Makefile index 6b07f7fa87..555e92ec9f 100644 --- a/projects/hip-tests/samples/2_Cookbook/8_peer2peer/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/8_peer2peer/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/2_Cookbook/9_unroll/CMakeLists.txt b/projects/hip-tests/samples/2_Cookbook/9_unroll/CMakeLists.txt index 02f900f70e..258138f2b9 100644 --- a/projects/hip-tests/samples/2_Cookbook/9_unroll/CMakeLists.txt +++ b/projects/hip-tests/samples/2_Cookbook/9_unroll/CMakeLists.txt @@ -22,8 +22,12 @@ project(unroll) cmake_minimum_required(VERSION 3.10) +if (NOT DEFINED ROCM_PATH ) + set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) +endif () + # Search for rocm in common locations -list(APPEND CMAKE_PREFIX_PATH /opt/rocm/hip /opt/rocm) +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}/hip ${ROCM_PATH}) # Find hip find_package(hip) diff --git a/projects/hip-tests/samples/2_Cookbook/9_unroll/Makefile b/projects/hip-tests/samples/2_Cookbook/9_unroll/Makefile index 138d412050..d1e3321b4f 100644 --- a/projects/hip-tests/samples/2_Cookbook/9_unroll/Makefile +++ b/projects/hip-tests/samples/2_Cookbook/9_unroll/Makefile @@ -18,7 +18,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -HIP_PATH?= $(wildcard /opt/rocm/hip) +ROCM_PATH?= $(wildcard /opt/rocm/) +HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) ifeq (,$(HIP_PATH)) HIP_PATH=../../.. endif diff --git a/projects/hip-tests/samples/README.md b/projects/hip-tests/samples/README.md index c54ec20b3a..ac4bd1ca94 100644 --- a/projects/hip-tests/samples/README.md +++ b/projects/hip-tests/samples/README.md @@ -24,7 +24,7 @@ cmake .. b. to build with static libs, run -cmake -DCMAKE_PREFIX_PATH="/opt/rocm/llvm/lib/cmake" .. +cmake -DCMAKE_PREFIX_PATH="/llvm/lib/cmake" .. Then run,