From a14c7579e9ebab7e57bf61514a628774b30a7e04 Mon Sep 17 00:00:00 2001 From: Mark Dokter Date: Sun, 6 Oct 2024 11:22:26 +0200 Subject: [PATCH] [DAPHNE-#830] Fix anonymous namespace issue when compiling with Clang When compiling with clang, there is a issue at runtime (LLVM complaining about anonymous namespaces not allowed in various places). These are hereby replaced with a non-anonymous namespace. For the lack of creativity these are all called "file_local". --- src/compiler/lowering/AggAllOpLowering.cpp | 8 ++++---- src/compiler/lowering/DaphneOptPass.cpp | 10 ++++++---- src/compiler/lowering/DistributeComputationsPass.cpp | 8 ++++---- src/compiler/lowering/EwOpsLowering.cpp | 10 ++++++---- src/compiler/lowering/LowerToLLVMPass.cpp | 8 ++++---- src/compiler/lowering/MapOpLowering.cpp | 10 ++++++---- src/compiler/lowering/MatMulOpLowering.cpp | 10 +++++----- src/compiler/lowering/ModOpLowering.cpp | 10 ++++++---- src/compiler/lowering/PhyOperatorSelectionPass.cpp | 10 ++++++---- src/compiler/lowering/RewriteSqlOpPass.cpp | 8 ++++---- src/compiler/lowering/RewriteToCallKernelOpPass.cpp | 10 ++++++---- .../lowering/SpecializeGenericFunctionsPass.cpp | 8 ++++---- src/compiler/lowering/VectorizeComputationsPass.cpp | 8 ++++---- 13 files changed, 65 insertions(+), 53 deletions(-) diff --git a/src/compiler/lowering/AggAllOpLowering.cpp b/src/compiler/lowering/AggAllOpLowering.cpp index 031f814d0..79e29304a 100644 --- a/src/compiler/lowering/AggAllOpLowering.cpp +++ b/src/compiler/lowering/AggAllOpLowering.cpp @@ -174,7 +174,7 @@ class SumAllOpLowering : public OpConversionPattern { } }; -namespace { +namespace file_local { /** * @brief Lowers the daphne::AggAll operator to a set of affine loops and * performs the aggregation on a MemRef which is created from the input @@ -198,9 +198,9 @@ struct AggAllLoweringPass : public mlir::PassWrapper mlir::daphne::createAggAllOpLoweringPass() { - return std::make_unique(); + return std::make_unique(); } diff --git a/src/compiler/lowering/DaphneOptPass.cpp b/src/compiler/lowering/DaphneOptPass.cpp index 4b4ea2493..006f3536e 100644 --- a/src/compiler/lowering/DaphneOptPass.cpp +++ b/src/compiler/lowering/DaphneOptPass.cpp @@ -43,7 +43,7 @@ class IntegerModOpt : public mlir::OpConversionPattern { } }; -namespace { +namespace file_local { /** * @brief This pass transforms operations (currently limited to the EwModOp) in * the DaphneDialect to a different set of operations also from the @@ -64,9 +64,9 @@ struct DenseMatrixOptPass : public mlir::PassWrapper mlir::daphne::createDaphneOptPass() { return std::make_unique(); } +std::unique_ptr mlir::daphne::createDaphneOptPass() { + return std::make_unique(); +} diff --git a/src/compiler/lowering/DistributeComputationsPass.cpp b/src/compiler/lowering/DistributeComputationsPass.cpp index 8f9428587..34cc372ed 100644 --- a/src/compiler/lowering/DistributeComputationsPass.cpp +++ b/src/compiler/lowering/DistributeComputationsPass.cpp @@ -27,7 +27,7 @@ using namespace mlir; -namespace { +namespace file_local { struct Distribute : public OpInterfaceConversionPattern { using OpInterfaceConversionPattern::OpInterfaceConversionPattern; @@ -71,13 +71,13 @@ struct DistributeComputationsPass : public PassWrappergetOperandTypes(), [](Type t) { return llvm::isa(t); }); } -void DistributeComputationsPass::runOnOperation() { +void file_local::DistributeComputationsPass::runOnOperation() { auto module = getOperation(); RewritePatternSet patterns(&getContext()); @@ -105,5 +105,5 @@ void DistributeComputationsPass::runOnOperation() { } std::unique_ptr daphne::createDistributeComputationsPass() { - return std::make_unique(); + return std::make_unique(); } diff --git a/src/compiler/lowering/EwOpsLowering.cpp b/src/compiler/lowering/EwOpsLowering.cpp index d04960c83..1274e781f 100644 --- a/src/compiler/lowering/EwOpsLowering.cpp +++ b/src/compiler/lowering/EwOpsLowering.cpp @@ -200,7 +200,7 @@ using DivOpLowering = BinaryOpLowering; // clang-format on -namespace { +namespace file_local { /** * @brief This pass lowers element-wise operations to affine loop * structures and arithmetic operations. @@ -223,7 +223,7 @@ struct EwOpLoweringPass : public mlir::PassWrapper mlir::daphne::createEwOpLoweringPass() { return std::make_unique(); } +std::unique_ptr mlir::daphne::createEwOpLoweringPass() { + return std::make_unique(); +} diff --git a/src/compiler/lowering/LowerToLLVMPass.cpp b/src/compiler/lowering/LowerToLLVMPass.cpp index 0f14ab0cf..25823aa7a 100644 --- a/src/compiler/lowering/LowerToLLVMPass.cpp +++ b/src/compiler/lowering/LowerToLLVMPass.cpp @@ -879,7 +879,7 @@ class GenericCallOpLowering : public OpConversionPattern } }; -namespace { +namespace file_local { struct DaphneLowerToLLVMPass : public PassWrapper> { explicit DaphneLowerToLLVMPass(const DaphneUserConfig &cfg) : cfg(cfg) {} const DaphneUserConfig &cfg; @@ -889,9 +889,9 @@ struct DaphneLowerToLLVMPass : public PassWrapper daphne::createLowerToLLVMPass(const DaphneUserConfig &cfg) { - return std::make_unique(cfg); + return std::make_unique(cfg); } diff --git a/src/compiler/lowering/MapOpLowering.cpp b/src/compiler/lowering/MapOpLowering.cpp index fa6ac9016..688233753 100644 --- a/src/compiler/lowering/MapOpLowering.cpp +++ b/src/compiler/lowering/MapOpLowering.cpp @@ -81,7 +81,7 @@ class InlineMapOpLowering : public mlir::OpConversionPattern mlir::daphne::createMapOpLoweringPass() { return std::make_unique(); } +std::unique_ptr mlir::daphne::createMapOpLoweringPass() { + return std::make_unique(); +} diff --git a/src/compiler/lowering/MatMulOpLowering.cpp b/src/compiler/lowering/MatMulOpLowering.cpp index c0aef46db..045c0a6e7 100644 --- a/src/compiler/lowering/MatMulOpLowering.cpp +++ b/src/compiler/lowering/MatMulOpLowering.cpp @@ -606,7 +606,7 @@ class MatMulLowering : public OpConversionPattern { } }; -namespace { +namespace file_local { /** * @brief The MatMulLoweringPass rewrites the MatMulOp from the DaphneDialect * to a affine loop structure implementing a multi tiled loop structure. @@ -663,9 +663,9 @@ struct MatMulLoweringPass : public impl::MatMulOpLoweringPassBase> mlir::daphne::createMatMulOpLoweringPas bool matmul_tile, int matmul_vec_size_bits, std::vector matmul_fixed_tile_sizes, bool matmul_use_fixed_tile_sizes, int matmul_unroll_factor, int matmul_unroll_jam_factor, int matmul_num_vec_registers, bool matmul_invert_loops) { - return std::make_unique( + return std::make_unique( matmul_tile, matmul_vec_size_bits, matmul_fixed_tile_sizes, matmul_use_fixed_tile_sizes, matmul_unroll_factor, matmul_unroll_jam_factor, matmul_num_vec_registers, matmul_invert_loops); } @@ -733,5 +733,5 @@ std::unique_ptr> mlir::daphne::createMatMulOpLoweringPas // This is used by daphne-opt and automatically inserts the options provided on // the command line into the pass. std::unique_ptr> mlir::daphne::createMatMulOpLoweringPass() { - return std::make_unique(); + return std::make_unique(); } diff --git a/src/compiler/lowering/ModOpLowering.cpp b/src/compiler/lowering/ModOpLowering.cpp index 8d047726e..0de777e2a 100644 --- a/src/compiler/lowering/ModOpLowering.cpp +++ b/src/compiler/lowering/ModOpLowering.cpp @@ -128,7 +128,7 @@ class EwModOpLowering : public mlir::OpConversionPattern } }; -namespace { +namespace file_local { /** * @brief Performs an integer mod optimization on the EwModOp operator by * lowering to an affine loop structure and performing the mod op on values @@ -153,9 +153,9 @@ struct ModOpLoweringPass : public mlir::PassWrapper mlir::daphne::createModOpLoweringPass() { return std::make_unique(); } +std::unique_ptr mlir::daphne::createModOpLoweringPass() { + return std::make_unique(); +} diff --git a/src/compiler/lowering/PhyOperatorSelectionPass.cpp b/src/compiler/lowering/PhyOperatorSelectionPass.cpp index 798784df9..969338df5 100644 --- a/src/compiler/lowering/PhyOperatorSelectionPass.cpp +++ b/src/compiler/lowering/PhyOperatorSelectionPass.cpp @@ -64,14 +64,14 @@ class MatMulOpLowering : public OpConversionPattern { } }; -namespace { +namespace file_local { struct PhyOperatorSelectionPass : public PassWrapper> { explicit PhyOperatorSelectionPass() {} void runOnOperation() final; }; -} // end anonymous namespace +} // namespace file_local -void PhyOperatorSelectionPass::runOnOperation() { +void file_local::PhyOperatorSelectionPass::runOnOperation() { auto module = getOperation(); ConversionTarget target(getContext()); @@ -108,4 +108,6 @@ void PhyOperatorSelectionPass::runOnOperation() { signalPassFailure(); } -std::unique_ptr daphne::createPhyOperatorSelectionPass() { return std::make_unique(); } \ No newline at end of file +std::unique_ptr daphne::createPhyOperatorSelectionPass() { + return std::make_unique(); +} \ No newline at end of file diff --git a/src/compiler/lowering/RewriteSqlOpPass.cpp b/src/compiler/lowering/RewriteSqlOpPass.cpp index 02509516e..e399f15e2 100644 --- a/src/compiler/lowering/RewriteSqlOpPass.cpp +++ b/src/compiler/lowering/RewriteSqlOpPass.cpp @@ -33,7 +33,7 @@ using namespace mlir; -namespace { +namespace file_local { std::unordered_map tables; struct SqlReplacement : public RewritePattern { @@ -81,9 +81,9 @@ struct RewriteSqlOpPass : public PassWrapper daphne::createRewriteSqlOpPass() { return std::make_unique(); } +std::unique_ptr daphne::createRewriteSqlOpPass() { return std::make_unique(); } diff --git a/src/compiler/lowering/RewriteToCallKernelOpPass.cpp b/src/compiler/lowering/RewriteToCallKernelOpPass.cpp index f99c9e472..0e537399e 100644 --- a/src/compiler/lowering/RewriteToCallKernelOpPass.cpp +++ b/src/compiler/lowering/RewriteToCallKernelOpPass.cpp @@ -37,7 +37,6 @@ #include #include #include -#include #include #include #include @@ -504,6 +503,7 @@ class DistributedPipelineKernelReplacement : public OpConversionPattern &usedLibPaths, PatternBenefit benefit = 2) @@ -584,7 +584,9 @@ class DistributedPipelineKernelReplacement : public OpConversionPattern> { const DaphneUserConfig &userConfig; std::unordered_map &usedLibPaths; @@ -594,9 +596,9 @@ struct RewriteToCallKernelOpPass : public PassWrapper daphne::createRewriteToCallKernelOpPass(const DaphneUserConfig &cfg, std::unordered_map &usedLibPaths) { - return std::make_unique(cfg, usedLibPaths); + return std::make_unique(cfg, usedLibPaths); } diff --git a/src/compiler/lowering/SpecializeGenericFunctionsPass.cpp b/src/compiler/lowering/SpecializeGenericFunctionsPass.cpp index e6b98bc8a..03e4f4a11 100644 --- a/src/compiler/lowering/SpecializeGenericFunctionsPass.cpp +++ b/src/compiler/lowering/SpecializeGenericFunctionsPass.cpp @@ -33,7 +33,7 @@ using namespace mlir; -namespace { +namespace file_local { /** * @brief Checks if the function is untyped, i.e., if at least one of the inputs @@ -413,7 +413,7 @@ class SpecializeGenericFunctionsPass : public PassWrapper daphne::createSpecializeGenericFunctionsPass(const DaphneUserConfig &cfg) { - return std::make_unique(cfg); + return std::make_unique(cfg); } diff --git a/src/compiler/lowering/VectorizeComputationsPass.cpp b/src/compiler/lowering/VectorizeComputationsPass.cpp index 985c6442e..cfba68d55 100644 --- a/src/compiler/lowering/VectorizeComputationsPass.cpp +++ b/src/compiler/lowering/VectorizeComputationsPass.cpp @@ -28,7 +28,7 @@ using namespace mlir; -namespace { +namespace file_local { /** * @brief Recursive function checking if the given value is transitively * dependant on the operation `op`. @@ -182,9 +182,9 @@ void movePipelineInterleavedOperations(Block::iterator pipelinePosition, struct VectorizeComputationsPass : public PassWrapper> { void runOnOperation() final; }; -} // namespace +} // namespace file_local -void VectorizeComputationsPass::runOnOperation() { +void file_local::VectorizeComputationsPass::runOnOperation() { auto func = getOperation(); // TODO: fuse pipelines that have the matching inputs, even if no output of // the one pipeline is used by the other. @@ -405,5 +405,5 @@ void VectorizeComputationsPass::runOnOperation() { } std::unique_ptr daphne::createVectorizeComputationsPass() { - return std::make_unique(); + return std::make_unique(); }