diff --git a/samples/0_Intro/bit_extract/CMakeLists.txt b/samples/0_Intro/bit_extract/CMakeLists.txt index 148f0b2904..de13dfdd07 100644 --- a/samples/0_Intro/bit_extract/CMakeLists.txt +++ b/samples/0_Intro/bit_extract/CMakeLists.txt @@ -30,6 +30,14 @@ if(${__HIP_ENABLE_PCH}) add_definitions(-D__HIP_ENABLE_PCH) endif() +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/0_Intro/module_api/CMakeLists.txt b/samples/0_Intro/module_api/CMakeLists.txt index 264304d31d..75f1cfa01a 100644 --- a/samples/0_Intro/module_api/CMakeLists.txt +++ b/samples/0_Intro/module_api/CMakeLists.txt @@ -23,6 +23,15 @@ project(module_api) cmake_minimum_required(VERSION 3.10) include_directories(../../common) + +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/0_Intro/module_api_global/CMakeLists.txt b/samples/0_Intro/module_api_global/CMakeLists.txt index 0f22e25e82..3d4fc31413 100644 --- a/samples/0_Intro/module_api_global/CMakeLists.txt +++ b/samples/0_Intro/module_api_global/CMakeLists.txt @@ -22,6 +22,14 @@ project(module_api_global) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/0_Intro/square/CMakeLists.txt b/samples/0_Intro/square/CMakeLists.txt index 3ce76b64ba..5cc2edbd7b 100644 --- a/samples/0_Intro/square/CMakeLists.txt +++ b/samples/0_Intro/square/CMakeLists.txt @@ -24,6 +24,14 @@ project(square) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # create square.cpp execute_process(COMMAND sh -c "${CMAKE_PREFIX_PATH}/bin/hipify-perl ../square.cu > ../square.cpp") diff --git a/samples/0_Intro/square/README.md b/samples/0_Intro/square/README.md index 5644184ee7..bdbb739e8e 100644 --- a/samples/0_Intro/square/README.md +++ b/samples/0_Intro/square/README.md @@ -20,7 +20,7 @@ $ export HIP_PATH=[MYHIP] $ cd ~/hip/samples/0_Intro/square mkdir -p build && cd build - cmake -DCMAKE_PREFIX_PATH= -DHIP_CXX_COMPILER= .. + cmake .. make $ Building without cmake diff --git a/samples/1_Utils/hipDispatchLatency/CMakeLists.txt b/samples/1_Utils/hipDispatchLatency/CMakeLists.txt index da1fe45480..a077044e26 100644 --- a/samples/1_Utils/hipDispatchLatency/CMakeLists.txt +++ b/samples/1_Utils/hipDispatchLatency/CMakeLists.txt @@ -23,6 +23,15 @@ project(hipDispatchLatency) cmake_minimum_required(VERSION 3.10) include_directories(../../common) + +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/1_Utils/hipInfo/CMakeLists.txt b/samples/1_Utils/hipInfo/CMakeLists.txt index 63bf4f7175..368b5da0e8 100644 --- a/samples/1_Utils/hipInfo/CMakeLists.txt +++ b/samples/1_Utils/hipInfo/CMakeLists.txt @@ -26,6 +26,13 @@ set(CMAKE_CXX_COMPILER_WORKS 1) project(hipInfo) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() # flag is set to ON in compute build for windows option(HIPINFO_INTERNAL_BUILD "Enable building hipInfo from compute" OFF) diff --git a/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt b/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt index a396bbc0c5..6970f457c3 100644 --- a/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt +++ b/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt @@ -22,6 +22,14 @@ project(MatrixTranspose) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/2_Cookbook/10_inline_asm/CMakeLists.txt b/samples/2_Cookbook/10_inline_asm/CMakeLists.txt index 712ea216bc..1b17cdf470 100644 --- a/samples/2_Cookbook/10_inline_asm/CMakeLists.txt +++ b/samples/2_Cookbook/10_inline_asm/CMakeLists.txt @@ -22,6 +22,14 @@ project(inline_asm) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/2_Cookbook/11_texture_driver/CMakeLists.txt b/samples/2_Cookbook/11_texture_driver/CMakeLists.txt index a11422877c..68b9531139 100644 --- a/samples/2_Cookbook/11_texture_driver/CMakeLists.txt +++ b/samples/2_Cookbook/11_texture_driver/CMakeLists.txt @@ -22,6 +22,14 @@ project(texture2dDrv) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt b/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt index 74c51f5c25..2cfbed261f 100644 --- a/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt +++ b/samples/2_Cookbook/12_cmake_hip_add_executable/CMakeLists.txt @@ -19,9 +19,11 @@ # THE SOFTWARE. cmake_minimum_required(VERSION 3.10) -if (NOT DEFINED ROCM_PATH ) - set ( ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory." ) -endif () +if(UNIX) + if(NOT DEFINED ROCM_PATH) + set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") + endif() +endif() if(NOT DEFINED HIP_PATH) if(NOT DEFINED ENV{HIP_PATH}) @@ -30,6 +32,9 @@ if(NOT DEFINED HIP_PATH) set(HIP_PATH $ENV{HIP_PATH} CACHE PATH "Path to which HIP has been installed") endif() endif() +# Search for rocm in common locations +list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) + set(CMAKE_MODULE_PATH "${HIP_PATH}/lib/cmake/hip/" ${CMAKE_MODULE_PATH}) set(CMAKE_HIP_ARCHITECTURES OFF) project(12_cmake) diff --git a/samples/2_Cookbook/13_occupancy/CMakeLists.txt b/samples/2_Cookbook/13_occupancy/CMakeLists.txt index c0ec339d1e..8b98de9e7e 100644 --- a/samples/2_Cookbook/13_occupancy/CMakeLists.txt +++ b/samples/2_Cookbook/13_occupancy/CMakeLists.txt @@ -22,6 +22,14 @@ project(occupancy) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt b/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt index 5a2a426db6..4e794a1dd1 100644 --- a/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt +++ b/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt @@ -22,6 +22,14 @@ project(gpuarch) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt b/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt index 98bde53e1c..26ea3792cb 100644 --- a/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt +++ b/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt @@ -2,6 +2,14 @@ project(static_lib) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip REQUIRED) diff --git a/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt b/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt index 4f5af10a01..9364c7243d 100644 --- a/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt +++ b/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt @@ -2,6 +2,14 @@ project(static_lib) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip REQUIRED) diff --git a/samples/2_Cookbook/18_cmake_hip_device/CMakeLists.txt b/samples/2_Cookbook/18_cmake_hip_device/CMakeLists.txt index 5ca7c40abe..a1167548d7 100644 --- a/samples/2_Cookbook/18_cmake_hip_device/CMakeLists.txt +++ b/samples/2_Cookbook/18_cmake_hip_device/CMakeLists.txt @@ -24,6 +24,14 @@ cmake_minimum_required(VERSION 3.10.2) include_directories(../../common) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip REQUIRED) diff --git a/samples/2_Cookbook/19_cmake_lang/CMakeLists.txt b/samples/2_Cookbook/19_cmake_lang/CMakeLists.txt index 0c3a2a7fa0..b1aea067e7 100644 --- a/samples/2_Cookbook/19_cmake_lang/CMakeLists.txt +++ b/samples/2_Cookbook/19_cmake_lang/CMakeLists.txt @@ -4,6 +4,14 @@ cmake_minimum_required(VERSION 3.18.0) project(cmake_lang_test CXX Fortran) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + find_package(hip REQUIRED) add_executable(test_fortran TestFortran.F90) diff --git a/samples/2_Cookbook/1_hipEvent/CMakeLists.txt b/samples/2_Cookbook/1_hipEvent/CMakeLists.txt index b709921162..0fcd276e09 100644 --- a/samples/2_Cookbook/1_hipEvent/CMakeLists.txt +++ b/samples/2_Cookbook/1_hipEvent/CMakeLists.txt @@ -22,6 +22,14 @@ project(hipEvent) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/2_Cookbook/20_hip_vulkan/CMakeLists.txt b/samples/2_Cookbook/20_hip_vulkan/CMakeLists.txt index 55918d5a6a..fb0bfdb130 100644 --- a/samples/2_Cookbook/20_hip_vulkan/CMakeLists.txt +++ b/samples/2_Cookbook/20_hip_vulkan/CMakeLists.txt @@ -29,6 +29,14 @@ project(hipVulkan) cmake_minimum_required(VERSION 3.10) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake;${CMAKE_MODULE_PATH}") +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # need to set rocm_path for windows # since clang and hip are two different folders during build/install step if (WIN32 AND HIPINFO_INTERNAL_BUILD) diff --git a/samples/2_Cookbook/20_hip_vulkan/buildcmd.txt b/samples/2_Cookbook/20_hip_vulkan/buildcmd.txt index 1a7f1ada44..b07111e8d3 100644 --- a/samples/2_Cookbook/20_hip_vulkan/buildcmd.txt +++ b/samples/2_Cookbook/20_hip_vulkan/buildcmd.txt @@ -25,6 +25,6 @@ Linux Build with CMake: • mkdir build; cd build -• cmake -DCMAKE_PREFIX_PATH=path\to\rocm -DHIP_CXX_COMPILER=path\to\clang +• cmake .. • make • run hipVulkan executable diff --git a/samples/2_Cookbook/21_cmake_hip_cxx_clang/CMakeLists.txt b/samples/2_Cookbook/21_cmake_hip_cxx_clang/CMakeLists.txt index b28efe8986..640c889b7b 100644 --- a/samples/2_Cookbook/21_cmake_hip_cxx_clang/CMakeLists.txt +++ b/samples/2_Cookbook/21_cmake_hip_cxx_clang/CMakeLists.txt @@ -24,6 +24,14 @@ project(cmake_cxx_amdclang++_test DESCRIPTION "Verifies CXX Language Support with amdclang++" LANGUAGES CXX) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find HIP find_package(hip REQUIRED) diff --git a/samples/2_Cookbook/23_cmake_hiprtc/CMakeLists.txt b/samples/2_Cookbook/23_cmake_hiprtc/CMakeLists.txt index e33fd552b5..b89c55c95d 100644 --- a/samples/2_Cookbook/23_cmake_hiprtc/CMakeLists.txt +++ b/samples/2_Cookbook/23_cmake_hiprtc/CMakeLists.txt @@ -22,6 +22,14 @@ project(cmake_hiprtc_test) cmake_minimum_required(VERSION 3.10.2) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hiprtc find_package(hiprtc REQUIRED) # Find hip diff --git a/samples/2_Cookbook/3_shared_memory/CMakeLists.txt b/samples/2_Cookbook/3_shared_memory/CMakeLists.txt index d1d87dccb2..d4fd0ab4d9 100644 --- a/samples/2_Cookbook/3_shared_memory/CMakeLists.txt +++ b/samples/2_Cookbook/3_shared_memory/CMakeLists.txt @@ -22,6 +22,14 @@ project(sharedMemory) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/2_Cookbook/4_shfl/CMakeLists.txt b/samples/2_Cookbook/4_shfl/CMakeLists.txt index e80ed36501..6ccfdbe49b 100644 --- a/samples/2_Cookbook/4_shfl/CMakeLists.txt +++ b/samples/2_Cookbook/4_shfl/CMakeLists.txt @@ -22,6 +22,14 @@ project(shfl) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/2_Cookbook/5_2dshfl/CMakeLists.txt b/samples/2_Cookbook/5_2dshfl/CMakeLists.txt index 942f17fc8d..741bd6628b 100644 --- a/samples/2_Cookbook/5_2dshfl/CMakeLists.txt +++ b/samples/2_Cookbook/5_2dshfl/CMakeLists.txt @@ -22,6 +22,14 @@ project(2dshfl) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt b/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt index 02bbe70ae6..d0997d6b73 100644 --- a/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt +++ b/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt @@ -23,6 +23,15 @@ project(dynamic_shared) cmake_minimum_required(VERSION 3.10) include_directories(../../common) + +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/2_Cookbook/7_streams/CMakeLists.txt b/samples/2_Cookbook/7_streams/CMakeLists.txt index 04bec0b422..658a386184 100644 --- a/samples/2_Cookbook/7_streams/CMakeLists.txt +++ b/samples/2_Cookbook/7_streams/CMakeLists.txt @@ -22,6 +22,14 @@ project(stream) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/2_Cookbook/8_peer2peer/CMakeLists.txt b/samples/2_Cookbook/8_peer2peer/CMakeLists.txt index 7d66525389..14de32dd60 100644 --- a/samples/2_Cookbook/8_peer2peer/CMakeLists.txt +++ b/samples/2_Cookbook/8_peer2peer/CMakeLists.txt @@ -22,6 +22,13 @@ project(peer2peer) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() # Find hip find_package(hip) diff --git a/samples/2_Cookbook/9_unroll/CMakeLists.txt b/samples/2_Cookbook/9_unroll/CMakeLists.txt index dfc34b641b..6770496a84 100644 --- a/samples/2_Cookbook/9_unroll/CMakeLists.txt +++ b/samples/2_Cookbook/9_unroll/CMakeLists.txt @@ -22,6 +22,14 @@ project(unroll) cmake_minimum_required(VERSION 3.10) +if(UNIX) + 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 ${ROCM_PATH}) +endif() + # Find hip find_package(hip) diff --git a/samples/README.md b/samples/README.md index a5184a6ee9..24bedafa18 100644 --- a/samples/README.md +++ b/samples/README.md @@ -20,7 +20,7 @@ mkdir -p build && cd build rm -rf * (to clear up) -cmake -DCMAKE_PREFIX_PATH= -DHIP_CXX_COMPILER= .. +cmake .. Then run,