alpaka
Abstraction Library for Parallel Kernel Acceleration
Loading...
Searching...
No Matches
RuntimeMacros.hpp File Reference
#include "alpaka/core/Sycl.hpp"
#include <stdexcept>

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 caught in the catch block.
 

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 caught in the catch block.

For CUDA __trap function is used which triggers std::runtime_error but can be caught 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 with the -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 caught by signal handler.

Definition at line 55 of file RuntimeMacros.hpp.