|
38 | 38 |
|
39 | 39 | namespace mlir::gc {
|
40 | 40 |
|
41 |
| -void populateGPUPipeline(mlir::OpPassManager &pm) { |
| 41 | +struct GPUPipelineOption : PassPipelineOptions<GPUPipelineOption> { |
| 42 | + PassOptions::Option<bool> isUsmArgs{ |
| 43 | + *this, "is-usm-args", |
| 44 | + llvm::cl::desc("Whether to use USM(unified shared memory) func args, in " |
| 45 | + "which the host and device could access the same buffer " |
| 46 | + "and there is no need to add memcpy explicitly"), |
| 47 | + llvm::cl::init(true)}; |
| 48 | +}; |
| 49 | + |
| 50 | +void populateGPUPipeline(mlir::OpPassManager &pm, |
| 51 | + const GPUPipelineOption &pipelineOption) { |
42 | 52 | pm.addNestedPass<func::FuncOp>(createIterativeTilingAndFusion());
|
43 | 53 |
|
44 | 54 | pm.addPass(bufferization::createEmptyTensorEliminationPass());
|
@@ -76,7 +86,11 @@ void populateGPUPipeline(mlir::OpPassManager &pm) {
|
76 | 86 | pm.addNestedPass<func::FuncOp>(createGpuMapParallelLoopsPass());
|
77 | 87 | pm.addNestedPass<func::FuncOp>(createParallelLoopToGpuPass());
|
78 | 88 |
|
79 |
| - pm.addNestedPass<func::FuncOp>(imex::createInsertGPUAllocsPass("opencl")); |
| 89 | + imex::InsertGPUAllocsOptions insertGPUAllocsOption{ |
| 90 | + /*clientAPI*/ "opencl", /*inRegions*/ false, |
| 91 | + /*isUsmArgs*/ pipelineOption.isUsmArgs.getValue()}; |
| 92 | + pm.addNestedPass<func::FuncOp>( |
| 93 | + imex::createInsertGPUAllocsPass(insertGPUAllocsOption)); |
80 | 94 | pm.addPass(createGpuKernelOutliningPass());
|
81 | 95 | pm.addPass(createCanonicalizerPass());
|
82 | 96 | pm.addPass(imex::createSetSPIRVCapabilitiesPass());
|
@@ -112,9 +126,9 @@ void populateGPUPipeline(mlir::OpPassManager &pm) {
|
112 | 126 | }
|
113 | 127 |
|
114 | 128 | void registerGPUPipeline() {
|
115 |
| - PassPipelineRegistration<>("gc-gpu-pipeline", |
116 |
| - "The GPU pipeline for Graph Compiler with IMEX", |
117 |
| - populateGPUPipeline); |
| 129 | + PassPipelineRegistration<GPUPipelineOption>( |
| 130 | + "gc-gpu-pipeline", "The GPU pipeline for Graph Compiler with IMEX", |
| 131 | + populateGPUPipeline); |
118 | 132 | }
|
119 | 133 |
|
120 | 134 | } // namespace mlir::gc
|
0 commit comments