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
137 lines
4.2 KiB
C++
137 lines
4.2 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#pragma clang diagnostic ignored "-Wunused-parameter"
|
|
|
|
#include <hip_test_common.hh>
|
|
|
|
constexpr size_t BlockSize = 16;
|
|
|
|
// read from a texture using normalized coordinates
|
|
constexpr size_t ChannelToRead = 1;
|
|
template <typename T>
|
|
__global__ void readFromTexture(T* output, hipTextureObject_t texObj, size_t width, size_t height,
|
|
bool textureGather) {
|
|
#if !__HIP_NO_IMAGE_SUPPORT
|
|
// Calculate normalized texture coordinates
|
|
const unsigned int x = blockIdx.x * blockDim.x + threadIdx.x;
|
|
const unsigned int y = blockIdx.y * blockDim.y + threadIdx.y;
|
|
const float u = x / (float)width;
|
|
|
|
// Read from texture and write to global memory
|
|
if (height == 0) {
|
|
output[x] = tex1D<T>(texObj, u);
|
|
} else {
|
|
const float v = y / (float)height;
|
|
if (textureGather) {
|
|
output[y * width + x] = tex2Dgather<T>(texObj, u, v, ChannelToRead);
|
|
} else {
|
|
output[y * width + x] = tex2D<T>(texObj, u, v);
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
template <typename T> void checkDataIsAscending(const std::vector<T>& hostData) {
|
|
bool allMatch = true;
|
|
size_t i = 0;
|
|
for (; i < hostData.size(); ++i) {
|
|
allMatch = allMatch && hostData[i] == static_cast<T>(i);
|
|
if (!allMatch) {
|
|
INFO("hostData[" << i << "] == " << static_cast<T>(hostData[i]));
|
|
break;
|
|
}
|
|
}
|
|
REQUIRE(allMatch);
|
|
}
|
|
|
|
struct Sizes {
|
|
int max1D;
|
|
std::array<int, 2> max2D;
|
|
std::array<int, 3> max3D;
|
|
|
|
Sizes(unsigned int flag) {
|
|
int device;
|
|
HIP_CHECK(hipGetDevice(&device));
|
|
static_assert(
|
|
hipArrayDefault == 0,
|
|
"hipArrayDefault is assumed to be equivalent to 0 for the following switch statment");
|
|
#if HT_NVIDIA
|
|
static_assert(hipArraySurfaceLoadStore == CUDA_ARRAY3D_SURFACE_LDST,
|
|
"hipArraySurface is assumed to be equivalent to CUDA_ARRAY3D_SURFACE_LDST for "
|
|
"the following switch statment");
|
|
#endif
|
|
switch (flag) {
|
|
case hipArrayDefault: { // 0
|
|
hipDeviceProp_t prop;
|
|
HIP_CHECK(hipGetDeviceProperties(&prop, device));
|
|
max1D = prop.maxTexture1D;
|
|
max2D = {prop.maxTexture2D[0], prop.maxTexture2D[1]};
|
|
max3D = {prop.maxTexture3D[0], prop.maxTexture3D[1], prop.maxTexture3D[2]};
|
|
return;
|
|
}
|
|
case hipArraySurfaceLoadStore: { // CUDA_ARRAY3D_SURFACE_LDST
|
|
int value;
|
|
HIP_CHECK(hipDeviceGetAttribute(&value, hipDeviceAttributeMaxSurface1D, device));
|
|
max1D = value;
|
|
HIP_CHECK(hipDeviceGetAttribute(&value, hipDeviceAttributeMaxSurface2D, device));
|
|
max2D = {value, value};
|
|
HIP_CHECK(hipDeviceGetAttribute(&value, hipDeviceAttributeMaxSurface3D, device));
|
|
max3D = {value, value, value};
|
|
return;
|
|
}
|
|
default: {
|
|
HIP_SKIP_TEST("array flag not supported.");
|
|
}
|
|
}
|
|
}
|
|
};
|
|
|
|
inline const char* channelFormatString(hipChannelFormatKind formatKind) noexcept {
|
|
switch (formatKind) {
|
|
case hipChannelFormatKindFloat:
|
|
return "float";
|
|
case hipChannelFormatKindSigned:
|
|
return "signed";
|
|
case hipChannelFormatKindUnsigned:
|
|
return "unsigned";
|
|
default:
|
|
return "error";
|
|
}
|
|
}
|
|
|
|
// All the possible formats for channel data in an array.
|
|
static const std::vector<hipArray_Format> driverFormats{
|
|
HIP_AD_FORMAT_UNSIGNED_INT8, HIP_AD_FORMAT_UNSIGNED_INT16, HIP_AD_FORMAT_UNSIGNED_INT32,
|
|
HIP_AD_FORMAT_SIGNED_INT8, HIP_AD_FORMAT_SIGNED_INT16, HIP_AD_FORMAT_SIGNED_INT32,
|
|
HIP_AD_FORMAT_HALF, HIP_AD_FORMAT_FLOAT};
|
|
|
|
// Helpful for printing errors
|
|
inline const char* formatToString(hipArray_Format f) {
|
|
switch (f) {
|
|
case HIP_AD_FORMAT_UNSIGNED_INT8:
|
|
return "Unsigned Int 8";
|
|
case HIP_AD_FORMAT_UNSIGNED_INT16:
|
|
return "Unsigned Int 16";
|
|
case HIP_AD_FORMAT_UNSIGNED_INT32:
|
|
return "Unsigned Int 32";
|
|
case HIP_AD_FORMAT_SIGNED_INT8:
|
|
return "Signed Int 8";
|
|
case HIP_AD_FORMAT_SIGNED_INT16:
|
|
return "Signed Int 16";
|
|
case HIP_AD_FORMAT_SIGNED_INT32:
|
|
return "Signed Int 32";
|
|
case HIP_AD_FORMAT_HALF:
|
|
return "Float 16";
|
|
case HIP_AD_FORMAT_FLOAT:
|
|
return "Float 32";
|
|
default:
|
|
return "not found";
|
|
}
|
|
}
|