1 //===- ParallelLoopMapper.h - Utilities for mapping parallel loops to GPU ====// 2 // 3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 4 // See https://llvm.org/LICENSE.txt for license information. 5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 // 7 //===----------------------------------------------------------------------===// 8 // 9 // This header file declares the utilities to generate mappings for parallel 10 // loops to GPU devices. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #ifndef MLIR_DIALECT_GPU_TRANSFORMS_PARALLELLOOPMAPPER_H 15 #define MLIR_DIALECT_GPU_TRANSFORMS_PARALLELLOOPMAPPER_H 16 17 #include "mlir/Dialect/GPU/IR/GPUDialect.h" 18 #include "mlir/Support/LLVM.h" 19 #include "llvm/ADT/StringRef.h" 20 21 namespace mlir { 22 23 class AffineMap; 24 struct LogicalResult; 25 class Operation; 26 class Region; 27 28 } // namespace mlir 29 30 namespace mlir { 31 namespace scf { 32 class ParallelOp; 33 } // namespace scf 34 35 namespace gpu { 36 37 /// Name of the mapping attribute produced by loop mappers. 38 StringRef getMappingAttrName(); 39 40 /// Sets the mapping attribute of a scf.parallel operation. Verifies that the 41 /// mapping passed is valid. 42 /// - the number of DimMapperAttr provided is same as the number of loops of 43 /// the `ploopOp`. 44 /// - the mapping does not map multiple loops to the same processor. 45 LogicalResult setMappingAttr(scf::ParallelOp ploopOp, 46 ArrayRef<ParallelLoopDimMappingAttr> mapping); 47 } // namespace gpu 48 } // namespace mlir 49 #endif // MLIR_DIALECT_GPU_TRANSFORMS_PARALLELLOOPMAPPER_H 50