From 1da7e6236425d40eeb17b8c6d73f6af633c31235 Mon Sep 17 00:00:00 2001 From: Ivan Radanov Ivanov Date: Wed, 6 Sep 2023 13:36:05 +0900 Subject: [PATCH] clang-format --- lib/polygeist/ExecutionEngine/PGORuntime.h | 8 +++--- lib/polygeist/Ops.cpp | 5 ++-- lib/polygeist/Passes/ConvertParallelToGPU.cpp | 26 +++++++++++-------- .../Passes/ConvertPolygeistToLLVM.cpp | 3 ++- lib/polygeist/Passes/LowerAlternatives.cpp | 5 ++-- lib/polygeist/Passes/ParallelLower.cpp | 11 +++++--- 6 files changed, 32 insertions(+), 26 deletions(-) diff --git a/lib/polygeist/ExecutionEngine/PGORuntime.h b/lib/polygeist/ExecutionEngine/PGORuntime.h index 478ccc4d156c..f4b6422fba9d 100644 --- a/lib/polygeist/ExecutionEngine/PGORuntime.h +++ b/lib/polygeist/ExecutionEngine/PGORuntime.h @@ -4,15 +4,15 @@ // PGO functions which should know whether the code in the alternatives op is // GPU code - we can add an attrib to the alternatives op for that +#include #include #include #include #include #include -#include #include -#include #include +#include extern "C" int32_t mgpurtDeviceSynchronizeErr(void); @@ -31,9 +31,7 @@ class PGOState { struct Logger { std::map> timings; - ~Logger() { - PGOState::writeResults(); - } + ~Logger() { PGOState::writeResults(); } }; inline static int alternative; diff --git a/lib/polygeist/Ops.cpp b/lib/polygeist/Ops.cpp index 2072997e67af..ffda8c8a83dd 100644 --- a/lib/polygeist/Ops.cpp +++ b/lib/polygeist/Ops.cpp @@ -108,8 +108,8 @@ LogicalResult GetDeviceGlobalOp::verifySymbolUses(SymbolTableCollection &symbolTable) { // Verify that the result type is same as the type of the referenced // memref.global op. - auto global = - symbolTable.lookupNearestSymbolFrom(*this, getNameAttr()); + auto global = symbolTable.lookupNearestSymbolFrom( + *this, getNameAttr()); if (!global) return emitOpError("'") << getName() << "' does not reference a valid global memref"; @@ -122,7 +122,6 @@ GetDeviceGlobalOp::verifySymbolUses(SymbolTableCollection &symbolTable) { return success(); } - //===----------------------------------------------------------------------===// // GPUErrorOp //===----------------------------------------------------------------------===// diff --git a/lib/polygeist/Passes/ConvertParallelToGPU.cpp b/lib/polygeist/Passes/ConvertParallelToGPU.cpp index 5c551f47517a..5a330ce9a784 100644 --- a/lib/polygeist/Passes/ConvertParallelToGPU.cpp +++ b/lib/polygeist/Passes/ConvertParallelToGPU.cpp @@ -1725,7 +1725,8 @@ struct ConvertParallelToGPU1Pass }); }; - auto getBlockUnrollFactors = [&](uint64_t unrollFactor, unsigned gridDims) { + auto getBlockUnrollFactors = [&](uint64_t unrollFactor, + unsigned gridDims) { std::vector divisors; for (unsigned i = 2; unrollFactor != 1; ++i) { while (unrollFactor % i == 0) { @@ -1745,7 +1746,8 @@ struct ConvertParallelToGPU1Pass llvm::errs() << "\n"; return unrollFactors; }; - auto getThreadUnrollFactors = [&](unsigned unrollFactor, unsigned blockDims) { + auto getThreadUnrollFactors = [&](unsigned unrollFactor, + unsigned blockDims) { unsigned powsOf2 = std::log2(unrollFactor); unsigned initial = std::pow(2, powsOf2 / blockDims); unsigned currentFactor = 1; @@ -1802,9 +1804,11 @@ struct ConvertParallelToGPU1Pass int gridDims = ubs.size(); assert(gridDims >= 1 && gridDims <= 3); - SmallVector blockUnrollFactors = convertToFactors(coarsenBlocks, gridDims, getBlockUnrollFactors); + SmallVector blockUnrollFactors = + convertToFactors(coarsenBlocks, gridDims, getBlockUnrollFactors); - if (blockUnrollFactors != noCoarsening && isValid(blockUnrollFactors)) { + if (blockUnrollFactors != noCoarsening && + isValid(blockUnrollFactors)) { if (polygeist::scfParallelUnrollByFactors( gridPop, ArrayRef(blockUnrollFactors), /* generateEpilogueLoop */ true, @@ -1819,9 +1823,11 @@ struct ConvertParallelToGPU1Pass int blockDims = ubs.size(); assert(blockDims >= 1 && blockDims <= 3); - SmallVector threadUnrollFactors = convertToFactors(coarsenThreads, blockDims, getThreadUnrollFactors); + SmallVector threadUnrollFactors = convertToFactors( + coarsenThreads, blockDims, getThreadUnrollFactors); - if (threadUnrollFactors != noCoarsening && isValid(threadUnrollFactors)) { + if (threadUnrollFactors != noCoarsening && + isValid(threadUnrollFactors)) { // TODO We kind of assume that the upper bounds will be divisible by // the factors and in that case this will succeed if the upper // bounds are dynamic - we need to insert runtime checks and @@ -2169,16 +2175,14 @@ struct ConvertParallelToGPU2Pass void runOnOperation() override { std::vector gdgops; - getOperation()->walk([&](polygeist::GetDeviceGlobalOp gdgo) { - gdgops.push_back(gdgo); - }); + getOperation()->walk( + [&](polygeist::GetDeviceGlobalOp gdgo) { gdgops.push_back(gdgo); }); for (auto gdgo : gdgops) { auto builder = OpBuilder(gdgo); auto ggo = builder.create( - gdgo->getLoc(), gdgo.getType(), gdgo.getNameAttr()); + gdgo->getLoc(), gdgo.getType(), gdgo.getNameAttr()); gdgo->replaceAllUsesWith(ggo); gdgo->erase(); - } RewritePatternSet patterns(&getContext()); diff --git a/lib/polygeist/Passes/ConvertPolygeistToLLVM.cpp b/lib/polygeist/Passes/ConvertPolygeistToLLVM.cpp index 37f64581c37e..b427dbe8dfa7 100644 --- a/lib/polygeist/Passes/ConvertPolygeistToLLVM.cpp +++ b/lib/polygeist/Passes/ConvertPolygeistToLLVM.cpp @@ -1449,7 +1449,8 @@ struct LowerGPUAlternativesOp return failure(); Location loc = gao->getLoc(); - std::string locStr = gao->getAttrOfType("polygeist.altop.id").data(); + std::string locStr = + gao->getAttrOfType("polygeist.altop.id").data(); auto descs = gao->getAttrOfType("alternatives.descs"); diff --git a/lib/polygeist/Passes/LowerAlternatives.cpp b/lib/polygeist/Passes/LowerAlternatives.cpp index 20409d6349e2..27cc1794b816 100644 --- a/lib/polygeist/Passes/LowerAlternatives.cpp +++ b/lib/polygeist/Passes/LowerAlternatives.cpp @@ -6,11 +6,11 @@ #include "mlir/Transforms/RegionUtils.h" #include "polygeist/Passes/Passes.h" +#include #include #include #include #include -#include #include "polygeist/Ops.h" #include "polygeist/Passes/Passes.h" @@ -169,7 +169,8 @@ struct LowerAlternativesPass for (char &c : locStr) if (c == '/') c = '+'; - altOp->setAttr("polygeist.altop.id", StringAttr::get(&getContext(), locStr)); + altOp->setAttr("polygeist.altop.id", + StringAttr::get(&getContext(), locStr)); }); if (PolygeistAlternativesMode == PAM_PGO_Opt) { diff --git a/lib/polygeist/Passes/ParallelLower.cpp b/lib/polygeist/Passes/ParallelLower.cpp index 1be327eb7f4e..42dadeabb677 100644 --- a/lib/polygeist/Passes/ParallelLower.cpp +++ b/lib/polygeist/Passes/ParallelLower.cpp @@ -624,16 +624,19 @@ void ParallelLower::runOnOperation() { // If we are compiling for GPU if (gpuKernelStructureMode != PGSM_Discard) { - // Tag device side get globals with an attribute so that CSE does not decide - // to reuse the host side get global for the device + // Tag device side get globals with an attribute so that CSE does not + // decide to reuse the host side get global for the device std::vector ggops; container.walk([&](mlir::memref::GetGlobalOp getGlobalOp) { ggops.push_back(getGlobalOp); }); for (auto ggo : ggops) { builder.setInsertionPoint(ggo); - builder.replaceOp(ggo, builder.create( - ggo->getLoc(), ggo.getType(), ggo.getNameAttr())->getResults()); + builder.replaceOp( + ggo, builder + .create( + ggo->getLoc(), ggo.getType(), ggo.getNameAttr()) + ->getResults()); } }