Skip to content

Commit 10d7805

Browse files
authored
[flang][cuda][NFC] Disambiguate namespace with cuf dialect (#102194)
Rename namespace `Fortran::runtime::cuf` to `Fortran::runtime::cuda` to avoid embiguity with the namespace `::cuf` that is defined in the CUF dialect.
1 parent f9f0ae1 commit 10d7805

File tree

6 files changed

+25
-25
lines changed

6 files changed

+25
-25
lines changed

flang/include/flang/Runtime/CUDA/allocator.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
terminator.Crash("'%s' failed with '%s'", #expr, name); \
2424
}(expr)
2525

26-
namespace Fortran::runtime::cuf {
26+
namespace Fortran::runtime::cuda {
2727

2828
void CUFRegisterAllocator();
2929

@@ -36,5 +36,5 @@ void CUFFreeDevice(void *);
3636
void *CUFAllocManaged(std::size_t);
3737
void CUFFreeManaged(void *);
3838

39-
} // namespace Fortran::runtime::cuf
39+
} // namespace Fortran::runtime::cuda
4040
#endif // FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_

flang/include/flang/Runtime/CUDA/descriptor.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
#include "flang/Runtime/entry-names.h"
1414
#include <cstddef>
1515

16-
namespace Fortran::runtime::cuf {
16+
namespace Fortran::runtime::cuda {
1717

1818
extern "C" {
1919

@@ -26,5 +26,5 @@ void RTDECL(CUFFreeDesciptor)(
2626
Descriptor *, const char *sourceFile = nullptr, int sourceLine = 0);
2727

2828
} // extern "C"
29-
} // namespace Fortran::runtime::cuf
29+
} // namespace Fortran::runtime::cuda
3030
#endif // FORTRAN_RUNTIME_CUDA_DESCRIPTOR_H_

flang/lib/Optimizer/Transforms/CufOpConversion.cpp

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ namespace fir {
2828
using namespace fir;
2929
using namespace mlir;
3030
using namespace Fortran::runtime;
31-
using namespace Fortran::runtime::cuf;
31+
using namespace Fortran::runtime::cuda;
3232

3333
namespace {
3434

@@ -79,11 +79,11 @@ static mlir::LogicalResult convertOpToCall(OpTy op,
7979
}
8080

8181
struct CufAllocateOpConversion
82-
: public mlir::OpRewritePattern<::cuf::AllocateOp> {
82+
: public mlir::OpRewritePattern<cuf::AllocateOp> {
8383
using OpRewritePattern::OpRewritePattern;
8484

8585
mlir::LogicalResult
86-
matchAndRewrite(::cuf::AllocateOp op,
86+
matchAndRewrite(cuf::AllocateOp op,
8787
mlir::PatternRewriter &rewriter) const override {
8888
// TODO: Allocation with source will need a new entry point in the runtime.
8989
if (op.getSource())
@@ -112,16 +112,16 @@ struct CufAllocateOpConversion
112112
mlir::func::FuncOp func =
113113
fir::runtime::getRuntimeFunc<mkRTKey(AllocatableAllocate)>(loc,
114114
builder);
115-
return convertOpToCall<::cuf::AllocateOp>(op, rewriter, func);
115+
return convertOpToCall<cuf::AllocateOp>(op, rewriter, func);
116116
}
117117
};
118118

119119
struct CufDeallocateOpConversion
120-
: public mlir::OpRewritePattern<::cuf::DeallocateOp> {
120+
: public mlir::OpRewritePattern<cuf::DeallocateOp> {
121121
using OpRewritePattern::OpRewritePattern;
122122

123123
mlir::LogicalResult
124-
matchAndRewrite(::cuf::DeallocateOp op,
124+
matchAndRewrite(cuf::DeallocateOp op,
125125
mlir::PatternRewriter &rewriter) const override {
126126
// TODO: Allocation of module variable will need more work as the descriptor
127127
// will be duplicated and needs to be synced after allocation.
@@ -137,19 +137,19 @@ struct CufDeallocateOpConversion
137137
mlir::func::FuncOp func =
138138
fir::runtime::getRuntimeFunc<mkRTKey(AllocatableDeallocate)>(loc,
139139
builder);
140-
return convertOpToCall<::cuf::DeallocateOp>(op, rewriter, func);
140+
return convertOpToCall<cuf::DeallocateOp>(op, rewriter, func);
141141
}
142142
};
143143

144-
struct CufAllocOpConversion : public mlir::OpRewritePattern<::cuf::AllocOp> {
144+
struct CufAllocOpConversion : public mlir::OpRewritePattern<cuf::AllocOp> {
145145
using OpRewritePattern::OpRewritePattern;
146146

147147
CufAllocOpConversion(mlir::MLIRContext *context, mlir::DataLayout *dl,
148148
fir::LLVMTypeConverter *typeConverter)
149149
: OpRewritePattern(context), dl{dl}, typeConverter{typeConverter} {}
150150

151151
mlir::LogicalResult
152-
matchAndRewrite(::cuf::AllocOp op,
152+
matchAndRewrite(cuf::AllocOp op,
153153
mlir::PatternRewriter &rewriter) const override {
154154
auto boxTy = mlir::dyn_cast_or_null<fir::BaseBoxType>(op.getInType());
155155

@@ -187,11 +187,11 @@ struct CufAllocOpConversion : public mlir::OpRewritePattern<::cuf::AllocOp> {
187187
fir::LLVMTypeConverter *typeConverter;
188188
};
189189

190-
struct CufFreeOpConversion : public mlir::OpRewritePattern<::cuf::FreeOp> {
190+
struct CufFreeOpConversion : public mlir::OpRewritePattern<cuf::FreeOp> {
191191
using OpRewritePattern::OpRewritePattern;
192192

193193
mlir::LogicalResult
194-
matchAndRewrite(::cuf::FreeOp op,
194+
matchAndRewrite(cuf::FreeOp op,
195195
mlir::PatternRewriter &rewriter) const override {
196196
// Only convert cuf.free on descriptor.
197197
if (!mlir::isa<fir::ReferenceType>(op.getDevptr().getType()))
@@ -235,8 +235,8 @@ class CufOpConversion : public fir::impl::CufOpConversionBase<CufOpConversion> {
235235
fir::LLVMTypeConverter typeConverter(module, /*applyTBAA=*/false,
236236
/*forceUnifiedTBAATree=*/false, *dl);
237237

238-
target.addIllegalOp<::cuf::AllocOp, ::cuf::AllocateOp, ::cuf::DeallocateOp,
239-
::cuf::FreeOp>();
238+
target.addIllegalOp<cuf::AllocOp, cuf::AllocateOp, cuf::DeallocateOp,
239+
cuf::FreeOp>();
240240
patterns.insert<CufAllocOpConversion>(ctx, &*dl, &typeConverter);
241241
patterns.insert<CufAllocateOpConversion, CufDeallocateOpConversion,
242242
CufFreeOpConversion>(ctx);

flang/runtime/CUDA/allocator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
#include "cuda.h"
1919

20-
namespace Fortran::runtime::cuf {
20+
namespace Fortran::runtime::cuda {
2121

2222
void CUFRegisterAllocator() {
2323
allocatorRegistry.Register(
@@ -57,4 +57,4 @@ void CUFFreeManaged(void *p) {
5757
CUDA_REPORT_IF_ERROR(cuMemFree(reinterpret_cast<CUdeviceptr>(p)));
5858
}
5959

60-
} // namespace Fortran::runtime::cuf
60+
} // namespace Fortran::runtime::cuda

flang/runtime/CUDA/descriptor.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#include "flang/Runtime/CUDA/descriptor.h"
1010
#include "flang/Runtime/CUDA/allocator.h"
1111

12-
namespace Fortran::runtime::cuf {
12+
namespace Fortran::runtime::cuda {
1313
extern "C" {
1414
RT_EXT_API_GROUP_BEGIN
1515

@@ -25,4 +25,4 @@ void RTDEF(CUFFreeDesciptor)(
2525

2626
RT_EXT_API_GROUP_END
2727
}
28-
} // namespace Fortran::runtime::cuf
28+
} // namespace Fortran::runtime::cuda

flang/unittests/Runtime/CUDA/AllocatorCUF.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include "cuda.h"
1818

1919
using namespace Fortran::runtime;
20-
using namespace Fortran::runtime::cuf;
20+
using namespace Fortran::runtime::cuda;
2121

2222
static OwningPtr<Descriptor> createAllocatable(
2323
Fortran::common::TypeCategory tc, int kind, int rank = 1) {
@@ -55,7 +55,7 @@ class ScopedContext {
5555

5656
TEST(AllocatableCUFTest, SimpleDeviceAllocate) {
5757
using Fortran::common::TypeCategory;
58-
Fortran::runtime::cuf::CUFRegisterAllocator();
58+
Fortran::runtime::cuda::CUFRegisterAllocator();
5959
ScopedContext ctx;
6060
// REAL(4), DEVICE, ALLOCATABLE :: a(:)
6161
auto a{createAllocatable(TypeCategory::Real, 4)};
@@ -73,7 +73,7 @@ TEST(AllocatableCUFTest, SimpleDeviceAllocate) {
7373

7474
TEST(AllocatableCUFTest, SimplePinnedAllocate) {
7575
using Fortran::common::TypeCategory;
76-
Fortran::runtime::cuf::CUFRegisterAllocator();
76+
Fortran::runtime::cuda::CUFRegisterAllocator();
7777
ScopedContext ctx;
7878
// INTEGER(4), PINNED, ALLOCATABLE :: a(:)
7979
auto a{createAllocatable(TypeCategory::Integer, 4)};
@@ -92,7 +92,7 @@ TEST(AllocatableCUFTest, SimplePinnedAllocate) {
9292

9393
TEST(AllocatableCUFTest, DescriptorAllocationTest) {
9494
using Fortran::common::TypeCategory;
95-
Fortran::runtime::cuf::CUFRegisterAllocator();
95+
Fortran::runtime::cuda::CUFRegisterAllocator();
9696
ScopedContext ctx;
9797
// REAL(4), DEVICE, ALLOCATABLE :: a(:)
9898
auto a{createAllocatable(TypeCategory::Real, 4)};

0 commit comments

Comments
 (0)