Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions flang-rt/include/flang-rt/runtime/terminator.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ class Terminator {
RT_API_ATTRS void NotifyOtherImagesOfNormalEnd();
RT_API_ATTRS void NotifyOtherImagesOfFailImageStatement();
RT_API_ATTRS void NotifyOtherImagesOfErrorTermination();

#if defined(RT_DEVICE_COMPILATION)
/// Trap the execution on the device.
[[noreturn]] void RT_API_ATTRS DeviceTrap() {
#if defined(__CUDACC__)
// NVCC supports __trap().
__trap();
#elif defined(__clang__)
// Clang supports __builtin_trap().
__builtin_trap();
#else
#error "unsupported compiler"
#endif
}
#endif
} // namespace Fortran::runtime

namespace Fortran::runtime::io {
Expand Down
24 changes: 3 additions & 21 deletions flang-rt/lib/runtime/stop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@

extern "C" {

static void DescribeIEEESignaledExceptions() {
[[maybe_unused]] static void DescribeIEEESignaledExceptions() {
#ifdef fetestexcept // a macro in some environments; omit std::
auto excepts{fetestexcept(FE_ALL_EXCEPT)};
#else
Expand Down Expand Up @@ -82,15 +82,7 @@ static void CloseAllExternalUnits(const char *why) {
}
std::printf("\n");
}
#if defined(__CUDACC__)
// NVCC supports __trap().
__trap();
#elif defined(__clang__)
// Clang supports __builtin_trap().
__builtin_trap();
#else
#error "unsupported compiler"
#endif
Fortran::runtime::DeviceTrap();
#else
CloseAllExternalUnits("STOP statement");
if (Fortran::runtime::executionEnvironment.noStopMessage && code == 0) {
Expand Down Expand Up @@ -119,17 +111,7 @@ static void CloseAllExternalUnits(const char *why) {
"Fortran %s: %s\n", isErrorStop ? "ERROR STOP" : "STOP", code);
}
}
if (isErrorStop) {
#if defined(__CUDACC__)
// NVCC supports __trap().
__trap();
#elif defined(__clang__)
// Clang supports __builtin_trap().
__builtin_trap();
#else
#error "unsupported compiler"
#endif
}
Fortran::runtime::DeviceTrap();
#else
CloseAllExternalUnits("STOP statement");
if (!quiet) {
Expand Down
10 changes: 1 addition & 9 deletions flang-rt/lib/runtime/terminator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,7 @@ RT_API_ATTRS void Terminator::CrashHeader() const {
#endif
NotifyOtherImagesOfErrorTermination();
#if defined(RT_DEVICE_COMPILATION)
#if defined(__CUDACC__)
// NVCC supports __trap().
__trap();
#elif defined(__clang__)
// Clang supports __builtin_trap().
__builtin_trap();
#else
#error "unsupported compiler"
#endif
DeviceTrap();
#else
std::abort();
#endif
Expand Down
1 change: 0 additions & 1 deletion flang/include/flang/Common/enum-class.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
#ifndef FORTRAN_COMMON_ENUM_CLASS_H_
#define FORTRAN_COMMON_ENUM_CLASS_H_

#include "flang/Common/variant.h"
#include <array>
#include <string>

Expand Down
5 changes: 4 additions & 1 deletion flang/include/flang/Runtime/complex.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@

#include "flang/Common/api-attrs.h"

#if RT_USE_LIBCUDACXX && defined(RT_DEVICE_COMPILATION)
#if RT_USE_LIBCUDACXX
#include <cuda/std/complex>
#endif

#if RT_USE_LIBCUDACXX && defined(RT_DEVICE_COMPILATION)
namespace Fortran::runtime::rtcmplx {
using cuda::std::complex;
using cuda::std::conj;
Expand Down