14ead2cf7SAlex Zinenko //===- SCFToGPUPass.h - Pass converting loops to GPU kernels ----*- C++ -*-===// 24ead2cf7SAlex Zinenko // 34ead2cf7SAlex Zinenko // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 44ead2cf7SAlex Zinenko // See https://llvm.org/LICENSE.txt for license information. 54ead2cf7SAlex Zinenko // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 64ead2cf7SAlex Zinenko // 74ead2cf7SAlex Zinenko //===----------------------------------------------------------------------===// 8eb8edd85SAlex Zinenko #ifndef MLIR_CONVERSION_SCFTOGPU_SCFTOGPUPASS_H_ 9eb8edd85SAlex Zinenko #define MLIR_CONVERSION_SCFTOGPU_SCFTOGPUPASS_H_ 104ead2cf7SAlex Zinenko 11*34a35a8bSMartin Erhart #include "mlir/Interfaces/FunctionInterfaces.h" 124ead2cf7SAlex Zinenko #include "mlir/Support/LLVM.h" 134ead2cf7SAlex Zinenko 144ead2cf7SAlex Zinenko #include <memory> 154ead2cf7SAlex Zinenko 164ead2cf7SAlex Zinenko namespace mlir { 174ead2cf7SAlex Zinenko template <typename T> 1847f175b0SRiver Riddle class InterfacePass; 194ead2cf7SAlex Zinenko class Pass; 204ead2cf7SAlex Zinenko 2167d0d7acSMichele Scuttari #define GEN_PASS_DECL_CONVERTAFFINEFORTOGPU 2267d0d7acSMichele Scuttari #define GEN_PASS_DECL_CONVERTPARALLELLOOPTOGPU 2367d0d7acSMichele Scuttari #include "mlir/Conversion/Passes.h.inc" 2467d0d7acSMichele Scuttari 254ead2cf7SAlex Zinenko /// Create a pass that converts loop nests into GPU kernels. It considers 262bcd1927SMaheshRavishankar /// top-level affine.for operations as roots of loop nests and converts them to 272bcd1927SMaheshRavishankar /// the gpu.launch operations if possible. 284ead2cf7SAlex Zinenko /// 294ead2cf7SAlex Zinenko /// No check on the size of the block or grid, or on the validity of 304ead2cf7SAlex Zinenko /// parallelization is performed, it is under the responsibility of the caller 314ead2cf7SAlex Zinenko /// to strip-mine the loops and to perform the dependence analysis before 324ead2cf7SAlex Zinenko /// calling the conversion. 3347f175b0SRiver Riddle std::unique_ptr<InterfacePass<FunctionOpInterface>> 342bcd1927SMaheshRavishankar createAffineForToGPUPass(unsigned numBlockDims, unsigned numThreadDims); 3547f175b0SRiver Riddle std::unique_ptr<InterfacePass<FunctionOpInterface>> createAffineForToGPUPass(); 364ead2cf7SAlex Zinenko 37039b969bSMichele Scuttari /// Creates a pass that converts scf.parallel operations into a gpu.launch 38039b969bSMichele Scuttari /// operation. The mapping of loop dimensions to launch dimensions is derived 39039b969bSMichele Scuttari /// from mapping attributes. See ParallelToGpuLaunchLowering::matchAndRewrite 40039b969bSMichele Scuttari /// for a description of the used attributes. 41039b969bSMichele Scuttari std::unique_ptr<Pass> createParallelLoopToGpuPass(); 42039b969bSMichele Scuttari 434ead2cf7SAlex Zinenko } // namespace mlir 444ead2cf7SAlex Zinenko 45eb8edd85SAlex Zinenko #endif // MLIR_CONVERSION_SCFTOGPU_SCFTOGPUPASS_H_ 46