Skip to content

Commit f0a955d

Browse files
committed
[HIP] Rename predefined macros
Rename HIP_API_PER_THREAD_DEFAULT_STREAM and __HIP_NO_IMAGE_SUPPORT so that they follow the convention with prefix and postfix __. Reviewed by: Artem Belevich Differential Revision: https://reviews.llvm.org/D155480
1 parent df11165 commit f0a955d

File tree

3 files changed

+26
-5
lines changed

3 files changed

+26
-5
lines changed

clang/lib/Frontend/InitPreprocessor.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -588,12 +588,18 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
588588
Builder.defineMacro("__HIP_MEMORY_SCOPE_SYSTEM", "5");
589589
if (LangOpts.CUDAIsDevice) {
590590
Builder.defineMacro("__HIP_DEVICE_COMPILE__");
591-
if (!TI.hasHIPImageSupport())
591+
if (!TI.hasHIPImageSupport()) {
592+
Builder.defineMacro("__HIP_NO_IMAGE_SUPPORT__", "1");
593+
// Deprecated.
592594
Builder.defineMacro("__HIP_NO_IMAGE_SUPPORT", "1");
595+
}
593596
}
594597
if (LangOpts.GPUDefaultStream ==
595-
LangOptions::GPUDefaultStreamKind::PerThread)
598+
LangOptions::GPUDefaultStreamKind::PerThread) {
599+
Builder.defineMacro("__HIP_API_PER_THREAD_DEFAULT_STREAM__");
600+
// Deprecated.
596601
Builder.defineMacro("HIP_API_PER_THREAD_DEFAULT_STREAM");
602+
}
597603
}
598604
}
599605

clang/test/CodeGenCUDA/Inputs/cuda.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ int hipConfigureCall(dim3 gridSize, dim3 blockSize, size_t sharedSize = 0,
3535
extern "C" hipError_t __hipPushCallConfiguration(dim3 gridSize, dim3 blockSize,
3636
size_t sharedSize = 0,
3737
hipStream_t stream = 0);
38-
#ifndef HIP_API_PER_THREAD_DEFAULT_STREAM
38+
#ifndef __HIP_API_PER_THREAD_DEFAULT_STREAM__
3939
extern "C" hipError_t hipLaunchKernel(const void *func, dim3 gridDim,
4040
dim3 blockDim, void **args,
4141
size_t sharedMem,
@@ -45,7 +45,7 @@ extern "C" hipError_t hipLaunchKernel_spt(const void *func, dim3 gridDim,
4545
dim3 blockDim, void **args,
4646
size_t sharedMem,
4747
hipStream_t stream);
48-
#endif //HIP_API_PER_THREAD_DEFAULT_STREAM
48+
#endif // __HIP_API_PER_THREAD_DEFAULT_STREAM__
4949
#else
5050
typedef struct cudaStream *cudaStream_t;
5151
typedef enum cudaError {} cudaError_t;

clang/test/Driver/hip-macros.hip

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,5 +61,20 @@
6161
// RUN: -Xclang -target-feature -Xclang "+image-insts" %s 2>&1 | FileCheck --check-prefixes=NOIMAGE,WARN %s
6262
// NOWARN-NOT: warning
6363
// WARN: warning: feature flag '{{[+|-]}}image-insts' is ignored since the feature is read only [-Winvalid-command-line-argument]
64+
// IMAGE-NOT: #define __HIP_NO_IMAGE_SUPPORT__
6465
// IMAGE-NOT: #define __HIP_NO_IMAGE_SUPPORT
65-
// NOIMAGE: #define __HIP_NO_IMAGE_SUPPORT 1
66+
// NOIMAGE-DAG: #define __HIP_NO_IMAGE_SUPPORT__ 1
67+
// NOIMAGE-DAG: #define __HIP_NO_IMAGE_SUPPORT 1
68+
69+
// RUN: %clang -E -dM --offload-arch=gfx1100 -nogpuinc -nogpulib \
70+
// RUN: -fgpu-default-stream=per-thread %s 2>&1 | FileCheck --check-prefixes=PTS %s
71+
// RUN: %clang -E -dM --offload-arch=gfx940 --cuda-device-only -nogpuinc -nogpulib \
72+
// RUN: -fgpu-default-stream=legacy %s 2>&1 | FileCheck --check-prefixes=NOPTS %s
73+
// RUN: %clang -E -dM --offload-arch=gfx940 --cuda-device-only -nogpuinc -nogpulib \
74+
// RUN: %s 2>&1 | FileCheck --check-prefixes=NOPTS %s
75+
// PTS-DAG: #define __HIP_API_PER_THREAD_DEFAULT_STREAM__ 1
76+
// PTS-DAG: #define __HIP_API_PER_THREAD_DEFAULT_STREAM__ 1
77+
// PTS-DAG: #define HIP_API_PER_THREAD_DEFAULT_STREAM 1
78+
// PTS-DAG: #define HIP_API_PER_THREAD_DEFAULT_STREAM 1
79+
// NOPTS-NOT: #define __HIP_API_PER_THREAD_DEFAULT_STREAM__
80+
// NOPTS-NOT: #define HIP_API_PER_THREAD_DEFAULT_STREAM

0 commit comments

Comments
 (0)