diff --git a/catch/CMakeLists.txt b/catch/CMakeLists.txt index f9078da432..e34f59180d 100644 --- a/catch/CMakeLists.txt +++ b/catch/CMakeLists.txt @@ -9,51 +9,45 @@ project(hiptests) # flag to generate standalone exe per src file. message(STATUS "STANDALONE_TESTS : ${STANDALONE_TESTS}") -# Check if platform and compiler are set -if(HIP_PLATFORM STREQUAL "amd") - if(HIP_COMPILER STREQUAL "nvcc") - message(FATAL_ERROR "Unexpected HIP_COMPILER:${HIP_COMPILER} is set for HIP_PLATFOR:amd") - endif() -elseif(HIP_PLATFORM STREQUAL "nvidia") - if(DEFINED HIP_COMPILER AND NOT HIP_COMPILER STREQUAL "nvcc") - message(FATAL_ERROR "Unexpected HIP_COMPILER: ${HIP_COMPILER} is set for HIP_PLATFORM:nvidia") - endif() -else() +# Check if platform is set +if(NOT HIP_PLATFORM STREQUAL "amd" AND NOT HIP_PLATFORM STREQUAL "nvidia") message(FATAL_ERROR "Unexpected HIP_PLATFORM: " ${HIP_PLATFORM}) endif() -if (WIN32) +if(WIN32) set(EXT ".bat") endif() -# Read -DROCM_Path and env{ROCM_PATH} -if(NOT DEFINED ROCM_PATH) - if(DEFINED ENV{ROCM_PATH}) - set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") +if(HIP_PLATFORM STREQUAL "amd") + if(UNIX AND DEFINED ROCM_PATH) + # Read -DROCM_PATH and set CXX_FLAGS for amd platform only + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --rocm-path=${ROCM_PATH}") + endif() + + if(DEFINED HIP_PATH) + # Read -DHIP_PATH and set CXX_FLAGS for amd platform only + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --hip-path=${HIP_PATH}") + endif() +endif() + +# Read -DHIP_PATH +# If not set read env{HIP_PATH} only on Windows +if(WIN32) + if(NOT DEFINED HIP_PATH) + if(DEFINED ENV{HIP_PATH}) + set(HIP_PATH $ENV{HIP_PATH} CACHE STRING "HIP Path") + endif() endif() endif() -# Read -DHIP_Path and env{HIP_PATH} if(NOT DEFINED HIP_PATH) - if(DEFINED ENV{HIP_PATH}) - set(HIP_PATH $ENV{HIP_PATH} CACHE STRING "HIP Path") - endif() -endif() - -# both are not set -if(NOT DEFINED HIP_PATH AND NOT DEFINED ROCM_PATH) - set(HIP_PATH "/opt/rocm") - set(ROCM_PATH "/opt/rocm") -elseif(DEFINED HIP_PATH AND NOT DEFINED ROCM_PATH) - execute_process(COMMAND ${HIP_PATH}/bin/hipconfig${EXT} --rocmpath - OUTPUT_VARIABLE ROCM_PATH - OUTPUT_STRIP_TRAILING_WHITESPACE) -elseif(DEFINED ROCM_PATH AND NOT DEFINED HIP_PATH) - set(HIP_PATH ${ROCM_PATH}) + if(DEFINED ROCM_PATH) + set(HIP_PATH ${ROCM_PATH}) + else() + set(HIP_PATH "/opt/rocm") + endif() endif() message(STATUS "HIP_PATH: ${HIP_PATH}") -message(STATUS "ROCM_PATH: ${ROCM_PATH}") - set(CMAKE_CXX_COMPILER "${HIP_PATH}/bin/hipcc${EXT}") set(CMAKE_C_COMPILER "${HIP_PATH}/bin/hipcc${EXT}") @@ -62,10 +56,6 @@ execute_process(COMMAND ${HIPCONFIG_EXECUTABLE} --version OUTPUT_VARIABLE HIP_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE) -if(HIP_PLATFORM STREQUAL "amd") - # prioritize -DROCM_PATH over env{ROCM_PATH} for amd platform only - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --rocm-path=${ROCM_PATH}") -endif() # enforce c++17 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --std=c++17") @@ -155,8 +145,8 @@ if (WIN32) SET(CMAKE_CXX_RESPONSE_FILE_LINK_FLAG "") endif() -if(HIP_PLATFORM MATCHES "amd" AND HIP_COMPILER MATCHES "clang") - add_compile_options(-Wall -Wextra -pedantic -Werror -Wno-deprecated) +if(HIP_PLATFORM STREQUAL "amd") + add_compile_options(-Wall -Wextra -Werror -Wno-deprecated) endif() cmake_policy(PUSH) @@ -178,10 +168,8 @@ message(STATUS "CMAKE HIP ARCHITECTURES: ${CMAKE_HIP_ARCHITECTURES}") # That results in hipcc building the test for gfx803 (the default target) # preference to pass arch - # OFFLOAD_ARCH_STR -# ENV{HCC_AMDGPU_TARGET} # rocm_agent_enumerator if(NOT DEFINED OFFLOAD_ARCH_STR - AND NOT DEFINED ENV{HCC_AMDGPU_TARGET} AND EXISTS "${ROCM_PATH}/bin/rocm_agent_enumerator" AND HIP_PLATFORM STREQUAL "amd" AND UNIX) execute_process(COMMAND ${ROCM_PATH}/bin/rocm_agent_enumerator @@ -208,10 +196,6 @@ endif() if(DEFINED OFFLOAD_ARCH_STR) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OFFLOAD_ARCH_STR} ") -elseif(DEFINED ENV{HCC_AMDGPU_TARGET}) - # hipcc pl script appends it to the options - set(OFFLOAD_ARCH_STR "--offload-arch=$ENV{HCC_AMDGPU_TARGET}") - set(HIP_GPU_ARCH_LIST $ENV{HCC_AMDGPU_TARGET}) endif() message(STATUS "Using offload arch string: ${OFFLOAD_ARCH_STR}") @@ -240,7 +224,7 @@ set(_subdirs ${_autogen} "subdirs(..)\n") file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/${CATCH_BUILD_DIR}/CTestTestfile.cmake ${_subdirs}) # Enable device lambda on nvidia platforms -if(HIP_COMPILER MATCHES "nvcc") +if(HIP_PLATFORM STREQUAL "nvidia") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --extended-lambda") endif() diff --git a/catch/README.md b/catch/README.md index 5688f558d4..22a4218766 100644 --- a/catch/README.md +++ b/catch/README.md @@ -11,7 +11,7 @@ Tests in Catch2 are declared via ```TEST_CASE```. [Catch2 Detailed Reference](https://github.com/catchorg/Catch2/blob/v2.13.6/docs/Readme.md#top) ## Taking care of existing features -- Don’t build on platform: EXCLUDE_(HIP_PLATFORM/HIP_RUNTIME), can be done via CMAKE. Adding source in if(HIP_PLATFORM == amd/nvidia). +- Don’t build on platform: EXCLUDE_HIP_PLATFORM, can be done via CMAKE. Adding source in if(HIP_PLATFORM == amd/nvidia). - HIPCC_OPTIONS/CLANG Options: Can be done via: set_source_files_properties(src.cc PROPERTIES COMPILE_FLAGS “…”). - Additional libraries: Can be done via target_link_libraries() - Multiple runs with different args: This can be done by Catch’s Feature: GENERATE(…) diff --git a/catch/include/hip_test_common.hh b/catch/include/hip_test_common.hh index 7b4b08ee38..f5442c5dbb 100644 --- a/catch/include/hip_test_common.hh +++ b/catch/include/hip_test_common.hh @@ -21,6 +21,7 @@ THE SOFTWARE. */ #pragma once +#pragma clang diagnostic ignored "-Wsign-compare" #include "hip_test_context.hh" #include @@ -355,7 +356,7 @@ class BlockingContext { hipStream_t stream; public: - BlockingContext(hipStream_t s) : stream(s), blocked(true) {} + BlockingContext(hipStream_t s) : blocked(true), stream(s) {} BlockingContext(const BlockingContext& in) { blocked = in.blocked_val(); diff --git a/catch/include/memcpy3d_tests_common.hh b/catch/include/memcpy3d_tests_common.hh index 49f09c1e50..c3c7028517 100644 --- a/catch/include/memcpy3d_tests_common.hh +++ b/catch/include/memcpy3d_tests_common.hh @@ -21,7 +21,8 @@ THE SOFTWARE. */ #pragma once - +#pragma clang diagnostic ignored "-Wmissing-field-initializers" +#pragma clang diagnostic ignored "-Wunused-lambda-capture" #include #include @@ -31,7 +32,7 @@ THE SOFTWARE. using PtrVariant = std::variant; -static hipMemcpyKind ReverseMemcpyDirection(const hipMemcpyKind direction) { +static inline hipMemcpyKind ReverseMemcpyDirection(const hipMemcpyKind direction) { switch (direction) { case hipMemcpyHostToDevice: return hipMemcpyDeviceToHost; @@ -76,7 +77,7 @@ static bool operator==(const hipExtent& lhs, const hipExtent& rhs) { return lhs.width == rhs.width && lhs.height == rhs.height && lhs.depth == rhs.depth; } -static bool operator==(const hipMemcpy3DParms& lhs, const hipMemcpy3DParms& rhs) { +static inline bool operator==(const hipMemcpy3DParms& lhs, const hipMemcpy3DParms& rhs) { return lhs.dstArray == rhs.dstArray && lhs.dstPtr == rhs.dstPtr && lhs.dstPos == rhs.dstPos && lhs.srcArray == rhs.srcArray && lhs.srcPtr == rhs.srcPtr && lhs.srcPos == rhs.srcPos && lhs.extent == rhs.extent && lhs.kind == rhs.kind; @@ -168,7 +169,6 @@ void Memcpy3DDeviceToDeviceShell(F memcpy_func, const hipStream_t kernel_stream const auto device_count = HipTest::getDeviceCount(); const auto src_device = GENERATE_COPY(range(0, device_count)); const auto dst_device = GENERATE_COPY(range(0, device_count)); - const size_t src_cols_mult = GENERATE(1, 2); INFO("Src device: " << src_device << ", Dst device: " << dst_device); @@ -797,4 +797,4 @@ void DrvMemcpy3DArrayDeviceShell(F memcpy_func, const hipStream_t kernel_stream }; PitchedMemoryVerify(host_alloc.ptr(), extent.width, extent.width / sizeof(int), extent.height, extent.depth, f); -} \ No newline at end of file +} diff --git a/catch/include/performance_common.hh b/catch/include/performance_common.hh index 9b0c790444..21e87ceb2c 100644 --- a/catch/include/performance_common.hh +++ b/catch/include/performance_common.hh @@ -33,6 +33,9 @@ THE SOFTWARE. #include #include +#pragma clang diagnostic ignored "-Wunused-but-set-variable" +#pragma clang diagnostic ignored "-Wunused-function" + #if defined(_WIN32) #if defined(_WIN64) typedef __int64 ssize_t; diff --git a/catch/multiproc/hipMemCoherencyTstMProc.cc b/catch/multiproc/hipMemCoherencyTstMProc.cc index 6098cf9e4c..8eacc288cf 100644 --- a/catch/multiproc/hipMemCoherencyTstMProc.cc +++ b/catch/multiproc/hipMemCoherencyTstMProc.cc @@ -131,7 +131,6 @@ TEST_CASE("Unit_malloc_CoherentTst") { p = strstr(prop.gcnArchName, "xnack+"); if (p) { // Test Case execution begins from here - int stat = 0; int managed = 0; HIPCHECK(hipDeviceGetAttribute(&managed, hipDeviceAttributeManagedMemory, 0)); @@ -162,7 +161,6 @@ TEST_CASE("Unit_malloc_CoherentTstWthAdvise") { char *p = NULL; p = strstr(prop.gcnArchName, "xnack+"); if (p) { - int stat = 0; int managed = 0; HIP_CHECK(hipDeviceGetAttribute(&managed, hipDeviceAttributeManagedMemory, 0)); @@ -195,7 +193,6 @@ TEST_CASE("Unit_mmap_CoherentTst") { char *p = NULL; p = strstr(prop.gcnArchName, "xnack+"); if (p) { - int stat = 0; int managed = 0; HIP_CHECK(hipDeviceGetAttribute(&managed, hipDeviceAttributeManagedMemory, 0)); @@ -233,7 +230,6 @@ TEST_CASE("Unit_mmap_CoherentTstWthAdvise") { char *p = NULL; p = strstr(prop.gcnArchName, "xnack+"); if (p) { - int stat = 0; int managed = 0; HIP_CHECK(hipDeviceGetAttribute(&managed, hipDeviceAttributeManagedMemory, 0)); diff --git a/catch/unit/cooperativeGrps/coalesced_groups_shfl_down.cc b/catch/unit/cooperativeGrps/coalesced_groups_shfl_down.cc index de13e8eda1..675da24dd5 100644 --- a/catch/unit/cooperativeGrps/coalesced_groups_shfl_down.cc +++ b/catch/unit/cooperativeGrps/coalesced_groups_shfl_down.cc @@ -31,7 +31,7 @@ THE SOFTWARE. #include #include #include - +#pragma clang diagnostic ignored "-Wunused-variable" using namespace cooperative_groups; #define ASSERT_EQUAL(lhs, rhs) assert(lhs == rhs) diff --git a/catch/unit/cooperativeGrps/coalesced_groups_shfl_up.cc b/catch/unit/cooperativeGrps/coalesced_groups_shfl_up.cc index 75ca40a6d7..54cd62c197 100644 --- a/catch/unit/cooperativeGrps/coalesced_groups_shfl_up.cc +++ b/catch/unit/cooperativeGrps/coalesced_groups_shfl_up.cc @@ -30,7 +30,7 @@ THE SOFTWARE. #include #include #include - +#pragma clang diagnostic ignored "-Wunused-variable" using namespace cooperative_groups; #define ASSERT_EQUAL(lhs, rhs) assert(lhs == rhs) @@ -247,4 +247,4 @@ TEST_CASE("Unit_coalesced_groups_shfl_up") { } } -/* Kogge-Stone algorithm */ \ No newline at end of file +/* Kogge-Stone algorithm */ diff --git a/catch/unit/cooperativeGrps/grid_group.cc b/catch/unit/cooperativeGrps/grid_group.cc index ee7402341a..51e1514762 100644 --- a/catch/unit/cooperativeGrps/grid_group.cc +++ b/catch/unit/cooperativeGrps/grid_group.cc @@ -143,7 +143,7 @@ TEST_CASE("Unit_Grid_Group_Getters_Positive_Basic") { HIP_CHECK(hipDeviceSynchronize()); // Verify grid_group.is_valid() values - ArrayAllOf(uint_arr.ptr(), grid.thread_count_, [](uint32_t i) { return 1; }); + ArrayAllOf(uint_arr.ptr(), grid.thread_count_, [](uint32_t) { return 1; }); } /** @@ -282,4 +282,4 @@ TEST_CASE("Unit_Grid_Group_Sync_Positive_Basic") { } REQUIRE(uint_arr.ptr()[i * grid.block_count_ + j] == max_in_this_loop - 1); } -} \ No newline at end of file +} diff --git a/catch/unit/device/getDeviceCount_exe.cc b/catch/unit/device/getDeviceCount_exe.cc index bf9951b6d4..851c0e257d 100644 --- a/catch/unit/device/getDeviceCount_exe.cc +++ b/catch/unit/device/getDeviceCount_exe.cc @@ -34,10 +34,10 @@ bool UNSETENV(std::string var) { return (result == 0) ? true: false; } -bool SETENV(std::string var, std::string value, int overwrite) { +bool SETENV(std::string var, std::string value) { int result = -1; #ifdef __unix__ - result = setenv(var.c_str(), value.c_str(), overwrite); + result = setenv(var.c_str(), value.c_str(), 1); #else result = _putenv((var + '=' + value).c_str()); #endif @@ -59,7 +59,7 @@ int main(int argc, char** argv) { // disable visible_devices env from shell #ifdef __HIP_PLATFORM_NVCC__ UNSETENV("CUDA_VISIBLE_DEVICES"); - SETENV("CUDA_VISIBLE_DEVICES", argv[1], 1); + SETENV("CUDA_VISIBLE_DEVICES", argv[1]); auto init_res = hipInit(0); if (hipSuccess != init_res) { std::cerr << "CUDA INIT API returned : " << hipGetErrorString(init_res) << std::endl; @@ -68,8 +68,8 @@ int main(int argc, char** argv) { #else UNSETENV("ROCR_VISIBLE_DEVICES"); UNSETENV("HIP_VISIBLE_DEVICES"); - SETENV("ROCR_VISIBLE_DEVICES", argv[1], 1); - SETENV("HIP_VISIBLE_DEVICES", argv[1], 1); + SETENV("ROCR_VISIBLE_DEVICES", argv[1]); + SETENV("HIP_VISIBLE_DEVICES", argv[1]); #endif int count = 0; @@ -86,4 +86,4 @@ int main(int argc, char** argv) { UNSETENV("HIP_VISIBLE_DEVICES"); #endif return count; -} \ No newline at end of file +} diff --git a/catch/unit/device/hipDeviceGetP2PAttribute_exe.cc b/catch/unit/device/hipDeviceGetP2PAttribute_exe.cc index 92b1c577f5..22afc7275a 100644 --- a/catch/unit/device/hipDeviceGetP2PAttribute_exe.cc +++ b/catch/unit/device/hipDeviceGetP2PAttribute_exe.cc @@ -32,10 +32,10 @@ bool UNSETENV(std::string var) { return (result == 0) ? true: false; } -bool SETENV(std::string var, std::string value, int overwrite) { +bool SETENV(std::string var, std::string value) { int result = -1; #ifdef __unix__ - result = setenv(var.c_str(), value.c_str(), overwrite); + result = setenv(var.c_str(), value.c_str(), 1); #else result = _putenv((var + '=' + value).c_str()); #endif @@ -44,10 +44,10 @@ bool SETENV(std::string var, std::string value, int overwrite) { void inline hideDevices(const char* devices) { #if HT_NVIDIA - SETENV("CUDA_VISIBLE_DEVICES", devices, 1); + SETENV("CUDA_VISIBLE_DEVICES", devices); #else - SETENV("HIP_VISIBLE_DEVICES", devices, 1); - SETENV("ROCR_VISIBLE_DEVICES", devices, 1); + SETENV("HIP_VISIBLE_DEVICES", devices); + SETENV("ROCR_VISIBLE_DEVICES", devices); #endif } diff --git a/catch/unit/device/hipDeviceGetUuid.cc b/catch/unit/device/hipDeviceGetUuid.cc index d495e9fe94..d02f595673 100644 --- a/catch/unit/device/hipDeviceGetUuid.cc +++ b/catch/unit/device/hipDeviceGetUuid.cc @@ -53,7 +53,7 @@ TEST_CASE("Unit_hipDeviceGetUuid_Positive") { // Atleast one non zero value size_t uuidSize = sizeof(uuid.bytes) / sizeof(uuid.bytes[0]); - for (int i = 0; i < uuidSize; i++) { + for (size_t i = 0; i < uuidSize; i++) { if (uuid.bytes[i] != 0) { uuidValid = true; break; diff --git a/catch/unit/deviceLib/BuiltIns_fadd.cc b/catch/unit/deviceLib/BuiltIns_fadd.cc index 769b0dc97a..5303afb519 100644 --- a/catch/unit/deviceLib/BuiltIns_fadd.cc +++ b/catch/unit/deviceLib/BuiltIns_fadd.cc @@ -198,8 +198,8 @@ TEST_CASE("Unit_BuiltInAtomicAdd_CoherentGlobalMemWithRtc") { void* config_d[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args_f, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END}; - hipModuleLaunchKernel(fmaxkernel, 1, 1, 1, 1, 1, 1, 0, - nullptr, nullptr, config_d); + HIP_CHECK(hipModuleLaunchKernel(fmaxkernel, 1, 1, 1, 1, 1, 1, 0, + nullptr, nullptr, config_d)); HIP_CHECK(hipDeviceSynchronize()); HIP_CHECK(hipMemcpy(B_h, result, sizeof(double), hipMemcpyDeviceToHost)); REQUIRE(A_h[0] == INITIAL_VAL); @@ -278,8 +278,8 @@ TEST_CASE("Unit_BuiltInAtomicAdd_NonCoherentGlobalMemWithRtc") { void* config_d[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args_f, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END}; - hipModuleLaunchKernel(fmaxkernel, 1, 1, 1, 1, 1, 1, 0, - nullptr, nullptr, config_d); + HIP_CHECK(hipModuleLaunchKernel(fmaxkernel, 1, 1, 1, 1, 1, 1, 0, + nullptr, nullptr, config_d)); HIP_CHECK(hipDeviceSynchronize()); HIP_CHECK(hipMemcpy(B_h, result, sizeof(double), hipMemcpyDeviceToHost)); REQUIRE(A_h[0] == INITIAL_VAL + INC_VAL); diff --git a/catch/unit/deviceLib/BuiltIns_fmax.cc b/catch/unit/deviceLib/BuiltIns_fmax.cc index 9dcddc0596..656d9b419e 100644 --- a/catch/unit/deviceLib/BuiltIns_fmax.cc +++ b/catch/unit/deviceLib/BuiltIns_fmax.cc @@ -229,8 +229,8 @@ TEST_CASE("Unit_BuiltinAtomicsRTC_fmaxCoherentGlobalMem") { void* config_d[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args_f, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END}; - hipModuleLaunchKernel(fmaxkernel, 1, 1, 1, 1, 1, 1, 0, - nullptr, nullptr, config_d); + HIP_CHECK(hipModuleLaunchKernel(fmaxkernel, 1, 1, 1, 1, 1, 1, 0, + nullptr, nullptr, config_d)); HIP_CHECK(hipDeviceSynchronize()); HIP_CHECK(hipMemcpy(B_h, result, sizeof(double), hipMemcpyDeviceToHost)); REQUIRE(*B_h == 0); @@ -324,8 +324,8 @@ TEST_CASE("Unit_BuiltinAtomicsRTC_fmaxNonCoherentGlobalFlatMem") { void* config_d[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args_f, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END}; - hipModuleLaunchKernel(fmaxkernel, 1, 1, 1, 1, 1, 1, 0, - nullptr, nullptr, config_d); + HIP_CHECK(hipModuleLaunchKernel(fmaxkernel, 1, 1, 1, 1, 1, 1, 0, + nullptr, nullptr, config_d)); HIP_CHECK(hipDeviceSynchronize()); HIP_CHECK(hipMemcpy(B_h, result, sizeof(double), hipMemcpyDeviceToHost)); REQUIRE(*B_h == INITIAL_VAL); diff --git a/catch/unit/deviceLib/BuiltIns_fmin.cc b/catch/unit/deviceLib/BuiltIns_fmin.cc index d669bee9aa..6372888b3f 100644 --- a/catch/unit/deviceLib/BuiltIns_fmin.cc +++ b/catch/unit/deviceLib/BuiltIns_fmin.cc @@ -230,8 +230,8 @@ TEST_CASE("Unit_BuiltinAtomicsRTC__fminCoherentGlobalMem") { void* config_d[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args_f, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END}; - hipModuleLaunchKernel(fmaxkernel, 1, 1, 1, 1, 1, 1, 0, - nullptr, nullptr, config_d); + HIP_CHECK(hipModuleLaunchKernel(fmaxkernel, 1, 1, 1, 1, 1, 1, 0, + nullptr, nullptr, config_d)); HIP_CHECK(hipDeviceSynchronize()); HIP_CHECK(hipMemcpy(B_h, result, sizeof(double), hipMemcpyDeviceToHost)); REQUIRE(*B_h == 0); @@ -327,8 +327,8 @@ TEST_CASE("Unit_BuiltinAtomicsRTC_fminNonCoherentGlobalFlatMem") { void* config_d[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args_f, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END}; - hipModuleLaunchKernel(fmaxkernel, 1, 1, 1, 1, 1, 1, 0, - nullptr, nullptr, config_d); + HIP_CHECK(hipModuleLaunchKernel(fmaxkernel, 1, 1, 1, 1, 1, 1, 0, + nullptr, nullptr, config_d)); HIP_CHECK(hipDeviceSynchronize()); HIP_CHECK(hipMemcpy(B_h, result, sizeof(double), hipMemcpyDeviceToHost)); REQUIRE(*B_h == INITIAL_VAL); diff --git a/catch/unit/deviceLib/hipStdComplex.cc b/catch/unit/deviceLib/hipStdComplex.cc index f900625d89..c0bafae007 100644 --- a/catch/unit/deviceLib/hipStdComplex.cc +++ b/catch/unit/deviceLib/hipStdComplex.cc @@ -22,6 +22,7 @@ THE SOFTWARE. #include #include +#pragma clang diagnostic ignored "-Wunused-variable" // Tolerance for error const double tolerance = 1e-6; diff --git a/catch/unit/deviceLib/unsafeAtomicAdd_RTC.cc b/catch/unit/deviceLib/unsafeAtomicAdd_RTC.cc index b91d15cf62..6a96dbe32c 100644 --- a/catch/unit/deviceLib/unsafeAtomicAdd_RTC.cc +++ b/catch/unit/deviceLib/unsafeAtomicAdd_RTC.cc @@ -126,8 +126,8 @@ TEMPLATE_TEST_CASE("Unit_unsafeAtomicAdd_CoherentRTCnounsafeatomicflag", "", void* config_d[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args_f, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END}; - hipModuleLaunchKernel(f_kernel, 1, 1, 1, 1, 1, 1, 0, - nullptr, nullptr, config_d); + HIP_CHECK(hipModuleLaunchKernel(f_kernel, 1, 1, 1, 1, 1, 1, 0, + nullptr, nullptr, config_d)); HIP_CHECK(hipDeviceSynchronize()); REQUIRE(A_h[0] == INITIAL_VAL); REQUIRE(*result == 0); @@ -218,8 +218,8 @@ TEMPLATE_TEST_CASE("Unit_unsafeAtomicAdd_CoherentRTCunsafeatomicflag", "", void* config_d[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args_f, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END}; - hipModuleLaunchKernel(f_kernel, 1, 1, 1, 1, 1, 1, 0, - nullptr, nullptr, config_d); + HIP_CHECK(hipModuleLaunchKernel(f_kernel, 1, 1, 1, 1, 1, 1, 0, + nullptr, nullptr, config_d)); HIP_CHECK(hipDeviceSynchronize()); REQUIRE(A_h[0] == INITIAL_VAL); REQUIRE(*result == 0); @@ -306,8 +306,8 @@ TEMPLATE_TEST_CASE("Unit_unsafeAtomicAdd_CoherentRTCwithoutflag", "", void* config_d[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args_f, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END}; - hipModuleLaunchKernel(f_kernel, 1, 1, 1, 1, 1, - 1, 0, nullptr, nullptr, config_d); + HIP_CHECK(hipModuleLaunchKernel(f_kernel, 1, 1, 1, 1, 1, + 1, 0, nullptr, nullptr, config_d)); HIP_CHECK(hipDeviceSynchronize()); REQUIRE(A_h[0] == INITIAL_VAL); REQUIRE(*result == 0); @@ -392,8 +392,8 @@ TEMPLATE_TEST_CASE("Unit_unsafeAtomicAdd_NonCoherentRTCnounsafeatomicflag", "", void* config_d[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args_f, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END}; - hipModuleLaunchKernel(f_kernel, 1, 1, 1, 1, 1, 1, 0, - nullptr, nullptr, config_d); + HIP_CHECK(hipModuleLaunchKernel(f_kernel, 1, 1, 1, 1, 1, 1, 0, + nullptr, nullptr, config_d)); HIP_CHECK(hipDeviceSynchronize()); REQUIRE(A_h[0] == INITIAL_VAL + INCREMENT_VAL); REQUIRE(*result == INITIAL_VAL); @@ -480,8 +480,8 @@ TEMPLATE_TEST_CASE("Unit_unsafeAtomicAdd_NonCoherentRTCunsafeatomicflag", "", void* config_d[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args_f, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END}; - hipModuleLaunchKernel(f_kernel, 1, 1, 1, 1, 1, 1, 0, - nullptr, nullptr, config_d); + HIP_CHECK(hipModuleLaunchKernel(f_kernel, 1, 1, 1, 1, 1, 1, 0, + nullptr, nullptr, config_d)); HIP_CHECK(hipDeviceSynchronize()); REQUIRE(A_h[0] == INITIAL_VAL + INCREMENT_VAL); REQUIRE(*result == INITIAL_VAL); @@ -568,8 +568,8 @@ TEMPLATE_TEST_CASE("Unit_unsafeAtomicAdd_NonCoherentRTC", "", void* config_d[] = {HIP_LAUNCH_PARAM_BUFFER_POINTER, &args_f, HIP_LAUNCH_PARAM_BUFFER_SIZE, &size, HIP_LAUNCH_PARAM_END}; - hipModuleLaunchKernel(f_kernel, 1, 1, 1, 1, 1, 1, 0, - nullptr, nullptr, config_d); + HIP_CHECK(hipModuleLaunchKernel(f_kernel, 1, 1, 1, 1, 1, 1, 0, + nullptr, nullptr, config_d)); HIP_CHECK(hipDeviceSynchronize()); REQUIRE(A_h[0] == INITIAL_VAL + INCREMENT_VAL); REQUIRE(*result == INITIAL_VAL); diff --git a/catch/unit/graph/hipGraphCycle.cc b/catch/unit/graph/hipGraphCycle.cc index dedf4dd558..bb1a7e63ae 100644 --- a/catch/unit/graph/hipGraphCycle.cc +++ b/catch/unit/graph/hipGraphCycle.cc @@ -132,7 +132,6 @@ TEST_CASE("Unit_hipGraph_BasicCyclic4") { HipTest::initArrays(&X_d, &Y_d, nullptr, &X_h, &Y_h, nullptr, N, false); - constexpr size_t memSetVal = 9; hipGraphNode_t kMemCpyH2D_X, memcpyD2D, memcpyD2H_RC, emptyNode1; HIP_CHECK(hipStreamCreate(&stream)); @@ -192,7 +191,6 @@ TEST_CASE("Unit_hipGraph_BasicCyclic5") { HipTest::initArrays(&X_d, &Y_d, nullptr, &X_h, &Y_h, nullptr, N, false); - constexpr size_t memSetVal = 9; hipGraphNode_t kMemCpyH2D_X, memcpyD2D, memcpyD2H_RC, emptyNode1, emptyNode2, emptyNode3; HIP_CHECK(hipStreamCreate(&stream)); @@ -241,4 +239,4 @@ TEST_CASE("Unit_hipGraph_BasicCyclic5") { HIP_CHECK(hipGraphExecDestroy(graphExec)); HIP_CHECK(hipGraphDestroy(graph)); HIP_CHECK(hipStreamDestroy(stream)); -} \ No newline at end of file +} diff --git a/catch/unit/graph/hipStreamBeginCapture.cc b/catch/unit/graph/hipStreamBeginCapture.cc index cc7e85ef5f..9814a05097 100644 --- a/catch/unit/graph/hipStreamBeginCapture.cc +++ b/catch/unit/graph/hipStreamBeginCapture.cc @@ -22,6 +22,7 @@ THE SOFTWARE. #include #include "stream_capture_common.hh" // NOLINT +#pragma clang diagnostic ignored "-Wunused-variable" /** * @addtogroup hipStreamBeginCapture hipStreamBeginCapture * @{ diff --git a/catch/unit/graph/user_object_common.hh b/catch/unit/graph/user_object_common.hh index 1929199b43..d649e3e746 100644 --- a/catch/unit/graph/user_object_common.hh +++ b/catch/unit/graph/user_object_common.hh @@ -24,6 +24,8 @@ THE SOFTWARE. #include +#pragma clang diagnostic ignored "-Wunused-function" + struct BoxStruct { int count; BoxStruct() { INFO("Constructor called for Struct!\n"); } @@ -58,4 +60,4 @@ void destroyFloatObj(void* ptr) { delete ptr2; } -} // anonymous namespace \ No newline at end of file +} // anonymous namespace diff --git a/catch/unit/kernel/hipShflTests.cc b/catch/unit/kernel/hipShflTests.cc index 711a8d1744..89c529c16b 100644 --- a/catch/unit/kernel/hipShflTests.cc +++ b/catch/unit/kernel/hipShflTests.cc @@ -150,7 +150,6 @@ static void runTest() { // verify the results REQUIRE(errors == compare(TransposeMatrix, cpuTransposeMatrix)); - double eps = 1.0E-6; // free the resources on device side HIP_CHECK(hipFree(gpuMatrix)); HIP_CHECK(hipFree(gpuTransposeMatrix)); diff --git a/catch/unit/memory/hipArrayCommon.hh b/catch/unit/memory/hipArrayCommon.hh index b19a32a206..52ade2ea21 100644 --- a/catch/unit/memory/hipArrayCommon.hh +++ b/catch/unit/memory/hipArrayCommon.hh @@ -43,12 +43,7 @@ __global__ void readFromTexture(T* output, hipTextureObject_t texObj, size_t wid } else { const float v = y / (float)height; if (textureGather) { - // tex2Dgather not supported on __gfx90a__ - #if !defined(__gfx90a__) output[y * width + x] = tex2Dgather(texObj, u, v, ChannelToRead); - #else - #warning("tex2Dgather not supported on gfx90a"); - #endif } else { output[y * width + x] = tex2D(texObj, u, v); } diff --git a/catch/unit/memory/hipArrayCreate.cc b/catch/unit/memory/hipArrayCreate.cc index a22386070b..b6058c8176 100644 --- a/catch/unit/memory/hipArrayCreate.cc +++ b/catch/unit/memory/hipArrayCreate.cc @@ -54,7 +54,7 @@ static void ArrayCreate_DiffSizes(int gpu) { std::vector> runs {std::make_pair(NUM_W, NUM_H), std::make_pair(BIGNUM_W, BIGNUM_H)}; for (const auto& size : runs) { std::array array; - size_t pavail, avail; + size_t pavail; HIP_CHECK_THREAD(hipMemGetInfo(&pavail, nullptr)); HIP_ARRAY_DESCRIPTOR desc; desc.NumChannels = 1; diff --git a/catch/unit/memory/hipFreeAsync.cc b/catch/unit/memory/hipFreeAsync.cc index 6962189655..c7fcd0b179 100644 --- a/catch/unit/memory/hipFreeAsync.cc +++ b/catch/unit/memory/hipFreeAsync.cc @@ -26,7 +26,7 @@ TEST_CASE("Unit_hipFreeAsync_negative") { HIP_CHECK(hipSetDevice(0)); void* p = nullptr; hipStream_t stream{nullptr}; - hipStreamCreate(&stream); + HIP_CHECK(hipStreamCreate(&stream)); SECTION("dev_ptr is nullptr") { REQUIRE(hipFreeAsync(nullptr, stream) != hipSuccess); } diff --git a/catch/unit/memory/hipMalloc3D.cc b/catch/unit/memory/hipMalloc3D.cc index 7e0e249bee..47dae81522 100644 --- a/catch/unit/memory/hipMalloc3D.cc +++ b/catch/unit/memory/hipMalloc3D.cc @@ -43,7 +43,7 @@ static void MemoryAlloc3DDiffSizes(int gpu) { size_t height{sizes}, depth{sizes}; hipPitchedPtr devPitchedPtr[CHUNK_LOOP]; hipExtent extent = make_hipExtent(width, height, depth); - size_t tot, avail, ptot, pavail; + size_t ptot, pavail; HIPCHECK(hipMemGetInfo(&pavail, &ptot)); for (int i = 0; i < CHUNK_LOOP; i++) { HIPCHECK(hipMalloc3D(&devPitchedPtr[i], extent)); diff --git a/catch/unit/memory/hipMallocArray.cc b/catch/unit/memory/hipMallocArray.cc index 1ea94d2146..14a095f6fd 100644 --- a/catch/unit/memory/hipMallocArray.cc +++ b/catch/unit/memory/hipMallocArray.cc @@ -399,12 +399,22 @@ TEMPLATE_TEST_CASE("Unit_hipMallocArray_happy", "", uint, int, int4, ushort, sho testArrayAsSurface(arrayPtr, width, height); } SECTION("hipArrayTextureGather") { - height = 1024; - INFO("flag is hipArrayTextureGather"); - INFO("height: " << height); + hipDeviceProp_t prop; + int device; + HIP_CHECK(hipGetDevice(&device)); + HIP_CHECK(hipGetDeviceProperties(&prop, device)); + // tex2Dgather not supported on gfx90a + if (std::string(prop.gcnArchName).find("gfx90a") == std::string::npos) { + height = 1024; + INFO("flag is hipArrayTextureGather"); + INFO("height: " << height); - HIP_CHECK(hipMallocArray(&arrayPtr, &desc, width, height, hipArrayTextureGather)); - testArrayAsTextureWithGather(arrayPtr, width, height); + HIP_CHECK(hipMallocArray(&arrayPtr, &desc, width, height, hipArrayTextureGather)); + testArrayAsTextureWithGather(arrayPtr, width, height); + } else { + SUCCEED("tex2Dgather is not supported for gfx90a, Hence" + "skipping the testcase for this device " << device); + } } #endif diff --git a/catch/unit/memory/hipMallocConcurrency.cc b/catch/unit/memory/hipMallocConcurrency.cc index 17028d232d..6481885f2e 100644 --- a/catch/unit/memory/hipMallocConcurrency.cc +++ b/catch/unit/memory/hipMallocConcurrency.cc @@ -82,7 +82,7 @@ static std::atomic g_thTestPassed{true}; /** * Validates data consistency on supplied gpu */ -static bool validateMemoryOnGPU(int gpu, bool concurOnOneGPU = false) { +static bool validateMemoryOnGPU(int gpu) { int *A_d, *B_d, *C_d; int *A_h, *B_h, *C_h; bool TestPassed = true; @@ -148,7 +148,7 @@ static bool regressAllocInLoop(int gpu) { * Validates data consistency on supplied gpu * In Multithreaded Environment */ -static bool validateMemoryOnGpuMThread(int gpu, bool concurOnOneGPU = false) { +static bool validateMemoryOnGpuMThread(int gpu) { int *A_d, *B_d, *C_d; int *A_h, *B_h, *C_h; bool TestPassed = true; @@ -213,7 +213,7 @@ static bool regressAllocInLoopMthread(int gpu) { * Thread func to regress alloc and check data consistency */ static void threadFunc(int gpu) { - g_thTestPassed = regressAllocInLoopMthread(gpu) && validateMemoryOnGpuMThread(gpu, true); + g_thTestPassed = regressAllocInLoopMthread(gpu) && validateMemoryOnGpuMThread(gpu); UNSCOPED_INFO("thread execution status on gpu" << gpu << ":" << g_thTestPassed.load()); } diff --git a/catch/unit/memory/hipMemAdviseMmap.cc b/catch/unit/memory/hipMemAdviseMmap.cc index f7f4db3fcc..044f2099cf 100644 --- a/catch/unit/memory/hipMemAdviseMmap.cc +++ b/catch/unit/memory/hipMemAdviseMmap.cc @@ -31,7 +31,7 @@ THE SOFTWARE. */ TEST_CASE("Unit_hipMemAdvise_MmapMem") { - int managed = 0, NUM_ELMS = 212992, PageableMem = 0; + int managed = 0, PageableMem = 0; INFO("The following are the attribute values related to HMM for" " device 0:\n"); HIP_CHECK(hipDeviceGetAttribute(&managed, @@ -54,6 +54,7 @@ TEST_CASE("Unit_hipMemAdvise_MmapMem") { #ifdef __linux__ // For now this test is enabled only for linux platforms FILE *fptr; + int NUM_ELMS = 212992; fptr = fopen("ForTest1.txt", "w"); for (int m = 0; m < NUM_ELMS; ++m) { putw(m, fptr); diff --git a/catch/unit/memory/hipMemAdvise_old.cc b/catch/unit/memory/hipMemAdvise_old.cc index 62dcb81627..b69e46af7b 100644 --- a/catch/unit/memory/hipMemAdvise_old.cc +++ b/catch/unit/memory/hipMemAdvise_old.cc @@ -666,7 +666,6 @@ TEST_CASE("Unit_hipMemAdvise_TstAlignedAllocMem") { std::string gfxName(prop.gcnArchName); if (gfxName.find("xnack+") != std::string::npos) { - int stat = 0; int managedMem = 0, pageMemAccess = 0; HIP_CHECK(hipDeviceGetAttribute(&pageMemAccess, hipDeviceAttributePageableMemoryAccess, 0)); diff --git a/catch/unit/memory/hipMemRangeGetAttributes_old.cc b/catch/unit/memory/hipMemRangeGetAttributes_old.cc index e1240f4330..63952f1bfd 100644 --- a/catch/unit/memory/hipMemRangeGetAttributes_old.cc +++ b/catch/unit/memory/hipMemRangeGetAttributes_old.cc @@ -26,6 +26,7 @@ THE SOFTWARE. #include #define MEM_SIZE 8192 +#ifdef __linux__ static bool CheckError(hipError_t err, int LineNo) { if (err == hipSuccess) { WARN("Error expected but received hipSuccess at line no.:" @@ -59,7 +60,6 @@ static int HmmAttrPrint() { return managed; } -#ifdef __linux__ /* Test Scenario: Testing basic working of hipMemRangeGetAttributes() api with different flags */ diff --git a/catch/unit/memory/hipMemcpy3D.cc b/catch/unit/memory/hipMemcpy3D.cc index 5ca6373308..79b9d0f90f 100644 --- a/catch/unit/memory/hipMemcpy3D.cc +++ b/catch/unit/memory/hipMemcpy3D.cc @@ -28,6 +28,8 @@ THE SOFTWARE. #include #include +#pragma clang diagnostic ignored "-Wunused-variable" + TEST_CASE("Unit_hipMemcpy3D_Positive_Basic") { constexpr bool async = false; diff --git a/catch/unit/memory/hipMemcpy3DAsync.cc b/catch/unit/memory/hipMemcpy3DAsync.cc index 4689c12dec..d346bdcac5 100644 --- a/catch/unit/memory/hipMemcpy3DAsync.cc +++ b/catch/unit/memory/hipMemcpy3DAsync.cc @@ -28,6 +28,8 @@ THE SOFTWARE. #include #include +#pragma clang diagnostic ignored "-Wunused-variable" + TEST_CASE("Unit_hipMemcpy3DAsync_Positive_Basic") { constexpr bool async = true; diff --git a/catch/unit/rtc/linker.cc b/catch/unit/rtc/linker.cc index 8733487ccf..151980b24c 100644 --- a/catch/unit/rtc/linker.cc +++ b/catch/unit/rtc/linker.cc @@ -11,8 +11,7 @@ #include #include -static constexpr auto NUM_THREADS{128}; -static constexpr auto NUM_BLOCKS{32}; +#pragma clang diagnostic ignored "-Wuninitialized" static constexpr auto src{ R"( @@ -125,4 +124,4 @@ TEST_CASE("Unit_RTC_LinkerAPI") { for (size_t i = 0; i < n; ++i) { REQUIRE(fabs(a * hX[i] + hY[i] - hOut[i]) <= fabs(hOut[i]) * 1e-6); } -} \ No newline at end of file +} diff --git a/catch/unit/stream/hipStreamCreateWithPriority.cc b/catch/unit/stream/hipStreamCreateWithPriority.cc index 9bc8bb32bf..ee3b723c7e 100644 --- a/catch/unit/stream/hipStreamCreateWithPriority.cc +++ b/catch/unit/stream/hipStreamCreateWithPriority.cc @@ -686,8 +686,8 @@ void TestForMultipleStreamWithPriority(void) { } // launch kernels repeatedly on each of the low prioritiy stream for (int k = 0; k < LOW_PRIORITY_STREAMCOUNT; ++k) { - for (int i = 0; i < size; i += MEMCPYSIZE1) { - int j = i / sizeof(T); + for (size_t i = 0; i < size; i += MEMCPYSIZE1) { + size_t j = i / sizeof(T); if (enable_priority_low) { hipLaunchKernelGGL((memcpy_kernel), dim3(GRIDSIZE), dim3(BLOCKSIZE), 0, stream_low[k], dst_d_low[k] + j, src_d_low[k] + j, @@ -697,8 +697,8 @@ void TestForMultipleStreamWithPriority(void) { } // launch kernels repeatedly on each of the normal prioritiy stream for (int k = 0; k < NORMAL_PRIORITY_STREAMCOUNT; ++k) { - for (int i = 0; i < size; i += MEMCPYSIZE1) { - int j = i / sizeof(T); + for (size_t i = 0; i < size; i += MEMCPYSIZE1) { + size_t j = i / sizeof(T); if (enable_priority_normal) { hipLaunchKernelGGL((memcpy_kernel), dim3(GRIDSIZE), dim3(BLOCKSIZE), 0, stream_normal[k], dst_d_normal[k] + j, src_d_normal[k] + j, @@ -708,8 +708,8 @@ void TestForMultipleStreamWithPriority(void) { } // launch kernels repeatedly on each of the high prioritiy stream for (int k = 0; k < HIGH_PRIORITY_STREAMCOUNT; ++k) { - for (int i = 0; i < size; i += MEMCPYSIZE1) { - int j = i / sizeof(T); + for (size_t i = 0; i < size; i += MEMCPYSIZE1) { + size_t j = i / sizeof(T); if (enable_priority_high) { hipLaunchKernelGGL((memcpy_kernel), dim3(GRIDSIZE), dim3(BLOCKSIZE), 0, stream_high[k], dst_d_high[k] + j, src_d_high[k] + j, diff --git a/catch/unit/surface/hipSurfaceObj1D.cc b/catch/unit/surface/hipSurfaceObj1D.cc index 5068e770b6..e8a59f30a0 100644 --- a/catch/unit/surface/hipSurfaceObj1D.cc +++ b/catch/unit/surface/hipSurfaceObj1D.cc @@ -19,7 +19,7 @@ THE SOFTWARE. #include #include #include - +#pragma clang diagnostic ignored "-Wunused-variable" template __global__ void surf1DKernelR(hipSurfaceObject_t surfaceObject, diff --git a/catch/unit/surface/hipSurfaceObj2D.cc b/catch/unit/surface/hipSurfaceObj2D.cc index 22f143e7df..725f949a20 100644 --- a/catch/unit/surface/hipSurfaceObj2D.cc +++ b/catch/unit/surface/hipSurfaceObj2D.cc @@ -19,7 +19,7 @@ THE SOFTWARE. #include #include #include - +#pragma clang diagnostic ignored "-Wunused-variable" #define LOG_DATA 0 template diff --git a/catch/unit/surface/hipSurfaceObj3D.cc b/catch/unit/surface/hipSurfaceObj3D.cc index 804cc5fb81..cb62de3524 100644 --- a/catch/unit/surface/hipSurfaceObj3D.cc +++ b/catch/unit/surface/hipSurfaceObj3D.cc @@ -19,7 +19,7 @@ THE SOFTWARE. #include #include #include - +#pragma clang diagnostic ignored "-Wunused-variable" template __global__ void surf3DKernelR(hipSurfaceObject_t surfaceObject, diff --git a/catch/unit/texture/hipTextureMipmapObj2D.cc b/catch/unit/texture/hipTextureMipmapObj2D.cc index 7c55e6103e..2b70c13c9f 100644 --- a/catch/unit/texture/hipTextureMipmapObj2D.cc +++ b/catch/unit/texture/hipTextureMipmapObj2D.cc @@ -98,7 +98,7 @@ static void runMipMapTest(unsigned int width, unsigned int height, unsigned int hipLaunchKernelGGL(tex2DKernel, dim3(dimGrid), dim3(dimBlock), 0, 0, dData, textureObject, width, (2 * mipmap_level)); HIP_CHECK(hipGetLastError()); - hipDeviceSynchronize(); + HIP_CHECK(hipDeviceSynchronize()); float* hOutputData = reinterpret_cast(malloc(size)); REQUIRE(hOutputData != nullptr); diff --git a/catch/unit/texture/hipTextureObjFetchVector.cc b/catch/unit/texture/hipTextureObjFetchVector.cc index d31e5fbd7f..7aa2fc8b37 100644 --- a/catch/unit/texture/hipTextureObjFetchVector.cc +++ b/catch/unit/texture/hipTextureObjFetchVector.cc @@ -21,7 +21,7 @@ THE SOFTWARE. #include #include #include - +#pragma clang diagnostic ignored "-Wunused-variable" template __global__ void tex1dKernelFetch(T *val, hipTextureObject_t obj, int N) { #if !defined(__HIP_NO_IMAGE_SUPPORT) || !__HIP_NO_IMAGE_SUPPORT @@ -79,7 +79,7 @@ bool runTest() { // Allocating the required buffer on gpu device T *texBuf, *texBufOut; T val[N], output[N]; - hipGetLastError(); // Clear err due to negative tests + auto err = hipGetLastError(); // Clear err due to negative tests memset(output, 0, sizeof(output)); std::srand(std::time(nullptr)); // use current time as seed for random generator diff --git a/samples/0_Intro/bit_extract/CMakeLists.txt b/samples/0_Intro/bit_extract/CMakeLists.txt index 4986dc1b1f..148f0b2904 100644 --- a/samples/0_Intro/bit_extract/CMakeLists.txt +++ b/samples/0_Intro/bit_extract/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -26,17 +26,10 @@ if(NOT WIN32 AND 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/0_Intro/bit_extract/Makefile b/samples/0_Intro/bit_extract/Makefile deleted file mode 100644 index 939aca00a5..0000000000 --- a/samples/0_Intro/bit_extract/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (c) 2016 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -#Dependencies : [MYHIP]/bin must be in user's path. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif -HIP_PLATFORM=$(shell $(HIP_PATH)/bin/hipconfig --platform) -HIPCC=$(HIP_PATH)/bin/hipcc -INCLUDES := -I../../common - -# Show how to use PLATFORM to specify different options for each compiler: -ifeq (${HIP_PLATFORM}, nvcc) - HIPCC_FLAGS = -gencode=arch=compute_20,code=sm_20 -endif - -EXE=bit_extract - -$(EXE): bit_extract.cpp - $(HIPCC) $(HIPCC_FLAGS) $(INCLUDES) $< -o $@ - -all: $(EXE) - -clean: - rm -f *.o $(EXE) diff --git a/samples/0_Intro/bit_extract/README.md b/samples/0_Intro/bit_extract/README.md index 69995721b0..abf829d75d 100644 --- a/samples/0_Intro/bit_extract/README.md +++ b/samples/0_Intro/bit_extract/README.md @@ -1,6 +1,6 @@ # bit_extract Show an application written directly in HIP which uses platform-specific check on __HIP_PLATFORM_AMD__ to enable use of -an instruction that only exists on the HCC platform. +an instruction that only exists on the AMD platform. See related [blog](http://gpuopen.com/platform-aware-coding-inside-hip/) demonstrating platform specialization. diff --git a/samples/0_Intro/module_api/CMakeLists.txt b/samples/0_Intro/module_api/CMakeLists.txt index 7106df44c0..264304d31d 100644 --- a/samples/0_Intro/module_api/CMakeLists.txt +++ b/samples/0_Intro/module_api/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,14 +23,6 @@ project(module_api) cmake_minimum_required(VERSION 3.10) include_directories(../../common) - -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}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/0_Intro/module_api/Makefile b/samples/0_Intro/module_api/Makefile deleted file mode 100644 index ee3e68e067..0000000000 --- a/samples/0_Intro/module_api/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (c) 2016 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif -HIPCC=$(HIP_PATH)/bin/hipcc -HIP_PLATFORM=$(shell $(HIP_PATH)/bin/hipconfig --compiler) -INCLUDES := -I../../common - -all: vcpy_kernel.code runKernel.hip.out launchKernelHcc.hip.out defaultDriver.hip.out - -runKernel.hip.out: runKernel.cpp - $(HIPCC) $(HIPCC_FLAGS) $(INCLUDES) $< -o $@ - -launchKernelHcc.hip.out: launchKernelHcc.cpp - $(HIPCC) $(HIPCC_FLAGS) $(INCLUDES) $< -o $@ - -defaultDriver.hip.out: defaultDriver.cpp - $(HIPCC) $(HIPCC_FLAGS) $(INCLUDES) $< -o $@ - -vcpy_kernel.code: vcpy_kernel.cpp - $(HIPCC) --genco $(GENCO_FLAGS) $(INCLUDES) $^ -o $@ - -clean: - rm -f *.code *.out diff --git a/samples/0_Intro/module_api_global/CMakeLists.txt b/samples/0_Intro/module_api_global/CMakeLists.txt index 186a99d164..0f22e25e82 100644 --- a/samples/0_Intro/module_api_global/CMakeLists.txt +++ b/samples/0_Intro/module_api_global/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -18,17 +18,10 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN # THE SOFTWARE. -project(modile_api_global) +project(module_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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) @@ -53,4 +46,4 @@ add_dependencies(runKernel.hip.out codeobj) target_include_directories(runKernel.hip.out PRIVATE ../../common) # Link with HIP -target_link_libraries(runKernel.hip.out hip::host) \ No newline at end of file +target_link_libraries(runKernel.hip.out hip::host) diff --git a/samples/0_Intro/module_api_global/Makefile b/samples/0_Intro/module_api_global/Makefile deleted file mode 100644 index 732eec63aa..0000000000 --- a/samples/0_Intro/module_api_global/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2017 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif -HIPCC=$(HIP_PATH)/bin/hipcc -HIP_PLATFORM=$(shell $(HIP_PATH)/bin/hipconfig --compiler) -INCLUDES := -I../../common - -all: vcpy_kernel.code runKernel.hip.out - -runKernel.hip.out: runKernel.cpp - $(HIPCC) $(HIPCC_FLAGS) $(INCLUDES) $< -o $@ - -vcpy_kernel.code: vcpy_kernel.cpp - $(HIPCC) --genco $(GENCO_FLAGS) $^ -o $@ - -clean: - rm -f *.code *.out diff --git a/samples/0_Intro/square/CMakeLists.txt b/samples/0_Intro/square/CMakeLists.txt index 104f828698..7ff5848efd 100644 --- a/samples/0_Intro/square/CMakeLists.txt +++ b/samples/0_Intro/square/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -24,15 +24,8 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # create square.cpp -execute_process(COMMAND sh -c "${ROCM_PATH}/hip/bin/hipify-perl ../square.cu > ../square.cpp") +execute_process(COMMAND sh -c "${CMAKE_PREFIX_PATH}/hip/bin/hipify-perl ../square.cu > ../square.cpp") # Find hip find_package(hip) @@ -45,4 +38,4 @@ set(CMAKE_CXX_LINKER ${HIP_HIPCC_EXECUTABLE}) add_executable(square square.cpp) # Link with HIP -target_link_libraries(square hip::host) \ No newline at end of file +target_link_libraries(square hip::host) diff --git a/samples/0_Intro/square/Makefile b/samples/0_Intro/square/Makefile deleted file mode 100644 index 83a37326ad..0000000000 --- a/samples/0_Intro/square/Makefile +++ /dev/null @@ -1,47 +0,0 @@ -# Copyright (c) 2016 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif -HIP_PLATFORM=$(shell $(HIP_PATH)/bin/hipconfig --platform) -HIPCC=$(HIP_PATH)/bin/hipcc - -ifeq (${HIP_PLATFORM}, nvidia) - SOURCES=square.cu -else - SOURCES=square.cpp -endif - -all: square.out - -# Step -square.cpp: square.cu - $(HIP_PATH)/bin/hipify-perl square.cu > square.cpp - -square.out: $(SOURCES) - $(HIPCC) $(CXXFLAGS) $(SOURCES) -o $@ - -clean: - rm -f *.o *.out square.cpp diff --git a/samples/0_Intro/square/README.md b/samples/0_Intro/square/README.md index 807f08754e..5644184ee7 100644 --- a/samples/0_Intro/square/README.md +++ b/samples/0_Intro/square/README.md @@ -14,11 +14,16 @@ $ export PATH=$PATH:[MYHIP]/bin $ export HIP_PATH=[MYHIP] ``` -- Build executible file +- Build executable file ``` $ cd ~/hip/samples/0_Intro/square -$ make + mkdir -p build && cd build + + cmake -DCMAKE_PREFIX_PATH= -DHIP_CXX_COMPILER= .. + make + +$ Building without cmake /opt/rocm/hip/bin/hipify-perl square.cu > square.cpp /opt/rocm/hip/bin/hipcc square.cpp -o square.out /opt/rocm/hip/bin/hipcc -use-staticlib square.cpp -o square.out.static diff --git a/samples/1_Utils/hipDispatchLatency/CMakeLists.txt b/samples/1_Utils/hipDispatchLatency/CMakeLists.txt index 33caab73b7..61c5f22b8a 100644 --- a/samples/1_Utils/hipDispatchLatency/CMakeLists.txt +++ b/samples/1_Utils/hipDispatchLatency/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,14 +23,6 @@ project(hipDispatchLatency) cmake_minimum_required(VERSION 3.10) include_directories(../../common) - -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}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/1_Utils/hipDispatchLatency/Makefile b/samples/1_Utils/hipDispatchLatency/Makefile deleted file mode 100644 index 6643e3f034..0000000000 --- a/samples/1_Utils/hipDispatchLatency/Makefile +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (c) 2016 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif -HIPCC=$(HIP_PATH)/bin/hipcc -std=c++11 -INCLUDES := -I../../common - -CXXFLAGS = -O3 $(INCLUDES) - -all: test_kernel.code hipDispatchLatency.out hipDispatchEnqueueRateMT.out - -hipDispatchLatency.out: hipDispatchLatency.cpp - $(HIPCC) $(CXXFLAGS) hipDispatchLatency.cpp -o $@ - -hipDispatchEnqueueRateMT.out: hipDispatchEnqueueRateMT.cpp - $(HIPCC) $(CXXFLAGS) hipDispatchEnqueueRateMT.cpp -lpthread -o $@ - -test_kernel.code: test_kernel.cpp - $(HIP_PATH)/bin/hipcc --genco $(GENCO_FLAGS) $^ -o $@ -clean: - rm -f *.o *.out diff --git a/samples/1_Utils/hipInfo/CMakeLists.txt b/samples/1_Utils/hipInfo/CMakeLists.txt index 60cf123282..63bf4f7175 100644 --- a/samples/1_Utils/hipInfo/CMakeLists.txt +++ b/samples/1_Utils/hipInfo/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -30,17 +30,10 @@ cmake_minimum_required(VERSION 3.10) # flag is set to ON in compute build for windows option(HIPINFO_INTERNAL_BUILD "Enable building hipInfo from compute" OFF) -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}/hip ${ROCM_PATH}) - # 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) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --rocm-path=${HIP_PATH}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --rocm-path=${CMAKE_PREFIX_PATH}") endif() # Find hip diff --git a/samples/1_Utils/hipInfo/Makefile b/samples/1_Utils/hipInfo/Makefile deleted file mode 100644 index c5bc1a9c74..0000000000 --- a/samples/1_Utils/hipInfo/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (c) 2016 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif -HIPCC=$(HIP_PATH)/bin/hipcc -INCLUDES := -I../../common - -EXE=hipInfo - -all: install - -$(EXE): hipInfo.cpp - $(HIPCC) hipInfo.cpp $(INCLUDES) -o $@ - -install: $(EXE) - cp $(EXE) $(HIP_PATH)/bin - - -clean: - rm -f *.o $(EXE) diff --git a/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt b/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt index 015e6a047e..a396bbc0c5 100644 --- a/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt +++ b/samples/2_Cookbook/0_MatrixTranspose/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/2_Cookbook/0_MatrixTranspose/Makefile b/samples/2_Cookbook/0_MatrixTranspose/Makefile deleted file mode 100644 index 308efa6dc6..0000000000 --- a/samples/2_Cookbook/0_MatrixTranspose/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2016 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc - -INCLUDES := -I../../common -SOURCES = MatrixTranspose.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./MatrixTranspose - -.PHONY: test - - -all: $(EXECUTABLE) test - -CXXFLAGS =-g $(INCLUDES) -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - -clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/samples/2_Cookbook/10_inline_asm/CMakeLists.txt b/samples/2_Cookbook/10_inline_asm/CMakeLists.txt index f20827df3f..712ea216bc 100644 --- a/samples/2_Cookbook/10_inline_asm/CMakeLists.txt +++ b/samples/2_Cookbook/10_inline_asm/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/2_Cookbook/10_inline_asm/Makefile b/samples/2_Cookbook/10_inline_asm/Makefile deleted file mode 100644 index 31928eb2dc..0000000000 --- a/samples/2_Cookbook/10_inline_asm/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (c) 2017 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc - -SOURCES = inline_asm.cpp -OBJECTS = $(SOURCES:.cpp=.o) -INCLUDES := -I../../common -EXECUTABLE=./inline_asm - -.PHONY: test - - -all: $(EXECUTABLE) test - -CXXFLAGS =-g $(INCLUDES) -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - -clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - diff --git a/samples/2_Cookbook/11_texture_driver/CMakeLists.txt b/samples/2_Cookbook/11_texture_driver/CMakeLists.txt index 55aa40b2a6..a11422877c 100644 --- a/samples/2_Cookbook/11_texture_driver/CMakeLists.txt +++ b/samples/2_Cookbook/11_texture_driver/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/2_Cookbook/11_texture_driver/Makefile b/samples/2_Cookbook/11_texture_driver/Makefile deleted file mode 100644 index 25737ea2e2..0000000000 --- a/samples/2_Cookbook/11_texture_driver/Makefile +++ /dev/null @@ -1,41 +0,0 @@ -# Copyright (c) 2017 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif -HIPCC=$(HIP_PATH)/bin/hipcc -HIP_PLATFORM=$(shell $(HIP_PATH)/bin/hipconfig --compiler) -INCLUDES := -I../../common - -all: tex2dKernel.code texture2dDrv.out - -texture2dDrv.out: texture2dDrv.cpp - $(HIPCC) $(HIPCC_FLAGS) $(INCLUDES) $< -o $@ - -tex2dKernel.code: tex2dKernel.cpp - $(HIPCC) --genco $(GENCO_FLAGS) $^ -o $@ - -clean: - rm -f *.code *.out diff --git a/samples/2_Cookbook/13_occupancy/CMakeLists.txt b/samples/2_Cookbook/13_occupancy/CMakeLists.txt index 44d0303068..c0ec339d1e 100644 --- a/samples/2_Cookbook/13_occupancy/CMakeLists.txt +++ b/samples/2_Cookbook/13_occupancy/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/2_Cookbook/13_occupancy/Makefile b/samples/2_Cookbook/13_occupancy/Makefile deleted file mode 100644 index dd4037418f..0000000000 --- a/samples/2_Cookbook/13_occupancy/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (c) 2019 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif -HIPCC=$(HIP_PATH)/bin/hipcc -INCLUDES := -I../../common -EXE=./occupancy - -.PHONY: test - -all: test - -$(EXE): occupancy.cpp - $(HIPCC) $(INCLUDES) $^ -o $@ - -test: $(EXE) - $(EXE) - -clean: - rm -f *.o $(EXE) diff --git a/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt b/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt index 91354b11cc..5a2a426db6 100644 --- a/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt +++ b/samples/2_Cookbook/14_gpu_arch/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/2_Cookbook/14_gpu_arch/Makefile b/samples/2_Cookbook/14_gpu_arch/Makefile deleted file mode 100644 index a3b1115780..0000000000 --- a/samples/2_Cookbook/14_gpu_arch/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif -HIPCC=$(HIP_PATH)/bin/hipcc -INCLUDES := -I../../common -EXE=./gpuarch - -.PHONY: test - -all: test - -$(EXE): gpuarch.cpp - $(HIPCC) $(INCLUDES) $^ -o $@ - -test: $(EXE) - $(EXE) - -clean: - rm -f *.o $(EXE) 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 317b7a819e..98bde53e1c 100644 --- a/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt +++ b/samples/2_Cookbook/15_static_library/device_functions/CMakeLists.txt @@ -2,13 +2,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip REQUIRED) @@ -38,7 +31,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 ${ROCM_PATH}/hsa/include) +target_include_directories(HipDevice PRIVATE ${CMAKE_PREFIX_PATH}/hsa/include) # Create test executable that uses libHipDevice.a set(TEST_SOURCES ${CMAKE_SOURCE_DIR}/hipMain2.cpp) diff --git a/samples/2_Cookbook/15_static_library/device_functions/Makefile b/samples/2_Cookbook/15_static_library/device_functions/Makefile deleted file mode 100644 index aaf7abb3c6..0000000000 --- a/samples/2_Cookbook/15_static_library/device_functions/Makefile +++ /dev/null @@ -1,35 +0,0 @@ -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -.PHONY: test - -all: $(RDC_EXE) test - -STATIC_LIB_SRC=hipDevice.cpp -STATIC_LIB=./libHipDevice.a -STATIC_MAIN_SRC=hipMain2.cpp -RDC_EXE=./test_device_static.out - -$(STATIC_LIB): - $(HIPCC) $(STATIC_LIB_SRC) -c -fgpu-rdc -fPIC -o hipDevice.o - ar rcsD $@ hipDevice.o - -# Compiles hipMain2 with hipcc and links with libHipDevice.a which contains device function. -$(RDC_EXE): $(STATIC_LIB) - $(HIPCC) $(STATIC_LIB) $(STATIC_MAIN_SRC) -fgpu-rdc -o $@ - -test: $(RDC_EXE) - $(RDC_EXE) - -clean: - rm -f $(RDC_EXE) - rm -f $(STATIC_LIB) - rm -f *.o 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 8404ac58b2..4f5af10a01 100644 --- a/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt +++ b/samples/2_Cookbook/15_static_library/host_functions/CMakeLists.txt @@ -2,13 +2,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip REQUIRED) diff --git a/samples/2_Cookbook/15_static_library/host_functions/Makefile b/samples/2_Cookbook/15_static_library/host_functions/Makefile deleted file mode 100644 index e6daa41da6..0000000000 --- a/samples/2_Cookbook/15_static_library/host_functions/Makefile +++ /dev/null @@ -1,42 +0,0 @@ -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc -GXX=g++ - -EMIT_STATIC_LIB_SRC=hipOptLibrary.cpp -EMIT_STATIC_LIB=./libHipOptLibrary.a -EMIT_STATIC_MAIN_SRC=hipMain1.cpp -HIPCC_EXE=./test_emit_static_hipcc_linker.out -HOST_EXE=./test_emit_static_host_linker.out - -.PHONY: test - -all: $(HIPCC_EXE) $(HOST_EXE) test - -$(EMIT_STATIC_LIB): - $(HIPCC) $(EMIT_STATIC_LIB_SRC) --emit-static-lib -fPIC -o $@ - -# Compiles hipMain1 with hipcc and links with libHipOptLibrary.a which contains host function. -$(HIPCC_EXE): $(EMIT_STATIC_LIB) - $(HIPCC) $(EMIT_STATIC_MAIN_SRC) -L. -lHipOptLibrary -o $@ - -# Compiles hipMain1 with g++ and links with libHipOptLibrary.a which contains host function. -$(HOST_EXE): $(EMIT_STATIC_LIB) - $(GXX) $(EMIT_STATIC_MAIN_SRC) -L. -lHipOptLibrary -L$(HIP_PATH)/lib -lamdhip64 -Wl,-rpath=$(HIP_PATH)/lib -o $@ - -test: $(HIPCC_EXE) $(HOST_EXE) - $(HIPCC_EXE) - $(HOST_EXE) - -clean: - rm -f $(HIPCC_EXE) - rm -f $(HOST_EXE) - rm -f $(EMIT_STATIC_LIB) - rm -f *.o diff --git a/samples/2_Cookbook/16_assembly_to_executable/Makefile b/samples/2_Cookbook/16_assembly_to_executable/Makefile index e0615b84dd..bc1f6ee341 100644 --- a/samples/2_Cookbook/16_assembly_to_executable/Makefile +++ b/samples/2_Cookbook/16_assembly_to_executable/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,9 +22,6 @@ ifeq ($(OS),Windows_NT) endif ROCM_PATH?= $(wildcard /opt/rocm/) HIP_PATH?= $(ROCM_PATH) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif HIPCC=$(HIP_PATH)/bin/hipcc CLANG=$(HIP_PATH)/llvm/bin/clang diff --git a/samples/2_Cookbook/17_llvm_ir_to_executable/Makefile b/samples/2_Cookbook/17_llvm_ir_to_executable/Makefile index eef1f6ff9f..330ad23c60 100644 --- a/samples/2_Cookbook/17_llvm_ir_to_executable/Makefile +++ b/samples/2_Cookbook/17_llvm_ir_to_executable/Makefile @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,9 +22,6 @@ ifeq ($(OS),Windows_NT) endif ROCM_PATH?= $(wildcard /opt/rocm/) HIP_PATH?= $(ROCM_PATH) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif HIPCC=$(HIP_PATH)/bin/hipcc CLANG=$(HIP_PATH)/llvm/bin/clang diff --git a/samples/2_Cookbook/1_hipEvent/CMakeLists.txt b/samples/2_Cookbook/1_hipEvent/CMakeLists.txt index 562d8e9c7f..b709921162 100644 --- a/samples/2_Cookbook/1_hipEvent/CMakeLists.txt +++ b/samples/2_Cookbook/1_hipEvent/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/2_Cookbook/1_hipEvent/Makefile b/samples/2_Cookbook/1_hipEvent/Makefile deleted file mode 100644 index 09d1cf923e..0000000000 --- a/samples/2_Cookbook/1_hipEvent/Makefile +++ /dev/null @@ -1,58 +0,0 @@ -# Copyright (c) 2016 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. - -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc - -SOURCES = hipEvent.cpp -OBJECTS = $(SOURCES:.cpp=.o) -INCLUDES := -I../../common - -EXECUTABLE=./hipEvent - -.PHONY: test - - -all: $(EXECUTABLE) test - -CXXFLAGS =-g $(INCLUDES) -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - -clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/samples/2_Cookbook/20_hip_vulkan/CMakeLists.txt b/samples/2_Cookbook/20_hip_vulkan/CMakeLists.txt index 288c47c3d2..55918d5a6a 100644 --- a/samples/2_Cookbook/20_hip_vulkan/CMakeLists.txt +++ b/samples/2_Cookbook/20_hip_vulkan/CMakeLists.txt @@ -1,5 +1,5 @@ -# Copyright (c) 2020 - 2022 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -29,17 +29,10 @@ project(hipVulkan) cmake_minimum_required(VERSION 3.10) set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake;${CMAKE_MODULE_PATH}") -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}/hip ${ROCM_PATH}) - # 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) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --rocm-path=${HIP_PATH}") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --rocm-path=${CMAKE_PREFIX_PATH}") endif() @@ -85,7 +78,7 @@ set(CMAKE_BUILD_TYPE Release) # Create the excutable add_executable(hipVulkan VulkanBaseApp.cpp VulkanBaseApp.h main.cpp SineWaveSimulation.cpp SineWaveSimulation.h linmath.h) -include_directories(${HIP_PATH}/include) +include_directories(${CMAKE_PREFIX_PATH}/include) include_directories(${GLFW_PATH}/include) # Link with HIP diff --git a/samples/2_Cookbook/20_hip_vulkan/SineWaveSimulation.hip b/samples/2_Cookbook/20_hip_vulkan/SineWaveSimulation.hip deleted file mode 100644 index 41adae8065..0000000000 --- a/samples/2_Cookbook/20_hip_vulkan/SineWaveSimulation.hip +++ /dev/null @@ -1,147 +0,0 @@ -/* Copyright (c) 2020, NVIDIA CORPORATION. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of NVIDIA CORPORATION nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY - * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Modifications Copyright (C)2021 Advanced - * Micro Devices, Inc. All rights reserved. - */ - -#include "SineWaveSimulation.h" -#include -//#include -#include "hip/hip_runtime.h" - - -__global__ void sinewave(float *heightMap, unsigned int width, unsigned int height, float time) -{ - const float freq = 4.0f; - const size_t stride = gridDim.x * blockDim.x; - - // Iterate through the entire array in a way that is - // independent of the grid configuration - for (size_t tid = blockIdx.x * blockDim.x + threadIdx.x; tid < width * height; tid += stride) { - // Calculate the x, y coordinates - const size_t y = tid / width; - const size_t x = tid - y * width; - // Normalize x, y to [0,1] - const float u = ((2.0f * x) / width) - 1.0f; - const float v = ((2.0f * y) / height) - 1.0f; - // Calculate the new height value - const float w = 0.5f * sinf(u * freq + time) * cosf(v * freq + time); - // Store this new height value - heightMap[tid] = w; - } -} - -SineWaveSimulation::SineWaveSimulation(size_t width, size_t height) - : m_heightMap(nullptr), m_width(width), m_height(height) -{ -} - -void SineWaveSimulation::initCudaLaunchConfig(int device) -{ - hipDeviceProp_t prop = {}; - checkHIPErrors(hipSetDevice(device)); - checkHIPErrors(hipGetDeviceProperties(&prop, device)); - - // We don't need large block sizes, since there's not much inter-thread communication - m_threads = prop.warpSize; - - // Use the occupancy calculator and fill the gpu as best as we can - checkHIPErrors(hipOccupancyMaxActiveBlocksPerMultiprocessor(&m_blocks, sinewave, prop.warpSize, 0)); - m_blocks *= prop.multiProcessorCount; - - // Go ahead and the clamp the blocks to the minimum needed for this height/width - m_blocks = std::min(m_blocks, (int)((m_width * m_height + m_threads - 1) / m_threads)); -} - -int SineWaveSimulation::initCuda(uint8_t *vkDeviceUUID, size_t UUID_SIZE) -{ - int current_device = 0; - int device_count = 0; - int devices_prohibited = 0; - - hipDeviceProp_t deviceProp; - checkHIPErrors(hipGetDeviceCount(&device_count)); - - if (device_count == 0) { - fprintf(stderr, "CUDA error: no devices supporting CUDA.\n"); - exit(EXIT_FAILURE); - } - - // Find the GPU which is selected by Vulkan - while (current_device < device_count) { - hipGetDeviceProperties(&deviceProp, current_device); - - if ((deviceProp.computeMode != hipComputeModeProhibited)) { - // Compare the cuda device UUID with vulkan UUID - // FIXME - int ret = 0; // memcmp((void*)&deviceProp.uuid, vkDeviceUUID, UUID_SIZE); - if (ret == 0) - { - checkHIPErrors(hipSetDevice(current_device)); - checkHIPErrors(hipGetDeviceProperties(&deviceProp, current_device)); - printf("GPU Device %d: \"%s\" with compute capability %d.%d\n\n", - current_device, deviceProp.name, deviceProp.major, - deviceProp.minor); - - return current_device; - } - - } else { - devices_prohibited++; - } - - current_device++; - } - - if (devices_prohibited == device_count) { - fprintf(stderr, - "HIP error:" - " No Vulkan-HIP Interop capable GPU found.\n"); - exit(EXIT_FAILURE); - } - - return -1; -} - -SineWaveSimulation::~SineWaveSimulation() -{ - m_heightMap = NULL; -} - -void SineWaveSimulation::initSimulation(float *heights) -{ - m_heightMap = heights; -} - -void SineWaveSimulation::stepSimulation(float time, hipStream_t stream) -{ - hipLaunchKernelGGL(sinewave, dim3(m_blocks), dim3(m_threads), 0, stream , m_heightMap, m_width, m_height, time); - getLastHIPError("Failed to launch CUDA simulation"); - //hipStreamSynchronize(stream); -} diff --git a/samples/2_Cookbook/20_hip_vulkan/buildcmd.txt b/samples/2_Cookbook/20_hip_vulkan/buildcmd.txt index 791466ec42..6f476b68bf 100644 --- a/samples/2_Cookbook/20_hip_vulkan/buildcmd.txt +++ b/samples/2_Cookbook/20_hip_vulkan/buildcmd.txt @@ -1,3 +1,5 @@ +Windows +-------- • Install hip and visual studio • Install vulkan sdk from vulkan.lunarg.com • Download GLFW binaries from glfw.org @@ -14,3 +16,15 @@ to build with cmake on windows: • mkdir build; cd build • cmake.exe -GNinja -DCMAKE_CXX_COMPILER_ID=ROCMClang -DCMAKE_C_COMPILER_ID=ROCMClang -DCMAKE_PREFIX_PATH=d:\driver2\drivers\drivers\compute\hip_sdk +Linux +------ +• Ideally, vulkan should be picked up by cmake from the location where it is installed. eg: /usr/lib +• If a specific version of vulkan is needed, install vulkan sdk from vulkan.lunarg.com following the steps +• To run this sample, connect to the machine where display is enabled using NoMachine app + +Build with CMake: +• mkdir build; cd build +• cmake -DCMAKE_PREFIX_PATH=path\to\rocm -DHIP_CXX_COMPILER=path\to\clang +• make +• run hipVulkan executable + diff --git a/samples/2_Cookbook/3_shared_memory/CMakeLists.txt b/samples/2_Cookbook/3_shared_memory/CMakeLists.txt index bab322511d..d1d87dccb2 100644 --- a/samples/2_Cookbook/3_shared_memory/CMakeLists.txt +++ b/samples/2_Cookbook/3_shared_memory/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/2_Cookbook/3_shared_memory/Makefile b/samples/2_Cookbook/3_shared_memory/Makefile deleted file mode 100644 index c8571cf21f..0000000000 --- a/samples/2_Cookbook/3_shared_memory/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2016 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc - -SOURCES = sharedMemory.cpp -OBJECTS = $(SOURCES:.cpp=.o) -INCLUDES := -I../../common - -EXECUTABLE=./sharedMemory - -.PHONY: test - - -all: $(EXECUTABLE) test - -CXXFLAGS =-g $(INCLUDES) -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - -clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/samples/2_Cookbook/4_shfl/CMakeLists.txt b/samples/2_Cookbook/4_shfl/CMakeLists.txt index d1e8a4843f..e80ed36501 100644 --- a/samples/2_Cookbook/4_shfl/CMakeLists.txt +++ b/samples/2_Cookbook/4_shfl/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/2_Cookbook/4_shfl/Makefile b/samples/2_Cookbook/4_shfl/Makefile deleted file mode 100644 index 6305ad10e0..0000000000 --- a/samples/2_Cookbook/4_shfl/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2016 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -ifeq (gfx701, $(findstring gfx701,$(HCC_AMDGPU_TARGET))) - $(error gfx701 is not a supported device for this sample) -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc - -SOURCES = shfl.cpp -OBJECTS = $(SOURCES:.cpp=.o) -INCLUDES := -I../../common - -EXECUTABLE=./shfl - -.PHONY: test - - -all: $(EXECUTABLE) test - -CXXFLAGS =-g $(INCLUDES) -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - -clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o diff --git a/samples/2_Cookbook/5_2dshfl/CMakeLists.txt b/samples/2_Cookbook/5_2dshfl/CMakeLists.txt index 80fa6e08b3..942f17fc8d 100644 --- a/samples/2_Cookbook/5_2dshfl/CMakeLists.txt +++ b/samples/2_Cookbook/5_2dshfl/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/2_Cookbook/5_2dshfl/Makefile b/samples/2_Cookbook/5_2dshfl/Makefile deleted file mode 100644 index 116d38057a..0000000000 --- a/samples/2_Cookbook/5_2dshfl/Makefile +++ /dev/null @@ -1,64 +0,0 @@ -# Copyright (c) 2016 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -ifeq (gfx701, $(findstring gfx701,$(HCC_AMDGPU_TARGET))) - $(error gfx701 is not a supported device for this sample) -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc - -SOURCES = 2dshfl.cpp -OBJECTS = $(SOURCES:.cpp=.o) -INCLUDES := -I../../common - -EXECUTABLE=./2dshfl - -.PHONY: test - - -all: $(EXECUTABLE) test - -CXXFLAGS =-g $(INCLUDES) -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - -clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt b/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt index cb90fb6b74..02bbe70ae6 100644 --- a/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt +++ b/samples/2_Cookbook/6_dynamic_shared/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -23,14 +23,6 @@ project(dynamic_shared) cmake_minimum_required(VERSION 3.10) include_directories(../../common) - -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}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/2_Cookbook/6_dynamic_shared/Makefile b/samples/2_Cookbook/6_dynamic_shared/Makefile deleted file mode 100644 index 8db78af246..0000000000 --- a/samples/2_Cookbook/6_dynamic_shared/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2016 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc - -SOURCES = dynamic_shared.cpp -OBJECTS = $(SOURCES:.cpp=.o) -INCLUDES := -I../../common - -EXECUTABLE=./dynamic_shared - -.PHONY: test - - -all: $(EXECUTABLE) test - -CXXFLAGS =-g $(INCLUDES) -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - -clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/samples/2_Cookbook/7_streams/CMakeLists.txt b/samples/2_Cookbook/7_streams/CMakeLists.txt index e1133da770..04bec0b422 100644 --- a/samples/2_Cookbook/7_streams/CMakeLists.txt +++ b/samples/2_Cookbook/7_streams/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/2_Cookbook/7_streams/Makefile b/samples/2_Cookbook/7_streams/Makefile deleted file mode 100644 index e55d9c8191..0000000000 --- a/samples/2_Cookbook/7_streams/Makefile +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (c) 2016 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc - -SOURCES = stream.cpp -OBJECTS = $(SOURCES:.cpp=.o) -INCLUDES := -I../../common - -EXECUTABLE=./stream - -.PHONY: test - - -all: $(EXECUTABLE) test - -CXXFLAGS =-g $(INCLUDES) -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - -clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/samples/2_Cookbook/8_peer2peer/CMakeLists.txt b/samples/2_Cookbook/8_peer2peer/CMakeLists.txt index ad34ee44df..7d66525389 100644 --- a/samples/2_Cookbook/8_peer2peer/CMakeLists.txt +++ b/samples/2_Cookbook/8_peer2peer/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/2_Cookbook/8_peer2peer/Makefile b/samples/2_Cookbook/8_peer2peer/Makefile deleted file mode 100644 index 4112c75696..0000000000 --- a/samples/2_Cookbook/8_peer2peer/Makefile +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (c) 2016 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc - -SOURCES = peer2peer.cpp -OBJECTS = $(SOURCES:.cpp=.o) - -EXECUTABLE=./peer2peer - -.PHONY: test - - -all: $(EXECUTABLE) test - -CXXFLAGS =-g -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - -clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o - diff --git a/samples/2_Cookbook/9_unroll/CMakeLists.txt b/samples/2_Cookbook/9_unroll/CMakeLists.txt index 070f66fe23..dfc34b641b 100644 --- a/samples/2_Cookbook/9_unroll/CMakeLists.txt +++ b/samples/2_Cookbook/9_unroll/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. +# Copyright (c) 2020 - 2023 Advanced Micro Devices, Inc. All Rights Reserved. # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal @@ -22,13 +22,6 @@ 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 ${ROCM_PATH}/hip ${ROCM_PATH}) - # Find hip find_package(hip) diff --git a/samples/2_Cookbook/9_unroll/Makefile b/samples/2_Cookbook/9_unroll/Makefile deleted file mode 100644 index 49bf51ece1..0000000000 --- a/samples/2_Cookbook/9_unroll/Makefile +++ /dev/null @@ -1,63 +0,0 @@ -# Copyright (c) 2017 - 2021 Advanced Micro Devices, Inc. All Rights Reserved. -# -# Permission is hereby granted, free of charge, to any person obtaining a copy -# of this software and associated documentation files (the "Software"), to deal -# in the Software without restriction, including without limitation the rights -# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -# copies of the Software, and to permit persons to whom the Software is -# furnished to do so, subject to the following conditions: -# -# The above copyright notice and this permission notice shall be included in -# all copies or substantial portions of the Software. -# -# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -# THE SOFTWARE. -ifeq ($(OS),Windows_NT) - $(error Makefile is not supported on windows platform. Please use cmake instead to build sample.) -endif -ROCM_PATH?= $(wildcard /opt/rocm/) -HIP_PATH?= $(wildcard $(ROCM_PATH)/hip) -ifeq (,$(HIP_PATH)) - HIP_PATH=../../.. -endif - -ifeq (gfx701, $(findstring gfx701,$(HCC_AMDGPU_TARGET))) - $(error gfx701 is not a supported device for this sample) -endif - -HIPCC=$(HIP_PATH)/bin/hipcc - -TARGET=hcc - -SOURCES = unroll.cpp -OBJECTS = $(SOURCES:.cpp=.o) -INCLUDES := -I../../common - -EXECUTABLE=./unroll - -.PHONY: test - - -all: $(EXECUTABLE) test - -CXXFLAGS =-g $(INCLUDES) -CXX=$(HIPCC) - - -$(EXECUTABLE): $(OBJECTS) - $(HIPCC) $(OBJECTS) -o $@ - - -test: $(EXECUTABLE) - $(EXECUTABLE) - - -clean: - rm -f $(EXECUTABLE) - rm -f $(OBJECTS) - rm -f $(HIP_PATH)/src/*.o diff --git a/samples/README.md b/samples/README.md index 8f0551bf91..a5184a6ee9 100644 --- a/samples/README.md +++ b/samples/README.md @@ -12,6 +12,7 @@ make 2.CMakeLists.txt can support shared and static libs of hip-rocclr runtime. +The same steps can be followed for both. To build a sample, run in the sample folder, @@ -19,15 +20,7 @@ mkdir -p build && cd build rm -rf * (to clear up) -a. to build with shared libs, run - -cmake .. - -make - -b. to build with static libs, run - -cmake -DCMAKE_PREFIX_PATH="/llvm/lib/cmake" .. +cmake -DCMAKE_PREFIX_PATH= -DHIP_CXX_COMPILER= .. Then run,