-
Notifications
You must be signed in to change notification settings - Fork 180
shift left : hip sanity tests #3366
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jainprad
wants to merge
20
commits into
develop
Choose a base branch
from
pradjain/ROCmTestCatch
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+243
−0
Open
Changes from all commits
Commits
Show all changes
20 commits
Select commit
Hold shift + click to select a range
38cc250
sanitytests
55d51aa
Merge branch 'develop' into pradjain/ROCmTestCatch
jainprad 9504a47
sanitytestsHIP
d34816a
Merge branch 'develop' into pradjain/ROCmTestCatch
jainprad 38313f9
Merge branch 'develop' into pradjain/ROCmTestCatch
jainprad 6b5c481
Merge branch 'develop' into pradjain/ROCmTestCatch
jainprad 9f0b505
Merge branch 'develop' into pradjain/ROCmTestCatch
jainprad 5210536
Merge branch 'develop' into pradjain/ROCmTestCatch
jainprad a843ebd
Merge branch 'develop' into pradjain/ROCmTestCatch
jainprad 0697983
Merge branch 'develop' into pradjain/ROCmTestCatch
jainprad 290b481
Merge branch 'develop' into pradjain/ROCmTestCatch
jainprad d715ea3
Merge branch 'develop' into pradjain/ROCmTestCatch
jainprad bf3ec90
sanityTestModify
jainprad 3481e8e
Merge branch 'develop' into pradjain/ROCmTestCatch
jainprad 18de914
Create sanityTests.yaml
jainprad df25043
yaml changes
jainprad 33b11c8
Update sanityTests.yaml
jainprad 99386eb
Update CMakeLists.txt
jainprad c3dadb7
Merge branch 'develop' into pradjain/ROCmTestCatch
jainprad 52eb2d9
Merge branch 'develop' into pradjain/ROCmTestCatch
jainprad File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
projects/hip-tests/catch/config/configs/unit/sanityTests.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| sanityTests: | ||
| Unit_AccessMallocAcrossKernels: *level_2 | ||
| Unit_hipHostRegister_RegisterUnregister: *level_2 | ||
| Unit_hipHostRegister_Nbuf_MultiFlag_RegisterUnregister: *level_2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| # Copyright (c) 2026 Advanced Micro Devices, Inc. All Rights Reserved. | ||
| # | ||
| # Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| # of this software and associated documentation files (the "Software"), to deal | ||
| # in the Software without restriction, including without limitation the rights | ||
| # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| # copies of the Software, and to permit persons to whom the Software is | ||
| # furnished to do so, subject to the following conditions: | ||
| # | ||
| # The above copyright notice and this permission notice shall be included in | ||
| # all copies or substantial portions of the Software. | ||
| # | ||
| # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| # THE SOFTWARE. | ||
|
|
||
| set(TEST_SRC | ||
| deviceSideMalloc.cc | ||
| hipHostRegister.cc | ||
| ) | ||
|
|
||
| hip_add_exe_to_target(NAME SanityTests | ||
| TEST_SRC ${TEST_SRC} | ||
| TEST_TARGET_NAME build_tests) | ||
92 changes: 92 additions & 0 deletions
92
projects/hip-tests/catch/unit/sanityTests/deviceSideMalloc.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,92 @@ | ||
| /* | ||
| Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved. | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. | ||
| */ | ||
|
|
||
| #include <hip_test_common.hh> | ||
| #include <hip_tests_config.hh> | ||
| #include <hip/hip_runtime.h> | ||
| #include <cstdlib> | ||
| #include <cstring> | ||
|
|
||
| /** | ||
| * @addtogroup DeviceSideMallocTest DeviceSideMallocTest | ||
| * @{ | ||
| * @ingroup DeviceSideMallocTest | ||
| */ | ||
|
|
||
| #define NUM_BLOCKS_DSM 20 | ||
|
|
||
| __device__ int* dataptr_dsm[NUM_BLOCKS_DSM]; | ||
|
|
||
| __global__ void allocmemKernel() { | ||
| if (threadIdx.x == 0) | ||
| dataptr_dsm[blockIdx.x] = static_cast<int*>(malloc(blockDim.x * sizeof(int))); | ||
| __syncthreads(); | ||
|
|
||
| if (dataptr_dsm[blockIdx.x] == nullptr) | ||
| return; | ||
|
|
||
| dataptr_dsm[blockIdx.x][threadIdx.x] = 0; | ||
| } | ||
jainprad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| __global__ void usememKernel() { | ||
| int* ptr = dataptr_dsm[blockIdx.x]; | ||
| if (ptr != nullptr) | ||
| ptr[threadIdx.x] += threadIdx.x; | ||
| } | ||
|
|
||
| __global__ void freememKernel() { | ||
| int* ptr = dataptr_dsm[blockIdx.x]; | ||
| if (ptr != nullptr && threadIdx.x == 0) { | ||
| free(ptr); | ||
| dataptr_dsm[blockIdx.x] = nullptr; | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Test Description | ||
| * ------------------------ | ||
| * - Allocates device memory in one kernel, uses it in multiple kernels, | ||
| * then frees in a separate kernel (allocation across kernels). | ||
| * Test source | ||
| * ------------------------ | ||
| * - unit/sanityTests/deviceSideMalloc.cc | ||
| */ | ||
| HIP_TEST_CASE(Unit_AccessMallocAcrossKernels) { | ||
| allocmemKernel<<<NUM_BLOCKS_DSM, 10>>>(); | ||
| HIP_CHECK(hipGetLastError()); | ||
| HIP_CHECK(hipDeviceSynchronize()); | ||
|
|
||
| usememKernel<<<NUM_BLOCKS_DSM, 10>>>(); | ||
| usememKernel<<<NUM_BLOCKS_DSM, 10>>>(); | ||
| usememKernel<<<NUM_BLOCKS_DSM, 10>>>(); | ||
| HIP_CHECK(hipGetLastError()); | ||
| HIP_CHECK(hipDeviceSynchronize()); | ||
|
|
||
| freememKernel<<<NUM_BLOCKS_DSM, 10>>>(); | ||
| HIP_CHECK(hipGetLastError()); | ||
| HIP_CHECK(hipDeviceSynchronize()); | ||
| } | ||
|
|
||
| /** | ||
| * End doxygen group DeviceSideMallocTest. | ||
| * @} | ||
| */ | ||
117 changes: 117 additions & 0 deletions
117
projects/hip-tests/catch/unit/sanityTests/hipHostRegister.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| /* | ||
| Copyright (c) 2026 Advanced Micro Devices, Inc. All rights reserved. | ||
|
|
||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
|
|
||
| The above copyright notice and this permission notice shall be included in | ||
| all copies or substantial portions of the Software. | ||
|
|
||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| THE SOFTWARE. | ||
| */ | ||
|
|
||
| #include <hip_test_common.hh> | ||
| #include <hip_tests_config.hh> | ||
| #include <hip/hip_runtime.h> | ||
| #include <cstdlib> | ||
| #include <vector> | ||
|
|
||
| /** | ||
| * @addtogroup HipHostRegisterStressTest HipHostRegisterStressTest | ||
| * @{ | ||
| * @ingroup HipHostRegisterStressTest | ||
| */ | ||
|
|
||
| constexpr size_t MEM_SIZE = 1024 * 1024; // 1 MB | ||
| constexpr int NUM_ITERATIONS = 5; // iterations with increasing size | ||
| constexpr int NBUF_ALLOCATIONS = 100; // number of buffers (sanity test) | ||
| constexpr int NBUF_SIZES = 3; // 1KB, 1MB, 10MB | ||
| constexpr int NBUF_FLAGS = 3; | ||
|
|
||
| /** | ||
| * Test Description | ||
| * ------------------------ | ||
| * - Stress test for hipHostRegister/hipHostUnregister with hipHostRegisterPortable. | ||
| * Allocates host memory of increasing size (1MB, 2MB, ...), registers it, | ||
| * performs CPU-GPU transfer, then unregisters and frees. | ||
| * Test source | ||
| * ------------------------ | ||
| * - unit/sanityTests/hipHostRegister.cc | ||
| */ | ||
| HIP_TEST_CASE(Unit_hipHostRegister_RegisterUnregister) { | ||
jungx098 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| HIP_CHECK(hipSetDevice(0)); | ||
|
|
||
| for (int count = 1; count <= NUM_ITERATIONS; ++count) { | ||
| size_t size = count * MEM_SIZE; | ||
| void* ptr = calloc(1, size); | ||
| REQUIRE(ptr != nullptr); | ||
|
|
||
| HIP_CHECK(hipHostRegister(ptr, size, hipHostRegisterPortable)); | ||
|
|
||
| void* dptr = nullptr; | ||
| HIP_CHECK(hipMalloc(&dptr, size)); | ||
| HIP_CHECK(hipMemcpy(dptr, ptr, size, hipMemcpyHostToDevice)); | ||
| HIP_CHECK(hipMemcpy(ptr, dptr, size, hipMemcpyDeviceToHost)); | ||
| HIP_CHECK(hipFree(dptr)); | ||
|
|
||
| HIP_CHECK(hipHostUnregister(ptr)); | ||
| free(ptr); | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * Test Description | ||
| * ------------------------ | ||
| * - Stress test for hipHostRegister/hipHostUnregister with multiple buffer | ||
| * counts and flag values. Allocates many chunks per size, registers all | ||
| * with each flag, unregisters all, then frees. | ||
| * Test source | ||
| * ------------------------ | ||
| * - unit/sanityTests/hipHostRegister.cc | ||
| */ | ||
|
|
||
| HIP_TEST_CASE(Unit_hipHostRegister_Nbuf_MultiFlag_RegisterUnregister) { | ||
| static const size_t sizes[NBUF_SIZES] = {1024, 1048576, 10485760}; | ||
jainprad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| static const unsigned int flags[NBUF_FLAGS] = { | ||
| hipHostRegisterDefault, hipHostRegisterPortable, hipHostRegisterMapped}; | ||
|
|
||
jainprad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| std::vector<void*> ptrs(NBUF_ALLOCATIONS); | ||
|
|
||
| for (int j = 0; j < NBUF_SIZES; ++j) { | ||
| size_t size = sizes[j]; | ||
| for (int i = 0; i < NBUF_ALLOCATIONS; ++i) { | ||
| ptrs[i] = calloc(1, size); | ||
| REQUIRE(ptrs[i] != nullptr); | ||
| } | ||
jainprad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| for (int ii = 0; ii < NBUF_FLAGS; ++ii) { | ||
| unsigned int fl = flags[ii]; | ||
| for (int i = 0; i < NBUF_ALLOCATIONS; ++i) { | ||
| HIP_CHECK(hipHostRegister(ptrs[i], size, fl)); | ||
jainprad marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
| for (int ur = 0; ur < NBUF_ALLOCATIONS; ++ur) { | ||
| HIP_CHECK(hipHostUnregister(ptrs[ur])); | ||
| } | ||
| } | ||
|
|
||
| for (int i = 0; i < NBUF_ALLOCATIONS; ++i) { | ||
| free(ptrs[i]); | ||
| } | ||
| } | ||
| } | ||
|
|
||
| /** | ||
| * End doxygen group HipHostRegisterStressTest. | ||
| * @} | ||
| */ | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.