Files
TheRock/rocm-systems/projects/hip-tests/catch/unit/deviceLib/hipThreadFence.cc
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

63 lines
1.9 KiB
C++

/*
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
*
* SPDX-License-Identifier: MIT
*/
#include <hip_test_common.hh>
#define NUM 1024
#define SIZE (NUM * sizeof(float))
__global__ static void vAdd(float* In1, float* In2, float* In3, float* In4, float* Out) {
int tid = threadIdx.x + blockIdx.x * blockDim.x;
In4[tid] = In1[tid] + In2[tid];
__threadfence();
In3[tid] = In3[tid] + In4[tid];
__threadfence_block();
Out[tid] = In4[tid] + In3[tid];
}
HIP_TEST_CASE(Unit_hipThreadFence) {
float* In1 = new float[NUM];
float* In2 = new float[NUM];
float* In3 = new float[NUM];
float* In4 = new float[NUM];
float* Out = new float[NUM];
// Initialization
for (uint32_t i = 0; i < NUM; i++) {
In1[i] = 1.0f;
In2[i] = 1.0f;
In3[i] = 1.0f;
In4[i] = 1.0f;
}
float *In1d, *In2d, *In3d, *In4d, *Outd;
HIP_CHECK(hipMalloc(reinterpret_cast<void**>(&In1d), SIZE));
HIP_CHECK(hipMalloc(reinterpret_cast<void**>(&In2d), SIZE));
HIP_CHECK(hipMalloc(reinterpret_cast<void**>(&In3d), SIZE));
HIP_CHECK(hipMalloc(reinterpret_cast<void**>(&In4d), SIZE));
HIP_CHECK(hipMalloc(reinterpret_cast<void**>(&Outd), SIZE));
HIP_CHECK(hipMemcpy(In1d, In1, SIZE, hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy(In2d, In2, SIZE, hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy(In3d, In3, SIZE, hipMemcpyHostToDevice));
HIP_CHECK(hipMemcpy(In4d, In4, SIZE, hipMemcpyHostToDevice));
hipLaunchKernelGGL(vAdd, dim3(32, 1, 1), dim3(32, 1, 1), 0, 0, In1d, In2d, In3d, In4d, Outd);
HIP_CHECK(hipMemcpy(Out, Outd, SIZE, hipMemcpyDeviceToHost));
for (uint32_t i = 0; i < NUM; i++) {
REQUIRE(Out[i] == 2 * In1[i] + 2 * In2[i] + In3[i]);
}
delete[] In1;
delete[] In2;
delete[] In3;
delete[] In4;
delete[] Out;
HIP_CHECK(hipFree(In1d));
HIP_CHECK(hipFree(In2d));
HIP_CHECK(hipFree(In3d));
HIP_CHECK(hipFree(In4d));
HIP_CHECK(hipFree(Outd));
}