Skip to content

Commit

Permalink
test: extent ALPAKA_CHECK to show better error messages
Browse files Browse the repository at this point in the history
To know where a test fails the line and file can be very usefull.
  • Loading branch information
psychocoderHPC committed Jul 29, 2022
1 parent 0b96515 commit 3c36501
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions include/alpaka/test/Check.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 3c36501

Please sign in to comment.