[flang-commits] [flang] [flang][runtime] Enable more code for offload device builds. (PR #67489)
Slava Zakharin via flang-commits
flang-commits at lists.llvm.org
Tue Sep 26 14:28:07 PDT 2023
================
@@ -12,26 +12,47 @@
namespace Fortran::runtime {
-[[noreturn]] void Terminator::Crash(const char *message, ...) const {
- va_list ap;
- va_start(ap, message);
- CrashArgs(message, ap);
- va_end(ap);
-}
-
-static void (*crashHandler)(const char *, int, const char *, va_list &){
+#if !defined(RT_DEVICE_COMPILATION)
+[[maybe_unused]] static void (*crashHandler)(const char *, int, const char *, va_list &){
nullptr};
void Terminator::RegisterCrashHandler(
void (*handler)(const char *, int, const char *, va_list &)) {
crashHandler = handler;
}
-[[noreturn]] void Terminator::CrashArgs(
- const char *message, va_list &ap) const {
+void Terminator::InvokeCrashHandler(const char *message, ...) const {
if (crashHandler) {
+ va_list ap;
+ va_start(ap, message);
crashHandler(sourceFileName_, sourceLine_, message, ap);
+ va_end(ap);
+ }
+}
+
+[[noreturn]] void Terminator::CrashArgs(
+ const char *message, va_list &ap) const {
+ CrashHeader();
+ std::vfprintf(stderr, message, ap);
+ va_end(ap);
+ CrashFooter();
+}
+#endif
+
+RT_OFFLOAD_API_GROUP_BEGIN
+
+RT_API_ATTRS void Terminator::CrashHeader() const {
+#if defined(RT_DEVICE_COMPILATION)
+ std::printf("\nfatal Fortran runtime error");
----------------
vzakhari wrote:
Device compilers (at least some of them) do not support `stderr`. In general, only a plain `printf` is supported on the device, e.g. https://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#formatted-output
https://github.com/llvm/llvm-project/pull/67489
More information about the flang-commits
mailing list