mirror of
https://github.com/llvm/llvm-project.git
synced 2025-04-21 18:26:47 +00:00
[flang-rt] Fixed warnings and miscompilations in CUDA build. (#134470)
* DescribeIEEESignaledExceptions() is unused on the device - warning. * StopStatementText() could return while marked noreturn - warning. * Including cuda/std/complex only in the device compilation may cause nvcc to try to register variables in `cuda` namespace, while they are not defined in the host compilation - error. I decided to include cuda/std/complex always under RT_USE_LIBCUDACXX.
This commit is contained in:
parent
337a4d5526
commit
755016a3a8
flang-rt
flang/include/flang
@ -115,6 +115,21 @@ private:
|
||||
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 {
|
||||
|
@ -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
|
||||
@ -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) {
|
||||
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user