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
84 lines
2.5 KiB
C++
84 lines
2.5 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#pragma clang diagnostic ignored "-Wunused-parameter"
|
|
#include <hip_test_common.hh>
|
|
|
|
|
|
#if CUDA_VERSION < CUDA_12000
|
|
|
|
texture<float, 2, hipReadModeElementType> tex;
|
|
|
|
__global__ void tex2DKernel(float* outputData, int width) {
|
|
#if !__HIP_NO_IMAGE_SUPPORT
|
|
int x = blockIdx.x * blockDim.x + threadIdx.x;
|
|
int y = blockIdx.y * blockDim.y + threadIdx.y;
|
|
outputData[y * width + x] = tex2D(tex, x, y);
|
|
#endif
|
|
}
|
|
|
|
HIP_TEST_CASE(Unit_hipTextureRef2D_Check) {
|
|
CHECK_IMAGE_SUPPORT
|
|
|
|
constexpr int SIZE = 256;
|
|
constexpr unsigned int width = SIZE;
|
|
constexpr unsigned int height = SIZE;
|
|
constexpr unsigned int size = width * height * sizeof(float);
|
|
unsigned int i, j;
|
|
|
|
float* hData = reinterpret_cast<float*>(malloc(size));
|
|
REQUIRE(hData != nullptr);
|
|
memset(hData, 0, size);
|
|
for (i = 0; i < height; i++) {
|
|
for (j = 0; j < width; j++) {
|
|
hData[i * width + j] = i * width + j;
|
|
}
|
|
}
|
|
|
|
hipChannelFormatDesc channelDesc = hipCreateChannelDesc(32, 0, 0, 0, hipChannelFormatKindFloat);
|
|
hipArray_t hipArray;
|
|
HIP_CHECK(hipMallocArray(&hipArray, &channelDesc, width, height));
|
|
HIP_CHECK(hipMemcpyToArray(hipArray, 0, 0, hData, size, hipMemcpyHostToDevice));
|
|
|
|
tex.addressMode[0] = hipAddressModeWrap;
|
|
tex.addressMode[1] = hipAddressModeWrap;
|
|
tex.filterMode = hipFilterModePoint;
|
|
tex.normalized = 0;
|
|
|
|
HIP_CHECK(hipBindTextureToArray(tex, hipArray, channelDesc));
|
|
|
|
float* dData = nullptr;
|
|
HIP_CHECK(hipMalloc(&dData, size));
|
|
REQUIRE(dData != nullptr);
|
|
|
|
dim3 dimBlock(16, 16, 1);
|
|
dim3 dimGrid(width / dimBlock.x, height / dimBlock.y, 1);
|
|
hipLaunchKernelGGL(tex2DKernel, dim3(dimGrid), dim3(dimBlock), 0, 0, dData, width);
|
|
HIP_CHECK(hipGetLastError());
|
|
HIP_CHECK(hipDeviceSynchronize());
|
|
|
|
float* hOutputData = reinterpret_cast<float*>(malloc(size));
|
|
REQUIRE(hOutputData != nullptr);
|
|
memset(hOutputData, 0, size);
|
|
HIP_CHECK(hipMemcpy(hOutputData, dData, size, hipMemcpyDeviceToHost));
|
|
|
|
for (i = 0; i < height; i++) {
|
|
for (j = 0; j < width; j++) {
|
|
if (hData[i * width + j] != hOutputData[i * width + j]) {
|
|
INFO("Difference found at [ " << i << j << " ]: " << hData[i * width + j]
|
|
<< hOutputData[i * width + j]);
|
|
REQUIRE(false);
|
|
}
|
|
}
|
|
}
|
|
HIP_CHECK(hipUnbindTexture(tex));
|
|
HIP_CHECK(hipFree(dData));
|
|
HIP_CHECK(hipFreeArray(hipArray));
|
|
}
|
|
|
|
|
|
#endif // CUDA_VERSION < CUDA_12000
|