From bfa8867a64d1fb8a5a7c2ac340b6fa9b2d7620cd Mon Sep 17 00:00:00 2001 From: Sarbojit2019 <52527887+SarbojitAMD@users.noreply.github.com> Date: Tue, 1 Oct 2019 12:38:32 +0530 Subject: [PATCH] [dtests] Separated C macros from CPP header file (#1429) * Separated C macros from CPP header file * Updated review comment [ROCm/hip commit: cde5119c9e074b5eaa161018e8ac35b565c7dcf7] --- projects/hip/tests/src/gcc/LaunchKernel.c | 13 +------- projects/hip/tests/src/test_common.h | 40 +++++++++++++++-------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/projects/hip/tests/src/gcc/LaunchKernel.c b/projects/hip/tests/src/gcc/LaunchKernel.c index 4ebe59d7c5..189d3ce614 100644 --- a/projects/hip/tests/src/gcc/LaunchKernel.c +++ b/projects/hip/tests/src/gcc/LaunchKernel.c @@ -27,21 +27,10 @@ */ -#include "hip/hip_runtime.h" +#include "../test_common.h" #include #include "LaunchKernel.h" -#define HIPCHECK(error) \ - { \ - hipError_t localError = error; \ - if ((localError != hipSuccess) && (localError != hipErrorPeerAccessAlreadyEnabled)) { \ - printf("%serror: '%s'(%d) from %s at %s:%d%s\n", "\x1B[31m", hipGetErrorString(localError), \ - localError, #error, __FILE__, __LINE__, "\x1B[0m"); \ - return false; \ - } \ - } - - bool LaunchKernelArg() { dim3 blocks = {1,1,1}; diff --git a/projects/hip/tests/src/test_common.h b/projects/hip/tests/src/test_common.h index 78aa845076..016cc34d52 100644 --- a/projects/hip/tests/src/test_common.h +++ b/projects/hip/tests/src/test_common.h @@ -17,13 +17,23 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -#include -#include -#if __CUDACC__ -#include -#else -#include +/* + * File is intended to C and CPP compliant hence any CPP specic changes + * should be added into CPP section + * + */ + +#ifdef __cplusplus + #include + #include + #if __CUDACC__ + #include + #else + #include + #endif #endif + +// ************************ GCC section ************************** #include #include "hip/hip_runtime.h" @@ -41,14 +51,6 @@ THE SOFTWARE. #define KCYN "\x1B[36m" #define KWHT "\x1B[37m" - -#ifdef __HIP_PLATFORM_HCC -#define TYPENAME(T) typeid(T).name() -#else -#define TYPENAME(T) "?" -#endif - - #define passed() \ printf("%sPASSED!%s\n", KGRN, KNRM); \ exit(0); @@ -114,6 +116,15 @@ extern int p_gpuDevice; extern unsigned p_verbose; extern int p_tests; +// ********************* CPP section ********************* +#ifdef __cplusplus + +#ifdef __HIP_PLATFORM_HCC +#define TYPENAME(T) typeid(T).name() +#else +#define TYPENAME(T) "?" +#endif + namespace HipTest { // Returns the current system time in microseconds @@ -470,3 +481,4 @@ struct MemTraits { }; }; // namespace HipTest +#endif //__cplusplus