CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
192 lines
6.1 KiB
C++
192 lines
6.1 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include <cmd_options.hh>
|
|
#include <hip_test_common.hh>
|
|
#include <resource_guards.hh>
|
|
|
|
#include "threadfence_common.hh"
|
|
|
|
/**
|
|
* @addtogroup __threadfence __threadfence
|
|
* @{
|
|
* @ingroup ThreadfenceTest
|
|
*/
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Basic test for a device-wide memory fence on shared memory.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/threadfence/__threadfence.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit___threadfence_Positive_Basic_Shared) {
|
|
LinearAllocGuard<int> in_dev(LinearAllocs::hipMalloc, 2 * sizeof(int));
|
|
LinearAllocGuard<int> out_dev(LinearAllocs::hipMalloc, 2 * sizeof(int));
|
|
|
|
LinearAllocGuard<int> out_host(LinearAllocs::hipHostMalloc, 2 * sizeof(int));
|
|
|
|
for (int i = 0; i < cmd_options.iterations; ++i) {
|
|
HIP_CHECK(hipMemsetD32((hipDeviceptr_t)(&(in_dev.ptr()[0])), kInitVal1, 1));
|
|
HIP_CHECK(hipMemsetD32((hipDeviceptr_t)(&(in_dev.ptr()[1])), kInitVal2, 1));
|
|
|
|
HipTest::launchKernel(ThreadfenceTestKernel<ThreadfenceScope::kDevice, true>, 1, 2,
|
|
4 * sizeof(int), nullptr, out_dev.ptr(), in_dev.ptr());
|
|
HIP_CHECK(hipDeviceSynchronize());
|
|
|
|
HIP_CHECK(hipMemcpy(out_host.host_ptr(), out_dev.ptr(), 2 * sizeof(int), hipMemcpyDefault));
|
|
|
|
REQUIRE(!(out_host.ptr()[0] == kInitVal1 && out_host.ptr()[1] == kSetVal2));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Basic test for a device-wide memory fence on global memory.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/threadfence/__threadfence.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit___threadfence_Positive_Basic_Global) {
|
|
LinearAllocGuard<int> in_dev(LinearAllocs::hipMalloc, 2 * sizeof(int));
|
|
LinearAllocGuard<int> out_dev(LinearAllocs::hipMalloc, 2 * sizeof(int));
|
|
|
|
LinearAllocGuard<int> out_host(LinearAllocs::hipHostMalloc, 2 * sizeof(int));
|
|
|
|
for (int i = 0; i < cmd_options.iterations; ++i) {
|
|
HIP_CHECK(hipMemsetD32((hipDeviceptr_t)(&(in_dev.ptr()[0])), kInitVal1, 1));
|
|
HIP_CHECK(hipMemsetD32((hipDeviceptr_t)(&(in_dev.ptr()[1])), kInitVal2, 1));
|
|
|
|
HipTest::launchKernel(ThreadfenceTestKernel<ThreadfenceScope::kDevice, false>, 2, 1, 0, nullptr,
|
|
out_dev.ptr(), in_dev.ptr());
|
|
HIP_CHECK(hipDeviceSynchronize());
|
|
|
|
HIP_CHECK(hipMemcpy(out_host.host_ptr(), out_dev.ptr(), 2 * sizeof(int), hipMemcpyDefault));
|
|
|
|
REQUIRE(!(out_host.ptr()[0] == kInitVal1 && out_host.ptr()[1] == kSetVal2));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Basic test for a device-wide memory fence on page-locked host memory.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/threadfence/__threadfence.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit___threadfence_Positive_Basic_Pinned) {
|
|
LinearAllocGuard<int> in_host(LinearAllocs::hipHostMalloc, 2 * sizeof(int));
|
|
LinearAllocGuard<int> out_host(LinearAllocs::hipHostMalloc, 2 * sizeof(int));
|
|
|
|
for (int i = 0; i < cmd_options.iterations; ++i) {
|
|
in_host.host_ptr()[0] = kInitVal1;
|
|
in_host.host_ptr()[1] = kInitVal2;
|
|
|
|
HipTest::launchKernel(ThreadfenceTestKernel<ThreadfenceScope::kDevice, false>, 2, 1, 0, nullptr,
|
|
out_host.host_ptr(), in_host.host_ptr());
|
|
HIP_CHECK(hipDeviceSynchronize());
|
|
|
|
REQUIRE(!(out_host.host_ptr()[0] == kInitVal1 && out_host.ptr()[1] == kSetVal2));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Basic test for a device-wide memory fence on managed memory.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/threadfence/__threadfence.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit___threadfence_Positive_Basic_Managed) {
|
|
LinearAllocGuard<int> in_host(LinearAllocs::hipMallocManaged, 2 * sizeof(int));
|
|
LinearAllocGuard<int> out_host(LinearAllocs::hipMallocManaged, 2 * sizeof(int));
|
|
|
|
for (int i = 0; i < cmd_options.iterations; ++i) {
|
|
in_host.host_ptr()[0] = kInitVal1;
|
|
in_host.host_ptr()[1] = kInitVal2;
|
|
|
|
HipTest::launchKernel(ThreadfenceTestKernel<ThreadfenceScope::kDevice, false>, 2, 1, 0, nullptr,
|
|
out_host.ptr(), in_host.ptr());
|
|
HIP_CHECK(hipDeviceSynchronize());
|
|
|
|
REQUIRE(!(out_host.host_ptr()[0] == kInitVal1 && out_host.ptr()[1] == kSetVal2));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* Test Description
|
|
* ------------------------
|
|
* - Basic test for a device-wide memory fence on global peer device memory.
|
|
*
|
|
* Test source
|
|
* ------------------------
|
|
* - unit/threadfence/__threadfence.cc
|
|
* Test requirements
|
|
* ------------------------
|
|
* - HIP_VERSION >= 5.2
|
|
*/
|
|
HIP_TEST_CASE(Unit___threadfence_Positive_Basic_Peer) {
|
|
const auto device_count = HipTest::getDeviceCount();
|
|
if (device_count < 2) {
|
|
HIP_SKIP_TEST(HipTest::SkipReason::kFewerThanTwoGpus);
|
|
}
|
|
|
|
int can_access_peer = 0;
|
|
HIP_CHECK(hipDeviceCanAccessPeer(&can_access_peer, 0, 1));
|
|
if (!can_access_peer) {
|
|
HIP_SKIP_TEST(HipTest::SkipReason::kPeerAccessUnavailable);
|
|
}
|
|
|
|
HIP_CHECK(hipSetDevice(0));
|
|
|
|
LinearAllocGuard<int> in_dev(LinearAllocs::hipMalloc, 2 * sizeof(int));
|
|
LinearAllocGuard<int> out_dev(LinearAllocs::hipMalloc, 2 * sizeof(int));
|
|
|
|
LinearAllocGuard<int> out_host(LinearAllocs::hipHostMalloc, 2 * sizeof(int));
|
|
|
|
for (int i = 0; i < cmd_options.iterations; ++i) {
|
|
HIP_CHECK(hipMemsetD32((hipDeviceptr_t)(&(in_dev.ptr()[0])), kInitVal1, 1));
|
|
HIP_CHECK(hipMemsetD32((hipDeviceptr_t)(&(in_dev.ptr()[1])), kInitVal2, 1));
|
|
|
|
HIP_CHECK(hipSetDevice(1));
|
|
HIP_CHECK(hipDeviceEnablePeerAccess(0, 0));
|
|
HipTest::launchKernel(ThreadfenceTestKernel<ThreadfenceScope::kDevice, false>, 2, 1, 0, nullptr,
|
|
out_dev.ptr(), in_dev.ptr());
|
|
HIP_CHECK(hipDeviceSynchronize());
|
|
|
|
HIP_CHECK(hipSetDevice(0));
|
|
|
|
HIP_CHECK(hipMemcpy(out_host.host_ptr(), out_dev.ptr(), 2 * sizeof(int), hipMemcpyDefault));
|
|
|
|
REQUIRE(!(out_host.ptr()[0] == kInitVal1 && out_host.ptr()[1] == kSetVal2));
|
|
}
|
|
}
|
|
|
|
/**
|
|
* End doxygen group ThreadfenceTest.
|
|
* @}
|
|
*/
|