From 6e153a743f7e53c667c63a29d5676562ac283c51 Mon Sep 17 00:00:00 2001 From: Yaxun Sam Liu Date: Tue, 7 Aug 2018 17:14:39 -0400 Subject: [PATCH] Fix __HIP_DEVICE_COMPILE__ not defined when hip/math_functions.h is included This fixes build failure in TensorFlow 1.8 for HCC [ROCm/clr commit: 058eb7535baa8d7224d44f67ca0bc5470fd2ad43] --- projects/clr/hipamd/include/hip/math_functions.h | 1 + .../tests/src/deviceLib/hipTestIncludeMath.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/projects/clr/hipamd/include/hip/math_functions.h b/projects/clr/hipamd/include/hip/math_functions.h index 23dddf9f9d..2dfec4551b 100644 --- a/projects/clr/hipamd/include/hip/math_functions.h +++ b/projects/clr/hipamd/include/hip/math_functions.h @@ -27,6 +27,7 @@ THE SOFTWARE. // paths to provide a consistent include env and avoid "missing symbol" errors that only appears // on NVCC path: +#include #if defined(__HIP_PLATFORM_HCC__) && !defined(__HIP_PLATFORM_NVCC__) #include diff --git a/projects/clr/hipamd/tests/src/deviceLib/hipTestIncludeMath.cpp b/projects/clr/hipamd/tests/src/deviceLib/hipTestIncludeMath.cpp index 1097c23166..fd9bff1ad9 100644 --- a/projects/clr/hipamd/tests/src/deviceLib/hipTestIncludeMath.cpp +++ b/projects/clr/hipamd/tests/src/deviceLib/hipTestIncludeMath.cpp @@ -31,6 +31,20 @@ THE SOFTWARE. // declartions. #include + +// Test __HIP_DEVICE_COMPILE__ is defined after math_functions.h +// is included. +// +__device__ __host__ inline void throw_std_bad_alloc() +{ + #ifndef __HIP_DEVICE_COMPILE__ + throw std::bad_alloc(); + #else + std::size_t huge = static_cast(-1); + new int[huge]; + #endif +} + #include #include "test_common.h"