[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:
@@ -115,6 +115,21 @@ private:
|
|||||||
RT_API_ATTRS void NotifyOtherImagesOfNormalEnd();
|
RT_API_ATTRS void NotifyOtherImagesOfNormalEnd();
|
||||||
RT_API_ATTRS void NotifyOtherImagesOfFailImageStatement();
|
RT_API_ATTRS void NotifyOtherImagesOfFailImageStatement();
|
||||||
RT_API_ATTRS void NotifyOtherImagesOfErrorTermination();
|
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
|
||||||
|
|
||||||
namespace Fortran::runtime::io {
|
namespace Fortran::runtime::io {
|
||||||
|
|||||||
@@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
|
|
||||||
static void DescribeIEEESignaledExceptions() {
|
[[maybe_unused]] static void DescribeIEEESignaledExceptions() {
|
||||||
#ifdef fetestexcept // a macro in some environments; omit std::
|
#ifdef fetestexcept // a macro in some environments; omit std::
|
||||||
auto excepts{fetestexcept(FE_ALL_EXCEPT)};
|
auto excepts{fetestexcept(FE_ALL_EXCEPT)};
|
||||||
#else
|
#else
|
||||||
@@ -82,15 +82,7 @@ static void CloseAllExternalUnits(const char *why) {
|
|||||||
}
|
}
|
||||||
std::printf("\n");
|
std::printf("\n");
|
||||||
}
|
}
|
||||||
#if defined(__CUDACC__)
|
Fortran::runtime::DeviceTrap();
|
||||||
// NVCC supports __trap().
|
|
||||||
__trap();
|
|
||||||
#elif defined(__clang__)
|
|
||||||
// Clang supports __builtin_trap().
|
|
||||||
__builtin_trap();
|
|
||||||
#else
|
|
||||||
#error "unsupported compiler"
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
CloseAllExternalUnits("STOP statement");
|
CloseAllExternalUnits("STOP statement");
|
||||||
if (Fortran::runtime::executionEnvironment.noStopMessage && code == 0) {
|
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);
|
"Fortran %s: %s\n", isErrorStop ? "ERROR STOP" : "STOP", code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (isErrorStop) {
|
Fortran::runtime::DeviceTrap();
|
||||||
#if defined(__CUDACC__)
|
|
||||||
// NVCC supports __trap().
|
|
||||||
__trap();
|
|
||||||
#elif defined(__clang__)
|
|
||||||
// Clang supports __builtin_trap().
|
|
||||||
__builtin_trap();
|
|
||||||
#else
|
|
||||||
#error "unsupported compiler"
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
#else
|
#else
|
||||||
CloseAllExternalUnits("STOP statement");
|
CloseAllExternalUnits("STOP statement");
|
||||||
if (!quiet) {
|
if (!quiet) {
|
||||||
|
|||||||
@@ -75,15 +75,7 @@ RT_API_ATTRS void Terminator::CrashHeader() const {
|
|||||||
#endif
|
#endif
|
||||||
NotifyOtherImagesOfErrorTermination();
|
NotifyOtherImagesOfErrorTermination();
|
||||||
#if defined(RT_DEVICE_COMPILATION)
|
#if defined(RT_DEVICE_COMPILATION)
|
||||||
#if defined(__CUDACC__)
|
DeviceTrap();
|
||||||
// NVCC supports __trap().
|
|
||||||
__trap();
|
|
||||||
#elif defined(__clang__)
|
|
||||||
// Clang supports __builtin_trap().
|
|
||||||
__builtin_trap();
|
|
||||||
#else
|
|
||||||
#error "unsupported compiler"
|
|
||||||
#endif
|
|
||||||
#else
|
#else
|
||||||
std::abort();
|
std::abort();
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@@ -17,7 +17,6 @@
|
|||||||
#ifndef FORTRAN_COMMON_ENUM_CLASS_H_
|
#ifndef FORTRAN_COMMON_ENUM_CLASS_H_
|
||||||
#define FORTRAN_COMMON_ENUM_CLASS_H_
|
#define FORTRAN_COMMON_ENUM_CLASS_H_
|
||||||
|
|
||||||
#include "flang/Common/variant.h"
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,11 @@
|
|||||||
|
|
||||||
#include "flang/Common/api-attrs.h"
|
#include "flang/Common/api-attrs.h"
|
||||||
|
|
||||||
#if RT_USE_LIBCUDACXX && defined(RT_DEVICE_COMPILATION)
|
#if RT_USE_LIBCUDACXX
|
||||||
#include <cuda/std/complex>
|
#include <cuda/std/complex>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if RT_USE_LIBCUDACXX && defined(RT_DEVICE_COMPILATION)
|
||||||
namespace Fortran::runtime::rtcmplx {
|
namespace Fortran::runtime::rtcmplx {
|
||||||
using cuda::std::complex;
|
using cuda::std::complex;
|
||||||
using cuda::std::conj;
|
using cuda::std::conj;
|
||||||
|
|||||||
Reference in New Issue
Block a user