@@ -47,6 +47,12 @@ class InsertGPUAllocsPass final
47
47
explicit InsertGPUAllocsPass () : m_clientAPI(" vulkan" ) {}
48
48
explicit InsertGPUAllocsPass (const mlir::StringRef &clientAPI)
49
49
: m_clientAPI(clientAPI) {}
50
+ explicit InsertGPUAllocsPass (const imex::InsertGPUAllocsOptions &options)
51
+ : InsertGPUAllocsBase<InsertGPUAllocsPass>(options) {
52
+ if (clientAPI == " opencl" ) {
53
+ m_clientAPI = " opencl" ;
54
+ }
55
+ }
50
56
51
57
mlir::LogicalResult
52
58
initializeOptions (mlir::StringRef options,
@@ -540,15 +546,17 @@ class InsertGPUAllocsPass final
540
546
// This is the case where the inputs are passed as arguments to the
541
547
// function. This code will add the IR for memory allocation on the device
542
548
// with gpu.alloc and insert a memref.copy from host to device
543
- for (const auto &it : gpuBufferParams) {
544
- auto param = block.getArgument (it.first );
545
- if (isGpuAddrSpace (param))
546
- continue ;
547
- auto access = getAccessType (param);
548
- access.hostRead = true ;
549
- access.hostWrite = true ;
550
- builder.setInsertionPointToStart (&block);
551
- add_gpu_alloc (builder, param, access, term);
549
+ if (!isUsmArgs.getValue ()) {
550
+ for (const auto &it : gpuBufferParams) {
551
+ auto param = block.getArgument (it.first );
552
+ if (isGpuAddrSpace (param))
553
+ continue ;
554
+ auto access = getAccessType (param);
555
+ access.hostRead = true ;
556
+ access.hostWrite = true ;
557
+ builder.setInsertionPointToStart (&block);
558
+ add_gpu_alloc (builder, param, access, term);
559
+ }
552
560
}
553
561
554
562
// CallOp Case: This is the case where the memref producer is coming
@@ -580,4 +588,8 @@ namespace imex {
580
588
std::unique_ptr<mlir::Pass> createInsertGPUAllocsPass (const char *clientAPI) {
581
589
return std::make_unique<InsertGPUAllocsPass>(clientAPI);
582
590
}
591
+ std::unique_ptr<mlir::Pass>
592
+ createInsertGPUAllocsPass (const InsertGPUAllocsOptions &option) {
593
+ return std::make_unique<InsertGPUAllocsPass>(option);
594
+ }
583
595
} // namespace imex
0 commit comments