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
77 lines
2.4 KiB
C++
77 lines
2.4 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#include <hip_test_common.hh>
|
|
|
|
|
|
__global__ void warpvote(int* device_any, int* device_all, int pshift) {
|
|
int tid = threadIdx.x + blockIdx.x * blockDim.x;
|
|
#if HT_AMD
|
|
device_any[threadIdx.x >> pshift] = __any(tid - 77);
|
|
device_all[threadIdx.x >> pshift] = __all(tid - 77);
|
|
#else
|
|
unsigned mask = 0xFFFFFFFF;
|
|
device_any[threadIdx.x >> pshift] = __any_sync(mask, tid - 77);
|
|
device_all[threadIdx.x >> pshift] = __all_sync(mask, tid - 77);
|
|
#endif
|
|
}
|
|
|
|
|
|
HIP_TEST_CASE(Unit_AnyAll_CompileTest) {
|
|
int warpSize, pshift;
|
|
hipDeviceProp_t devProp;
|
|
HIP_CHECK(hipGetDeviceProperties(&devProp, 0));
|
|
warpSize = devProp.warpSize;
|
|
|
|
int w = warpSize;
|
|
pshift = 0;
|
|
while (w >>= 1) ++pshift;
|
|
|
|
INFO("WarpSize:: " << warpSize << " pShift: " << pshift);
|
|
|
|
|
|
int anycount = 0;
|
|
int allcount = 0;
|
|
int Num_Threads_per_Block = 1024;
|
|
int Num_Blocks_per_Grid = 1;
|
|
int Num_Warps_per_Grid = (Num_Threads_per_Block * Num_Blocks_per_Grid) / warpSize;
|
|
|
|
int* host_any = (int*)malloc(Num_Warps_per_Grid * sizeof(int));
|
|
int* host_all = (int*)malloc(Num_Warps_per_Grid * sizeof(int));
|
|
int* device_any;
|
|
int* device_all;
|
|
HIP_CHECK(hipMalloc((void**)&device_any, Num_Warps_per_Grid * sizeof(int)));
|
|
HIP_CHECK(hipMalloc((void**)&device_all, Num_Warps_per_Grid * sizeof(int)));
|
|
for (int i = 0; i < Num_Warps_per_Grid; i++) {
|
|
host_any[i] = 0;
|
|
host_all[i] = 0;
|
|
}
|
|
HIP_CHECK(hipMemcpy(device_any, host_any, sizeof(int), hipMemcpyHostToDevice));
|
|
HIP_CHECK(hipMemcpy(device_all, host_all, sizeof(int), hipMemcpyHostToDevice));
|
|
|
|
hipLaunchKernelGGL(warpvote, dim3(Num_Blocks_per_Grid), dim3(Num_Threads_per_Block), 0, 0,
|
|
device_any, device_all, pshift);
|
|
|
|
HIP_CHECK(hipGetLastError());
|
|
HIP_CHECK(
|
|
hipMemcpy(host_any, device_any, Num_Warps_per_Grid * sizeof(int), hipMemcpyDeviceToHost));
|
|
HIP_CHECK(
|
|
hipMemcpy(host_all, device_all, Num_Warps_per_Grid * sizeof(int), hipMemcpyDeviceToHost));
|
|
for (int i = 0; i < Num_Warps_per_Grid; i++) {
|
|
INFO("Warp Number: " << i << " __any: " << host_any[i] << " __all: " << host_all[i]);
|
|
|
|
if (host_all[i] != 1) ++allcount;
|
|
if (host_any[i] != 1) ++anycount;
|
|
}
|
|
|
|
HIP_CHECK(hipFree(device_any));
|
|
HIP_CHECK(hipFree(device_all));
|
|
free(host_any);
|
|
free(host_all);
|
|
REQUIRE(anycount == 0);
|
|
REQUIRE(allcount == 1);
|
|
}
|