├── catch ├── unit │ ├── module │ │ ├── empty_file.txt │ │ ├── emptyModuleCount.cpp │ │ ├── not_a_module.txt │ │ ├── log │ │ ├── empty_module.cc │ │ ├── managed_kernel.cpp │ │ ├── hipModuleGetGlobal.hh │ │ ├── get_function_module.cc │ │ ├── vcpy_kernel.cpp │ │ ├── get_tex_ref_module.cc │ │ ├── copyKernel.cc │ │ ├── kernel_count.cpp │ │ ├── addKernel.cc │ │ └── copiousArgKernel.cc │ ├── rtc │ │ ├── headers │ │ │ ├── RtcFact.h │ │ │ ├── RtcKernels.h │ │ │ ├── RtcUtility.h │ │ │ ├── RtcFunctions.h │ │ │ ├── printf_common.h │ │ │ ├── test_header1.h │ │ │ └── test_header2.h │ │ └── saxpy.h │ ├── memory │ │ ├── memoryGlobal.hh │ │ ├── memoryCommon.cc │ │ ├── malloc.cc │ │ ├── hipMemsetBasic.cc │ │ ├── memoryCommon.hh │ │ ├── DriverContext.cc │ │ ├── DriverContext.hh │ │ ├── hipMemGetInfo.cc │ │ └── inlineVar.cc │ ├── synchronization │ │ ├── memcpyIntDevice.cpp │ │ └── CMakeLists.txt │ ├── multiThread │ │ └── CMakeLists.txt │ ├── library │ │ ├── library_code_load.cc │ │ └── CMakeLists.txt │ ├── g++ │ │ ├── CMakeLists.txt │ │ └── hipMalloc.h │ ├── executionControl │ │ ├── CMakeLists.txt │ │ ├── execution_control_common.hh │ │ └── execution_control_common.cc │ ├── event │ │ └── CMakeLists.txt │ ├── streamperthread │ │ └── CMakeLists.txt │ ├── p2p │ │ └── CMakeLists.txt │ ├── callback │ │ └── SimpleKernel.cc │ ├── occupancy │ │ ├── simple_kernel.cc │ │ └── CMakeLists.txt │ ├── graph │ │ └── add_Kernel.cpp │ ├── deviceLib │ │ ├── hipTestDeviceLimit.cc │ │ ├── kerDevWriteMultCO.cc │ │ └── kerDevAllocMultCO.cc │ ├── errorHandling │ │ ├── hipGetLastErrorEnv_Exe.cc │ │ ├── hipPeekAtLastErrorEnv_Exe.cc │ │ └── CMakeLists.txt │ ├── texture │ │ └── tex_ref_get_module.cc │ ├── channelDescriptor │ │ └── CMakeLists.txt │ ├── dynamicLoading │ │ ├── vecadd.cc │ │ └── bit_extract_kernel.cpp │ ├── vector_types │ │ ├── negative_bitwise_float.cc │ │ ├── negative_bitwise_double.cc │ │ ├── negative_calculate_assign_with_value_1D.cc │ │ ├── negative_calculate_assign_with_value_2D.cc │ │ ├── negative_calculate_assign_with_value_3D.cc │ │ ├── negative_calculate_assign_with_value_4D.cc │ │ ├── negative_calculate_assign_with_unsigned_value_1D.cc │ │ ├── negative_calculate_assign_with_unsigned_value_2D.cc │ │ ├── negative_calculate_assign_with_unsigned_value_3D.cc │ │ └── negative_calculate_assign_with_unsigned_value_4D.cc │ ├── compiler │ │ └── hipSpirvTest.cc │ ├── device │ │ ├── setuuidGetDevCount_Exe.cc │ │ ├── ResetUUIDInChild_Exe.cc │ │ ├── passUUIDToGrandChild_Exe.cc │ │ └── setEnvInChildProc_Exe.cc │ ├── clock │ │ └── CMakeLists.txt │ ├── threadfence │ │ └── CMakeLists.txt │ ├── warp │ │ └── CMakeLists.txt │ ├── gcc │ │ ├── CMakeLists.txt │ │ ├── hipMalloc.c │ │ └── LaunchKernel.h │ ├── context │ │ ├── CMakeLists.txt │ │ ├── hipDrvGetPCIBusId.cc │ │ └── hipMemsetD8.cc │ ├── syncthreads │ │ ├── __syncthreads_or_negative_kernels.cc │ │ ├── __syncthreads_and_negative_kernels.cc │ │ ├── __syncthreads_count_negative_kernels.cc │ │ ├── __syncthreads_or_negative_kernels_rtc.hh │ │ ├── __syncthreads_and_negative_kernels_rtc.hh │ │ └── __syncthreads_count_negative_kernels_rtc.hh │ ├── c_compilation │ │ ├── hipGetDeviceProp.c │ │ └── hipGetDeviceProp.cc │ ├── launchBounds │ │ ├── launch_bounds_parse_error_kernels.cc │ │ └── launch_bounds_compiler_error_kernels.cc │ ├── assertion │ │ ├── static_assert_kernels_negative.cc │ │ └── static_assert_kernels_positive.cc │ ├── printf │ │ └── printfFlagsNonHost_exe.cc │ ├── device_memory │ │ ├── memset_negative_kernels.cc │ │ ├── memcpy_negative_kernels.cc │ │ ├── memset_negative_kernels_rtc.hh │ │ └── memcpy_negative_kernels_rtc.hh │ ├── stream │ │ ├── hipDeviceGetStreamPriorityRange.cc │ │ └── hipStreamCreate.cc │ └── surface │ │ └── CMakeLists.txt ├── ABM │ ├── CMakeLists.txt │ └── AddKernels │ │ ├── CMakeLists.txt │ │ └── add.cc ├── perftests │ ├── memory │ │ ├── hipPerfBufferCopySpeedP2P.cc │ │ └── FindNUMA.cmake │ ├── vmm │ │ └── CMakeLists.txt │ ├── event │ │ └── CMakeLists.txt │ ├── dispatch │ │ └── CMakeLists.txt │ ├── compute │ │ └── CMakeLists.txt │ ├── graph │ │ └── CMakeLists.txt │ ├── CMakeLists.txt │ └── stream │ │ └── CMakeLists.txt ├── TypeQualifiers │ └── CMakeLists.txt ├── stress │ ├── deviceallocation │ │ └── CMakeLists.txt │ ├── stream │ │ └── CMakeLists.txt │ ├── printf │ │ └── CMakeLists.txt │ ├── module │ │ └── CMakeLists.txt │ ├── CMakeLists.txt │ └── memory │ │ ├── CMakeLists.txt │ │ └── memcpy.cc ├── kernels │ ├── CMakeLists.txt │ ├── Set.cpp │ └── vectorADD.inl ├── multiproc │ ├── dummy_kernel.cpp │ └── CMakeLists.txt ├── catchProp_in_rc.in ├── packaging │ └── catch_package.cmake.in ├── include │ ├── kernel_mapping.hh │ └── cmd_options.hh ├── performance │ ├── example │ │ └── CMakeLists.txt │ ├── CMakeLists.txt │ ├── warpSync │ │ └── CMakeLists.txt │ ├── event │ │ └── CMakeLists.txt │ ├── kernelLaunch │ │ └── CMakeLists.txt │ └── memset │ │ └── CMakeLists.txt ├── external │ └── picojson │ │ └── LICENSE └── hipTestMain │ └── CMakeLists.txt ├── CODEOWNERS ├── .github ├── hooks │ ├── pre-commit │ └── clang-format-check.sh ├── palamida.yml ├── workflows │ ├── kws-caller.yml │ ├── validate-pr-description.yml │ ├── clang-format.yml │ └── pr-title-validate.yml └── pull_request_template.md ├── samples ├── 2_Cookbook │ ├── 19_cmake_lang │ │ ├── TestFortran.F90 │ │ ├── README.md │ │ └── CMakeLists.txt │ ├── 8_peer2peer │ │ └── Readme.md │ ├── 14_gpu_arch │ │ └── Readme.md │ ├── 23_cmake_hiprtc │ │ └── README.md │ ├── 22_cmake_hip_lang │ │ └── README.md │ ├── 11_texture_driver │ │ └── Readme.md │ ├── 13_occupancy │ │ └── Readme.md │ ├── 16_assembly_to_executable │ │ └── hip_obj_gen.mcin │ ├── 17_llvm_ir_to_executable │ │ └── hip_obj_gen.mcin │ ├── 18_cmake_hip_device │ │ └── README.md │ ├── 21_cmake_hip_cxx_clang │ │ └── README.md │ └── 15_static_library │ │ ├── device_functions │ │ └── hipDevice.cpp │ │ └── host_functions │ │ └── hipMain1.cpp ├── 0_Intro │ ├── module_api_global │ │ ├── README.md │ │ └── vcpy_kernel.cpp │ ├── module_api │ │ ├── README.md │ │ └── vcpy_kernel.cpp │ ├── bit_extract │ │ └── README.md │ ├── square │ │ └── README.md │ └── CMakeLists.txt ├── 1_Utils │ ├── hipDispatchLatency │ │ ├── README.md │ │ └── test_kernel.cpp │ └── CMakeLists.txt ├── README.md └── common │ └── hip_helper.h ├── utils └── coverage │ └── coverageReportHTML │ └── resources │ ├── amber.png │ ├── glass.png │ ├── ruby.png │ ├── snow.png │ ├── updown.png │ └── emerald.png ├── .clang-format ├── README.md ├── .gitignore ├── .gitattributes ├── .azuredevops └── rocm-ci.yml └── LICENSE.md /catch/unit/module/empty_file.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /catch/unit/module/emptyModuleCount.cpp: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /catch/ABM/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(AddKernels) 2 | -------------------------------------------------------------------------------- /catch/unit/module/not_a_module.txt: -------------------------------------------------------------------------------- 1 | This is not a module! 2 | -------------------------------------------------------------------------------- /catch/unit/module/log: -------------------------------------------------------------------------------- 1 | bash: ./ModuleTest: No such file or directory 2 | -------------------------------------------------------------------------------- /CODEOWNERS: -------------------------------------------------------------------------------- 1 | * @cpaquot_amdeng @gandryey_amdeng @skudchad_amdeng @lmoriche_amdeng 2 | 3 | -------------------------------------------------------------------------------- /catch/unit/rtc/headers/RtcFact.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/hip-tests/HEAD/catch/unit/rtc/headers/RtcFact.h -------------------------------------------------------------------------------- /catch/unit/rtc/headers/RtcKernels.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/hip-tests/HEAD/catch/unit/rtc/headers/RtcKernels.h -------------------------------------------------------------------------------- /catch/unit/rtc/headers/RtcUtility.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/hip-tests/HEAD/catch/unit/rtc/headers/RtcUtility.h -------------------------------------------------------------------------------- /.github/hooks/pre-commit: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | exec "$(git rev-parse --show-toplevel)/.github/hooks/clang-format-check.sh" 3 | -------------------------------------------------------------------------------- /.github/palamida.yml: -------------------------------------------------------------------------------- 1 | disabled: false 2 | scmId: gh-emu-rocm 3 | branchesToScan: 4 | - amd-staging 5 | - amd-mainline 6 | -------------------------------------------------------------------------------- /catch/unit/rtc/headers/RtcFunctions.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/hip-tests/HEAD/catch/unit/rtc/headers/RtcFunctions.h -------------------------------------------------------------------------------- /catch/unit/rtc/headers/printf_common.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/hip-tests/HEAD/catch/unit/rtc/headers/printf_common.h -------------------------------------------------------------------------------- /catch/perftests/memory/hipPerfBufferCopySpeedP2P.cc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/hip-tests/HEAD/catch/perftests/memory/hipPerfBufferCopySpeedP2P.cc -------------------------------------------------------------------------------- /catch/unit/memory/memoryGlobal.hh: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #include 3 | #include 4 | 5 | inline __constant__ int globalVar; 6 | -------------------------------------------------------------------------------- /samples/2_Cookbook/19_cmake_lang/TestFortran.F90: -------------------------------------------------------------------------------- 1 | program fortran_test_program 2 | print *, "Succeeded testing Fortran!" 3 | end program -------------------------------------------------------------------------------- /utils/coverage/coverageReportHTML/resources/amber.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/hip-tests/HEAD/utils/coverage/coverageReportHTML/resources/amber.png -------------------------------------------------------------------------------- /utils/coverage/coverageReportHTML/resources/glass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/hip-tests/HEAD/utils/coverage/coverageReportHTML/resources/glass.png -------------------------------------------------------------------------------- /utils/coverage/coverageReportHTML/resources/ruby.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/hip-tests/HEAD/utils/coverage/coverageReportHTML/resources/ruby.png -------------------------------------------------------------------------------- /utils/coverage/coverageReportHTML/resources/snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/hip-tests/HEAD/utils/coverage/coverageReportHTML/resources/snow.png -------------------------------------------------------------------------------- /utils/coverage/coverageReportHTML/resources/updown.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/hip-tests/HEAD/utils/coverage/coverageReportHTML/resources/updown.png -------------------------------------------------------------------------------- /utils/coverage/coverageReportHTML/resources/emerald.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ROCm/hip-tests/HEAD/utils/coverage/coverageReportHTML/resources/emerald.png -------------------------------------------------------------------------------- /catch/unit/rtc/headers/test_header1.h: -------------------------------------------------------------------------------- 1 | #ifndef HIPRTC_TEST_HEADER1_H 2 | #define HIPRTC_TEST_HEADER1_H 3 | typedef float real; 4 | #endif // HIPRTC_TEST_HEADER1_H 5 | -------------------------------------------------------------------------------- /catch/unit/rtc/headers/test_header2.h: -------------------------------------------------------------------------------- 1 | #ifndef HIPRTC_TEST_HEADER2_H 2 | #define HIPRTC_TEST_HEADER2_H 3 | typedef float* realptr; 4 | #endif // HIPRTC_TEST_HEADER2_H 5 | -------------------------------------------------------------------------------- /catch/TypeQualifiers/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests 2 | set(TEST_SRC 3 | hipManagedKeyword.cc 4 | ) 5 | 6 | hip_add_exe_to_target(NAME TypeQualifiers 7 | TEST_SRC ${TEST_SRC} 8 | TEST_TARGET_NAME build_tests) 9 | -------------------------------------------------------------------------------- /catch/ABM/AddKernels/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | set(TEST_SRC 3 | add.cc 4 | ) 5 | 6 | hip_add_exe_to_target(NAME ABMAddKernels 7 | TEST_SRC ${TEST_SRC} 8 | TEST_TARGET_NAME build_tests) 9 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | Language: Cpp 2 | BasedOnStyle: Google 3 | AlignEscapedNewlinesLeft: false 4 | AlignOperands: Align 5 | ColumnLimit: 100 6 | BreakTemplateDeclarations: No 7 | DerivePointerAlignment: false 8 | IndentFunctionDeclarationAfterType: false 9 | MaxEmptyLinesToKeep: 2 10 | SortIncludes: Never 11 | -------------------------------------------------------------------------------- /catch/stress/deviceallocation/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | set(TEST_SRC 3 | Stress_deviceAllocationStress.cc 4 | ) 5 | 6 | hip_add_exe_to_target(NAME devalloc_stress 7 | TEST_SRC ${TEST_SRC} 8 | TEST_TARGET_NAME stress_test) 9 | -------------------------------------------------------------------------------- /samples/2_Cookbook/8_peer2peer/Readme.md: -------------------------------------------------------------------------------- 1 | # peer2peer 2 | - Build the sample using cmake 3 | ``` 4 | $ mkdir build; cd build 5 | $ cmake .. -DCMAKE_PREFIX_PATH=/opt/rocm 6 | $ make 7 | ``` 8 | - Execute the sample 9 | ``` 10 | $ ./peer2peer 11 | Peer2Peer application requires atleast 2 gpu devices 12 | ``` -------------------------------------------------------------------------------- /catch/unit/rtc/saxpy.h: -------------------------------------------------------------------------------- 1 | #include "test_header1.h" 2 | #include "test_header2.h" 3 | 4 | extern "C" __global__ void saxpy(real a, realptr x, realptr y, realptr out, size_t n) { 5 | size_t tid = blockIdx.x * blockDim.x + threadIdx.x; 6 | if (tid < n) { 7 | out[tid] = a * x[tid] + y[tid]; 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /catch/stress/stream/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | set(TEST_SRC 3 | Stress_hipStreamCreate.cc 4 | streamEnqueue.cc 5 | ) 6 | 7 | hip_add_exe_to_target(NAME stream_stress 8 | TEST_SRC ${TEST_SRC} 9 | TEST_TARGET_NAME stress_test) 10 | -------------------------------------------------------------------------------- /samples/2_Cookbook/14_gpu_arch/Readme.md: -------------------------------------------------------------------------------- 1 | # gpu_arch 2 | 3 | - Build the sample using cmake 4 | ``` 5 | $ mkdir build; cd build 6 | $ cmake .. -DCMAKE_PREFIX_PATH=/opt/rocm 7 | $ make 8 | ``` 9 | - Execute the sample 10 | ``` 11 | $ ./gpuarch 12 | success 13 | ``` 14 | 15 | ## Note : This sample works on architectures gfx908 and above -------------------------------------------------------------------------------- /samples/0_Intro/module_api_global/README.md: -------------------------------------------------------------------------------- 1 | # module_api_global 2 | 3 | - Steps to build this sample 4 | ``` 5 | $ mkdir build; cd build 6 | $ cmake .. -DCMAKE_PREFIX_PATH=/opt/rocm 7 | $ make 8 | ``` 9 | 10 | - Execute Code 11 | ``` 12 | $ ./runKernel1.hip.out 13 | PASSED! 14 | Shared Size Bytes = 0 15 | Num Regs = 3 16 | PASSED! 17 | ``` -------------------------------------------------------------------------------- /catch/stress/printf/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | set(TEST_SRC 3 | Stress_printf_ComplexKernels.cc 4 | Stress_printf_SimpleKernels.cc 5 | ) 6 | 7 | hip_add_exe_to_target(NAME printf_stress 8 | TEST_SRC ${TEST_SRC} 9 | TEST_TARGET_NAME stress_test) 10 | -------------------------------------------------------------------------------- /catch/stress/module/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | set(TEST_SRC 3 | hipModuleLoadUnload.cc 4 | ) 5 | 6 | hip_add_exe_to_target(NAME module_stress 7 | TEST_SRC ${TEST_SRC} 8 | TEST_TARGET_NAME stress_test 9 | LINKER_LIBS hiprtc::hiprtc) 10 | -------------------------------------------------------------------------------- /catch/unit/synchronization/memcpyIntDevice.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | extern "C" __global__ void memcpyIntKernel(int* dst, const int* src, size_t numElements) { 3 | int gid = (blockIdx.x * blockDim.x + threadIdx.x); 4 | int stride = blockDim.x * gridDim.x; 5 | for (size_t i = gid; i < numElements; i += stride) { 6 | dst[i] = src[i]; 7 | } 8 | }; 9 | -------------------------------------------------------------------------------- /samples/2_Cookbook/23_cmake_hiprtc/README.md: -------------------------------------------------------------------------------- 1 | ### This will test linking hiprtc::hiprtc interface in cmake 2 | I. Build 3 | 4 | ``` 5 | $ mkdir -p build; cd build 6 | $ rm -rf *; 7 | $ CXX="$(hipconfig -l)"/amdclang++ cmake -DCMAKE_PREFIX_PATH=/opt/rocm .. 8 | $ make 9 | ``` 10 | 11 | II. Test 12 | 13 | ``` 14 | $ ./test 15 | SAXPY test completed 16 | ``` 17 | -------------------------------------------------------------------------------- /samples/0_Intro/module_api/README.md: -------------------------------------------------------------------------------- 1 | # module_api 2 | 3 | - Steps to build this sample 4 | 5 | ``` 6 | $ mkdir build; cd build 7 | $ cmake .. -DCMAKE_PREFIX_PATH=/opt/rocm 8 | $ make 9 | ``` 10 | 11 | - Execute Code 12 | ``` 13 | $ ./launchKernelHcc.hip.out 14 | PASSED! 15 | $ ./runKernel.hip.out 16 | PASSED! 17 | $ ./defaultDriver.hip.out 18 | PASSED! 19 | ``` -------------------------------------------------------------------------------- /catch/unit/memory/memoryCommon.cc: -------------------------------------------------------------------------------- 1 | #include "memoryCommon.hh" 2 | #include "memoryGlobal.hh" 3 | 4 | void set_value(int const value) { 5 | HIP_CHECK(hipMemcpyToSymbol(HIP_SYMBOL(globalVar), &value, sizeof(value))); 6 | } 7 | 8 | int get_value() { 9 | int value; 10 | HIP_CHECK(hipMemcpyFromSymbol(&value, HIP_SYMBOL(globalVar), sizeof(value))); 11 | return value; 12 | } 13 | -------------------------------------------------------------------------------- /catch/unit/multiThread/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | set(TEST_SRC 3 | hipMemsetAsyncMultiThread.cc 4 | hipMultiThreadDevice.cc 5 | hipMultiThreadStreams1.cc 6 | hipMultiThreadStreams2.cc 7 | ) 8 | 9 | hip_add_exe_to_target(NAME MultiThreadTest 10 | TEST_SRC ${TEST_SRC} 11 | TEST_TARGET_NAME build_tests) 12 | -------------------------------------------------------------------------------- /catch/kernels/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT RTC_TESTING) 2 | set(TEST_SRC 3 | Set.cpp 4 | ) 5 | 6 | add_library(KERNELS EXCLUDE_FROM_ALL OBJECT ${TEST_SRC}) 7 | set_source_files_properties(${TEST_SRC} PROPERTIES LANGUAGE HIP) 8 | #set_property(TARGET KERNELS PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded") 9 | target_link_libraries(KERNELS PRIVATE Catch2::Catch2) 10 | endif() 11 | -------------------------------------------------------------------------------- /catch/stress/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_custom_target(stress_test COMMAND "${CMAKE_CTEST_COMMAND}" -R "Stress_" 2 | COMMENT "Build complete, now executing the stress test ...") 3 | 4 | add_subdirectory(memory) 5 | add_subdirectory(module) 6 | if(HIP_PLATFORM MATCHES "amd") 7 | add_subdirectory(printf) 8 | add_subdirectory(stream) 9 | endif() 10 | add_subdirectory(deviceallocation) 11 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # hip-tests 2 | 3 | > [!CAUTION] 4 | > The hip-tests repository is retired, please use the [ROCm/rocm-systems](https://github.com/ROCm/rocm-systems/tree/develop/projects/hip-tests) repository for development. This `develop` branch will only accept patch updates from a bot that mirrors hip-tests-specific updates from `rocm-systems` into here. 5 | 6 | This repository provides unit tests for [HIP](https://github.com/ROCm/rocm-systems/tree/develop/projects/hip) implementation. 7 | -------------------------------------------------------------------------------- /catch/unit/library/library_code_load.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | extern "C" { 4 | __global__ void add_kernel(float* out, float* a, float* b) { 5 | size_t i = threadIdx.x; 6 | out[i] = a[i] + b[i]; 7 | } 8 | __global__ void sub_kernel(float* out, float* a, float* b) { 9 | size_t i = threadIdx.x; 10 | out[i] = a[i] - b[i]; 11 | } 12 | __global__ void mul_kernel(float* out, float* a, float* b) { 13 | size_t i = threadIdx.x; 14 | out[i] = a[i] * b[i]; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /catch/unit/memory/malloc.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | TEST_CASE("Unit_hipHostMalloc_4bytes") { 4 | int* d_a; 5 | auto res = hipHostMalloc(&d_a, sizeof(int), 0); 6 | REQUIRE(res == hipSuccess); 7 | res = hipHostFree(d_a); 8 | REQUIRE(res == hipSuccess); 9 | } 10 | 11 | TEST_CASE("Unit_hipMalloc_4bytes") { 12 | int* d_a; 13 | auto res = hipMalloc(&d_a, sizeof(int)); 14 | REQUIRE(res == hipSuccess); 15 | res = hipFree(d_a); 16 | REQUIRE(res == hipSuccess); 17 | } 18 | -------------------------------------------------------------------------------- /.github/workflows/kws-caller.yml: -------------------------------------------------------------------------------- 1 | name: Rocm Validation Suite KWS 2 | on: 3 | push: 4 | branches: [amd-staging, amd-mainline] 5 | pull_request: 6 | types: [opened, synchronize, reopened] 7 | workflow_dispatch: 8 | jobs: 9 | kws: 10 | if: ${{ github.event_name == 'pull_request' }} 11 | uses: AMD-ROCm-Internal/rocm_ci_infra/.github/workflows/kws.yml@mainline 12 | secrets: inherit 13 | with: 14 | pr_number: ${{github.event.pull_request.number}} 15 | base_branch: ${{github.base_ref}} 16 | -------------------------------------------------------------------------------- /samples/2_Cookbook/22_cmake_hip_lang/README.md: -------------------------------------------------------------------------------- 1 | ### This will test HIP language support in upstream CMake 2 | I. Build 3 | 4 | ``` 5 | $ mkdir -p build; cd build 6 | $ rm -rf *; 7 | $ cmake -DCMAKE_PREFIX_PATH=/opt/rocm .. 8 | $ make 9 | ``` 10 | 11 | II. Test 12 | 13 | ``` 14 | $ ./square 15 | info: running on device 16 | info: allocate host mem ( 7.63 MB) 17 | info: allocate device mem ( 7.63 MB) 18 | info: copy Host2Device 19 | info: launch 'vector_square' kernel 20 | info: copy Device2Host 21 | info: check result 22 | PASSED! 23 | ``` 24 | -------------------------------------------------------------------------------- /samples/2_Cookbook/11_texture_driver/Readme.md: -------------------------------------------------------------------------------- 1 | # texture_driver 2 | 3 | - Build the sample using cmake 4 | ``` 5 | $ mkdir build; cd build 6 | $ cmake .. -DCMAKE_PREFIX_PATH=/opt/rocm 7 | $ make 8 | ``` 9 | - Execute the sample 10 | ``` 11 | $ ./texture2dDrv 12 | tex2dKernelChar test PASSED ... 13 | tex2dKernelShort test PASSED ... 14 | tex2dKernelInt test PASSED ... 15 | tex2dKernelFloat test PASSED ... 16 | tex2dKernelChar4 test PASSED ... 17 | tex2dKernelShort4 test PASSED ... 18 | tex2dKernelInt4 test PASSED ... 19 | tex2dKernelFloat4 test PASSED ... 20 | texture2dDrv PASSED ... 21 | ``` -------------------------------------------------------------------------------- /samples/2_Cookbook/13_occupancy/Readme.md: -------------------------------------------------------------------------------- 1 | # occupancy 2 | 3 | - Build the sample using cmake 4 | ``` 5 | $ mkdir build; cd build 6 | $ cmake .. -DCMAKE_PREFIX_PATH=/opt/rocm 7 | $ make 8 | ``` 9 | - Execute the sample 10 | ``` 11 | $ ./occupancy 12 | Manual Configuration with block size 32 13 | kernel Execution time = 0.433ms 14 | Theoretical Occupancy is 40% 15 | 16 | Automatic Configuation based on hipOccupancyMaxPotentialBlockSize 17 | Suggested blocksize is 1024, Minimum gridsize is 128 18 | kernel Execution time = 0.037ms 19 | Theoretical Occupancy is 80% 20 | 21 | Manual Test PASSED! 22 | 23 | Automatic Test PASSED! 24 | ``` -------------------------------------------------------------------------------- /catch/unit/memory/hipMemsetBasic.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | TEST_CASE("Unit_hipMemset_4bytes") { 4 | int* d_a; 5 | auto res = hipMalloc(&d_a, sizeof(int)); 6 | REQUIRE(res == hipSuccess); 7 | res = hipMemset(d_a, 0, sizeof(int)); 8 | REQUIRE(res == hipSuccess); 9 | res = hipFree(d_a); 10 | REQUIRE(res == hipSuccess); 11 | } 12 | 13 | TEST_CASE("Unit_hipMemset_4bytes_hostMem") { 14 | int* d_a; 15 | auto res = hipHostMalloc(&d_a, sizeof(int), 0); 16 | REQUIRE(res == hipSuccess); 17 | res = hipMemset(d_a, 0, sizeof(int)); 18 | REQUIRE(res == hipSuccess); 19 | res = hipHostFree(d_a); 20 | REQUIRE(res == hipSuccess); 21 | } 22 | -------------------------------------------------------------------------------- /.github/workflows/validate-pr-description.yml: -------------------------------------------------------------------------------- 1 | name: Validate PR desription 2 | 3 | on: 4 | pull_request: 5 | types: [opened, edited, synchronize] 6 | 7 | jobs: 8 | validate-pr-description: 9 | runs-on: AMD-ROCm-Internal-dev1 10 | steps: 11 | - name: Checkout repository 12 | uses: actions/checkout@v4 13 | 14 | - name: Set up Python 15 | uses: actions/setup-python@v5 16 | with: 17 | python-version: "3.13" 18 | 19 | - name: Validate PR description 20 | env: 21 | PR_DESCRIPTION: ${{ github.event.pull_request.body }} 22 | run: python .github/scripts/validate_pr_description.py 23 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .* 2 | !.gitignore 3 | *.o 4 | *.exe 5 | *.swp 6 | lib 7 | packages 8 | build 9 | tags 10 | samples/0_Intro/module_api/runKernel.hip.out 11 | samples/0_Intro/module_api/vcpy_isa.code 12 | samples/0_Intro/module_api/vcpy_isa.hsaco 13 | samples/0_Intro/module_api/vcpy_kernel.co 14 | samples/0_Intro/module_api/vcpy_kernel.code 15 | samples/1_Utils/hipInfo/hipInfo 16 | samples/1_Utils/hipDispatchLatency/hipDispatchLatency 17 | 18 | utils/coverage/generateHipAPICoverage 19 | utils/coverage/CoverageReport.xml 20 | utils/coverage/coverageReportHTML/CoverageReport.html 21 | utils/coverage/coverageReportHTML/testAPIs 22 | utils/coverage/coverageReportHTML/testModules 23 | -------------------------------------------------------------------------------- /catch/stress/memory/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | set(TEST_SRC 3 | memcpy.cc 4 | hipMemcpyMThreadMSize.cc 5 | hipMallocManagedStress.cc 6 | hipMemPrftchAsyncStressTst.cc 7 | hipHostMallocStress.cc 8 | hipHostRegisterStress.cc 9 | ) 10 | 11 | if(UNIX) 12 | set(TEST_SRC ${TEST_SRC} 13 | hipHmmOvrSubscriptionTst.cc) 14 | add_executable(hold_memory EXCLUDE_FROM_ALL hold_memory.cc) 15 | add_dependencies(stress_test hold_memory) 16 | endif() 17 | 18 | hip_add_exe_to_target(NAME memory_stress 19 | TEST_SRC ${TEST_SRC} 20 | TEST_TARGET_NAME stress_test) 21 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autolf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to have LF line endings on checkout. 6 | *.c text eol=lf 7 | *.cpp text eol=lf 8 | *.cc text eol=lf 9 | *.h text eol=lf 10 | *.hpp text eol=lf 11 | *.txt text eol=lf 12 | 13 | # Define files to support auto-remove trailing white space 14 | # Need to run the command below, before add modified file(s) to the staging area 15 | # git config filter.trimspace.clean 'sed -e "s/[[:space:]]*$//g"' 16 | *.cpp filter=trimspace 17 | *.c filter=trimspace 18 | *.h filter=trimspacecpp 19 | *.hpp filter=trimspace 20 | *.md filter=trimspace -------------------------------------------------------------------------------- /.github/workflows/clang-format.yml: -------------------------------------------------------------------------------- 1 | name: Clang format check 2 | on: 3 | pull_request: 4 | types: [synchronize, opened] 5 | 6 | jobs: 7 | format: 8 | runs-on: AMD-ROCm-Internal-dev1 9 | steps: 10 | - uses: actions/checkout@v4 11 | with: 12 | fetch-depth: 0 13 | 14 | - name: Install clang-format 15 | run: | 16 | sudo apt update && sudo apt install -y clang-format 17 | 18 | - name: Run clang-format-check 19 | id: clang-format 20 | run: | 21 | chmod +x .github/hooks/clang-format-check.sh 22 | ./.github/hooks/clang-format-check.sh --range "${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}" 23 | -------------------------------------------------------------------------------- /samples/1_Utils/hipDispatchLatency/README.md: -------------------------------------------------------------------------------- 1 | # hipDispatchLatency.cpp 2 | 3 | - Steps to build this sample 4 | ``` 5 | $ mkdir build; cd build 6 | $ cmake .. -DCMAKE_PREFIX_PATH=/opt/rocm 7 | $ make 8 | ``` 9 | 10 | - Execute Code 11 | ``` 12 | $ ./hipDispatchEnqueueRateMT 1 0 13 | Thread ID : 0 , hipModuleLaunchKernel enqueue rate: 0.8 us, std: 0.1 us 14 | 15 | $ ./hipDispatchEnqueueRateMT 1 1 16 | Thread ID : 0 , hipLaunchKernelGGL enqueue rate: 1.0 us, std: 0.1 us 17 | 18 | $ ./hipDispatchLatency 19 | hipModuleLaunchKernel enqueue rate: 0.8 us, std: 0.1 us 20 | 21 | hipLaunchKernelGGL enqueue rate: 1.0 us, std: 0.1 us 22 | 23 | Timing around single dispatch latency: 8.1 us, std: 4.7 us 24 | 25 | Batch dispatch latency: 1.4 us, std: 0.0 us 26 | ``` -------------------------------------------------------------------------------- /samples/2_Cookbook/16_assembly_to_executable/hip_obj_gen.mcin: -------------------------------------------------------------------------------- 1 | # HIP Object Generator 2 | # Use this generator to create a host bundled object file 3 | # with the input of an offload bundled fat binary. 4 | # 5 | # Input: Bundled Object file .hipfb file 6 | # Output: Host Bundled Object File .o 7 | # 8 | # Add MC directives to embed target binaries. We ensure that each 9 | # section and image is 4096-byte aligned. This facilitates faster 10 | # loading of device binaries. It has been verified this align does 11 | # not cause significant overall file size increase. 12 | # 13 | # Note: log 2 of 4096 is 12. 14 | # 15 | .type __hip_fatbin,@object 16 | .section .hip_fatbin,"a",@progbits 17 | .globl __hip_fatbin 18 | .p2align 12 19 | __hip_fatbin: 20 | .incbin "offload_bundle.hipfb" 21 | -------------------------------------------------------------------------------- /samples/2_Cookbook/17_llvm_ir_to_executable/hip_obj_gen.mcin: -------------------------------------------------------------------------------- 1 | # HIP Object Generator 2 | # Use this generator to create a host bundled object file 3 | # with the input of an offload bundled fat binary. 4 | # 5 | # Input: Bundled Object file .hipfb file 6 | # Output: Host Bundled Object File .o 7 | # 8 | # Add MC directives to embed target binaries. We ensure that each 9 | # section and image is 4096-byte aligned. This facilitates faster 10 | # loading of device binaries. It has been verified this align does 11 | # not cause significant overall file size increase. 12 | # 13 | # Note: log 2 of 4096 is 12. 14 | # 15 | .type __hip_fatbin,@object 16 | .section .hip_fatbin,"a",@progbits 17 | .globl __hip_fatbin 18 | .p2align 12 19 | __hip_fatbin: 20 | .incbin "offload_bundle.hipfb" 21 | -------------------------------------------------------------------------------- /samples/2_Cookbook/18_cmake_hip_device/README.md: -------------------------------------------------------------------------------- 1 | ### This will test linking hip::device interface in cmake 2 | I. Build 3 | 4 | ``` 5 | $ mkdir build; cd build 6 | $ CXX="$(hipconfig -l)"/clang++ cmake -DCMAKE_PREFIX_PATH=/opt/rocm .. 7 | $ make 8 | ``` 9 | 10 | Note, users may need to add ADMGPU support as command line option, if test failed to run, for example, 11 | ``` 12 | $ CXX="$(hipconfig -l)"/clang++ cmake -DCMAKE_PREFIX_PATH=/opt/rocm -DAMDGPU_TARGETS="gfx1102" .. 13 | ``` 14 | 15 | II. Test 16 | 17 | ``` 18 | $ ../test_cpp 19 | info: running on device AMD Radeon Graphics 20 | info: allocate host mem ( 7.63 MB) 21 | info: allocate device mem ( 7.63 MB) 22 | info: copy Host2Device 23 | info: launch 'vector_square' kernel 24 | info: copy Device2Host 25 | info: check result 26 | PASSED! 27 | ``` 28 | -------------------------------------------------------------------------------- /catch/unit/g++/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # AMD specific test 2 | if(HIP_PLATFORM MATCHES "amd" AND UNIX AND GPP_EXEC) 3 | set(TEST_SRC 4 | hipMalloc.cc 5 | ) 6 | 7 | add_custom_target(malloc_custom COMMAND ${GPP_EXEC} -c 8 | ${CMAKE_CURRENT_SOURCE_DIR}/hipMalloc.cpp -I${HIP_INCLUDE_DIR} 9 | -D__HIP_PLATFORM_AMD__ -o malloc.o BYPRODUCTS malloc.o) 10 | add_library(malloc_gpp OBJECT IMPORTED) 11 | set_property(TARGET malloc_gpp PROPERTY IMPORTED_OBJECTS 12 | "${CMAKE_CURRENT_BINARY_DIR}/malloc.o") 13 | 14 | hip_add_exe_to_target(NAME gppTests 15 | TEST_SRC ${TEST_SRC} 16 | TEST_TARGET_NAME build_tests 17 | LINKER_LIBS malloc_gpp) 18 | 19 | add_dependencies(gppTests malloc_custom) 20 | endif() 21 | -------------------------------------------------------------------------------- /samples/2_Cookbook/21_cmake_hip_cxx_clang/README.md: -------------------------------------------------------------------------------- 1 | ### This sample tests CXX Language support with amdclang++ 2 | I. Build 3 | 4 | ``` 5 | $ mkdir -p build; cd build 6 | $ rm -rf *; 7 | $ CXX="$(hipconfig -l)"/amdclang++ cmake -DCMAKE_PREFIX_PATH=/opt/rocm .. 8 | $ make 9 | ``` 10 | To enable compiler auto detection of gpu users may need to add ADMGPU support as command line option, if test failed to run, for example, 11 | ``` 12 | $ CXX="$(hipconfig -l)"/amdclang++ cmake -DCMAKE_PREFIX_PATH=/opt/rocm -DAMDGPU_TARGETS="gfx1102" .. 13 | ``` 14 | II. Test 15 | 16 | ``` 17 | $ ./square 18 | info: running on device AMD Radeon Graphics 19 | info: allocate host mem ( 7.63 MB) 20 | info: allocate device mem ( 7.63 MB) 21 | info: copy Host2Device 22 | info: launch 'vector_square' kernel 23 | info: copy Device2Host 24 | info: check result 25 | PASSED! 26 | ``` 27 | -------------------------------------------------------------------------------- /samples/0_Intro/bit_extract/README.md: -------------------------------------------------------------------------------- 1 | # bit_extract 2 | 3 | Show an application written directly in HIP which uses platform-specific check on __HIP_PLATFORM_AMD__ to enable use of 4 | an instruction that only exists on the AMD platform. 5 | 6 | See related [blog](http://gpuopen.com/platform-aware-coding-inside-hip/) demonstrating platform specialization. 7 | 8 | - Steps to build this sample: 9 | ``` 10 | $ mkdir build; cd build 11 | $ cmake .. -DCMAKE_PREFIX_PATH=/opt/rocm 12 | $ make 13 | ``` 14 | 15 | - Execute File 16 | ``` 17 | $ ./bit_extract 18 | 19 | pch size: 11743288 20 | __hipGetPCH succeeded! 21 | info: running on device #0 22 | info: allocate host mem ( 7.63 MB) 23 | info: allocate device mem ( 7.63 MB) 24 | info: copy Host2Device 25 | info: launch 'bit_extract_kernel' 26 | info: copy Device2Host 27 | info: check result 28 | PASSED! 29 | ``` 30 | -------------------------------------------------------------------------------- /catch/unit/executionControl/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TEST_SRC 2 | execution_control_common.cc 3 | hipFuncGetAttributesBasic.cc 4 | hipLaunchKernel.cc 5 | hipLaunchCooperativeKernel.cc 6 | hipLaunchCooperativeKernelMultiDevice.cc 7 | ) 8 | 9 | if(HIP_PLATFORM MATCHES "amd") 10 | set(TEST_SRC ${TEST_SRC} 11 | hipExtLaunchKernel.cc 12 | hipExtLaunchMultiKernelMultiDevice.cc 13 | launch_api.cc 14 | hipGetProcAddressLaunchCbExecCtrlApis.cc 15 | ) 16 | else() 17 | # These functions are currently unimplemented on AMD 18 | set(TEST_SRC ${TEST_SRC} 19 | hipFuncSetCacheConfig.cc 20 | hipFuncSetSharedMemConfig.cc 21 | hipFuncSetAttribute.cc 22 | ) 23 | endif() 24 | 25 | hip_add_exe_to_target(NAME ExecutionControlTest 26 | TEST_SRC ${TEST_SRC} 27 | TEST_TARGET_NAME build_tests) 28 | -------------------------------------------------------------------------------- /catch/unit/event/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | set(TEST_SRC 3 | Unit_hipEvent_Negative.cc 4 | Unit_hipEvent.cc 5 | Unit_hipEventElapsedTime.cc 6 | Unit_hipEventRecord.cc 7 | Unit_hipEventIpc.cc 8 | hipEventDestroy.cc 9 | hipEventCreate.cc 10 | hipEventCreateWithFlags.cc 11 | hipEventSynchronize.cc 12 | Unit_hipEventMGpuMThreads.cc 13 | ) 14 | 15 | # The test used wait mechanism and doesnt play well with all arch of nvidia 16 | if(HIP_PLATFORM MATCHES "amd") 17 | set(AMD_SRC 18 | Unit_hipEventQuery.cc 19 | ) 20 | if(UNIX) 21 | set(AMD_SRC 22 | ${AMD_SRC} 23 | Unit_hipEventIpc_shm_cleanup.cc) 24 | endif() 25 | set(TEST_SRC ${TEST_SRC} ${AMD_SRC}) 26 | endif() 27 | 28 | hip_add_exe_to_target(NAME EventTest 29 | TEST_SRC ${TEST_SRC} 30 | TEST_TARGET_NAME build_tests) 31 | -------------------------------------------------------------------------------- /catch/unit/streamperthread/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | set(TEST_SRC 3 | hipStreamPerThread_Basic.cc 4 | hipStreamPerThread_Event.cc 5 | hipStreamPerThread_MultiThread.cc 6 | hipStreamPerThread_DeviceReset.cc 7 | # hipStreamPerThrdTsts.cc TODO 8 | hipStreamPerThrdCompilerOptn.cc 9 | ) 10 | 11 | if(HIP_PLATFORM MATCHES "amd") 12 | set(TEST_SRC ${TEST_SRC} 13 | hipGetProcAddressSptApis.cc) 14 | endif() 15 | 16 | if(HIP_PLATFORM MATCHES "amd") 17 | set_source_files_properties(hipStreamPerThrdCompilerOptn.cc PROPERTIES COMPILE_OPTIONS "-fgpu-default-stream=per-thread") 18 | endif() 19 | 20 | if(HIP_PLATFORM MATCHES "nvidia") 21 | set_source_files_properties(hipStreamPerThrdCompilerOptn.cc PROPERTIES COMPILE_OPTIONS "--default-stream=per-thread") 22 | endif() 23 | 24 | hip_add_exe_to_target(NAME StreamPerThreadTest 25 | TEST_SRC ${TEST_SRC} 26 | TEST_TARGET_NAME build_tests) 27 | -------------------------------------------------------------------------------- /catch/stress/memory/memcpy.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | TEST_CASE("Stress_hipMalloc", "DifferentSizes") { 4 | int* d_a = nullptr; 5 | SECTION("Size 10") { 6 | auto res = hipMalloc(&d_a, sizeof(10)); 7 | REQUIRE(res == hipSuccess); 8 | HIP_CHECK(hipFree(d_a)); 9 | d_a = nullptr; 10 | } 11 | SECTION("Size 100") { 12 | auto res = hipMalloc(&d_a, sizeof(100)); 13 | REQUIRE(res == hipSuccess); 14 | HIP_CHECK(hipFree(d_a)); 15 | d_a = nullptr; 16 | } 17 | SECTION("Size 1000") { 18 | auto res = hipMalloc(&d_a, sizeof(1000)); 19 | REQUIRE(res == hipSuccess); 20 | HIP_CHECK(hipFree(d_a)); 21 | d_a = nullptr; 22 | } 23 | SECTION("Size 10000") { 24 | auto res = hipMalloc(&d_a, sizeof(10000)); 25 | REQUIRE(res == hipSuccess); 26 | HIP_CHECK(hipFree(d_a)); 27 | d_a = nullptr; 28 | } 29 | SECTION("Size MAX") { 30 | auto res = hipMalloc(&d_a, ~(size_t)0); 31 | REQUIRE(res == hipErrorOutOfMemory); 32 | d_a = nullptr; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /samples/0_Intro/square/README.md: -------------------------------------------------------------------------------- 1 | # Square.md 2 | 3 | Simple test below is an example, shows how to use hipify-perl to port CUDA code to HIP: 4 | 5 | - Add hip/bin path to the PATH 6 | ``` 7 | $ export PATH=$PATH:[MYHIP]/bin 8 | ``` 9 | 10 | - Define environment variable 11 | ``` 12 | $ export HIP_PATH=[MYHIP] 13 | ``` 14 | 15 | - Build executable file 16 | ``` 17 | $ cd ~/hip/samples/0_Intro/square 18 | mkdir -p build && cd build 19 | 20 | cmake .. 21 | make 22 | 23 | $ Building without cmake 24 | /opt/rocm/hip/bin/hipify-perl square.cu > square.cpp 25 | /opt/rocm/hip/bin/hipcc square.cpp -o square.out 26 | /opt/rocm/hip/bin/hipcc -use-staticlib square.cpp -o square.out.static 27 | ``` 28 | - Execute file 29 | ``` 30 | $ ./square.out 31 | info: running on device AMD Radeon RX 6900 XT 32 | info: allocate host mem ( 7.63 MB) 33 | info: allocate device mem ( 7.63 MB) 34 | info: copy Host2Device 35 | info: launch 'vector_square' kernel 36 | info: copy Device2Host 37 | info: check result 38 | PASSED! 39 | ``` 40 | -------------------------------------------------------------------------------- /.azuredevops/rocm-ci.yml: -------------------------------------------------------------------------------- 1 | resources: 2 | repositories: 3 | - repository: pipelines_repo 4 | type: github 5 | endpoint: ROCm 6 | name: ROCm/ROCm 7 | pipelines: 8 | - pipeline: hip_pipeline 9 | source: \HIP 10 | trigger: 11 | branches: 12 | include: 13 | - amd-staging 14 | - amd-mainline 15 | 16 | variables: 17 | - group: common 18 | - template: /.azuredevops/variables-global.yml@pipelines_repo 19 | 20 | trigger: 21 | batch: true 22 | branches: 23 | include: 24 | - amd-staging 25 | - amd-mainline 26 | paths: 27 | exclude: 28 | - '.jenkins' 29 | - CODEOWNERS 30 | - LICENSE.txt 31 | - '**/.md' 32 | 33 | pr: 34 | autoCancel: true 35 | branches: 36 | include: 37 | - amd-staging 38 | - amd-mainline 39 | paths: 40 | exclude: 41 | - '.jenkins' 42 | - CODEOWNERS 43 | - LICENSE.txt 44 | - '**/.md' 45 | drafts: false 46 | 47 | jobs: 48 | - template: ${{ variables.CI_COMPONENT_PATH }}/hip-tests.yml@pipelines_repo 49 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | ## Associated JIRA ticket number/Github issue number 2 | 3 | 4 | ## What type of PR is this? (check all applicable) 5 | 6 | - [ ] Refactor 7 | - [ ] Feature 8 | - [ ] Bug Fix 9 | - [ ] Optimization 10 | - [ ] Documentation Update 11 | - [ ] Continuous Integration 12 | 13 | ## What were the changes? 14 | 15 | 16 | 17 | ## Why are these changes needed? 18 | 19 | 20 | 21 | ## Updated CHANGELOG? 22 | 23 | 24 | 25 | - [ ] Yes 26 | - [ ] No, Does not apply to this PR. 27 | 28 | ## Added/Updated documentation? 29 | 30 | - [ ] Yes 31 | - [ ] No, Does not apply to this PR. 32 | 33 | ## Additional Checks 34 | 35 | - [ ] I have added tests relevant to the introduced functionality, and the unit tests are passing locally. 36 | - [ ] Any dependent changes have been merged. 37 | -------------------------------------------------------------------------------- /catch/unit/p2p/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | # moved hipDeviceGetP2PAttribute.cc from /catch/unit/device to 3 | # /catch/unit/p2p folder and its dependent files. 4 | set(TEST_SRC 5 | hipDeviceGetP2PAttribute.cc 6 | ) 7 | 8 | # only for AMD 9 | if(HIP_PLATFORM MATCHES "amd") 10 | set(AMD_SRC 11 | hipP2pLinkTypeAndHopFunc.cc 12 | ) 13 | set(TEST_SRC ${TEST_SRC} ${AMD_SRC}) 14 | endif() 15 | 16 | add_executable(hipDeviceGetP2PAttribute_exe EXCLUDE_FROM_ALL hipDeviceGetP2PAttribute_exe.cc) 17 | set_source_files_properties(hipDeviceGetP2PAttribute_exe.cc PROPERTIES LANGUAGE HIP) 18 | set_target_properties(hipDeviceGetP2PAttribute_exe PROPERTIES LINKER_LANGUAGE HIP) 19 | target_link_libraries(hipDeviceGetP2PAttribute_exe hip::host hip::device) 20 | 21 | set_property(GLOBAL APPEND PROPERTY G_INSTALL_EXE_TARGETS hipDeviceGetP2PAttribute_exe) 22 | 23 | hip_add_exe_to_target(NAME p2pTests 24 | TEST_SRC ${TEST_SRC} 25 | TEST_TARGET_NAME build_tests) 26 | 27 | add_dependencies(build_tests hipDeviceGetP2PAttribute_exe) 28 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (C) Advanced Micro Devices, Inc. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /catch/unit/library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TEST_SRC 2 | loadlib_rtc.cc 3 | #loadlib_co.cc TODO 4 | library_negative.cc 5 | ) 6 | 7 | add_custom_target(library_code_load.code 8 | COMMAND ${CMAKE_HIP_COMPILER} --cuda-device-only -x hip ${CMAKE_CURRENT_SOURCE_DIR}/library_code_load.cc 9 | -o ${CMAKE_CURRENT_BINARY_DIR}/../library/library_code_load.code ${OFFLOAD_ARCH_LIST} 10 | -I${CMAKE_CURRENT_SOURCE_DIR}/../../include 11 | -I${HIP_INCLUDE_DIR} ${HIP_PATH_OPT}) 12 | set_property(GLOBAL APPEND PROPERTY 13 | G_INSTALL_CUSTOM_TARGETS ${CMAKE_CURRENT_BINARY_DIR}/library_code_load.code) 14 | 15 | if(HIP_PLATFORM MATCHES "amd") 16 | hip_add_exe_to_target(NAME LibraryTests 17 | TEST_SRC ${TEST_SRC} 18 | TEST_TARGET_NAME build_tests 19 | LINKER_LIBS hiprtc::hiprtc) 20 | else() 21 | hip_add_exe_to_target(NAME LibraryTests 22 | TEST_SRC ${TEST_SRC} 23 | TEST_TARGET_NAME build_tests 24 | LINKER_LIBS nvrtc) 25 | endif() 26 | 27 | add_dependencies(LibraryTests library_code_load.code) 28 | -------------------------------------------------------------------------------- /catch/unit/module/empty_module.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | */ -------------------------------------------------------------------------------- /catch/unit/synchronization/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | set(TEST_SRC 3 | copy_coherency.cc 4 | ) 5 | add_custom_target(memcpyInt.hsaco COMMAND ${CMAKE_HIP_COMPILER} --cuda-device-only ${OFFLOAD_ARCH_LIST} 6 | -x hip ${CMAKE_CURRENT_SOURCE_DIR}/memcpyIntDevice.cpp -o 7 | ${CMAKE_CURRENT_BINARY_DIR}/../synchronization/memcpyInt.hsaco 8 | -I${HIP_INCLUDE_DIR} ${HIP_PATH_OPT} 9 | -I${CMAKE_CURRENT_SOURCE_DIR}/../../include) 10 | set_property(GLOBAL APPEND PROPERTY G_INSTALL_CUSTOM_TARGETS ${CMAKE_CURRENT_BINARY_DIR}/memcpyInt.hsaco) 11 | # only for AMD 12 | if(HIP_PLATFORM MATCHES "amd") 13 | # There are problems in Windows: __hip_atomicsXXX() won't work as expected 14 | if(NOT WIN32) 15 | set(AMD_SRC 16 | cache_coherency_cpu_gpu.cc 17 | cache_coherency_gpu_gpu.cc 18 | ) 19 | set(TEST_SRC ${TEST_SRC} ${AMD_SRC}) 20 | endif() 21 | endif() 22 | 23 | hip_add_exe_to_target(NAME synchronizationTests 24 | TEST_SRC ${TEST_SRC} 25 | TEST_TARGET_NAME build_tests 26 | COMPILE_OPTIONS -std=c++14) 27 | add_dependencies(synchronizationTests memcpyInt.hsaco) 28 | 29 | -------------------------------------------------------------------------------- /samples/2_Cookbook/19_cmake_lang/README.md: -------------------------------------------------------------------------------- 1 | ### This will test cmake lang support: CXX and Fortran 2 | I. Prepare 3 | 1) You must install cmake version 3.18 or above to support LINK_LANGUAGE. 4 | Otherwise, Fortran build will fail. 5 | To download the latest cmake, see https://cmake.org/download/. 6 | 2) If there is no Fortran on your system, you must install it via, 7 | sudo apt install gfortran 8 | 9 | II. Build 10 | ``` 11 | $ mkdir -p build; cd build 12 | $ rm -rf *; 13 | $ CXX="$(hipconfig -l)"/clang++ FC=$(which gfortran) cmake -DCMAKE_PREFIX_PATH=/opt/rocm .. 14 | $ cmake .. 15 | $ make 16 | ``` 17 | 18 | Note, users may need to add AMD GPU support, if test failed, for example, 19 | ``` 20 | $ CXX="$(hipconfig -l)"/clang++ FC=$(which gfortran) cmake -DCMAKE_PREFIX_PATH=/opt/rocm -DAMDGPU_TARGETS="gfx1102" .. 21 | ``` 22 | To enable compiler auto detection of gpu users may need to add ADMGPU support as command line option, 23 | if test failed to run, for example, 24 | ``` 25 | $ CXX="$(hipconfig -l)"/clang++ FC=$(which gfortran) cmake -DCMAKE_PREFIX_PATH=/opt/rocm -DAMDGPU_TARGETS=native .. 26 | ``` 27 | III. Test 28 | ``` 29 | $ ./test_fortran 30 | Succeeded testing Fortran! 31 | 32 | $ ./test_cpp 33 | Device name AMD Radeon Graphics 34 | PASSED! 35 | ``` 36 | -------------------------------------------------------------------------------- /catch/unit/memory/memoryCommon.hh: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #pragma once 21 | 22 | void set_value(int const value); 23 | 24 | int get_value(); 25 | -------------------------------------------------------------------------------- /samples/README.md: -------------------------------------------------------------------------------- 1 | Building 2 | --- 3 | 4 | The CMakeLists.txt at hip-tests/samples folder can be used for building and packaging samples. 5 | 6 | CMakeLists.txt can support shared and static libs of hip-rocclr runtime. The same steps can be followed for both. 7 | 8 | To build a specific sample (e.g. `0_Intro/bit_extract`) run: 9 | ```bash 10 | $ cd samples/0_Intro/bit_extract 11 | $ mkdir -p build && cd build 12 | $ cmake .. 13 | $ make all 14 | ``` 15 | 16 | To build all samples together run: 17 | ```bash 18 | $ cd hip-tests 19 | $ mkdir -p build && cd build 20 | $ rm -rf * # (to clear up) 21 | $ cmake ../samples 22 | $ make build_samples 23 | ``` 24 | 25 | In order to build specific samples (Intro, Utils or Cookbook) run: 26 | ```bash 27 | $ make build_intro 28 | $ make build_utils 29 | $ make build_cookbook 30 | ``` 31 | 32 | Note that if you want debug version, add `-DCMAKE_BUILD_TYPE=Debug` in cmake cmd. 33 | 34 | 3. To package samples and generate packages. From hip-tests/build: 35 | ```bash 36 | $ cmake ../samples 37 | $ make package_samples 38 | ``` 39 | 40 | Note 41 | --- 42 | 43 | Sample `2_Cookbook/22_cmake_hip_lang` is current not included in toplevel cmake. To build this sample from toplevel cmake, uncomment Line 43 inside `samples/2_Cookbook/CMakeLists.txt`. 44 | -------------------------------------------------------------------------------- /catch/unit/g++/hipMalloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * The above copyright notice and this permission notice shall be included in 10 | * all copies or substantial portions of the Software. 11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | * IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | * FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER 15 | * LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | * OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | * THE SOFTWARE. 18 | * */ 19 | 20 | #include 21 | 22 | extern int MallocFunc(); -------------------------------------------------------------------------------- /samples/1_Utils/hipDispatchLatency/test_kernel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include "hip/hip_runtime.h" 21 | 22 | extern "C" __global__ void test() {} 23 | -------------------------------------------------------------------------------- /catch/multiproc/dummy_kernel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | extern "C" __global__ void dummy_ker() {} 26 | -------------------------------------------------------------------------------- /catch/unit/module/managed_kernel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | #include 20 | __managed__ int x = 10; 21 | 22 | extern "C" __global__ void GPU_func() { x++; } 23 | -------------------------------------------------------------------------------- /catch/catchProp_in_rc.in: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define HIP_VERSION "@HIP_VERSION@" 4 | #define HIP_VERSION_MAJOR @HIP_VERSION_MAJOR@ 5 | #define HIP_VERSION_MINOR @HIP_VERSION_MINOR@ 6 | #define HIP_VERSION_PATCH @HIP_VERSION_PATCH@ 7 | 8 | VS_VERSION_INFO VERSIONINFO 9 | FILEVERSION HIP_VERSION_MAJOR, HIP_VERSION_MINOR , HIP_VERSION_PATCH 10 | PRODUCTVERSION 10,1 11 | FILEFLAGSMASK 0x3fL 12 | #ifdef _DEBUG 13 | FILEFLAGS VS_FF_DEBUG 14 | #else 15 | FILEFLAGS 0x0L 16 | #endif 17 | FILEOS VOS_NT_WINDOWS32 18 | FILETYPE VFT_APP 19 | FILESUBTYPE VFT2_UNKNOWN 20 | BEGIN 21 | BLOCK "StringFileInfo" 22 | BEGIN 23 | BLOCK "040904b0" 24 | BEGIN 25 | VALUE "CompanyName", "Advanced Micro Devices Inc.\0" 26 | VALUE "FileDescription", "HIP unit tests" 27 | VALUE "FileVersion", "amdhip64.dll" HIP_VERSION 28 | VALUE "LegalCopyright", "Copyright (C) 2022 Advanced Micro Devices Inc.\0" 29 | VALUE "ProductName", "HIP unit tests" 30 | VALUE "ProductVersion", HIP_VERSION 31 | VALUE "Comments", "\0" 32 | VALUE "InternalName", "HIP unit tests" 33 | END 34 | END 35 | BLOCK "VarFileInfo" 36 | BEGIN 37 | VALUE "Translation", 0x0409, 1200 38 | END 39 | END 40 | /* End of Version info */ 41 | -------------------------------------------------------------------------------- /catch/unit/callback/SimpleKernel.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | extern "C" __global__ void simple_kernel() { printf("Hello World!"); } 26 | -------------------------------------------------------------------------------- /samples/1_Utils/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016 - 2023 Advanced Micro Devices, Inc. All rights reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | add_custom_target(build_utils) 21 | add_subdirectory(hipDispatchLatency) 22 | add_subdirectory(hipInfo) -------------------------------------------------------------------------------- /catch/packaging/catch_package.cmake.in: -------------------------------------------------------------------------------- 1 | # cmake variables are replaced since cpack cannot find them 2 | # but cpack can understand cpack variables 3 | # this file gets executed by each CPACK_GENERATOR. 4 | # During standalone install step 5 | if(NOT DEFINED CPACK_GENERATOR) 6 | get_filename_component(ABS_INSTALL_PATH "${CMAKE_INSTALL_PREFIX}" ABSOLUTE) 7 | get_filename_component(ABS_CPACK_INSTALL "@CPACK_INSTALL_PREFIX@" ABSOLUTE) 8 | if("${ABS_INSTALL_PATH}" STREQUAL "${ABS_CPACK_INSTALL}") 9 | return() 10 | endif() 11 | set(CPACK_PKG_DIRS ${CMAKE_INSTALL_PREFIX}/@INSTALL_DIR@) 12 | else() 13 | set(CPACK_PKG_DIRS 14 | @PROJECT_BINARY_DIR@/_CPack_Packages/${CPACK_SYSTEM_NAME}/${CPACK_GENERATOR}/${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}/${CPACK_INSTALL_PREFIX}/@INSTALL_DIR@) 15 | endif() 16 | 17 | execute_process(COMMAND @Python_EXECUTABLE@ 18 | @CMAKE_SOURCE_DIR@/cmake/relative_paths.py @CATCH_BUILD_DIR@ ${CPACK_PKG_DIRS} 19 | OUTPUT_VARIABLE workaround_out 20 | RESULT_VARIABLE workaround_res) 21 | if(NOT ${workaround_res} EQUAL 0) 22 | message(FATAL_ERROR 23 | "Error performing workaround using relative_paths.py :\n" 24 | " Result: ${workaround_res}\n" 25 | " Output: ${workaround_out}\n" 26 | ) 27 | endif() 28 | -------------------------------------------------------------------------------- /catch/unit/module/hipModuleGetGlobal.hh: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | */ 21 | 22 | #pragma once 23 | 24 | #include 25 | 26 | namespace { 27 | constexpr size_t kArraySize = 5; 28 | } // anonymous namespace -------------------------------------------------------------------------------- /catch/unit/module/get_function_module.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | */ 21 | 22 | #include 23 | 24 | extern "C" { 25 | __global__ void GlobalKernel() {} 26 | 27 | __device__ void DeviceKernel() {} 28 | } -------------------------------------------------------------------------------- /catch/unit/module/vcpy_kernel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | #include 20 | 21 | extern "C" __global__ void hello_world(float* a, float* b) { 22 | int tx = threadIdx.x; 23 | b[tx] = a[tx]; 24 | } 25 | -------------------------------------------------------------------------------- /catch/unit/occupancy/simple_kernel.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include 21 | 22 | extern "C" __global__ void SimpleKernel(int* a, int* b) { 23 | int tx = threadIdx.x; 24 | b[tx] = a[tx]; 25 | } 26 | -------------------------------------------------------------------------------- /catch/kernels/Set.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Advanced Micro Devices, Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | #include 23 | 24 | __global__ void Set(int* Ad, int val) { 25 | int tx = threadIdx.x + blockIdx.x * blockDim.x; 26 | Ad[tx] = val; 27 | } 28 | -------------------------------------------------------------------------------- /catch/unit/graph/add_Kernel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | #include 20 | extern "C" __global__ void Add(int* a, int* b, int* c) { 21 | size_t tx = (blockIdx.x * blockDim.x + threadIdx.x); 22 | c[tx] = a[tx] + b[tx]; 23 | } 24 | -------------------------------------------------------------------------------- /catch/include/kernel_mapping.hh: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #pragma once 21 | 22 | #include 23 | 24 | const std::map mapKernelToFileName{ 25 | {"Set", "Set.cpp"}, 26 | {"HipTest::vectorADD", "vectorADD.inl"}, 27 | }; -------------------------------------------------------------------------------- /samples/0_Intro/module_api/vcpy_kernel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2015 - 2021 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #include "hip/hip_runtime.h" 24 | 25 | extern "C" __global__ void hello_world(float* a, float* b) { 26 | int tx = threadIdx.x; 27 | b[tx] = a[tx]; 28 | } 29 | -------------------------------------------------------------------------------- /samples/2_Cookbook/15_static_library/device_functions/hipDevice.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * */ 22 | 23 | #include 24 | 25 | __device__ int square_me(int A) { return A * A; } 26 | -------------------------------------------------------------------------------- /catch/unit/deviceLib/hipTestDeviceLimit.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | #include 20 | TEST_CASE("Unit_hipTestDeviceLimit_Basic") { 21 | size_t heap; 22 | HIP_CHECK(hipDeviceGetLimit(&heap, hipLimitMallocHeapSize)); 23 | REQUIRE(heap != 0); 24 | } 25 | -------------------------------------------------------------------------------- /catch/unit/module/get_tex_ref_module.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | */ 21 | 22 | #include 23 | 24 | #if defined(__HIP_PLATFORM_AMD__) || CUDA_VERSION < CUDA_12000 25 | 26 | texture tex; 27 | 28 | #endif // CUDA_VERSION < CUDA_12000 29 | -------------------------------------------------------------------------------- /catch/unit/executionControl/execution_control_common.hh: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | __global__ void kernel(); 26 | 27 | __global__ void kernel2(); 28 | 29 | __global__ void kernel_42(int* val); 30 | 31 | __global__ void coop_kernel(); -------------------------------------------------------------------------------- /catch/unit/errorHandling/hipGetLastErrorEnv_Exe.cc: -------------------------------------------------------------------------------- 1 | /*Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 2 | Permission is hereby granted, free of charge, to any person obtaining a copy 3 | of this software and associated documentation files (the "Software"), to deal 4 | in the Software without restriction, including without limitation the rights 5 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6 | copies of the Software, and to permit persons to whom the Software is 7 | furnished to do so, subject to the following conditions: 8 | The above copyright notice and this permission notice shall be included in 9 | all copies or substantial portions of the Software. 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16 | THE SOFTWARE. 17 | */ 18 | #include "hip/hip_runtime_api.h" 19 | #include 20 | int main() { 21 | hipError_t err; 22 | err = hipGetLastError(); 23 | if (err == hipSuccess) 24 | return 1; 25 | else 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /catch/unit/errorHandling/hipPeekAtLastErrorEnv_Exe.cc: -------------------------------------------------------------------------------- 1 | /*Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 2 | Permission is hereby granted, free of charge, to any person obtaining a copy 3 | of this software and associated documentation files (the "Software"), to deal 4 | in the Software without restriction, including without limitation the rights 5 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6 | copies of the Software, and to permit persons to whom the Software is 7 | furnished to do so, subject to the following conditions: 8 | The above copyright notice and this permission notice shall be included in 9 | all copies or substantial portions of the Software. 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16 | THE SOFTWARE. 17 | */ 18 | #include "hip/hip_runtime_api.h" 19 | #include 20 | int main() { 21 | hipError_t err; 22 | err = hipPeekAtLastError(); 23 | if (err == hipSuccess) 24 | return 1; 25 | else 26 | return 0; 27 | } 28 | -------------------------------------------------------------------------------- /catch/perftests/vmm/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | set(TEST_SRC 22 | hipPerfVMMAlloc.cc 23 | ) 24 | 25 | hip_add_exe_to_target(NAME perfVMMTest 26 | TEST_SRC ${TEST_SRC} 27 | TEST_TARGET_NAME perf_test) 28 | -------------------------------------------------------------------------------- /catch/unit/texture/tex_ref_get_module.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | */ 21 | 22 | #include 23 | 24 | #if defined(__HIP_PLATFORM_AMD__) || CUDA_VERSION < CUDA_12000 25 | 26 | texture tex; 27 | 28 | #endif // defined(__HIP_PLATFORM_AMD__) || CUDA_VERSION < CUDA_12000 29 | -------------------------------------------------------------------------------- /catch/performance/example/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | set(TEST_SRC 22 | example.cc 23 | ) 24 | 25 | hip_add_exe_to_target(NAME ExamplePerformance 26 | TEST_SRC ${TEST_SRC} 27 | TEST_TARGET_NAME build_tests) 28 | -------------------------------------------------------------------------------- /catch/performance/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | add_subdirectory(memset) 22 | add_subdirectory(memcpy) 23 | add_subdirectory(kernelLaunch) 24 | add_subdirectory(stream) 25 | add_subdirectory(event) 26 | add_subdirectory(warpSync) 27 | add_subdirectory(example) 28 | -------------------------------------------------------------------------------- /catch/unit/module/copyKernel.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | #include 23 | 24 | extern "C" __global__ void copy_ker(int* Ad, int* Bd, size_t size) { 25 | int myId = threadIdx.x + blockDim.x * blockIdx.x; 26 | if (myId < size) { 27 | Bd[myId] = Ad[myId]; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /samples/0_Intro/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | # Copyright (c) 2016 - 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | # 4 | # Permission is hereby granted, free of charge, to any person obtaining a copy 5 | # of this software and associated documentation files (the "Software"), to deal 6 | # in the Software without restriction, including without limitation the rights 7 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | # copies of the Software, and to permit persons to whom the Software is 9 | # furnished to do so, subject to the following conditions: 10 | # 11 | # The above copyright notice and this permission notice shall be included in 12 | # all copies or substantial portions of the Software. 13 | # 14 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | # THE SOFTWARE. 21 | 22 | add_custom_target(build_intro) 23 | add_subdirectory(bit_extract) 24 | add_subdirectory(module_api) 25 | add_subdirectory(module_api_global) 26 | add_subdirectory(square) 27 | add_subdirectory(generic_target) -------------------------------------------------------------------------------- /samples/2_Cookbook/15_static_library/host_functions/hipMain1.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All rights reserved. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a copy 5 | * of this software and associated documentation files (the "Software"), to deal 6 | * in the Software without restriction, including without limitation the rights 7 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | * copies of the Software, and to permit persons to whom the Software is 9 | * furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included in 12 | * all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | * THE SOFTWARE. 21 | * */ 22 | 23 | extern void run_test1(); 24 | 25 | int main() { 26 | // Run test that generates static lib with -emit-static-lib 27 | run_test1(); 28 | } 29 | -------------------------------------------------------------------------------- /catch/external/picojson/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2009-2010 Cybozu Labs, Inc. 2 | Copyright 2011-2014 Kazuho Oku 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 25 | POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /catch/unit/channelDescriptor/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | set(TEST_SRC 22 | channel_descriptor.cc 23 | ) 24 | 25 | hip_add_exe_to_target(NAME ChannelDescriptorTest 26 | TEST_SRC ${TEST_SRC} 27 | TEST_TARGET_NAME build_tests) 28 | -------------------------------------------------------------------------------- /catch/unit/dynamicLoading/vecadd.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | #include 20 | 21 | __global__ void kerAdd(int* in_a, int* in_b, int* out_c, int nelem) { 22 | int id = blockIdx.x * blockDim.x + threadIdx.x; 23 | if (id >= nelem) { 24 | return; 25 | } 26 | out_c[id] = in_a[id] + in_b[id]; 27 | } 28 | -------------------------------------------------------------------------------- /catch/unit/vector_types/negative_bitwise_float.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include "negative_macros_common.hh" 21 | 22 | BITWISE_FLOATING_POINT_VECTOR_FUNCTIONS(float1) 23 | BITWISE_FLOATING_POINT_VECTOR_FUNCTIONS(float2) 24 | BITWISE_FLOATING_POINT_VECTOR_FUNCTIONS(float3) 25 | BITWISE_FLOATING_POINT_VECTOR_FUNCTIONS(float4) 26 | -------------------------------------------------------------------------------- /catch/unit/compiler/hipSpirvTest.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | __global__ void kernel() { asm volatile("v_nop" ::: "memory"); } 26 | 27 | // This test case compiles with --offload-arch=amdgcnspirv to verify SPIRV mode 28 | TEST_CASE("Unit_test_spirv_mode") { kernel<<<1, 32>>>(); } -------------------------------------------------------------------------------- /catch/unit/vector_types/negative_bitwise_double.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include "negative_macros_common.hh" 21 | 22 | BITWISE_FLOATING_POINT_VECTOR_FUNCTIONS(double1) 23 | BITWISE_FLOATING_POINT_VECTOR_FUNCTIONS(double2) 24 | BITWISE_FLOATING_POINT_VECTOR_FUNCTIONS(double3) 25 | BITWISE_FLOATING_POINT_VECTOR_FUNCTIONS(double4) 26 | -------------------------------------------------------------------------------- /catch/unit/device/setuuidGetDevCount_Exe.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | #include 20 | int main() { 21 | int devCount = 0; 22 | hipError_t localError; 23 | localError = hipGetDeviceCount(&devCount); 24 | if (localError == hipSuccess) { 25 | printf("HIP Api returned hipSuccess"); 26 | } 27 | return devCount; 28 | } 29 | -------------------------------------------------------------------------------- /catch/unit/clock/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | # Common Tests - Test independent of all platforms 22 | 23 | set(TEST_SRC 24 | hipClockCheck.cc 25 | ) 26 | 27 | hip_add_exe_to_target(NAME ClockCheckTest 28 | TEST_SRC ${TEST_SRC} 29 | TEST_TARGET_NAME build_tests) 30 | -------------------------------------------------------------------------------- /catch/unit/module/kernel_count.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2025 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | #include 20 | 21 | extern "C" __device__ void hello_world_2(float* a, float* b) { 22 | int tx = threadIdx.x; 23 | b[tx] = a[tx]; 24 | } 25 | 26 | extern "C" __global__ void hello_world(float* a, float* b) { 27 | int tx = threadIdx.x; 28 | b[tx] = a[tx]; 29 | } 30 | -------------------------------------------------------------------------------- /catch/perftests/event/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # Permission is hereby granted, free of charge, to any person obtaining a copy 3 | # of this software and associated documentation files (the "Software"), to deal 4 | # in the Software without restriction, including without limitation the rights 5 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6 | # copies of the Software, and to permit persons to whom the Software is 7 | # furnished to do so, subject to the following conditions: 8 | # The above copyright notice and this permission notice shall be included in 9 | # all copies or substantial portions of the Software. 10 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16 | # THE SOFTWARE. 17 | # Common Tests - Test independent of all platforms 18 | set(TEST_SRC 19 | hipKernelLookUpPerf.cc 20 | hipEventOverFlowPerf.cc 21 | ) 22 | hip_add_exe_to_target(NAME perfEventTest 23 | TEST_SRC ${TEST_SRC} 24 | TEST_TARGET_NAME perf_test) 25 | -------------------------------------------------------------------------------- /catch/unit/threadfence/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | set(TEST_SRC 22 | __threadfence_block.cc 23 | __threadfence.cc 24 | __threadfence_system.cc 25 | ) 26 | 27 | hip_add_exe_to_target(NAME ThreadfenceTest 28 | TEST_SRC ${TEST_SRC} 29 | TEST_TARGET_NAME build_tests) -------------------------------------------------------------------------------- /catch/perftests/dispatch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | # Common Tests - Test independent of all platforms 22 | set(TEST_SRC 23 | hipPerfDispatchSpeed.cc 24 | ) 25 | 26 | hip_add_exe_to_target(NAME perfDispatchTest 27 | TEST_SRC ${TEST_SRC} 28 | TEST_TARGET_NAME perf_test) 29 | -------------------------------------------------------------------------------- /catch/unit/vector_types/negative_calculate_assign_with_value_1D.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include "negative_macros_common.hh" 21 | 22 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(char1) 23 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(short1) 24 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(int1) 25 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(long1) 26 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(longlong1) 27 | -------------------------------------------------------------------------------- /catch/unit/vector_types/negative_calculate_assign_with_value_2D.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include "negative_macros_common.hh" 21 | 22 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(char2) 23 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(short2) 24 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(int2) 25 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(long2) 26 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(longlong2) 27 | -------------------------------------------------------------------------------- /catch/unit/vector_types/negative_calculate_assign_with_value_3D.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include "negative_macros_common.hh" 21 | 22 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(char3) 23 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(short3) 24 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(int3) 25 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(long3) 26 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(longlong3) 27 | -------------------------------------------------------------------------------- /catch/unit/vector_types/negative_calculate_assign_with_value_4D.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include "negative_macros_common.hh" 21 | 22 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(char4) 23 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(short4) 24 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(int4) 25 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(long4) 26 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(longlong4) 27 | -------------------------------------------------------------------------------- /catch/unit/warp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | set(TEST_SRC 3 | warp_ballot.cc 4 | warp_any.cc 5 | warp_all.cc 6 | hipMatchSyncAllTests.cc 7 | hipMatchSyncAnyTests.cc 8 | hipShflSyncDownTests.cc 9 | hipShflSyncUpTests.cc 10 | hipShflSyncXorTests.cc 11 | hipShflSyncTests.cc 12 | hipVoteSyncTests.cc 13 | ) 14 | 15 | if(HIP_PLATFORM MATCHES "amd") 16 | set(TEST_SRC ${TEST_SRC} 17 | warp_shfl.cc 18 | warp_shfl_xor.cc 19 | warp_shfl_up.cc 20 | warp_shfl_down.cc 21 | warp_reduce.cc 22 | hipShflUpDownTest.cc 23 | hipShflTests.cc 24 | ) 25 | endif() 26 | 27 | if(HIP_PLATFORM MATCHES "nvidia") 28 | set_source_files_properties(hipMatchSyncAllTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") 29 | set_source_files_properties(hipMatchSyncAnyTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") 30 | set_source_files_properties(hipShflSyncDownTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") 31 | set_source_files_properties(hipShflSyncUpTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") 32 | set_source_files_properties(hipShflSyncXorTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") 33 | set_source_files_properties(hipShflSyncTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") 34 | set_source_files_properties(hipVoteSyncTests.cc PROPERTIES COMPILE_FLAGS "-arch=sm_70") 35 | endif() 36 | 37 | hip_add_exe_to_target(NAME WarpTest 38 | TEST_SRC ${TEST_SRC} 39 | TEST_TARGET_NAME build_tests) 40 | -------------------------------------------------------------------------------- /catch/ABM/AddKernels/add.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | template __global__ void add(T* a, T* b, T* c, size_t size) { 5 | size_t i = threadIdx.x; 6 | if (i < size) c[i] = a[i] + b[i]; 7 | } 8 | 9 | TEMPLATE_TEST_CASE("ABM_AddKernel_MultiTypeMultiSize", "", int, long, float, long long, double) { 10 | auto size = GENERATE(as{}, 100, 500, 1000); 11 | TestType *d_a, *d_b, *d_c; 12 | auto res = hipMalloc(&d_a, sizeof(TestType) * size); 13 | REQUIRE(res == hipSuccess); 14 | res = hipMalloc(&d_b, sizeof(TestType) * size); 15 | REQUIRE(res == hipSuccess); 16 | res = hipMalloc(&d_c, sizeof(TestType) * size); 17 | REQUIRE(res == hipSuccess); 18 | 19 | std::vector a, b, c; 20 | for (size_t i = 0; i < size; i++) { 21 | a.push_back(i + 1); 22 | b.push_back(i + 1); 23 | c.push_back(2 * (i + 1)); 24 | } 25 | 26 | res = hipMemcpy(d_a, a.data(), sizeof(TestType) * size, hipMemcpyHostToDevice); 27 | REQUIRE(res == hipSuccess); 28 | res = hipMemcpy(d_b, b.data(), sizeof(TestType) * size, hipMemcpyHostToDevice); 29 | REQUIRE(res == hipSuccess); 30 | 31 | hipLaunchKernelGGL(add, 1, size, 0, 0, d_a, d_b, d_c, size); 32 | HIP_CHECK(hipGetLastError()); 33 | 34 | res = hipMemcpy(a.data(), d_c, sizeof(TestType) * size, hipMemcpyDeviceToHost); 35 | REQUIRE(res == hipSuccess); 36 | 37 | HIP_CHECK(hipFree(d_a)); 38 | HIP_CHECK(hipFree(d_b)); 39 | HIP_CHECK(hipFree(d_c)); 40 | REQUIRE(a == c); 41 | } 42 | -------------------------------------------------------------------------------- /catch/unit/vector_types/negative_calculate_assign_with_unsigned_value_1D.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include "negative_macros_common.hh" 21 | 22 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(uchar1) 23 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(ushort1) 24 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(uint1) 25 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(ulong1) 26 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(ulonglong1) 27 | -------------------------------------------------------------------------------- /catch/unit/vector_types/negative_calculate_assign_with_unsigned_value_2D.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include "negative_macros_common.hh" 21 | 22 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(uchar2) 23 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(ushort2) 24 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(uint2) 25 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(ulong2) 26 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(ulonglong2) 27 | -------------------------------------------------------------------------------- /catch/unit/vector_types/negative_calculate_assign_with_unsigned_value_3D.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include "negative_macros_common.hh" 21 | 22 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(uchar3) 23 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(ushort3) 24 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(uint3) 25 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(ulong3) 26 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(ulonglong3) 27 | -------------------------------------------------------------------------------- /catch/unit/vector_types/negative_calculate_assign_with_unsigned_value_4D.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include "negative_macros_common.hh" 21 | 22 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(uchar4) 23 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(ushort4) 24 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(uint4) 25 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(ulong4) 26 | CALCULATE_ASSIGN_VECTOR_FUNCTIONS(ulonglong4) 27 | -------------------------------------------------------------------------------- /samples/2_Cookbook/19_cmake_lang/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The test must be with CMake 3.18 or above which supports LINK_LANGUAGE that is necessary for 2 | # Fortran build. 3 | cmake_minimum_required(VERSION 3.18.0) 4 | if(ENABLE_ADDRESS_SANITIZER) 5 | message(STATUS "This fortran sample is temporarily disabled due to SWDEV-462616.") 6 | return() 7 | endif() 8 | project(cmake_lang_test CXX Fortran) 9 | 10 | if(UNIX) 11 | if(NOT DEFINED ROCM_PATH) 12 | if(DEFINED ENV{ROCM_PATH}) 13 | set(ROCM_PATH $ENV{ROCM_PATH} CACHE STRING "ROCM Path") 14 | else() 15 | set(ROCM_PATH "/opt/rocm" CACHE STRING "Default ROCM installation directory.") 16 | endif() 17 | endif() 18 | # Search for rocm in common locations 19 | list(APPEND CMAKE_PREFIX_PATH ${ROCM_PATH}) 20 | endif() 21 | 22 | set(CMAKE_CXX_COMPILER "${ROCM_PATH}/llvm/bin/clang++") 23 | 24 | find_package(hip REQUIRED) 25 | 26 | if(TARGET build_cookbook) 27 | set(EXCLUDE_OPTION EXCLUDE_FROM_ALL) 28 | else() 29 | set(EXCLUDE_OPTION ) 30 | endif() 31 | add_executable(test_fortran ${EXCLUDE_OPTION} TestFortran.F90) 32 | add_executable(test_cpp1 ${EXCLUDE_OPTION} MatrixTranspose.cpp) 33 | 34 | target_link_libraries(test_cpp1 PUBLIC hip::device) 35 | 36 | target_include_directories(test_cpp1 PRIVATE ../../common) 37 | 38 | # Assuming to build a C/C++-to-Fortran library binding. 39 | target_link_libraries(test_fortran PUBLIC hip::device) 40 | 41 | if(TARGET build_cookbook) 42 | add_dependencies(build_cookbook test_cpp1 test_fortran) 43 | endif() 44 | -------------------------------------------------------------------------------- /catch/unit/gcc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | if(HIP_PLATFORM MATCHES "amd" AND UNIX AND GCC_EXEC) 3 | set(TEST_SRC 4 | gccTest.cc 5 | gpu.cpp 6 | ) 7 | # Creating Custom object file 8 | add_custom_command(OUTPUT LaunchKernel.o COMMAND ${GCC_EXEC} -c 9 | ${CMAKE_CURRENT_SOURCE_DIR}/LaunchKernel.c -Wno-deprecated-declarations -I${HIP_INCLUDE_DIR} 10 | -D__HIP_PLATFORM_AMD__ -o LaunchKernel.o) 11 | add_custom_target(LaunchKernel_custom DEPENDS LaunchKernel.o) 12 | add_custom_command(OUTPUT hipMalloc.o COMMAND ${GCC_EXEC} -c 13 | ${CMAKE_CURRENT_SOURCE_DIR}/hipMalloc.c -Wno-deprecated-declarations -I${HIP_INCLUDE_DIR} 14 | -D__HIP_PLATFORM_AMD__ -o hipMalloc.o) 15 | add_custom_target(hipMalloc_custom DEPENDS hipMalloc.o) 16 | 17 | add_library(LaunchKernel_lib OBJECT IMPORTED) 18 | add_library(hipMalloc_lib OBJECT IMPORTED) 19 | 20 | set_property(TARGET LaunchKernel_lib PROPERTY IMPORTED_OBJECTS 21 | "${CMAKE_CURRENT_BINARY_DIR}/LaunchKernel.o") 22 | set_property(TARGET hipMalloc_lib PROPERTY IMPORTED_OBJECTS 23 | "${CMAKE_CURRENT_BINARY_DIR}/hipMalloc.o") 24 | 25 | 26 | hip_add_exe_to_target(NAME gccTests 27 | TEST_SRC ${TEST_SRC} 28 | TEST_TARGET_NAME build_tests 29 | LINKER_LIBS LaunchKernel_lib hipMalloc_lib) 30 | 31 | add_dependencies(gccTests LaunchKernel_custom hipMalloc_custom) 32 | endif() 33 | -------------------------------------------------------------------------------- /catch/perftests/compute/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | # Common Tests - Test independent of all platforms 22 | set(TEST_SRC 23 | hipPerfDotProduct.cc 24 | hipPerfMandelbrot.cc 25 | ) 26 | 27 | hip_add_exe_to_target(NAME perfComputeTest 28 | TEST_SRC ${TEST_SRC} 29 | TEST_TARGET_NAME perf_test) 30 | -------------------------------------------------------------------------------- /catch/perftests/graph/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # Permission is hereby granted, free of charge, to any person obtaining a copy 3 | # of this software and associated documentation files (the "Software"), to deal 4 | # in the Software without restriction, including without limitation the rights 5 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6 | # copies of the Software, and to permit persons to whom the Software is 7 | # furnished to do so, subject to the following conditions: 8 | # The above copyright notice and this permission notice shall be included in 9 | # all copies or substantial portions of the Software. 10 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 11 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16 | # THE SOFTWARE. 17 | 18 | # Common Tests - Test independent of all platforms 19 | set(TEST_SRC 20 | hipPerfGraphLaunch.cc 21 | parallelGraph.cc 22 | hipGraphTopology.cc 23 | ) 24 | 25 | hip_add_exe_to_target(NAME perfGraphTest 26 | TEST_SRC ${TEST_SRC} 27 | TEST_TARGET_NAME perf_test) 28 | -------------------------------------------------------------------------------- /catch/perftests/memory/FindNUMA.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2020 - 2021 Advanced Micro Devices, Inc. All rights reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | find_path(NUMA_INCLUDE_DIR numa.h) 22 | find_library(NUMA_LIBRARIES numa) 23 | 24 | include(FindPackageHandleStandardArgs) 25 | find_package_handle_standard_args(NUMA 26 | DEFAULT_MSG 27 | NUMA_LIBRARIES NUMA_INCLUDE_DIR) 28 | 29 | mark_as_advanced(NUMA_LIBRARIES NUMA_INCLUDE_DIR) 30 | -------------------------------------------------------------------------------- /catch/unit/context/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | # Common Tests - Test independent of all platforms 21 | set(TEST_SRC 22 | hipDrvGetPCIBusId.cc 23 | hipDrvMemcpy.cc 24 | hipMemsetD8.cc 25 | hipCtxNotSupported.cc 26 | ) 27 | hip_add_exe_to_target(NAME Context 28 | TEST_SRC ${TEST_SRC} 29 | TEST_TARGET_NAME build_tests) 30 | -------------------------------------------------------------------------------- /catch/unit/context/hipDrvGetPCIBusId.cc: -------------------------------------------------------------------------------- 1 | /*Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 2 | Permission is hereby granted, free of charge, to any person obtaining a copy 3 | of this software and associated documentation files (the "Software"), to deal 4 | in the Software without restriction, including without limitation the rights 5 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 6 | copies of the Software, and to permit persons to whom the Software is 7 | furnished to do so, subject to the following conditions: 8 | The above copyright notice and this permission notice shall be included in 9 | all copies or substantial portions of the Software. 10 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 11 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 12 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 13 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 14 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 15 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 16 | THE SOFTWARE. 17 | */ 18 | #include 19 | 20 | TEST_CASE("Unit_hipDeviceGetPCIBusId_Functional") { 21 | HIP_CHECK(hipInit(0)); 22 | hipDevice_t device; 23 | HIP_CHECK(hipDeviceGet(&device, 0)); 24 | char pciBusId[13]; 25 | memset(pciBusId, 0, 13); 26 | HIP_CHECK(hipDeviceGetPCIBusId(pciBusId, 13, device)); 27 | REQUIRE(pciBusId[0] != '\0'); 28 | } 29 | -------------------------------------------------------------------------------- /catch/unit/occupancy/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | set(TEST_SRC 3 | hipOccupancyMaxActiveBlocksPerMultiprocessor.cc 4 | hipOccupancyMaxActiveBlocksPerMultiprocessor_old.cc 5 | hipOccupancyMaxPotentialBlockSize.cc 6 | hipOccupancyMaxPotentialBlockSize_old.cc 7 | hipModuleOccupancyMaxPotentialBlockSize.cc 8 | hipModuleOccupancyMaxPotentialBlockSizeWithFlags.cc 9 | hipModuleOccupancyMaxActiveBlocksPerMultiprocessor.cc 10 | hipModuleOccupancyMaxActiveBlocksPerMultiprocessorWithFlags.cc 11 | hipOccupancyMaxPotentialBlockSizeVariableSMemWithFlags.cc 12 | hipOccupancyMaxActiveBlocksPerMultiprocessorWithFlags.cc 13 | hipOccupancyAvailableDynamicSMemPerBlock.cc 14 | ) 15 | 16 | add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/simple_kernel.code 17 | COMMAND ${CMAKE_HIP_COMPILER} --cuda-device-only ${OFFLOAD_ARCH_LIST} 18 | -x hip ${CMAKE_CURRENT_SOURCE_DIR}/simple_kernel.cc 19 | -o simple_kernel.code 20 | -I${HIP_INCLUDE_DIR} ${HIP_PATH_OPT} 21 | DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/simple_kernel.cc) 22 | 23 | add_custom_target(simple_kernel ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/simple_kernel.code) 24 | set_property(GLOBAL APPEND PROPERTY G_INSTALL_CUSTOM_TARGETS ${CMAKE_CURRENT_BINARY_DIR}/simple_kernel.code) 25 | hip_add_exe_to_target(NAME OccupancyTest 26 | TEST_SRC ${TEST_SRC} 27 | TEST_TARGET_NAME build_tests) 28 | 29 | add_dependencies(OccupancyTest simple_kernel) 30 | -------------------------------------------------------------------------------- /catch/kernels/vectorADD.inl: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) Advanced Micro Devices, Inc. 3 | * 4 | * Permission is hereby granted, free of charge, to any person obtaining a 5 | * copy of this software and associated documentation files (the "Software"), 6 | * to deal in the Software without restriction, including without limitation 7 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 | * and/or sell copies of the Software, and to permit persons to whom the 9 | * Software is furnished to do so, subject to the following conditions: 10 | * 11 | * The above copyright notice and this permission notice shall be included 12 | * in all copies or substantial portions of the Software. 13 | * 14 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 15 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 | * THE COPYRIGHT HOLDER(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 18 | * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 19 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 20 | */ 21 | 22 | namespace HipTest { 23 | template __global__ void vectorADD(const T* A_d, const T* B_d, T* C_d, size_t NELEM) { 24 | size_t offset = (blockIdx.x * blockDim.x + threadIdx.x); 25 | size_t stride = blockDim.x * gridDim.x; 26 | 27 | for (size_t i = offset; i < NELEM; i += stride) { 28 | C_d[i] = A_d[i] + B_d[i]; 29 | } 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /catch/unit/gcc/hipMalloc.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2019 - 2021 Advanced Micro Devices, Inc. All rights reserved. 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * The above copyright notice and this permission notice shall be included in 10 | * all copies or substantial portions of the Software. 11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | * IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | * FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER 15 | * LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | * OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | * THE SOFTWARE. 18 | * */ 19 | 20 | #include 21 | #include 22 | 23 | #ifdef __cplusplus 24 | extern "C" { 25 | #endif 26 | int hipMallocfunc() { 27 | int* Ad; 28 | hipMalloc((void**)&Ad, 1024); 29 | printf("hipMalloc PASSED!\n"); 30 | hipFree(Ad); 31 | return 1; 32 | } 33 | #ifdef __cplusplus 34 | } 35 | #endif 36 | -------------------------------------------------------------------------------- /catch/unit/syncthreads/__syncthreads_or_negative_kernels.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | struct Dummy { 26 | __device__ Dummy() {} 27 | __device__ ~Dummy() {} 28 | }; 29 | 30 | __global__ void __syncthreads_or_v1(int* predicate) { int result = __syncthreads_or(predicate); } 31 | 32 | __global__ void __syncthreads_or_v2(Dummy predicate) { int result = __syncthreads_or(predicate); } -------------------------------------------------------------------------------- /.github/hooks/clang-format-check.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | RANGE="" 6 | 7 | while [[ $# -gt 0 ]]; do 8 | echo $1 9 | echo $2 10 | case "$1" in 11 | --range) 12 | RANGE="$2" 13 | shift 2 14 | ;; 15 | *) 16 | echo "Unknown arg $1" >&2 17 | exit 64 18 | ;; 19 | esac 20 | done 21 | 22 | regex='\.(c|cc|cpp|cxx|h|hh|hpp|hxx)$' 23 | 24 | if [[ -n $RANGE ]]; then 25 | files=$(git diff --name-only "$RANGE" | grep -E "$regex" || true) 26 | else 27 | files=$(git diff --cached --name-only --diff-filter=ACMR | grep -E "$regex" || true) 28 | fi 29 | echo "Checking $files" 30 | [[ -z $files ]] && exit 0 31 | 32 | clang_bin="${CLANG_FORMAT:-clang-format}" 33 | if ! command -v "$clang_bin" >/dev/null 2>&1; then 34 | if [[ -x "/c/Program Files/LLVM/bin/clang-format.exe" ]]; then 35 | clang_bin="/c/Program Files/LLVM/bin/clang-format.exe" 36 | fi 37 | fi 38 | 39 | clang_format_diff="${CLANG_FORMAT_DIFF:-clang-format-diff}" 40 | if ! command -v "$clang_format_diff" >/dev/null 2>&1; then 41 | if [[ -x "/c/Program Files/LLVM/share/clang/clang-format-diff.py" ]]; then 42 | clang_format_diff="/c/Program Files/LLVM/share/clang/clang-format-diff.py" 43 | fi 44 | fi 45 | 46 | for file in $files; do 47 | echo "Checking lines of $file" 48 | 49 | if [[ -n $RANGE ]]; then 50 | diff_output=$(git diff -U0 "$RANGE" -- "$file") 51 | else 52 | diff_output=$(git diff -U0 --cached -- "$file") 53 | fi 54 | 55 | echo "$diff_output" | "$clang_format_diff" -style=file -fallback-style=none -p1 56 | done 57 | -------------------------------------------------------------------------------- /catch/unit/syncthreads/__syncthreads_and_negative_kernels.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | struct Dummy { 26 | __device__ Dummy() {} 27 | __device__ ~Dummy() {} 28 | }; 29 | 30 | __global__ void __syncthreads_and_v1(int* predicate) { int result = __syncthreads_and(predicate); } 31 | 32 | __global__ void __syncthreads_and_v2(Dummy predicate) { int result = __syncthreads_and(predicate); } -------------------------------------------------------------------------------- /catch/performance/warpSync/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | # As CUDA use 32-bit sync masks and not 64-bit this has been disabled on Nvidia 22 | if(HIP_PLATFORM MATCHES "amd") 23 | set(TEST_SRC 24 | warpSync.cc 25 | ) 26 | endif() 27 | 28 | hip_add_exe_to_target(NAME WarpSyncPerformance 29 | TEST_SRC ${TEST_SRC} 30 | TEST_TARGET_NAME build_tests) 31 | -------------------------------------------------------------------------------- /catch/perftests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2025 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | add_custom_target(perf_test COMMAND "${CMAKE_CTEST_COMMAND}" -R "Perf_" 22 | COMMENT "Build complete, now executing the performnce test ...") 23 | 24 | add_subdirectory(memory) 25 | add_subdirectory(stream) 26 | add_subdirectory(dispatch) 27 | add_subdirectory(compute) 28 | add_subdirectory(graph) 29 | add_subdirectory(event) 30 | add_subdirectory(vmm) -------------------------------------------------------------------------------- /catch/unit/c_compilation/hipGetDeviceProp.c: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * The above copyright notice and this permission notice shall be included in 10 | * all copies or substantial portions of the Software. 11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | * IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | * FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER 15 | * LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | * OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | * THE SOFTWARE. 18 | * */ 19 | 20 | #include 21 | #include 22 | 23 | int hipGetDeviceProp() { 24 | hipDeviceProp_t prop; 25 | hipError_t err = hipGetDeviceProperties(&prop, 0); 26 | 27 | if (err == hipSuccess) { 28 | printf("PASSED!\n"); 29 | return 1; 30 | } else { 31 | printf("FAILED!\n"); 32 | return 0; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /catch/unit/launchBounds/launch_bounds_parse_error_kernels.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include 21 | 22 | __launch_bounds__(-1) __global__ void MaxThreadsNegative(int* sum) { 23 | const int tid = threadIdx.x + blockIdx.x * blockDim.x; 24 | atomicAdd(sum, tid); 25 | } 26 | 27 | __launch_bounds__(128, -1) __global__ void MinWarpsNegative(int* sum) { 28 | const int tid = threadIdx.x + blockIdx.x * blockDim.x; 29 | atomicAdd(sum, tid); 30 | } 31 | -------------------------------------------------------------------------------- /catch/unit/errorHandling/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests - Test independent of all platforms 2 | set(TEST_SRC 3 | error_handling_common.cc 4 | hipGetErrorName.cc 5 | hipGetErrorString.cc 6 | hipDrvGetErrorName.cc 7 | hipDrvGetErrorString.cc 8 | hipGetLastError.cc 9 | hipPeekAtLastError.cc 10 | ) 11 | 12 | if(UNIX) 13 | set(TEST_SRC 14 | ${TEST_SRC} 15 | hipGetLastErrorOnAbort.cc) 16 | endif() 17 | 18 | add_executable(hipGetLastErrorEnv_Exe EXCLUDE_FROM_ALL hipGetLastErrorEnv_Exe.cc) 19 | add_executable(hipPeekAtLastErrorEnv_Exe EXCLUDE_FROM_ALL hipPeekAtLastErrorEnv_Exe.cc) 20 | 21 | set_source_files_properties(hipGetLastErrorEnv_Exe.cc PROPERTIES LANGUAGE HIP) 22 | set_source_files_properties(hipPeekAtLastErrorEnv_Exe.cc PROPERTIES LANGUAGE HIP) 23 | set_target_properties(hipGetLastErrorEnv_Exe PROPERTIES LINKER_LANGUAGE HIP) 24 | set_target_properties(hipPeekAtLastErrorEnv_Exe PROPERTIES LINKER_LANGUAGE HIP) 25 | target_link_libraries(hipGetLastErrorEnv_Exe hip::host hip::device) 26 | target_link_libraries(hipPeekAtLastErrorEnv_Exe hip::host hip::device) 27 | 28 | if(HIP_PLATFORM MATCHES "amd") 29 | set(AMD_SRC 30 | hipExtGetLastError.cc 31 | ) 32 | set(TEST_SRC ${TEST_SRC} ${AMD_SRC}) 33 | endif() 34 | hip_add_exe_to_target(NAME ErrorHandlingTest 35 | TEST_SRC ${TEST_SRC} 36 | TEST_TARGET_NAME build_tests) 37 | 38 | add_dependencies(ErrorHandlingTest hipGetLastErrorEnv_Exe hipPeekAtLastErrorEnv_Exe) 39 | set_property(GLOBAL APPEND PROPERTY G_INSTALL_EXE_TARGETS hipGetLastErrorEnv_Exe hipPeekAtLastErrorEnv_Exe) 40 | -------------------------------------------------------------------------------- /catch/unit/syncthreads/__syncthreads_count_negative_kernels.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #include 24 | 25 | struct Dummy { 26 | __device__ Dummy() {} 27 | __device__ ~Dummy() {} 28 | }; 29 | 30 | __global__ void __syncthreads_count_v1(int* predicate) { 31 | int result = __syncthreads_count(predicate); 32 | } 33 | 34 | __global__ void __syncthreads_count_v2(Dummy predicate) { 35 | int result = __syncthreads_count(predicate); 36 | } -------------------------------------------------------------------------------- /catch/unit/assertion/static_assert_kernels_negative.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include 21 | 22 | __global__ void StaticAssertErrorKernel1() { 23 | const int tid = threadIdx.x + blockIdx.x * blockDim.x; 24 | static_assert(tid % 2 == 1, "[StaticAssertErrorKernel1]"); 25 | } 26 | 27 | __global__ void StaticAssertErrorKernel2() { 28 | int tid = threadIdx.x + blockIdx.x * blockDim.x; 29 | static_assert(++tid > 2, "[StaticAssertErrorKernel2]"); 30 | } 31 | -------------------------------------------------------------------------------- /catch/performance/event/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | set(TEST_SRC 22 | hipEventCreate.cc 23 | hipEventCreateWithFlags.cc 24 | hipEventRecord.cc 25 | hipEventDestroy.cc 26 | hipEventSynchronize.cc 27 | hipEventElapsedTime.cc 28 | hipEventQuery.cc 29 | ) 30 | 31 | hip_add_exe_to_target(NAME EventPerformance 32 | TEST_SRC ${TEST_SRC} 33 | TEST_TARGET_NAME build_tests) 34 | -------------------------------------------------------------------------------- /catch/unit/module/addKernel.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include 21 | 22 | __device__ int globalDevData = 10; 23 | 24 | extern "C" __global__ void addKernel(int* a, int size) { 25 | int offset = blockDim.x * blockIdx.x + threadIdx.x; 26 | int stride = blockDim.x * gridDim.x; 27 | for (int i = offset; i < size; i += stride) { 28 | a[i] += 2; 29 | } 30 | } 31 | 32 | texture tex; 33 | 34 | extern "C" __global__ void sampleModuleKernel() {} 35 | -------------------------------------------------------------------------------- /catch/unit/gcc/LaunchKernel.h: -------------------------------------------------------------------------------- 1 | 2 | /* Copyright (c) 2019 - 2021 Advanced Micro Devices, Inc. All rights reserved. 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * The above copyright notice and this permission notice shall be included in 10 | * all copies or substantial portions of the Software. 11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | * IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | * FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER 15 | * LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | * OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | * THE SOFTWARE. 18 | */ 19 | 20 | #ifdef __cplusplus 21 | extern "C" { 22 | #endif 23 | 24 | struct things { 25 | char c; 26 | short s; 27 | int i; 28 | }; 29 | 30 | typedef enum func { mykernel, mykernel1, mykernel2, mykernel3, mykernel4 } func; 31 | 32 | extern const void* getKernelFunc(enum func f); 33 | 34 | int launchKernel(); 35 | int hipMallocfunc(); 36 | 37 | #ifdef __cplusplus 38 | } 39 | #endif 40 | -------------------------------------------------------------------------------- /catch/unit/device/ResetUUIDInChild_Exe.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | #include 20 | 21 | #ifdef _WIN64 22 | #define setenv(x, y, z) _putenv_s(x, y) 23 | #endif 24 | 25 | int main() { 26 | int testPassed = 0; 27 | setenv("HIP_VISIBLE_DEVICES", "", 1); 28 | hip::SpawnProc proc("setuuidGetDevCount", true); 29 | if (proc.run() == 0) { 30 | testPassed = 1; 31 | } else { 32 | testPassed = 0; 33 | } 34 | unsetenv("HIP_VISIBLE_DEVICES"); 35 | return testPassed; 36 | } 37 | -------------------------------------------------------------------------------- /catch/unit/executionControl/execution_control_common.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #include "execution_control_common.hh" 24 | 25 | #include 26 | #include 27 | 28 | __global__ void kernel() {} 29 | 30 | __global__ void kernel2() {} 31 | 32 | __global__ void kernel_42(int* val) { *val = 42; } 33 | 34 | __global__ void coop_kernel() { 35 | cooperative_groups::grid_group grid = cooperative_groups::this_grid(); 36 | grid.sync(); 37 | } -------------------------------------------------------------------------------- /catch/unit/memory/DriverContext.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #include "DriverContext.hh" 24 | #include 25 | 26 | DriverContext::DriverContext() { 27 | HIP_CHECK(hipInit(0)); 28 | HIP_CHECK(hipDeviceGet(&device, 0)); 29 | HIP_CHECK(hipDevicePrimaryCtxRetain(&ctx, device)); 30 | HIP_CHECK(hipCtxPushCurrent(ctx)); 31 | } 32 | 33 | DriverContext::~DriverContext() { 34 | HIP_CHECK(hipCtxPopCurrent(&ctx)); 35 | HIP_CHECK(hipDevicePrimaryCtxRelease(device)); 36 | } 37 | -------------------------------------------------------------------------------- /catch/unit/memory/DriverContext.hh: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | #include 25 | #include 26 | 27 | #include 28 | 29 | class DriverContext { 30 | private: 31 | hipCtx_t ctx; 32 | hipDevice_t device; 33 | 34 | public: 35 | DriverContext(); 36 | ~DriverContext(); 37 | 38 | // Rule of three 39 | DriverContext(const DriverContext& other) = delete; 40 | DriverContext(DriverContext&& other) noexcept = delete; 41 | }; 42 | -------------------------------------------------------------------------------- /catch/unit/device/passUUIDToGrandChild_Exe.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | #include 20 | #include 21 | int main(int argc, char** argv) { 22 | if (argc < 0) { 23 | return -1; 24 | } 25 | int testPassed = 0; 26 | std::string uuid = argv[1]; 27 | hip::SpawnProc proc("chkUUIDInGrandChild_Exe", true); 28 | std::string t_uuid = uuid.substr(4, 19); 29 | if (proc.run(t_uuid) == 1) { 30 | testPassed = 1; 31 | } else { 32 | testPassed = 0; 33 | } 34 | return testPassed; 35 | } 36 | -------------------------------------------------------------------------------- /.github/workflows/pr-title-validate.yml: -------------------------------------------------------------------------------- 1 | name: Validate PR Title 2 | 3 | on: 4 | pull_request: 5 | types: [opened, edited, synchronize, reopened] 6 | 7 | jobs: 8 | validate-pr-title: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - name: Check PR Title 12 | id: check-pr-title 13 | run: | 14 | PR_TITLE="${{ github.event.pull_request.title }}" 15 | 16 | if [[ ! "$PR_TITLE" =~ ^SWDEV-[0-9]+ ]]; then 17 | echo "::error::PR title must start with a Jira ticket ID, SWDEV-" 18 | exit 1 19 | else 20 | echo "PR title is valid" 21 | fi 22 | 23 | validate-commit-messages: 24 | runs-on: AMD-ROCm-Internal-dev1 25 | steps: 26 | - name: Checkout code 27 | uses: actions/checkout@v3 28 | with: 29 | fetch-depth: 0 30 | 31 | - name: Check all commit messages 32 | id: validate-commit-messags 33 | run: | 34 | COMMITS=$(git log --format="%H %s" origin/${{ github.event.pull_request.base.ref }}..origin/${{ github.event.pull_request.head.ref }}) 35 | echo "$COMMITS" 36 | echo "$COMMITS" | while read -r hash message; do 37 | echo -e "$hash $message\n " 38 | if [[ "$message" =~ ^SWDEV-[0-9]+ ]]; then 39 | echo "Valid JIRA ticket format" 40 | elif [[ "$message" =~ ^Merge\ branch ]]; then 41 | echo "Merge commits are allowed" 42 | else 43 | echo "::error:: $hash commit should start with Jira ticket ID, SWDEV- or be a merge commit" 44 | exit 1 45 | fi 46 | done 47 | -------------------------------------------------------------------------------- /catch/perftests/stream/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | # Common Tests - Test independent of all platforms 22 | set(TEST_SRC 23 | hipPerfDeviceConcurrency.cc 24 | hipPerfStreamConcurrency.cc 25 | hipPerfStreamCreateCopyDestroy.cc 26 | hipPerfIncreasingNumberOfStreams.cc 27 | hipPerfMultiStreamKernelLaunch.cc 28 | ) 29 | 30 | hip_add_exe_to_target(NAME perfStreamTest 31 | TEST_SRC ${TEST_SRC} 32 | TEST_TARGET_NAME perf_test) 33 | -------------------------------------------------------------------------------- /catch/unit/dynamicLoading/bit_extract_kernel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | #include 20 | extern "C" __global__ void bit_extract_kernel(uint32_t* C_d, const uint32_t* A_d, size_t N) { 21 | size_t offset = (blockIdx.x * blockDim.x + threadIdx.x); 22 | size_t stride = blockDim.x * gridDim.x; 23 | for (size_t i = offset; i < N; i += stride) { 24 | #if HT_AMD 25 | C_d[i] = __bitextract_u32(A_d[i], 8, 4); 26 | #else /* defined __HIP_PLATFORM_NVIDIA__ or other path */ 27 | C_d[i] = ((A_d[i] & 0xf00) >> 8); 28 | #endif 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /catch/hipTestMain/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2021 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | if(CMAKE_BUILD_TYPE MATCHES "^Debug$") 22 | add_definitions(-DHT_LOG_ENABLE) 23 | endif() 24 | 25 | set(MAIN_SRC 26 | main.cc 27 | hip_test_context.cc 28 | hip_test_features.cc) 29 | add_library(Main_Object EXCLUDE_FROM_ALL OBJECT ${MAIN_SRC}) 30 | set_source_files_properties(${MAIN_SRC} PROPERTIES LANGUAGE HIP) 31 | #set_property(TARGET Main_Object PROPERTY MSVC_RUNTIME_LIBRARY "MultiThreaded") 32 | target_link_libraries(Main_Object PRIVATE Catch2::Catch2) 33 | -------------------------------------------------------------------------------- /samples/0_Intro/module_api_global/vcpy_kernel.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2017 - 2021 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #include "hip/hip_runtime.h" 24 | 25 | #define ARRAY_SIZE (16) 26 | 27 | __device__ float myDeviceGlobal; 28 | __device__ float myDeviceGlobalArray[16]; 29 | 30 | extern "C" __global__ void hello_world(const float* a, float* b) { 31 | int tx = threadIdx.x; 32 | b[tx] = a[tx]; 33 | } 34 | 35 | extern "C" __global__ void test_globals(const float* a, float* b) { 36 | int tx = threadIdx.x; 37 | b[tx] = a[tx] + myDeviceGlobal + myDeviceGlobalArray[tx % ARRAY_SIZE]; 38 | } 39 | -------------------------------------------------------------------------------- /catch/performance/kernelLaunch/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | set(TEST_SRC 22 | kernel_launch_common.cc 23 | triple_chevron.cc 24 | hipLaunchKernel.cc 25 | hipLaunchCooperativeKernel.cc 26 | ) 27 | 28 | if(HIP_PLATFORM MATCHES "amd") 29 | set(TEST_SRC ${TEST_SRC} 30 | hipExtLaunchKernel.cc 31 | hipExtLaunchKernelGGL.cc 32 | ) 33 | endif() 34 | 35 | hip_add_exe_to_target(NAME KernelLaunchPerformance 36 | TEST_SRC ${TEST_SRC} 37 | TEST_TARGET_NAME build_tests) 38 | -------------------------------------------------------------------------------- /catch/unit/memory/hipMemGetInfo.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include 21 | 22 | TEST_CASE("Unit_hipMemGetInfo_FreeLessThanTotal") { 23 | unsigned int* A_mem{nullptr}; 24 | size_t freeMemInit, totalMemInit; 25 | size_t freeMem, totalMem; 26 | 27 | HIP_CHECK(hipMemGetInfo(&freeMemInit, &totalMemInit)); 28 | REQUIRE(freeMemInit <= totalMemInit); 29 | HIP_CHECK(hipMalloc(&A_mem, 1024)); 30 | HIP_CHECK(hipMemGetInfo(&freeMem, &totalMem)); 31 | REQUIRE(freeMem < totalMem); 32 | REQUIRE(totalMem == totalMemInit); 33 | 34 | HIP_CHECK(hipFree(A_mem)); 35 | } 36 | -------------------------------------------------------------------------------- /catch/unit/printf/printfFlagsNonHost_exe.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include 21 | 22 | __global__ void test_kernel() { 23 | printf("%08d\n", 42); 24 | printf("%08i\n", -42); 25 | printf("%08u\n", 42); 26 | printf("%08g\n", 123.456); 27 | printf("%0+8d\n", 42); 28 | printf("%+d\n", -42); 29 | printf("%+08d\n", 42); 30 | printf("%-8s\n", "xyzzy"); 31 | printf("% i\n", -42); 32 | printf("%-16.8d\n", 42); 33 | printf("%16.8d\n", 42); 34 | } 35 | 36 | int main() { 37 | test_kernel<<<1, 1>>>(); 38 | static_cast(hipDeviceSynchronize()); 39 | } 40 | -------------------------------------------------------------------------------- /catch/performance/memset/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | set(TEST_SRC 22 | hipMemset.cc 23 | hipMemsetAsync.cc 24 | hipMemsetD8.cc 25 | hipMemsetD8Async.cc 26 | hipMemsetD16.cc 27 | hipMemsetD16Async.cc 28 | hipMemsetD32.cc 29 | hipMemsetD32Async.cc 30 | hipMemset2D.cc 31 | hipMemset2DAsync.cc 32 | hipMemset3D.cc 33 | hipMemset3DAsync.cc 34 | ) 35 | 36 | hip_add_exe_to_target(NAME MemsetPerformance 37 | TEST_SRC ${TEST_SRC} 38 | TEST_TARGET_NAME build_tests) 39 | -------------------------------------------------------------------------------- /catch/unit/assertion/static_assert_kernels_positive.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include 21 | 22 | __global__ void StaticAssertPassKernel1() { 23 | static_assert(sizeof(int) < sizeof(long), "[StaticAssertPassKernel1]"); 24 | } 25 | 26 | __global__ void StaticAssertPassKernel2() { static_assert(10 > 5, "[StaticAssertPassKernel2]"); } 27 | 28 | __global__ void StaticAssertFailKernel1() { 29 | static_assert(sizeof(int) > sizeof(long), "[StaticAssertFailKernel1]"); 30 | } 31 | 32 | __global__ void StaticAssertFailKernel2() { static_assert(10 < 5, "[StaticAssertFailKernel2]"); } 33 | -------------------------------------------------------------------------------- /catch/unit/syncthreads/__syncthreads_or_negative_kernels_rtc.hh: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | static constexpr auto kSyncthreadsOrSource{ 26 | R"( 27 | struct Dummy { 28 | __device__ Dummy() {} 29 | __device__ ~Dummy() {} 30 | }; 31 | 32 | __global__ void __syncthreads_or_v1(int* predicate) { 33 | int result = __syncthreads_or(predicate); 34 | } 35 | 36 | __global__ void __syncthreads_or_v2(Dummy predicate) { 37 | int result = __syncthreads_or(predicate); 38 | } 39 | )"}; -------------------------------------------------------------------------------- /catch/unit/memory/inlineVar.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | // This test verifies the usage of inline constant variable in different translation units 21 | // The inline variable is declared in MemUtils.hh, it is used in memoryCommon.cc where 22 | // set_value and get_value are defined. 23 | 24 | #include "MemUtils.hh" 25 | #include "memoryCommon.hh" 26 | using namespace mem_utils; 27 | 28 | TEST_CASE("Unit_hipMemcpyToFromSymbol_GlobalConstVar") { 29 | int const initialValue = 10; 30 | set_value(initialValue); 31 | int const finalValue = get_value(); 32 | REQUIRE(finalValue == initialValue); 33 | } 34 | -------------------------------------------------------------------------------- /catch/unit/syncthreads/__syncthreads_and_negative_kernels_rtc.hh: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | static constexpr auto kSyncthreadsAndSource{ 26 | R"( 27 | struct Dummy { 28 | __device__ Dummy() {} 29 | __device__ ~Dummy() {} 30 | }; 31 | 32 | __global__ void __syncthreads_and_v1(int* predicate) { 33 | int result = __syncthreads_and(predicate); 34 | } 35 | 36 | __global__ void __syncthreads_and_v2(Dummy predicate) { 37 | int result = __syncthreads_and(predicate); 38 | } 39 | )"}; -------------------------------------------------------------------------------- /catch/unit/device_memory/memset_negative_kernels.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include 21 | 22 | struct Dummy { 23 | __device__ Dummy() {} 24 | __device__ ~Dummy() {} 25 | }; 26 | 27 | /*void* memset(void* ptr, int val, size_t size)*/ 28 | __global__ void memset_n1(int* ptr, int* val, size_t size) { memset(ptr, val, size); } 29 | __global__ void memset_n2(int ptr, int val, size_t size) { memset(ptr, val, size); } 30 | __global__ void memset_n3(int* ptr, int val, size_t* size) { memset(ptr, val, size); } 31 | __global__ void memset_n4(int* ptr, int val, Dummy size) { memset(ptr, val, size); } -------------------------------------------------------------------------------- /catch/unit/syncthreads/__syncthreads_count_negative_kernels_rtc.hh: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | static constexpr auto kSyncthreadsCountSource{ 26 | R"( 27 | struct Dummy { 28 | __device__ Dummy() {} 29 | __device__ ~Dummy() {} 30 | }; 31 | 32 | __global__ void __syncthreads_count_v1(int* predicate) { 33 | int result = __syncthreads_count(predicate); 34 | } 35 | 36 | __global__ void __syncthreads_count_v2(Dummy predicate) { 37 | int result = __syncthreads_count(predicate); 38 | } 39 | )"}; -------------------------------------------------------------------------------- /samples/common/hip_helper.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #include "hip/hip_runtime.h" 24 | 25 | #ifndef checkHipErrors 26 | #define checkHipErrors(err) __checkHipErrors(err, __FILE__, __LINE__) 27 | 28 | inline void __checkHipErrors(hipError_t err, const char* file, const int line) { 29 | if (HIP_SUCCESS != err) { 30 | const char* errorStr = hipGetErrorString(err); 31 | fprintf(stderr, 32 | "checkHipErrors() HIP API error = %04d \"%s\" from file <%s>, " 33 | "line %i.\n", 34 | err, errorStr, file, line); 35 | exit(EXIT_FAILURE); 36 | } 37 | } 38 | #endif 39 | -------------------------------------------------------------------------------- /catch/unit/deviceLib/kerDevWriteMultCO.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include 21 | #include "./defs.h" 22 | 23 | /** 24 | * This kernel writes to memory allocated in ker_Alloc_MultCodeObj<<<>>>. 25 | */ 26 | extern "C" __global__ void ker_Write_MultCodeObj(int** dev_mem, int value) { 27 | int myId = threadIdx.x + blockDim.x * blockIdx.x; 28 | // Check allocated memory in all threads in block before access 29 | if (*dev_mem == nullptr) { 30 | printf("Device Allocation Failed in thread = %d \n", myId); 31 | return; 32 | } 33 | // Copy to buffer 34 | (*dev_mem)[myId] = value; 35 | } 36 | -------------------------------------------------------------------------------- /catch/unit/stream/hipDeviceGetStreamPriorityRange.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | /* 23 | Testcase Scenarios : 24 | Unit_hipDeviceGetStreamPriorityRange_Default - Check if device stream piority range is valid 25 | */ 26 | 27 | #include 28 | 29 | TEST_CASE("Unit_hipDeviceGetStreamPriorityRange_Default") { 30 | int priority_low = 0; 31 | int priority_high = 0; 32 | int devID = GENERATE(range(0, HipTest::getDeviceCount())); 33 | HIP_CHECK(hipSetDevice(devID)); 34 | HIP_CHECK(hipDeviceGetStreamPriorityRange(&priority_low, &priority_high)); 35 | 36 | REQUIRE(priority_low >= priority_high); 37 | } 38 | -------------------------------------------------------------------------------- /catch/unit/launchBounds/launch_bounds_compiler_error_kernels.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include 21 | 22 | __launch_bounds__(0) __global__ void MaxThreadsZero(int* sum) { 23 | const int tid = threadIdx.x + blockIdx.x * blockDim.x; 24 | atomicAdd(sum, tid); 25 | } 26 | 27 | __launch_bounds__(1.5) __global__ void MaxThreadsNotInt(int* sum) { 28 | const int tid = threadIdx.x + blockIdx.x * blockDim.x; 29 | atomicAdd(sum, tid); 30 | } 31 | 32 | __launch_bounds__(128, 1.5) __global__ void MinWarpsNotInt(int* sum) { 33 | const int tid = threadIdx.x + blockIdx.x * blockDim.x; 34 | atomicAdd(sum, tid); 35 | } 36 | -------------------------------------------------------------------------------- /catch/unit/device_memory/memcpy_negative_kernels.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include 21 | 22 | struct Dummy { 23 | __device__ Dummy() {} 24 | __device__ ~Dummy() {} 25 | }; 26 | 27 | /*void* memcpy(void* dst, const void* src, size_t size)*/ 28 | __global__ void memcpy_n1(int* dst, const int src, size_t size) { memcpy(dst, src, size); } 29 | __global__ void memcpy_n2(int dst, const int* src, size_t size) { memcpy(dst, src, size); } 30 | __global__ void memcpy_n3(int* dst, const int* src, size_t* size) { memcpy(dst, src, size); } 31 | __global__ void memcpy_n4(int* dst, const int* src, Dummy size) { memcpy(dst, src, size); } -------------------------------------------------------------------------------- /catch/unit/stream/hipStreamCreate.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2021 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include "streamCommon.hh" 21 | 22 | TEST_CASE("Unit_hipStreamCreate_default") { 23 | int id = GENERATE(range(0, HipTest::getDeviceCount())); 24 | HIP_CHECK(hipSetDevice(id)); 25 | 26 | hipStream_t stream{nullptr}; 27 | HIP_CHECK(hipStreamCreate(&stream)); 28 | REQUIRE(stream != nullptr); // Check if stream has a valid ptr 29 | REQUIRE(hip::checkStream(stream)); // check its flags and priority 30 | HIP_CHECK(hipStreamDestroy(stream)); 31 | } 32 | 33 | TEST_CASE("Unit_hipStreamCreate_Negative") { 34 | REQUIRE(hipErrorInvalidValue == hipStreamCreate(nullptr)); 35 | } 36 | -------------------------------------------------------------------------------- /catch/include/cmd_options.hh: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining a copy 5 | of this software and associated documentation files (the "Software"), to deal 6 | in the Software without restriction, including without limitation the rights 7 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 8 | copies of the Software, and to permit persons to whom the Software is 9 | furnished to do so, subject to the following conditions: 10 | 11 | The above copyright notice and this permission notice shall be included in 12 | all copies or substantial portions of the Software. 13 | 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 19 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 20 | THE SOFTWARE. 21 | */ 22 | 23 | #pragma once 24 | 25 | #include 26 | #include 27 | 28 | struct CmdOptions { 29 | int iterations = 5; 30 | int warmups = 5; 31 | int cg_extended_run = 5; 32 | int cg_iterations = 2; 33 | bool no_display = false; 34 | bool progress = false; 35 | uint64_t accuracy_iterations = std::numeric_limits::max() + 1ull; 36 | uint64_t reduce_iterations = 1; 37 | uint64_t reduce_input_size = 50; 38 | int accuracy_max_memory = 80; 39 | uint64_t max_memory = 2147483648; // 2 GB 40 | double reduction_factor = 0.1; 41 | }; 42 | 43 | extern CmdOptions cmd_options; 44 | -------------------------------------------------------------------------------- /catch/unit/deviceLib/kerDevAllocMultCO.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2022 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include 21 | #include "./defs.h" 22 | 23 | /** 24 | * This kernel allocates memory in thread 0. 25 | */ 26 | extern "C" __global__ void ker_Alloc_MultCodeObj(int** dev_mem, int test_type) { 27 | int myId = threadIdx.x + blockDim.x * blockIdx.x; 28 | // Allocate memory in thread 0 of block 0 29 | if (0 == myId) { 30 | if (test_type == TEST_MALLOC_FREE) { 31 | *dev_mem = reinterpret_cast(malloc(blockDim.x * gridDim.x * sizeof(int))); 32 | } else { 33 | *dev_mem = reinterpret_cast(new int[blockDim.x * gridDim.x]); 34 | } 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /catch/unit/device_memory/memset_negative_kernels_rtc.hh: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #pragma once 21 | 22 | static constexpr auto kMemsetParam{ 23 | R"( 24 | struct Dummy { 25 | __device__ Dummy() {} 26 | __device__ ~Dummy() {} 27 | }; 28 | __global__ void memset_n1(int* ptr, int* val, size_t size) { memset(ptr, val, size); } 29 | __global__ void memset_n2(int ptr, int val, size_t size) { memset(ptr, val, size); } 30 | __global__ void memset_n3(int* ptr, int val, size_t* size) { memset(ptr, val, size); } 31 | __global__ void memset_n4(int* ptr, int val, Dummy size) { memset(ptr, val, size); } 32 | )"}; -------------------------------------------------------------------------------- /catch/unit/device/setEnvInChildProc_Exe.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | #include 20 | #include 21 | #ifdef _WIN64 22 | #define setenv(x, y, z) _putenv_s(x, y) 23 | #define unsetenv(x) _putenv(x) 24 | #endif 25 | 26 | int main(int argc, char** argv) { 27 | if (argc < 0) { 28 | return -1; 29 | } 30 | std::string uuid = argv[1]; 31 | unsetenv("HIP_VISIBLE_DEVICES"); 32 | setenv("HIP_VISIBLE_DEVICES", uuid.c_str(), 1); 33 | int devCount = 0; 34 | hipError_t localError; 35 | localError = hipGetDeviceCount(&devCount); 36 | if (localError == hipSuccess) { 37 | printf("HIP Api returned hipSuccess"); 38 | } 39 | return devCount; 40 | } 41 | -------------------------------------------------------------------------------- /catch/unit/surface/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 Advanced Micro Devices, Inc. All Rights Reserved. 2 | # 3 | # Permission is hereby granted, free of charge, to any person obtaining a copy 4 | # of this software and associated documentation files (the "Software"), to deal 5 | # in the Software without restriction, including without limitation the rights 6 | # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | # copies of the Software, and to permit persons to whom the Software is 8 | # furnished to do so, subject to the following conditions: 9 | # 10 | # The above copyright notice and this permission notice shall be included in 11 | # all copies or substantial portions of the Software. 12 | # 13 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | # THE SOFTWARE. 20 | 21 | # Common Tests - Test independent of all platforms 22 | set(TEST_SRC 23 | hipCreateSurfaceObject.cc 24 | hipDestroySurfaceObject.cc 25 | surf1D.cc 26 | surf1DLayered.cc 27 | surf2D.cc 28 | surf2DLayered.cc 29 | surf3D.cc 30 | surfCubemap.cc 31 | ) 32 | 33 | if(HIP_PLATFORM MATCHES "nvidia") # Disabled on AMD due to defect EXSWHTEC-377 34 | set(TEST_SRC 35 | ${TEST_SRC} 36 | surfCubemapLayered.cc) 37 | endif() 38 | 39 | hip_add_exe_to_target(NAME SurfaceTest 40 | TEST_SRC ${TEST_SRC} 41 | TEST_TARGET_NAME build_tests) -------------------------------------------------------------------------------- /catch/unit/c_compilation/hipGetDeviceProp.cc: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy 4 | * of this software and associated documentation files (the "Software"), to deal 5 | * in the Software without restriction, including without limitation the rights 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | * copies of the Software, and to permit persons to whom the Software is 8 | * furnished to do so, subject to the following conditions: 9 | * The above copyright notice and this permission notice shall be included in 10 | * all copies or substantial portions of the Software. 11 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | * IMPLIED, INNCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | * FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANNY CLAIM, DAMAGES OR OTHER 15 | * LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | * OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | * THE SOFTWARE. 18 | * */ 19 | 20 | #include 21 | /** 22 | * Test Description 23 | * ------------------------ 24 | * - Call a hip function (hipGetDeviceProperties) from a c compilation unit 25 | 26 | * Test source 27 | * ------------------------ 28 | * - catch/unit/c_compilation/hipGetDeviceProp.cc 29 | * Test requirements 30 | * ------------------------ 31 | * - HIP_VERSION >= 5.6 32 | */ 33 | 34 | extern "C" int hipGetDeviceProp(); 35 | 36 | TEST_CASE("Unit_hipGetDeviceProp_ctest") { 37 | int result = hipGetDeviceProp(); 38 | REQUIRE(result == 1); 39 | } 40 | -------------------------------------------------------------------------------- /catch/unit/device_memory/memcpy_negative_kernels_rtc.hh: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #pragma once 21 | 22 | static constexpr auto kMemcpyParam{ 23 | R"( 24 | struct Dummy { 25 | __device__ Dummy() {} 26 | __device__ ~Dummy() {} 27 | }; 28 | __global__ void memcpy_n1(int* dst, const int src, size_t size) { memcpy(dst, src, size); } 29 | __global__ void memcpy_n2(int dst, const int* src, size_t size) { memcpy(dst, src, size); } 30 | __global__ void memcpy_n3(int* dst, const int* src, size_t* size) { memcpy(dst, src, size); } 31 | __global__ void memcpy_n8(int* dst, const int* src, Dummy size) { memcpy(dst, src, size); } 32 | )"}; -------------------------------------------------------------------------------- /catch/multiproc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Common Tests 2 | set(TEST_SRC 3 | childMalloc.cc 4 | hipDeviceComputeCapabilityMproc.cc 5 | hipDeviceGetPCIBusIdMproc.cc 6 | hipDeviceTotalMemMproc.cc 7 | hipGetDeviceAttributeMproc.cc 8 | hipGetDeviceCountMproc.cc 9 | hipGetDevicePropertiesMproc.cc 10 | hipSetGetDeviceMproc.cc 11 | hipIpcMemAccessTest.cc 12 | hipMallocConcurrencyMproc.cc 13 | hipMemCoherencyTstMProc.cc 14 | hipIpcEventHandle.cc 15 | deviceAllocationMproc.cc 16 | hipNoGpuTsts.cc 17 | hipMemGetInfoMProc.cc 18 | ) 19 | 20 | if(UNIX) 21 | add_custom_target(dummy_kernel.code 22 | COMMAND ${CMAKE_HIP_COMPILER} 23 | --cuda-device-only -x hip ${CMAKE_CURRENT_SOURCE_DIR}/dummy_kernel.cpp 24 | -o ${CMAKE_CURRENT_BINARY_DIR}/../multiproc/dummy_kernel.code 25 | -I${HIP_INCLUDE_DIR} 26 | -I${CMAKE_CURRENT_SOURCE_DIR}/../../include) 27 | set_property(GLOBAL APPEND PROPERTY 28 | G_INSTALL_CUSTOM_TARGETS ${CMAKE_CURRENT_BINARY_DIR}/dummy_kernel.code) 29 | endif() 30 | 31 | # the last argument linker libraries is required for this test but optional to the function 32 | if(HIP_PLATFORM MATCHES "nvidia") 33 | hip_add_exe_to_target(NAME MultiProc 34 | TEST_SRC ${TEST_SRC} 35 | TEST_TARGET_NAME build_tests 36 | LINKER_LIBS nvrtc) 37 | set_target_properties(MultiProc PROPERTIES COMPILE_FLAGS -arch=sm_70) 38 | elseif(HIP_PLATFORM MATCHES "amd") 39 | hip_add_exe_to_target(NAME MultiProc 40 | TEST_SRC ${TEST_SRC} 41 | TEST_TARGET_NAME build_tests 42 | LINKER_LIBS hiprtc::hiprtc) 43 | endif() 44 | 45 | if(UNIX) 46 | add_dependencies(build_tests dummy_kernel.code) 47 | endif() 48 | -------------------------------------------------------------------------------- /catch/unit/context/hipMemsetD8.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANNTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER INN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR INN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | #include 20 | #define N 1024 21 | constexpr char memsetval = 'b'; 22 | 23 | TEST_CASE("Unit_hipMemsetD8_Functional") { 24 | size_t Nbytes = N * sizeof(char); 25 | char* A_h = new char[Nbytes]; 26 | ; 27 | 28 | hipDeviceptr_t A_d; 29 | HIP_CHECK(hipMalloc(reinterpret_cast(&A_d), Nbytes)); 30 | 31 | HIP_CHECK(hipMemsetD8(A_d, memsetval, Nbytes)); 32 | 33 | HIP_CHECK(hipMemcpy(A_h, reinterpret_cast(A_d), Nbytes, hipMemcpyDeviceToHost)); 34 | 35 | for (int i = 0; i < N; i++) { 36 | REQUIRE(A_h[i] == memsetval); 37 | } 38 | 39 | HIP_CHECK(hipFree(reinterpret_cast(A_d))); 40 | delete[] A_h; 41 | } 42 | -------------------------------------------------------------------------------- /catch/unit/module/copiousArgKernel.cc: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2023 Advanced Micro Devices, Inc. All rights reserved. 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | The above copyright notice and this permission notice shall be included in 10 | all copies or substantial portions of the Software. 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 12 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 13 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 14 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 15 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 16 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 17 | THE SOFTWARE. 18 | */ 19 | 20 | #include 21 | 22 | extern "C" __global__ void kernelMultipleArgsSaxpy(int a1, int a2, int* x1, int b1, int b2, int* x2, 23 | int c1, int c2, int* x3, int d1, int d2, int* x4, 24 | int e1, int e2, int* x5, int f1, int f2, 25 | int* x6) { 26 | int id = threadIdx.x + blockIdx.x * blockDim.x; 27 | x1[id] = a1 * x1[id] + a2; 28 | x2[id] = b1 * x2[id] + b2; 29 | x3[id] = c1 * x3[id] + c2; 30 | x4[id] = d1 * x4[id] + d2; 31 | x5[id] = e1 * x5[id] + e2; 32 | x6[id] = f1 * x6[id] + f2; 33 | } 34 | --------------------------------------------------------------------------------