Files
TheRock/rocm-systems/projects/hip-tests/catch/unit/rtc/headers/RtcKernels.h
T
derek.holloway 7502bf64a4
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
Flatten subprojects into a single base monorepo
2026-09-02 16:34:47 -07:00

151 lines
2.9 KiB
C

/*
* Copyright (c) Advanced Micro Devices, Inc., or its affiliates.
*
* SPDX-License-Identifier: MIT
*/
/*
RtcKernels.h contains the string's with the which includes the kernel code.
They are utilized by the compiler option functions, defined in RtcFunctions.cpp
*/
#ifndef CATCH_UNIT_RTC_HEADERS_RTCKERNELS_H_
#define CATCH_UNIT_RTC_HEADERS_RTCKERNELS_H_
#include <hip/hiprtc.h>
#include <hip/hip_runtime.h>
#include <math.h>
static constexpr auto max_thread_string{
R"(
extern "C"
__global__ void max_thread(int* a) {
int BD = blockDim.x;
*a = BD;
}
)"};
static constexpr auto denormals_string{
R"(
extern "C"
__global__ void denormals(double* base, double* power, double* result) {
float denorm = powf(*base, *power);
if (*result == 0 || *result ==1 )
*result = (denorm==0) ? 0 : 1;
else
*result = powf(*base, *power);
}
)"};
static constexpr auto warning_string{
R"(
extern "C"
__global__ void warning() {
#warning "Just printing a WARNING message onto the terminal";
}
)"};
static constexpr auto fp32_div_sqrt_string{
R"(
extern "C"
__global__ void fp32_div_sqrt(float* result) {
float input = 109.6209;
*result = sqrt(input);
}
)"};
static constexpr auto error_string{
R"(
extern "C"
__global__ void error() {
unsigned int a = -1;
unsigned int b = +1;
signed int c = -1;
signed int d = +1;
}
)"};
static constexpr auto macro_string{
R"(
extern "C"
__global__ void macro(int *result) {
*result = PI;
}
)"};
static constexpr auto undef_macro_string{
R"(
extern "C"
__global__ void undef_macro() {
int a = Z;
}
)"};
static constexpr auto header_dir_string{
R"(
#include "RtcFact.h"
extern "C"
__global__ void header_dir(int* a, int* val) {
*a = fact(*val);
}
)"};
static constexpr auto rdc_string{
R"(
extern "C"
__global__ void rdc(float* a, float* b, float* c) {
*c = *a * *b;
}
)"};
static constexpr auto ffp_contract_string{
R"(
extern "C"
__global__ void ffp_contract(float* a, float* b, float* c) {
*c = *a * *b + *c;
}
)"};
static constexpr auto slp_vectorize_string{
R"(
extern "C"
__global__ void slp_vectorize(__half2 a, __half2 x, __half2 *y) {
(*y).data.x = x.data.x + a.data.x;
(*y).data.y = x.data.y + a.data.y;
}
)"};
static constexpr auto unsafe_atomic_string{
R"(
extern "C"
__global__ void unsafe_atomic(float* a) {
int id = threadIdx.x + blockIdx.x * blockDim.x;
if (id < 1000) {
unsafeAtomicAdd(&a[id], 0.2f);
}
}
)"};
static constexpr auto amdgpu_ieee_string{
R"(
extern "C"
__global__ void amdgpu_ieee(float* a, float* b, float* c) {
*c = sqrt(*a / *b);
printf("sqrt(a * b) = %f\n", *c);
}
)"};
static constexpr auto associative_math_string{
R"(
extern "C"
__global__ void associative_math(int* check) {
double x = 0.1f;
double y = 0.2f;
double z = 0.3f;
if((x*y)*z != x*(y*z))
*check = 1;
else *check = 0;
}
)"};
#endif // CATCH_UNIT_RTC_HEADERS_RTCKERNELS_H_