alpaka
Abstraction Library for Parallel Kernel Acceleration
RuntimeMacros.hpp File Reference

Go to the source code of this file.

Macros

#define ALPAKA_THROW_ACC(MSG)
 ALPAKA_THROW_ACC either aborts(terminating the program and creating a core dump) or throws std::runtime_error depending on the Acc. The std::runtime_error exception can be catched in the catch block. More...
 

Macro Definition Documentation

◆ ALPAKA_THROW_ACC

#define ALPAKA_THROW_ACC (   MSG)
Value:
{ \
printf("alpaka encountered a user-defined error condition:\n%s", (MSG)); \
throw std::runtime_error(MSG); \
}

ALPAKA_THROW_ACC either aborts(terminating the program and creating a core dump) or throws std::runtime_error depending on the Acc. The std::runtime_error exception can be catched in the catch block.

For CUDA __trap function is used which triggers std::runtime_error but can be catched during wait not exec. For HIP abort() function is used and calls __builtin_trap() For Sycl assert(false) is not used since it can be disabled -DNDEBUG compile option. abort() is used although it generates a runtime error instead of aborting in GPUs: "Caught synchronous SYCL exception: Unresolved Symbol <abort> -999 (Unknown PI error)."

The OpenMP specification mandates that exceptions thrown by some thread must be handled by the same thread. Therefore std::runtime_error thrown by ALPAKA_THROW_ACC aborts the the program for OpenMP backends. If needed the SIGABRT signal can be catched by signal handler.

Definition at line 47 of file RuntimeMacros.hpp.