From 4ead2cf76c4a1df260e7dff0fa767074bae6e2b8 Mon Sep 17 00:00:00 2001 From: Alex Zinenko Date: Thu, 14 May 2020 14:41:35 +0200 Subject: [PATCH] [mlir] Rename conversions involving ex-Loop dialect to mention SCF The following Conversions are affected: LoopToStandard -> SCFToStandard, LoopsToGPU -> SCFToGPU, VectorToLoops -> VectorToSCF. Full file paths are affected. Additionally, drop the 'Convert' prefix from filenames living under lib/Conversion where applicable. API names and CLI options for pass testing are also renamed when applicable. In particular, LoopsToGPU contains several passes that apply to different kinds of loops (`for` or `parallel`), for which the original names are preserved. Differential Revision: https://reviews.llvm.org/D79940 --- flang/tools/tco/CMakeLists.txt | 2 +- mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp | 2 +- mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp | 2 +- mlir/include/mlir/Conversion/Passes.td | 12 ++++++------ .../{LoopsToGPU/LoopsToGPU.h => SCFToGPU/SCFToGPU.h} | 8 ++++---- .../LoopsToGPUPass.h => SCFToGPU/SCFToGPUPass.h} | 9 +++++---- .../SCFToStandard.h} | 8 ++++---- .../VectorToSCF.h} | 12 ++++++------ mlir/include/mlir/Dialect/GPU/ParallelLoopMapper.h | 2 +- mlir/include/mlir/Dialect/Vector/VectorTransforms.h | 2 +- mlir/include/mlir/InitAllPasses.h | 4 ++-- mlir/lib/Conversion/CMakeLists.txt | 6 +++--- mlir/lib/Conversion/LinalgToLLVM/CMakeLists.txt | 6 +++--- mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp | 6 +++--- .../Conversion/{LoopsToGPU => SCFToGPU}/CMakeLists.txt | 8 ++++---- .../LoopsToGPU.cpp => SCFToGPU/SCFToGPU.cpp} | 4 ++-- .../LoopsToGPUPass.cpp => SCFToGPU/SCFToGPUPass.cpp} | 17 ++++++++--------- .../{LoopToStandard => SCFToStandard}/CMakeLists.txt | 6 +++--- .../SCFToStandard.cpp} | 11 +++++------ .../{VectorToLoops => VectorToSCF}/CMakeLists.txt | 6 +++--- .../VectorToSCF.cpp} | 6 +++--- mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp | 2 +- mlir/lib/Dialect/Vector/VectorTransforms.cpp | 2 +- mlir/test/Conversion/LoopsToGPU/linalg_to_gpu.mlir | 2 +- .../Conversion/LoopsToGPU/no_blocks_no_threads.mlir | 4 ++-- mlir/test/Conversion/LoopsToGPU/step_one.mlir | 4 ++-- mlir/test/Conversion/LoopsToGPU/step_positive.mlir | 2 +- mlir/test/Conversion/VectorToLoops/vector-to-loops.mlir | 2 +- mlir/test/Conversion/convert-to-cfg.mlir | 2 +- mlir/test/lib/Transforms/CMakeLists.txt | 4 ++-- mlir/test/lib/Transforms/TestGpuParallelLoopMapping.cpp | 2 +- ...oopsConversion.cpp => TestVectorToSCFConversion.cpp} | 16 ++++++++-------- mlir/test/mlir-cpu-runner/bare_ptr_call_conv.mlir | 2 +- mlir/test/mlir-cpu-runner/sgemm_naive_codegen.mlir | 2 +- mlir/tools/mlir-opt/mlir-opt.cpp | 4 ++-- 35 files changed, 94 insertions(+), 95 deletions(-) rename mlir/include/mlir/Conversion/{LoopsToGPU/LoopsToGPU.h => SCFToGPU/SCFToGPU.h} (94%) rename mlir/include/mlir/Conversion/{LoopsToGPU/LoopsToGPUPass.h => SCFToGPU/SCFToGPUPass.h} (89%) rename mlir/include/mlir/Conversion/{LoopToStandard/ConvertLoopToStandard.h => SCFToStandard/SCFToStandard.h} (79%) rename mlir/include/mlir/Conversion/{VectorToLoops/ConvertVectorToLoops.h => VectorToSCF/VectorToSCF.h} (52%) rename mlir/lib/Conversion/{LoopsToGPU => SCFToGPU}/CMakeLists.txt (62%) rename mlir/lib/Conversion/{LoopsToGPU/LoopsToGPU.cpp => SCFToGPU/SCFToGPU.cpp} (99%) rename mlir/lib/Conversion/{LoopsToGPU/LoopsToGPUPass.cpp => SCFToGPU/SCFToGPUPass.cpp} (89%) rename mlir/lib/Conversion/{LoopToStandard => SCFToStandard}/CMakeLists.txt (52%) rename mlir/lib/Conversion/{LoopToStandard/LoopToStandard.cpp => SCFToStandard/SCFToStandard.cpp} (98%) rename mlir/lib/Conversion/{VectorToLoops => VectorToSCF}/CMakeLists.txt (50%) rename mlir/lib/Conversion/{VectorToLoops/ConvertVectorToLoops.cpp => VectorToSCF/VectorToSCF.cpp} (99%) rename mlir/test/lib/Transforms/{TestVectorToLoopsConversion.cpp => TestVectorToSCFConversion.cpp} (64%) diff --git a/flang/tools/tco/CMakeLists.txt b/flang/tools/tco/CMakeLists.txt index 451952b..f893af2 100644 --- a/flang/tools/tco/CMakeLists.txt +++ b/flang/tools/tco/CMakeLists.txt @@ -11,7 +11,7 @@ set(LIBS MLIRTransforms MLIRAffineToStandard MLIRAnalysis - MLIRLoopToStandard + MLIRSCFToStandard MLIREDSC MLIRParser MLIRStandardToLLVM diff --git a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp index 65ba25e..58458ff 100644 --- a/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch6/mlir/LowerToLLVM.cpp @@ -16,7 +16,7 @@ #include "toy/Passes.h" #include "mlir/Conversion/AffineToStandard/AffineToStandard.h" -#include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" +#include "mlir/Conversion/SCFToStandard/SCFToStandard.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" diff --git a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp index 65ba25e..58458ff 100644 --- a/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp +++ b/mlir/examples/toy/Ch7/mlir/LowerToLLVM.cpp @@ -16,7 +16,7 @@ #include "toy/Passes.h" #include "mlir/Conversion/AffineToStandard/AffineToStandard.h" -#include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" +#include "mlir/Conversion/SCFToStandard/SCFToStandard.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td index f0724b2..ea4ea84 100644 --- a/mlir/include/mlir/Conversion/Passes.td +++ b/mlir/include/mlir/Conversion/Passes.td @@ -161,22 +161,22 @@ def ConvertLinalgToSPIRV : Pass<"convert-linalg-to-spirv", "ModuleOp"> { } //===----------------------------------------------------------------------===// -// LoopToStandard +// SCFToStandard //===----------------------------------------------------------------------===// -def ConvertLoopToStandard : Pass<"convert-loop-to-std"> { +def SCFToStandard : Pass<"convert-scf-to-std"> { let summary = "Convert SCF dialect to Standard dialect, replacing structured" " control flow with a CFG"; let constructor = "mlir::createLowerToCFGPass()"; } //===----------------------------------------------------------------------===// -// LoopsToGPU +// SCFToGPU //===----------------------------------------------------------------------===// -def ConvertSimpleLoopsToGPU : FunctionPass<"convert-loops-to-gpu"> { +def ConvertSimpleSCFToGPU : FunctionPass<"convert-scf-to-gpu"> { let summary = "Convert top-level loops to GPU kernels"; - let constructor = "mlir::createSimpleLoopsToGPUPass()"; + let constructor = "mlir::createSimpleSCFToGPUPass()"; let options = [ Option<"numBlockDims", "gpu-block-dims", "unsigned", /*default=*/"1u", "Number of GPU block dimensions for mapping">, @@ -185,7 +185,7 @@ def ConvertSimpleLoopsToGPU : FunctionPass<"convert-loops-to-gpu"> { ]; } -def ConvertLoopsToGPU : FunctionPass<"convert-loop-op-to-gpu"> { +def ConvertSCFToGPU : FunctionPass<"convert-loop-op-to-gpu"> { let summary = "Convert top-level scf::ForOp to GPU kernels"; let constructor = "mlir::createLoopToGPUPass()"; let options = [ diff --git a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h b/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPU.h similarity index 94% rename from mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h rename to mlir/include/mlir/Conversion/SCFToGPU/SCFToGPU.h index a3be39b..02e3a02 100644 --- a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPU.h +++ b/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPU.h @@ -1,12 +1,12 @@ -//===- LoopsToGPU.h - Convert loop nests to GPU kernels ---------*- C++ -*-===// +//===- SCFToGPU.h - Convert loop nests to GPU kernels -----------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// -#ifndef MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPU_H_ -#define MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPU_H_ +#ifndef MLIR_CONVERSION_SCFTOGPU_SCFTOGPU_H_ +#define MLIR_CONVERSION_SCFTOGPU_SCFTOGPU_H_ #include "mlir/Support/LLVM.h" @@ -81,4 +81,4 @@ void populateParallelLoopToGPUPatterns(OwningRewritePatternList &patterns, } // namespace mlir -#endif // MLIR_CONVERSION_LOOPSTOGPU_LOOPSTOGPU_H_ +#endif // MLIR_CONVERSION_SCFTOGPU_SCFTOGPU_H_ diff --git a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h b/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPUPass.h similarity index 89% rename from mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h rename to mlir/include/mlir/Conversion/SCFToGPU/SCFToGPUPass.h index 5e56bc8..930380e 100644 --- a/mlir/include/mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h +++ b/mlir/include/mlir/Conversion/SCFToGPU/SCFToGPUPass.h @@ -1,4 +1,4 @@ -//===- LoopsToGPUPass.h - Pass converting loops to GPU kernels --*- C++ -*-===// +//===- SCFToGPUPass.h - Pass converting loops to GPU kernels ----*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -14,7 +14,8 @@ namespace mlir { class FuncOp; -template class OperationPass; +template +class OperationPass; class Pass; /// Create a pass that converts loop nests into GPU kernels. It considers @@ -26,8 +27,8 @@ class Pass; /// to strip-mine the loops and to perform the dependence analysis before /// calling the conversion. std::unique_ptr> -createSimpleLoopsToGPUPass(unsigned numBlockDims, unsigned numThreadDims); -std::unique_ptr> createSimpleLoopsToGPUPass(); +createSimpleSCFToGPUPass(unsigned numBlockDims, unsigned numThreadDims); +std::unique_ptr> createSimpleSCFToGPUPass(); /// Create a pass that converts every loop operation within the body of the /// FuncOp into a GPU launch. The number of workgroups and workgroup size for diff --git a/mlir/include/mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h b/mlir/include/mlir/Conversion/SCFToStandard/SCFToStandard.h similarity index 79% rename from mlir/include/mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h rename to mlir/include/mlir/Conversion/SCFToStandard/SCFToStandard.h index 5e6d674..fd85a3d 100644 --- a/mlir/include/mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h +++ b/mlir/include/mlir/Conversion/SCFToStandard/SCFToStandard.h @@ -1,4 +1,4 @@ -//===- ConvertLoopToStandard.h - Pass entrypoint ----------------*- C++ -*-===// +//===- ConvertSCFToStandard.h - Pass entrypoint -----------------*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,8 +6,8 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_CONVERSION_LOOPTOSTANDARD_CONVERTLOOPTOSTANDARD_H_ -#define MLIR_CONVERSION_LOOPTOSTANDARD_CONVERTLOOPTOSTANDARD_H_ +#ifndef MLIR_CONVERSION_SCFTOSTANDARD_SCFTOSTANDARD_H_ +#define MLIR_CONVERSION_SCFTOSTANDARD_SCFTOSTANDARD_H_ #include #include @@ -32,4 +32,4 @@ std::unique_ptr createLowerToCFGPass(); } // namespace mlir -#endif // MLIR_CONVERSION_LOOPTOSTANDARD_CONVERTLOOPTOSTANDARD_H_ +#endif // MLIR_CONVERSION_SCFTOSTANDARD_SCFTOSTANDARD_H_ diff --git a/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h b/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h similarity index 52% rename from mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h rename to mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h index 61d4de7..976751e 100644 --- a/mlir/include/mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h +++ b/mlir/include/mlir/Conversion/VectorToSCF/VectorToSCF.h @@ -1,4 +1,4 @@ -//===- ConvertVectorToLoops.h - Utils to convert from the vector dialect --===// +//===- VectorToSCF.h - Utils to convert from the vector dialect -*- C++ -*-===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,17 +6,17 @@ // //===----------------------------------------------------------------------===// -#ifndef MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLOOPS_H_ -#define MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLOOPS_H_ +#ifndef MLIR_CONVERSION_VECTORTOSCF_VECTORTOSCF_H_ +#define MLIR_CONVERSION_VECTORTOSCF_VECTORTOSCF_H_ namespace mlir { class MLIRContext; class OwningRewritePatternList; /// Collect a set of patterns to convert from the Vector dialect to loops + std. -void populateVectorToLoopsConversionPatterns(OwningRewritePatternList &patterns, - MLIRContext *context); +void populateVectorToSCFConversionPatterns(OwningRewritePatternList &patterns, + MLIRContext *context); } // namespace mlir -#endif // MLIR_CONVERSION_VECTORTOLLVM_CONVERTVECTORTOLOOPS_H_ +#endif // MLIR_CONVERSION_VECTORTOSCF_VECTORTOSCF_H_ diff --git a/mlir/include/mlir/Dialect/GPU/ParallelLoopMapper.h b/mlir/include/mlir/Dialect/GPU/ParallelLoopMapper.h index 8dd7c7f..842734d 100644 --- a/mlir/include/mlir/Dialect/GPU/ParallelLoopMapper.h +++ b/mlir/include/mlir/Dialect/GPU/ParallelLoopMapper.h @@ -63,7 +63,7 @@ LogicalResult setMappingAttr(scf::ParallelOp ploopOp, /// encountered to the local workgroup. Within each mapping, the first three /// dimensions are mapped to x/y/z hardware ids and all following dimensions are /// mapped to sequential loops. -void greedilyMapParallelLoopsToGPU(Region ®ion); +void greedilyMapParallelSCFToGPU(Region ®ion); } // end namespace mlir #endif // MLIR_DIALECT_GPU_PARALLELLOOPMAPPER_H diff --git a/mlir/include/mlir/Dialect/Vector/VectorTransforms.h b/mlir/include/mlir/Dialect/Vector/VectorTransforms.h index d2858b8..a7325ce 100644 --- a/mlir/include/mlir/Dialect/Vector/VectorTransforms.h +++ b/mlir/include/mlir/Dialect/Vector/VectorTransforms.h @@ -16,7 +16,7 @@ class MLIRContext; class OwningRewritePatternList; /// Collect a set of patterns to convert from the Vector dialect to itself. -/// Should be merged with populateVectorToLoopsLoweringPattern. +/// Should be merged with populateVectorToSCFLoweringPattern. void populateVectorToVectorConversionPatterns( MLIRContext *context, OwningRewritePatternList &patterns, ArrayRef coarseVectorShape = {}, diff --git a/mlir/include/mlir/InitAllPasses.h b/mlir/include/mlir/InitAllPasses.h index 26c1162..5b5f72f 100644 --- a/mlir/include/mlir/InitAllPasses.h +++ b/mlir/include/mlir/InitAllPasses.h @@ -23,8 +23,8 @@ #include "mlir/Conversion/LinalgToLLVM/LinalgToLLVM.h" #include "mlir/Conversion/LinalgToSPIRV/LinalgToSPIRVPass.h" #include "mlir/Conversion/LinalgToStandard/LinalgToStandard.h" -#include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" -#include "mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h" +#include "mlir/Conversion/SCFToGPU/SCFToGPUPass.h" +#include "mlir/Conversion/SCFToStandard/SCFToStandard.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Conversion/StandardToSPIRV/ConvertStandardToSPIRVPass.h" #include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h" diff --git a/mlir/lib/Conversion/CMakeLists.txt b/mlir/lib/Conversion/CMakeLists.txt index 3ac3b11..d78fb89 100644 --- a/mlir/lib/Conversion/CMakeLists.txt +++ b/mlir/lib/Conversion/CMakeLists.txt @@ -8,9 +8,9 @@ add_subdirectory(GPUToVulkan) add_subdirectory(LinalgToLLVM) add_subdirectory(LinalgToSPIRV) add_subdirectory(LinalgToStandard) -add_subdirectory(LoopsToGPU) -add_subdirectory(LoopToStandard) +add_subdirectory(SCFToGPU) +add_subdirectory(SCFToStandard) add_subdirectory(StandardToLLVM) add_subdirectory(StandardToSPIRV) add_subdirectory(VectorToLLVM) -add_subdirectory(VectorToLoops) +add_subdirectory(VectorToSCF) diff --git a/mlir/lib/Conversion/LinalgToLLVM/CMakeLists.txt b/mlir/lib/Conversion/LinalgToLLVM/CMakeLists.txt index 45b60c7..d507b41 100644 --- a/mlir/lib/Conversion/LinalgToLLVM/CMakeLists.txt +++ b/mlir/lib/Conversion/LinalgToLLVM/CMakeLists.txt @@ -17,9 +17,9 @@ add_mlir_conversion_library(MLIRLinalgToLLVM MLIRIR MLIRLinalgOps MLIRLLVMIR - MLIRLoopToStandard + MLIRSCFToStandard MLIRStandardToLLVM - MLIRVectorToLLVM - MLIRVectorToLoops MLIRTransforms + MLIRVectorToLLVM + MLIRVectorToSCF ) diff --git a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp index 68ac974..6dbe563 100644 --- a/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp +++ b/mlir/lib/Conversion/LinalgToLLVM/LinalgToLLVM.cpp @@ -10,11 +10,11 @@ #include "../PassDetail.h" #include "mlir/Conversion/AffineToStandard/AffineToStandard.h" -#include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" +#include "mlir/Conversion/SCFToStandard/SCFToStandard.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVM.h" #include "mlir/Conversion/StandardToLLVM/ConvertStandardToLLVMPass.h" #include "mlir/Conversion/VectorToLLVM/ConvertVectorToLLVM.h" -#include "mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h" +#include "mlir/Conversion/VectorToSCF/VectorToSCF.h" #include "mlir/Dialect/LLVMIR/LLVMDialect.h" #include "mlir/Dialect/Linalg/IR/LinalgOps.h" #include "mlir/Dialect/Linalg/IR/LinalgTypes.h" @@ -377,7 +377,7 @@ void ConvertLinalgToLLVMPass::runOnOperation() { populateAffineToStdConversionPatterns(patterns, &getContext()); populateLoopToStdConversionPatterns(patterns, &getContext()); populateStdToLLVMConversionPatterns(converter, patterns); - populateVectorToLoopsConversionPatterns(patterns, &getContext()); + populateVectorToSCFConversionPatterns(patterns, &getContext()); populateVectorToLLVMMatrixConversionPatterns(converter, patterns); populateVectorToLLVMConversionPatterns(converter, patterns); populateLinalgToLLVMConversionPatterns(converter, patterns, &getContext()); diff --git a/mlir/lib/Conversion/LoopsToGPU/CMakeLists.txt b/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt similarity index 62% rename from mlir/lib/Conversion/LoopsToGPU/CMakeLists.txt rename to mlir/lib/Conversion/SCFToGPU/CMakeLists.txt index 9b4e184..1da4dac 100644 --- a/mlir/lib/Conversion/LoopsToGPU/CMakeLists.txt +++ b/mlir/lib/Conversion/SCFToGPU/CMakeLists.txt @@ -1,9 +1,9 @@ -add_mlir_conversion_library(MLIRLoopsToGPU - LoopsToGPU.cpp - LoopsToGPUPass.cpp +add_mlir_conversion_library(MLIRSCFToGPU + SCFToGPU.cpp + SCFToGPUPass.cpp ADDITIONAL_HEADER_DIRS - ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/LoopsToGPU + ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/SCFToGPU DEPENDS MLIRConversionPassIncGen diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp similarity index 99% rename from mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp rename to mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp index 84cbf1b..034cd1e 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPU.cpp +++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPU.cpp @@ -1,4 +1,4 @@ -//===- LoopsToGPU.cpp - Convert an affine loop nest to a GPU kernel -------===// +//===- SCFToGPU.cpp - Convert an affine loop nest to a GPU kernel -------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -12,7 +12,7 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Conversion/LoopsToGPU/LoopsToGPU.h" +#include "mlir/Conversion/SCFToGPU/SCFToGPU.h" #include "mlir/Conversion/AffineToStandard/AffineToStandard.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" diff --git a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp b/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp similarity index 89% rename from mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp rename to mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp index 71aefe7..e8c4e76 100644 --- a/mlir/lib/Conversion/LoopsToGPU/LoopsToGPUPass.cpp +++ b/mlir/lib/Conversion/SCFToGPU/SCFToGPUPass.cpp @@ -1,4 +1,4 @@ -//===- LoopsToGPUPass.cpp - Convert a loop nest to a GPU kernel -----------===// +//===- SCFToGPUPass.cpp - Convert a loop nest to a GPU kernel -----------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -6,9 +6,9 @@ // //===----------------------------------------------------------------------===// -#include "mlir/Conversion/LoopsToGPU/LoopsToGPUPass.h" +#include "mlir/Conversion/SCFToGPU/SCFToGPUPass.h" #include "../PassDetail.h" -#include "mlir/Conversion/LoopsToGPU/LoopsToGPU.h" +#include "mlir/Conversion/SCFToGPU/SCFToGPU.h" #include "mlir/Dialect/Affine/IR/AffineOps.h" #include "mlir/Dialect/GPU/GPUDialect.h" #include "mlir/Dialect/SCF/SCF.h" @@ -18,7 +18,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/CommandLine.h" -#define PASS_NAME "convert-loops-to-gpu" +#define PASS_NAME "convert-scf-to-gpu" #define LOOPOP_TO_GPU_PASS_NAME "convert-loop-op-to-gpu" using namespace mlir; @@ -28,7 +28,7 @@ namespace { // A pass that traverses top-level loops in the function and converts them to // GPU launch operations. Nested launches are not allowed, so this does not // walk the function recursively to avoid considering nested loops. -struct ForLoopMapper : public ConvertSimpleLoopsToGPUBase { +struct ForLoopMapper : public ConvertSimpleSCFToGPUBase { ForLoopMapper() = default; ForLoopMapper(unsigned numBlockDims, unsigned numThreadDims) { this->numBlockDims = numBlockDims; @@ -56,7 +56,7 @@ struct ForLoopMapper : public ConvertSimpleLoopsToGPUBase { // nested loops as the size of `numWorkGroups`. Within these any loop nest has // to be perfectly nested upto depth equal to size of `workGroupSize`. struct ImperfectlyNestedForLoopMapper - : public ConvertLoopsToGPUBase { + : public ConvertSCFToGPUBase { ImperfectlyNestedForLoopMapper() = default; ImperfectlyNestedForLoopMapper(ArrayRef numWorkGroups, ArrayRef workGroupSize) { @@ -108,11 +108,10 @@ struct ParallelLoopToGpuPass } // namespace std::unique_ptr> -mlir::createSimpleLoopsToGPUPass(unsigned numBlockDims, - unsigned numThreadDims) { +mlir::createSimpleSCFToGPUPass(unsigned numBlockDims, unsigned numThreadDims) { return std::make_unique(numBlockDims, numThreadDims); } -std::unique_ptr> mlir::createSimpleLoopsToGPUPass() { +std::unique_ptr> mlir::createSimpleSCFToGPUPass() { return std::make_unique(); } diff --git a/mlir/lib/Conversion/LoopToStandard/CMakeLists.txt b/mlir/lib/Conversion/SCFToStandard/CMakeLists.txt similarity index 52% rename from mlir/lib/Conversion/LoopToStandard/CMakeLists.txt rename to mlir/lib/Conversion/SCFToStandard/CMakeLists.txt index 89d8cb9..a9447ea 100644 --- a/mlir/lib/Conversion/LoopToStandard/CMakeLists.txt +++ b/mlir/lib/Conversion/SCFToStandard/CMakeLists.txt @@ -1,8 +1,8 @@ -add_mlir_conversion_library(MLIRLoopToStandard - LoopToStandard.cpp +add_mlir_conversion_library(MLIRSCFToStandard + SCFToStandard.cpp ADDITIONAL_HEADER_DIRS - ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/LoopToStandard + ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/SCFToStandard DEPENDS MLIRConversionPassIncGen diff --git a/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp b/mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp similarity index 98% rename from mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp rename to mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp index d064ad2..96fdaf3 100644 --- a/mlir/lib/Conversion/LoopToStandard/LoopToStandard.cpp +++ b/mlir/lib/Conversion/SCFToStandard/SCFToStandard.cpp @@ -1,4 +1,4 @@ -//===- LoopToStandard.cpp - ControlFlow to CFG conversion -----------------===// +//===- SCFToStandard.cpp - ControlFlow to CFG conversion ------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -11,8 +11,8 @@ // //===----------------------------------------------------------------------===// +#include "mlir/Conversion/SCFToStandard/SCFToStandard.h" #include "../PassDetail.h" -#include "mlir/Conversion/LoopToStandard/ConvertLoopToStandard.h" #include "mlir/Dialect/SCF/SCF.h" #include "mlir/Dialect/StandardOps/IR/Ops.h" #include "mlir/IR/BlockAndValueMapping.h" @@ -29,8 +29,7 @@ using namespace mlir::scf; namespace { -struct LoopToStandardPass - : public ConvertLoopToStandardBase { +struct SCFToStandardPass : public SCFToStandardBase { void runOnOperation() override; }; @@ -405,7 +404,7 @@ void mlir::populateLoopToStdConversionPatterns( patterns.insert(ctx); } -void LoopToStandardPass::runOnOperation() { +void SCFToStandardPass::runOnOperation() { OwningRewritePatternList patterns; populateLoopToStdConversionPatterns(patterns, &getContext()); ConversionTarget target(getContext()); @@ -415,5 +414,5 @@ void LoopToStandardPass::runOnOperation() { } std::unique_ptr mlir::createLowerToCFGPass() { - return std::make_unique(); + return std::make_unique(); } diff --git a/mlir/lib/Conversion/VectorToLoops/CMakeLists.txt b/mlir/lib/Conversion/VectorToSCF/CMakeLists.txt similarity index 50% rename from mlir/lib/Conversion/VectorToLoops/CMakeLists.txt rename to mlir/lib/Conversion/VectorToSCF/CMakeLists.txt index 08cbc39..d6bc8da 100644 --- a/mlir/lib/Conversion/VectorToLoops/CMakeLists.txt +++ b/mlir/lib/Conversion/VectorToSCF/CMakeLists.txt @@ -1,8 +1,8 @@ -add_mlir_conversion_library(MLIRVectorToLoops - ConvertVectorToLoops.cpp +add_mlir_conversion_library(MLIRVectorToSCF + VectorToSCF.cpp ADDITIONAL_HEADER_DIRS - ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/VectorToLoops + ${MLIR_MAIN_INCLUDE_DIR}/mlir/Conversion/VectorToSCF LINK_COMPONENTS Core diff --git a/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp similarity index 99% rename from mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp rename to mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp index ad57355..c9cd605 100644 --- a/mlir/lib/Conversion/VectorToLoops/ConvertVectorToLoops.cpp +++ b/mlir/lib/Conversion/VectorToSCF/VectorToSCF.cpp @@ -1,4 +1,4 @@ -//===- VectorToLoops.cpp - Conversion from Vector to mix of Loops and Std -===// +//===- VectorToSCF.cpp - Conversion from Vector to mix of SCF and Std -----===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -12,7 +12,7 @@ #include -#include "mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h" +#include "mlir/Conversion/VectorToSCF/VectorToSCF.h" #include "mlir/Dialect/Affine/EDSC/Intrinsics.h" #include "mlir/Dialect/SCF/EDSC/Builders.h" #include "mlir/Dialect/SCF/EDSC/Intrinsics.h" @@ -583,7 +583,7 @@ LogicalResult VectorTransferRewriter::matchAndRewrite( } // namespace -void mlir::populateVectorToLoopsConversionPatterns( +void mlir::populateVectorToSCFConversionPatterns( OwningRewritePatternList &patterns, MLIRContext *context) { patterns.insert, VectorTransferRewriter>(context); diff --git a/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp b/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp index bf079f7..85609aa 100644 --- a/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp +++ b/mlir/lib/Dialect/GPU/Transforms/ParallelLoopMapper.cpp @@ -146,6 +146,6 @@ static void mapParallelOp(ParallelOp parallelOp, } } -void mlir::greedilyMapParallelLoopsToGPU(Region ®ion) { +void mlir::greedilyMapParallelSCFToGPU(Region ®ion) { region.walk([](ParallelOp parallelOp) { mapParallelOp(parallelOp); }); } diff --git a/mlir/lib/Dialect/Vector/VectorTransforms.cpp b/mlir/lib/Dialect/Vector/VectorTransforms.cpp index ef536e2..4f8e237 100644 --- a/mlir/lib/Dialect/Vector/VectorTransforms.cpp +++ b/mlir/lib/Dialect/Vector/VectorTransforms.cpp @@ -1,4 +1,4 @@ -//===- VectorToLoops.cpp - Conversion within the Vector dialect -----------===// +//===- VectorTransforms.cpp - Conversion within the Vector dialect --------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. diff --git a/mlir/test/Conversion/LoopsToGPU/linalg_to_gpu.mlir b/mlir/test/Conversion/LoopsToGPU/linalg_to_gpu.mlir index 71555fa..e1aec40 100644 --- a/mlir/test/Conversion/LoopsToGPU/linalg_to_gpu.mlir +++ b/mlir/test/Conversion/LoopsToGPU/linalg_to_gpu.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt -convert-loops-to-gpu %s | FileCheck %s +// RUN: mlir-opt -convert-scf-to-gpu %s | FileCheck %s // CHECK-LABEL: @foo func @foo(%arg0: memref, %arg1 : index) { diff --git a/mlir/test/Conversion/LoopsToGPU/no_blocks_no_threads.mlir b/mlir/test/Conversion/LoopsToGPU/no_blocks_no_threads.mlir index 6100a10..8fb9d41 100644 --- a/mlir/test/Conversion/LoopsToGPU/no_blocks_no_threads.mlir +++ b/mlir/test/Conversion/LoopsToGPU/no_blocks_no_threads.mlir @@ -1,5 +1,5 @@ -// RUN: mlir-opt -convert-loops-to-gpu="gpu-block-dims=0 gpu-thread-dims=1" %s | FileCheck --check-prefix=CHECK-THREADS %s --dump-input-on-failure -// RUN: mlir-opt -convert-loops-to-gpu="gpu-block-dims=1 gpu-thread-dims=0" %s | FileCheck --check-prefix=CHECK-BLOCKS %s --dump-input-on-failure +// RUN: mlir-opt -convert-scf-to-gpu="gpu-block-dims=0 gpu-thread-dims=1" %s | FileCheck --check-prefix=CHECK-THREADS %s --dump-input-on-failure +// RUN: mlir-opt -convert-scf-to-gpu="gpu-block-dims=1 gpu-thread-dims=0" %s | FileCheck --check-prefix=CHECK-BLOCKS %s --dump-input-on-failure // CHECK-THREADS-LABEL: @one_d_loop // CHECK-BLOCKS-LABEL: @one_d_loop diff --git a/mlir/test/Conversion/LoopsToGPU/step_one.mlir b/mlir/test/Conversion/LoopsToGPU/step_one.mlir index d5fc395..cd8ec0d 100644 --- a/mlir/test/Conversion/LoopsToGPU/step_one.mlir +++ b/mlir/test/Conversion/LoopsToGPU/step_one.mlir @@ -1,5 +1,5 @@ -// RUN: mlir-opt -convert-loops-to-gpu="gpu-block-dims=1 gpu-thread-dims=1" %s | FileCheck --check-prefix=CHECK-11 %s -// RUN: mlir-opt -convert-loops-to-gpu="gpu-block-dims=2 gpu-thread-dims=2" %s | FileCheck --check-prefix=CHECK-22 %s +// RUN: mlir-opt -convert-scf-to-gpu="gpu-block-dims=1 gpu-thread-dims=1" %s | FileCheck --check-prefix=CHECK-11 %s +// RUN: mlir-opt -convert-scf-to-gpu="gpu-block-dims=2 gpu-thread-dims=2" %s | FileCheck --check-prefix=CHECK-22 %s // CHECK-11-LABEL: @step_1 // CHECK-22-LABEL: @step_1 diff --git a/mlir/test/Conversion/LoopsToGPU/step_positive.mlir b/mlir/test/Conversion/LoopsToGPU/step_positive.mlir index 9037eac..26f2dfa 100644 --- a/mlir/test/Conversion/LoopsToGPU/step_positive.mlir +++ b/mlir/test/Conversion/LoopsToGPU/step_positive.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt -convert-loops-to-gpu="gpu-block-dims=1 gpu-thread-dims=1" %s | FileCheck %s +// RUN: mlir-opt -convert-scf-to-gpu="gpu-block-dims=1 gpu-thread-dims=1" %s | FileCheck %s // CHECK-LABEL: @step_var func @step_var(%A : memref, %B : memref) { diff --git a/mlir/test/Conversion/VectorToLoops/vector-to-loops.mlir b/mlir/test/Conversion/VectorToLoops/vector-to-loops.mlir index 13796c0..491196c 100644 --- a/mlir/test/Conversion/VectorToLoops/vector-to-loops.mlir +++ b/mlir/test/Conversion/VectorToLoops/vector-to-loops.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt %s -test-convert-vector-to-loops -split-input-file | FileCheck %s +// RUN: mlir-opt %s -test-convert-vector-to-scf -split-input-file | FileCheck %s // CHECK-LABEL: func @materialize_read_1d() { func @materialize_read_1d() { diff --git a/mlir/test/Conversion/convert-to-cfg.mlir b/mlir/test/Conversion/convert-to-cfg.mlir index 5ebfbc4..d2dedf9 100644 --- a/mlir/test/Conversion/convert-to-cfg.mlir +++ b/mlir/test/Conversion/convert-to-cfg.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt -convert-loop-to-std %s | FileCheck %s +// RUN: mlir-opt -convert-scf-to-std %s | FileCheck %s // CHECK-LABEL: func @simple_std_for_loop(%{{.*}}: index, %{{.*}}: index, %{{.*}}: index) { // CHECK-NEXT: br ^bb1(%{{.*}} : index) diff --git a/mlir/test/lib/Transforms/CMakeLists.txt b/mlir/test/lib/Transforms/CMakeLists.txt index 4d89f06..d040cdf 100644 --- a/mlir/test/lib/Transforms/CMakeLists.txt +++ b/mlir/test/lib/Transforms/CMakeLists.txt @@ -19,7 +19,7 @@ add_mlir_library(MLIRTestTransforms TestMemRefBoundCheck.cpp TestMemRefDependenceCheck.cpp TestMemRefStrideCalculation.cpp - TestVectorToLoopsConversion.cpp + TestVectorToSCFConversion.cpp TestVectorTransforms.cpp EXCLUDE_FROM_LIBMLIR @@ -45,7 +45,7 @@ add_mlir_library(MLIRTestTransforms MLIRStandardOpsTransforms MLIRTestDialect MLIRTransformUtils - MLIRVectorToLoops + MLIRVectorToSCF MLIRVector ) diff --git a/mlir/test/lib/Transforms/TestGpuParallelLoopMapping.cpp b/mlir/test/lib/Transforms/TestGpuParallelLoopMapping.cpp index d877001..916b7203 100644 --- a/mlir/test/lib/Transforms/TestGpuParallelLoopMapping.cpp +++ b/mlir/test/lib/Transforms/TestGpuParallelLoopMapping.cpp @@ -25,7 +25,7 @@ class TestGpuGreedyParallelLoopMappingPass void runOnOperation() override { Operation *op = getOperation(); for (Region ®ion : op->getRegions()) - greedilyMapParallelLoopsToGPU(region); + greedilyMapParallelSCFToGPU(region); } }; } // end namespace diff --git a/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp b/mlir/test/lib/Transforms/TestVectorToSCFConversion.cpp similarity index 64% rename from mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp rename to mlir/test/lib/Transforms/TestVectorToSCFConversion.cpp index 907e200..fb3010d 100644 --- a/mlir/test/lib/Transforms/TestVectorToLoopsConversion.cpp +++ b/mlir/test/lib/Transforms/TestVectorToSCFConversion.cpp @@ -1,4 +1,4 @@ -//===- TestVectorToLoopsConversion.cpp - Test VectorTransfers lowering ----===// +//===- TestVectorToSCFConversion.cpp - Test VectorTransfers lowering ------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. @@ -8,7 +8,7 @@ #include -#include "mlir/Conversion/VectorToLoops/ConvertVectorToLoops.h" +#include "mlir/Conversion/VectorToSCF/VectorToSCF.h" #include "mlir/IR/PatternMatch.h" #include "mlir/Pass/Pass.h" #include "mlir/Transforms/Passes.h" @@ -17,12 +17,12 @@ using namespace mlir; namespace { -struct TestVectorToLoopsPass - : public PassWrapper { +struct TestVectorToSCFPass + : public PassWrapper { void runOnFunction() override { OwningRewritePatternList patterns; auto *context = &getContext(); - populateVectorToLoopsConversionPatterns(patterns, context); + populateVectorToSCFConversionPatterns(patterns, context); applyPatternsAndFoldGreedily(getFunction(), patterns); } }; @@ -30,9 +30,9 @@ struct TestVectorToLoopsPass } // end anonymous namespace namespace mlir { -void registerTestVectorToLoopsPass() { - PassRegistration pass( - "test-convert-vector-to-loops", +void registerTestVectorToSCFPass() { + PassRegistration pass( + "test-convert-vector-to-scf", "Converts vector transfer ops to loops over scalars and vector casts"); } } // namespace mlir diff --git a/mlir/test/mlir-cpu-runner/bare_ptr_call_conv.mlir b/mlir/test/mlir-cpu-runner/bare_ptr_call_conv.mlir index 61b98b1..b48b523 100644 --- a/mlir/test/mlir-cpu-runner/bare_ptr_call_conv.mlir +++ b/mlir/test/mlir-cpu-runner/bare_ptr_call_conv.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt %s -convert-loop-to-std -convert-std-to-llvm='use-bare-ptr-memref-call-conv=1' | mlir-cpu-runner -shared-libs=%linalg_test_lib_dir/libmlir_c_runner_utils%shlibext -entry-point-result=void | FileCheck %s +// RUN: mlir-opt %s -convert-scf-to-std -convert-std-to-llvm='use-bare-ptr-memref-call-conv=1' | mlir-cpu-runner -shared-libs=%linalg_test_lib_dir/libmlir_c_runner_utils%shlibext -entry-point-result=void | FileCheck %s // Verify bare pointer memref calling convention. `simple_add1_add2_test` // gets two 2xf32 memrefs, adds 1.0f to the first one and 2.0f to the second diff --git a/mlir/test/mlir-cpu-runner/sgemm_naive_codegen.mlir b/mlir/test/mlir-cpu-runner/sgemm_naive_codegen.mlir index eadf51d..c65a3e3 100644 --- a/mlir/test/mlir-cpu-runner/sgemm_naive_codegen.mlir +++ b/mlir/test/mlir-cpu-runner/sgemm_naive_codegen.mlir @@ -1,4 +1,4 @@ -// RUN: mlir-opt -convert-linalg-to-loops -lower-affine -convert-loop-to-std -convert-std-to-llvm %s | mlir-cpu-runner -O3 -e main -entry-point-result=void -shared-libs=%mlir_runner_utils_dir/libmlir_runner_utils%shlibext | FileCheck %s +// RUN: mlir-opt -convert-linalg-to-loops -lower-affine -convert-scf-to-std -convert-std-to-llvm %s | mlir-cpu-runner -O3 -e main -entry-point-result=void -shared-libs=%mlir_runner_utils_dir/libmlir_runner_utils%shlibext | FileCheck %s func @main() { %A = alloc() : memref<64x64xf32> diff --git a/mlir/tools/mlir-opt/mlir-opt.cpp b/mlir/tools/mlir-opt/mlir-opt.cpp index 9d583dc..218d6c0 100644 --- a/mlir/tools/mlir-opt/mlir-opt.cpp +++ b/mlir/tools/mlir-opt/mlir-opt.cpp @@ -61,7 +61,7 @@ void registerTestOpaqueLoc(); void registerTestParallelismDetection(); void registerTestGpuParallelLoopMappingPass(); void registerTestVectorConversions(); -void registerTestVectorToLoopsPass(); +void registerTestVectorToSCFPass(); void registerVectorizerTestPass(); } // namespace mlir @@ -128,7 +128,7 @@ void registerTestPasses() { registerTestParallelismDetection(); registerTestGpuParallelLoopMappingPass(); registerTestVectorConversions(); - registerTestVectorToLoopsPass(); + registerTestVectorToSCFPass(); registerVectorizerTestPass(); } -- 2.7.4