From 4d748e3cd70265777860d69568008863edba0809 Mon Sep 17 00:00:00 2001 From: pensun Date: Thu, 9 Mar 2017 16:30:34 -0600 Subject: [PATCH] update porting guide for updated __HIP_DEVICE_COMPILE__ Change-Id: I0f025d354f76e2d728231bf112a77e8c8fcacc8c [ROCm/hip commit: 37ed319a20f006f62bdff3889b19c647730b08f6] --- projects/hip/docs/markdown/hip_porting_guide.md | 6 +++--- projects/hip/include/hip/hip_common.h | 17 ++++------------- 2 files changed, 7 insertions(+), 16 deletions(-) diff --git a/projects/hip/docs/markdown/hip_porting_guide.md b/projects/hip/docs/markdown/hip_porting_guide.md index 721a6fabd7..9f20d12423 100644 --- a/projects/hip/docs/markdown/hip_porting_guide.md +++ b/projects/hip/docs/markdown/hip_porting_guide.md @@ -166,10 +166,10 @@ Both nvcc and hcc make two passes over the code: one for host code and one for d ``` // #ifdef __CUDA_ARCH__ -#if defined(__HIP_DEVICE_COMPILE__) && (__HIP_DEVICE_COMPILE__ == 1) +#if __HIP_DEVICE_COMPILE__ ``` -Unlike `__CUDA_ARCH__`, the `__HIP_DEVICE_COMPILE__` value is 0 or 1, and it doesn’t represent the feature capability of the target device. +Unlike `__CUDA_ARCH__`, the `__HIP_DEVICE_COMPILE__` value is 1 or undefined, and it doesn’t represent the feature capability of the target device. ### Compiler Defines: Summary @@ -178,7 +178,7 @@ Unlike `__CUDA_ARCH__`, the `__HIP_DEVICE_COMPILE__` value is 0 or 1, and it doe |HIP-related defines:| |`__HIP_PLATFORM_HCC___`| Defined | Undefined | Defined if targeting hcc platform; undefined otherwise | |`__HIP_PLATFORM_NVCC___`| Undefined | Defined | Defined if targeting nvcc platform; undefined otherwise | -|`__HIP_DEVICE_COMPILE__` | 1 if compiling for device; 0 if compiling for host |1 if compiling for device; 0 if compiling for host | Undefined +|`__HIP_DEVICE_COMPILE__` | 1 if compiling for device; undefined if compiling for host |1 if compiling for device; undefined if compiling for host | Undefined |`__HIPCC__` | Defined | Defined | Undefined |`__HIP_ARCH_*` | 0 or 1 depending on feature support (see below) | 0 or 1 depending on feature support (see below) | 0 |nvcc-related defines:| diff --git a/projects/hip/include/hip/hip_common.h b/projects/hip/include/hip/hip_common.h index 6223a2fe9e..6317a792ee 100644 --- a/projects/hip/include/hip/hip_common.h +++ b/projects/hip/include/hip/hip_common.h @@ -27,13 +27,6 @@ THE SOFTWARE. // Other compiler (GCC,ICC,etc) need to set one of these macros explicitly #if defined(__HCC__) #define __HIP_PLATFORM_HCC__ - -#if defined(__HCC_ACCELERATOR__) && (__HCC_ACCELERATOR__ != 0) -#define __HIP_DEVICE_COMPILE__ 1 -#else -#define __HIP_DEVICE_COMPILE__ 0 -#endif - #endif //__HCC__ // Auto enable __HIP_PLATFORM_NVCC__ if compiling with NVCC @@ -43,14 +36,12 @@ THE SOFTWARE. #define __HIPCC__ #endif -#if defined(__CUDA_ARCH__) && (__CUDA_ARCH__ != 0) -#define __HIP_DEVICE_COMPILE__ 1 -#else -#define __HIP_DEVICE_COMPILE__ 0 -#endif - #endif //__NVCC__ +// Auto enable __HIP_DEVICE_COMPILE__ if compiled in HCC or NVCC device path +#if (defined(__HCC_ACCELERATOR__) && __HCC_ACCELERATOR__ != 0) || (defined(__CUDA_ARCH__) && __CUDA_ARCH__ != 0) + #define __HIP_DEVICE_COMPILE__ 1 +#endif #if __HIP_DEVICE_COMPILE__ == 0 // 32-bit Atomics