Skip to content

Commit 72f3804

Browse files
authored
Removing CUF runtime dependency with llvm::EnableABIBreakingChecks (#111200)
getMemType happens to only be used in CufOpConversion.cpp. So, moving it here for now. If it needs to be shared with the runtime, then care should be taken in not bringing the include `#include "flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h"` which introduces the dependency with llvm::EnableABIBreakingChecks
1 parent 3b88805 commit 72f3804

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

flang/include/flang/Runtime/CUDA/common.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
#ifndef FORTRAN_RUNTIME_CUDA_COMMON_H_
1010
#define FORTRAN_RUNTIME_CUDA_COMMON_H_
1111

12-
#include "flang/Optimizer/Dialect/CUF/Attributes/CUFAttr.h"
1312
#include "flang/Runtime/descriptor.h"
1413
#include "flang/Runtime/entry-names.h"
1514

@@ -35,16 +34,4 @@ static constexpr unsigned kDeviceToDevice = 2;
3534
terminator.Crash("'%s' failed with '%s'", #expr, name); \
3635
}(expr)
3736

38-
static inline unsigned getMemType(cuf::DataAttribute attr) {
39-
if (attr == cuf::DataAttribute::Device)
40-
return kMemTypeDevice;
41-
if (attr == cuf::DataAttribute::Managed)
42-
return kMemTypeManaged;
43-
if (attr == cuf::DataAttribute::Unified)
44-
return kMemTypeUnified;
45-
if (attr == cuf::DataAttribute::Pinned)
46-
return kMemTypePinned;
47-
llvm::report_fatal_error("unsupported memory type");
48-
}
49-
5037
#endif // FORTRAN_RUNTIME_CUDA_COMMON_H_

flang/lib/Optimizer/Transforms/CufOpConversion.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,18 @@ using namespace Fortran::runtime::cuda;
3636

3737
namespace {
3838

39+
static inline unsigned getMemType(cuf::DataAttribute attr) {
40+
if (attr == cuf::DataAttribute::Device)
41+
return kMemTypeDevice;
42+
if (attr == cuf::DataAttribute::Managed)
43+
return kMemTypeManaged;
44+
if (attr == cuf::DataAttribute::Unified)
45+
return kMemTypeUnified;
46+
if (attr == cuf::DataAttribute::Pinned)
47+
return kMemTypePinned;
48+
llvm::report_fatal_error("unsupported memory type");
49+
}
50+
3951
template <typename OpTy>
4052
static bool isPinned(OpTy op) {
4153
if (op.getDataAttr() && *op.getDataAttr() == cuf::DataAttribute::Pinned)

0 commit comments

Comments
 (0)