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
69 lines
2.1 KiB
C++
69 lines
2.1 KiB
C++
/*
|
|
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <algorithm>
|
|
#include <cmath>
|
|
|
|
#include <hip_test_common.hh>
|
|
|
|
class TextureGuard {
|
|
public:
|
|
TextureGuard(hipResourceDesc* res_desc, hipTextureDesc* tex_desc) {
|
|
HIP_CHECK(hipCreateTextureObject(&tex_obj_, res_desc, tex_desc, nullptr));
|
|
}
|
|
|
|
~TextureGuard() { static_cast<void>(hipDestroyTextureObject(tex_obj_)); }
|
|
|
|
TextureGuard(const TextureGuard&) = delete;
|
|
TextureGuard& operator=(const TextureGuard&) = delete;
|
|
|
|
hipTextureObject_t object() const { return tex_obj_; }
|
|
|
|
private:
|
|
hipTextureObject_t tex_obj_ = 0;
|
|
};
|
|
|
|
template <typename T> std::enable_if_t<std::is_integral_v<T>, float> NormalizeInteger(const T x) {
|
|
// On the GPU, -1.0 will be returned both for the minimum value of a signed type and its
|
|
// successor e.g. for char, -1.0 will be returned for both -128 and -127.
|
|
auto xf = std::abs(static_cast<float>(x));
|
|
xf = std::min<float>(xf, std::numeric_limits<T>::max());
|
|
return std::copysign(xf / std::numeric_limits<T>::max(), x);
|
|
}
|
|
|
|
inline std::tuple<size_t, size_t> GetLaunchConfig(size_t max_num_threads, size_t num_iters) {
|
|
auto num_threads = std::min<size_t>(max_num_threads, num_iters);
|
|
auto num_blocks = (num_iters + num_threads - 1) / num_threads;
|
|
return {num_threads, num_blocks};
|
|
}
|
|
|
|
inline std::string AddressModeToString(decltype(hipAddressModeClamp) address_mode) {
|
|
switch (address_mode) {
|
|
case hipAddressModeClamp:
|
|
return "hipAddressModeClamp";
|
|
case hipAddressModeBorder:
|
|
return "hipAddressModeBorder";
|
|
case hipAddressModeWrap:
|
|
return "hipAddressModeWrap";
|
|
case hipAddressModeMirror:
|
|
return "hipAddressModeMirror";
|
|
default:
|
|
throw std::invalid_argument("Invalid hipAddressMode value");
|
|
}
|
|
}
|
|
|
|
inline std::string FilteringModeToString(decltype(hipFilterModePoint) filter_mode) {
|
|
switch (filter_mode) {
|
|
case hipFilterModePoint:
|
|
return "hipFilterModePoint";
|
|
case hipFilterModeLinear:
|
|
return "hipFilterModeLinear";
|
|
default:
|
|
throw std::invalid_argument("Invalid hipFilterMode value");
|
|
}
|
|
} |