Skip to content

Commit 9b2dfff

Browse files
committed
Partially revert "clang/HIP: Remove __llvm_amdgcn_* wrapper hacks"
Revert part of f407a73. Some of the HIP headers were using the f16 rcp inline, such that it breaks compiling code against non-top-of-tree headers. Need to wait for a few HIP releases to expire to fully remove these. Fixes #63981
1 parent bd20307 commit 9b2dfff

File tree

2 files changed

+56
-0
lines changed

2 files changed

+56
-0
lines changed

clang/lib/Headers/__clang_hip_libdevice_declares.h

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@
1010
#ifndef __CLANG_HIP_LIBDEVICE_DECLARES_H__
1111
#define __CLANG_HIP_LIBDEVICE_DECLARES_H__
1212

13+
#if !defined(__HIPCC_RTC__) && __has_include("hip/hip_version.h")
14+
#include "hip/hip_version.h"
15+
#endif // __has_include("hip/hip_version.h")
16+
1317
#ifdef __cplusplus
1418
extern "C" {
1519
#endif
@@ -312,6 +316,29 @@ __device__ __attribute__((const)) __2i16 __ocml_isnan_2f16(__2f16);
312316
__device__ __attribute__((pure)) __2f16 __ocml_log_2f16(__2f16);
313317
__device__ __attribute__((pure)) __2f16 __ocml_log10_2f16(__2f16);
314318
__device__ __attribute__((pure)) __2f16 __ocml_log2_2f16(__2f16);
319+
320+
#if HIP_VERSION_MAJOR * 100 + HIP_VERSION_MINOR >= 560 || 1
321+
#define __DEPRECATED_SINCE_HIP_560(X) __attribute__((deprecated(X)))
322+
#else
323+
#define __DEPRECATED_SINCE_HIP_560(X)
324+
#endif
325+
326+
// Deprecated, should be removed when rocm releases using it are no longer
327+
// relevant.
328+
__DEPRECATED_SINCE_HIP_560("use ((_Float16)1.0) / ")
329+
__device__ inline _Float16 __llvm_amdgcn_rcp_f16(_Float16 x) {
330+
return ((_Float16)1.0f) / x;
331+
}
332+
333+
__DEPRECATED_SINCE_HIP_560("use ((__2f16)1.0) / ")
334+
__device__ inline __2f16
335+
__llvm_amdgcn_rcp_2f16(__2f16 __x)
336+
{
337+
return ((__2f16)1.0f) / __x;
338+
}
339+
340+
#undef __DEPRECATED_SINCE_HIP_560
341+
315342
__device__ __attribute__((const)) __2f16 __ocml_rint_2f16(__2f16);
316343
__device__ __attribute__((const)) __2f16 __ocml_rsqrt_2f16(__2f16);
317344
__device__ __2f16 __ocml_sin_2f16(__2f16);
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// NOTE: Assertions have been autogenerated by utils/update_cc_test_checks.py
2+
// REQUIRES: amdgpu-registered-target
3+
4+
// RUN: %clang_cc1 -include __clang_hip_runtime_wrapper.h \
5+
// RUN: -internal-isystem %S/../../lib/Headers/cuda_wrappers \
6+
// RUN: -internal-isystem %S/Inputs/include \
7+
// RUN: -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown \
8+
// RUN: -target-cpu gfx906 -emit-llvm %s -fcuda-is-device -O1 -o - \
9+
// RUN: -D__HIPCC_RTC__ | FileCheck %s
10+
11+
// Test deprecated functions in the header that should be removed eventually
12+
13+
// CHECK-LABEL: @test_rcpf16_wrapper(
14+
// CHECK-NEXT: entry:
15+
// CHECK-NEXT: [[DIV_I:%.*]] = fdiv contract half 0xH3C00, [[X:%.*]]
16+
// CHECK-NEXT: ret half [[DIV_I]]
17+
//
18+
extern "C" __device__ _Float16 test_rcpf16_wrapper(_Float16 x) {
19+
return __llvm_amdgcn_rcp_f16(x);
20+
}
21+
22+
// CHECK-LABEL: @test_rcp2f16_wrapper(
23+
// CHECK-NEXT: entry:
24+
// CHECK-NEXT: [[DIV_I:%.*]] = fdiv contract <2 x half> <half 0xH3C00, half 0xH3C00>, [[X:%.*]]
25+
// CHECK-NEXT: ret <2 x half> [[DIV_I]]
26+
//
27+
extern "C" __device__ __2f16 test_rcp2f16_wrapper(__2f16 x) {
28+
return __llvm_amdgcn_rcp_2f16(x);
29+
}

0 commit comments

Comments
 (0)