From 3c36501782968e73d46baa6f51886d99b6614f6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Widera?= Date: Thu, 28 Jul 2022 14:22:39 +0200 Subject: [PATCH] test: extent ALPAKA_CHECK to show better error messages To know where a test fails the line and file can be very usefull. --- include/alpaka/test/Check.hpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/include/alpaka/test/Check.hpp b/include/alpaka/test/Check.hpp index 6aa453fc83ef..4fed62ab7b5c 100644 --- a/include/alpaka/test/Check.hpp +++ b/include/alpaka/test/Check.hpp @@ -14,23 +14,32 @@ // TODO: SYCL doesn't have a way to detect if we're looking at device or host code. This needs a workaround so that // SYCL and other back-ends are compatible. #ifdef ALPAKA_ACC_SYCL_ENABLED -# define ALPAKA_CHECK(success, expression) \ +# define ALPAKA_CHECK_DO(success, expression, file, line) \ do \ { \ if(!(expression)) \ { \ - acc.cout << "ALPAKA_CHECK failed because '!(" << #expression << ")'\n"; \ + acc.cout << "ALPAKA_CHECK failed because '!(" << #expression << ")' in " << file << ":" << line \ + << "\n"; \ success = false; \ } \ } while(0) #else -# define ALPAKA_CHECK(success, expression) \ +# define ALPAKA_CHECK_DO(success, expression, file, line) \ do \ { \ if(!(expression)) \ { \ - printf("ALPAKA_CHECK failed because '!(%s)'\n", #expression); \ + printf("ALPAKA_CHECK failed because '!(%s)' in %s:%d\n", #expression, file, line); \ success = false; \ } \ } while(0) #endif + +#if BOOST_LANG_HIP == BOOST_VERSION_NUMBER(4, 5, 0) +// Do not forward the file name to avoid the compiler crashes with: "error: stack size limit exceeded (181056) in +// _ZN6alpaka16uniform_cuda_hip..." +# define ALPAKA_CHECK(success, expression) ALPAKA_CHECK_DO(success, expression, "unknown", __LINE__) +# eles +# define ALPAKA_CHECK(success, expression) ALPAKA_CHECK_DO(success, expression, __FILE__, __LINE__) +#endif