[flang-commits] [flang] 10d7805 - [flang][cuda][NFC] Disambiguate namespace with cuf dialect (#102194)
via flang-commits
flang-commits at lists.llvm.org
Tue Aug 6 14:04:48 PDT 2024
Author: Valentin Clement (バレンタイン クレメン)
Date: 2024-08-06T14:04:45-07:00
New Revision: 10d7805c4f8f2226bee23c4cc021cebc2c56727e
URL: https://github.com/llvm/llvm-project/commit/10d7805c4f8f2226bee23c4cc021cebc2c56727e
DIFF: https://github.com/llvm/llvm-project/commit/10d7805c4f8f2226bee23c4cc021cebc2c56727e.diff
LOG: [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.
Added:
Modified:
flang/include/flang/Runtime/CUDA/allocator.h
flang/include/flang/Runtime/CUDA/descriptor.h
flang/lib/Optimizer/Transforms/CufOpConversion.cpp
flang/runtime/CUDA/allocator.cpp
flang/runtime/CUDA/descriptor.cpp
flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
Removed:
################################################################################
diff --git a/flang/include/flang/Runtime/CUDA/allocator.h b/flang/include/flang/Runtime/CUDA/allocator.h
index 46ff5dbe2f385..849785cf991ff 100644
--- a/flang/include/flang/Runtime/CUDA/allocator.h
+++ b/flang/include/flang/Runtime/CUDA/allocator.h
@@ -23,7 +23,7 @@
terminator.Crash("'%s' failed with '%s'", #expr, name); \
}(expr)
-namespace Fortran::runtime::cuf {
+namespace Fortran::runtime::cuda {
void CUFRegisterAllocator();
@@ -36,5 +36,5 @@ void CUFFreeDevice(void *);
void *CUFAllocManaged(std::size_t);
void CUFFreeManaged(void *);
-} // namespace Fortran::runtime::cuf
+} // namespace Fortran::runtime::cuda
#endif // FORTRAN_RUNTIME_CUDA_ALLOCATOR_H_
diff --git a/flang/include/flang/Runtime/CUDA/descriptor.h b/flang/include/flang/Runtime/CUDA/descriptor.h
index 33b993b219f29..d593989420420 100644
--- a/flang/include/flang/Runtime/CUDA/descriptor.h
+++ b/flang/include/flang/Runtime/CUDA/descriptor.h
@@ -13,7 +13,7 @@
#include "flang/Runtime/entry-names.h"
#include <cstddef>
-namespace Fortran::runtime::cuf {
+namespace Fortran::runtime::cuda {
extern "C" {
@@ -26,5 +26,5 @@ void RTDECL(CUFFreeDesciptor)(
Descriptor *, const char *sourceFile = nullptr, int sourceLine = 0);
} // extern "C"
-} // namespace Fortran::runtime::cuf
+} // namespace Fortran::runtime::cuda
#endif // FORTRAN_RUNTIME_CUDA_DESCRIPTOR_H_
diff --git a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
index 61c95843a3431..70b5037994216 100644
--- a/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
+++ b/flang/lib/Optimizer/Transforms/CufOpConversion.cpp
@@ -28,7 +28,7 @@ namespace fir {
using namespace fir;
using namespace mlir;
using namespace Fortran::runtime;
-using namespace Fortran::runtime::cuf;
+using namespace Fortran::runtime::cuda;
namespace {
@@ -79,11 +79,11 @@ static mlir::LogicalResult convertOpToCall(OpTy op,
}
struct CufAllocateOpConversion
- : public mlir::OpRewritePattern<::cuf::AllocateOp> {
+ : public mlir::OpRewritePattern<cuf::AllocateOp> {
using OpRewritePattern::OpRewritePattern;
mlir::LogicalResult
- matchAndRewrite(::cuf::AllocateOp op,
+ matchAndRewrite(cuf::AllocateOp op,
mlir::PatternRewriter &rewriter) const override {
// TODO: Allocation with source will need a new entry point in the runtime.
if (op.getSource())
@@ -112,16 +112,16 @@ struct CufAllocateOpConversion
mlir::func::FuncOp func =
fir::runtime::getRuntimeFunc<mkRTKey(AllocatableAllocate)>(loc,
builder);
- return convertOpToCall<::cuf::AllocateOp>(op, rewriter, func);
+ return convertOpToCall<cuf::AllocateOp>(op, rewriter, func);
}
};
struct CufDeallocateOpConversion
- : public mlir::OpRewritePattern<::cuf::DeallocateOp> {
+ : public mlir::OpRewritePattern<cuf::DeallocateOp> {
using OpRewritePattern::OpRewritePattern;
mlir::LogicalResult
- matchAndRewrite(::cuf::DeallocateOp op,
+ matchAndRewrite(cuf::DeallocateOp op,
mlir::PatternRewriter &rewriter) const override {
// TODO: Allocation of module variable will need more work as the descriptor
// will be duplicated and needs to be synced after allocation.
@@ -137,11 +137,11 @@ struct CufDeallocateOpConversion
mlir::func::FuncOp func =
fir::runtime::getRuntimeFunc<mkRTKey(AllocatableDeallocate)>(loc,
builder);
- return convertOpToCall<::cuf::DeallocateOp>(op, rewriter, func);
+ return convertOpToCall<cuf::DeallocateOp>(op, rewriter, func);
}
};
-struct CufAllocOpConversion : public mlir::OpRewritePattern<::cuf::AllocOp> {
+struct CufAllocOpConversion : public mlir::OpRewritePattern<cuf::AllocOp> {
using OpRewritePattern::OpRewritePattern;
CufAllocOpConversion(mlir::MLIRContext *context, mlir::DataLayout *dl,
@@ -149,7 +149,7 @@ struct CufAllocOpConversion : public mlir::OpRewritePattern<::cuf::AllocOp> {
: OpRewritePattern(context), dl{dl}, typeConverter{typeConverter} {}
mlir::LogicalResult
- matchAndRewrite(::cuf::AllocOp op,
+ matchAndRewrite(cuf::AllocOp op,
mlir::PatternRewriter &rewriter) const override {
auto boxTy = mlir::dyn_cast_or_null<fir::BaseBoxType>(op.getInType());
@@ -187,11 +187,11 @@ struct CufAllocOpConversion : public mlir::OpRewritePattern<::cuf::AllocOp> {
fir::LLVMTypeConverter *typeConverter;
};
-struct CufFreeOpConversion : public mlir::OpRewritePattern<::cuf::FreeOp> {
+struct CufFreeOpConversion : public mlir::OpRewritePattern<cuf::FreeOp> {
using OpRewritePattern::OpRewritePattern;
mlir::LogicalResult
- matchAndRewrite(::cuf::FreeOp op,
+ matchAndRewrite(cuf::FreeOp op,
mlir::PatternRewriter &rewriter) const override {
// Only convert cuf.free on descriptor.
if (!mlir::isa<fir::ReferenceType>(op.getDevptr().getType()))
@@ -235,8 +235,8 @@ class CufOpConversion : public fir::impl::CufOpConversionBase<CufOpConversion> {
fir::LLVMTypeConverter typeConverter(module, /*applyTBAA=*/false,
/*forceUnifiedTBAATree=*/false, *dl);
- target.addIllegalOp<::cuf::AllocOp, ::cuf::AllocateOp, ::cuf::DeallocateOp,
- ::cuf::FreeOp>();
+ target.addIllegalOp<cuf::AllocOp, cuf::AllocateOp, cuf::DeallocateOp,
+ cuf::FreeOp>();
patterns.insert<CufAllocOpConversion>(ctx, &*dl, &typeConverter);
patterns.insert<CufAllocateOpConversion, CufDeallocateOpConversion,
CufFreeOpConversion>(ctx);
diff --git a/flang/runtime/CUDA/allocator.cpp b/flang/runtime/CUDA/allocator.cpp
index 26a3c29696269..08fae9efb3e9d 100644
--- a/flang/runtime/CUDA/allocator.cpp
+++ b/flang/runtime/CUDA/allocator.cpp
@@ -17,7 +17,7 @@
#include "cuda.h"
-namespace Fortran::runtime::cuf {
+namespace Fortran::runtime::cuda {
void CUFRegisterAllocator() {
allocatorRegistry.Register(
@@ -57,4 +57,4 @@ void CUFFreeManaged(void *p) {
CUDA_REPORT_IF_ERROR(cuMemFree(reinterpret_cast<CUdeviceptr>(p)));
}
-} // namespace Fortran::runtime::cuf
+} // namespace Fortran::runtime::cuda
diff --git a/flang/runtime/CUDA/descriptor.cpp b/flang/runtime/CUDA/descriptor.cpp
index e228c0f76aae0..1031b1e601b64 100644
--- a/flang/runtime/CUDA/descriptor.cpp
+++ b/flang/runtime/CUDA/descriptor.cpp
@@ -9,7 +9,7 @@
#include "flang/Runtime/CUDA/descriptor.h"
#include "flang/Runtime/CUDA/allocator.h"
-namespace Fortran::runtime::cuf {
+namespace Fortran::runtime::cuda {
extern "C" {
RT_EXT_API_GROUP_BEGIN
@@ -25,4 +25,4 @@ void RTDEF(CUFFreeDesciptor)(
RT_EXT_API_GROUP_END
}
-} // namespace Fortran::runtime::cuf
+} // namespace Fortran::runtime::cuda
diff --git a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp b/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
index 2355c47778cca..4f53e654034cb 100644
--- a/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
+++ b/flang/unittests/Runtime/CUDA/AllocatorCUF.cpp
@@ -17,7 +17,7 @@
#include "cuda.h"
using namespace Fortran::runtime;
-using namespace Fortran::runtime::cuf;
+using namespace Fortran::runtime::cuda;
static OwningPtr<Descriptor> createAllocatable(
Fortran::common::TypeCategory tc, int kind, int rank = 1) {
@@ -55,7 +55,7 @@ class ScopedContext {
TEST(AllocatableCUFTest, SimpleDeviceAllocate) {
using Fortran::common::TypeCategory;
- Fortran::runtime::cuf::CUFRegisterAllocator();
+ Fortran::runtime::cuda::CUFRegisterAllocator();
ScopedContext ctx;
// REAL(4), DEVICE, ALLOCATABLE :: a(:)
auto a{createAllocatable(TypeCategory::Real, 4)};
@@ -73,7 +73,7 @@ TEST(AllocatableCUFTest, SimpleDeviceAllocate) {
TEST(AllocatableCUFTest, SimplePinnedAllocate) {
using Fortran::common::TypeCategory;
- Fortran::runtime::cuf::CUFRegisterAllocator();
+ Fortran::runtime::cuda::CUFRegisterAllocator();
ScopedContext ctx;
// INTEGER(4), PINNED, ALLOCATABLE :: a(:)
auto a{createAllocatable(TypeCategory::Integer, 4)};
@@ -92,7 +92,7 @@ TEST(AllocatableCUFTest, SimplePinnedAllocate) {
TEST(AllocatableCUFTest, DescriptorAllocationTest) {
using Fortran::common::TypeCategory;
- Fortran::runtime::cuf::CUFRegisterAllocator();
+ Fortran::runtime::cuda::CUFRegisterAllocator();
ScopedContext ctx;
// REAL(4), DEVICE, ALLOCATABLE :: a(:)
auto a{createAllocatable(TypeCategory::Real, 4)};
More information about the flang-commits
mailing list