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
115 lines
3.6 KiB
C++
115 lines
3.6 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>
|
|
#include <hip_test_checkers.hh>
|
|
|
|
#if CUDA_VERSION < CUDA_12000
|
|
|
|
// Texture reference for 3D texture
|
|
texture<float, hipTextureType3D, hipReadModeElementType> texf;
|
|
texture<int, hipTextureType3D, hipReadModeElementType> texi;
|
|
texture<char, hipTextureType3D, hipReadModeElementType> texc;
|
|
|
|
template <typename T>
|
|
__global__ void simpleKernel3DArray(T* outputData, int width, int height, int depth) {
|
|
#if !__HIP_NO_IMAGE_SUPPORT
|
|
for (int i = 0; i < depth; i++) {
|
|
for (int j = 0; j < height; j++) {
|
|
for (int k = 0; k < width; k++) {
|
|
if (std::is_same<T, float>::value)
|
|
outputData[i * width * height + j * width + k] = tex3D(texf, k, j, i);
|
|
else if (std::is_same<T, int>::value)
|
|
outputData[i * width * height + j * width + k] = tex3D(texi, k, j, i);
|
|
else if (std::is_same<T, char>::value)
|
|
outputData[i * width * height + j * width + k] = tex3D(texc, k, j, i);
|
|
}
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
template <typename T>
|
|
static void runSimpleTexture3D_Check(int width, int height, int depth,
|
|
texture<T, hipTextureType3D, hipReadModeElementType>* tex) {
|
|
unsigned int size = width * height * depth * sizeof(T);
|
|
T* hData = reinterpret_cast<T*>(malloc(size));
|
|
REQUIRE(hData != nullptr);
|
|
memset(hData, 0, size);
|
|
|
|
for (int i = 0; i < depth; i++) {
|
|
for (int j = 0; j < height; j++) {
|
|
for (int k = 0; k < width; k++) {
|
|
hData[i * width * height + j * width + k] = i * width * height + j * width + k;
|
|
}
|
|
}
|
|
}
|
|
|
|
// Allocate array and copy image data
|
|
hipChannelFormatDesc channelDesc = hipCreateChannelDesc<T>();
|
|
hipArray_t arr;
|
|
|
|
HIP_CHECK(
|
|
hipMalloc3DArray(&arr, &channelDesc, make_hipExtent(width, height, depth), hipArrayDefault));
|
|
hipMemcpy3DParms myparms{};
|
|
myparms.srcPos = make_hipPos(0, 0, 0);
|
|
myparms.dstPos = make_hipPos(0, 0, 0);
|
|
myparms.srcPtr = make_hipPitchedPtr(hData, width * sizeof(T), width, height);
|
|
myparms.dstArray = arr;
|
|
myparms.extent = make_hipExtent(width, height, depth);
|
|
myparms.kind = hipMemcpyHostToDevice;
|
|
|
|
HIP_CHECK(hipMemcpy3D(&myparms));
|
|
|
|
// set texture parameters
|
|
tex->addressMode[0] = hipAddressModeWrap;
|
|
tex->addressMode[1] = hipAddressModeWrap;
|
|
tex->filterMode = hipFilterModePoint;
|
|
tex->normalized = false;
|
|
|
|
// Bind the array to the texture
|
|
HIP_CHECK(hipBindTextureToArray(*tex, arr, channelDesc));
|
|
|
|
// Allocate device memory for result
|
|
T* dData = nullptr;
|
|
HIP_CHECK(hipMalloc(&dData, size));
|
|
REQUIRE(dData != nullptr);
|
|
|
|
hipLaunchKernelGGL(simpleKernel3DArray, dim3(1, 1, 1), dim3(1, 1, 1), 0, 0, dData, width, height,
|
|
depth);
|
|
HIP_CHECK(hipGetLastError());
|
|
HIP_CHECK(hipDeviceSynchronize());
|
|
|
|
// Allocate mem for the result on host side
|
|
T* hOutputData = reinterpret_cast<T*>(malloc(size));
|
|
REQUIRE(hOutputData != nullptr);
|
|
memset(hOutputData, 0, size);
|
|
|
|
// copy result from device to host
|
|
HIP_CHECK(hipMemcpy(hOutputData, dData, size, hipMemcpyDeviceToHost));
|
|
HipTest::checkArray(hData, hOutputData, width, height, depth);
|
|
|
|
HIP_CHECK(hipFree(dData));
|
|
HIP_CHECK(hipFreeArray(arr));
|
|
free(hData);
|
|
free(hOutputData);
|
|
}
|
|
|
|
HIP_TEST_CASE(Unit_hipSimpleTexture3D_Check_DataTypes) {
|
|
CHECK_IMAGE_SUPPORT
|
|
|
|
|
|
for (int i = 1; i < 25; i++) {
|
|
runSimpleTexture3D_Check<float>(i, i, i, &texf);
|
|
runSimpleTexture3D_Check<int>(i + 1, i, i, &texi);
|
|
runSimpleTexture3D_Check<char>(i, i + 1, i, &texc);
|
|
}
|
|
}
|
|
|
|
|
|
#endif // CUDA_VERSION < CUDA_12000
|