1 //===- TestGPUParallelLoopMapping.cpp - Test pass for GPU loop mapping ----===// 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 file implements the pass testing the utilities for mapping parallel 10 // loops to gpu hardware ids. 11 // 12 //===----------------------------------------------------------------------===// 13 14 #include "mlir/Dialect/GPU/ParallelLoopMapper.h" 15 #include "mlir/Pass/Pass.h" 16 17 using namespace mlir; 18 19 namespace { 20 /// Simple pass for testing the mapping of parallel loops to hardware ids using 21 /// a greedy mapping strategy. 22 class TestGpuGreedyParallelLoopMappingPass 23 : public PassWrapper<TestGpuGreedyParallelLoopMappingPass, 24 OperationPass<FuncOp>> { runOnOperation()25 void runOnOperation() override { 26 Operation *op = getOperation(); 27 for (Region ®ion : op->getRegions()) 28 greedilyMapParallelSCFToGPU(region); 29 } 30 }; 31 } // namespace 32 33 namespace mlir { 34 namespace test { registerTestGpuParallelLoopMappingPass()35void registerTestGpuParallelLoopMappingPass() { 36 PassRegistration<TestGpuGreedyParallelLoopMappingPass> registration( 37 "test-gpu-greedy-parallel-loop-mapping", 38 "Greedily maps all parallel loops to gpu hardware ids."); 39 } 40 } // namespace test 41 } // namespace mlir 42