Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add an option for insert gpu allocs to treat allocations as gpu-native #354

Merged
merged 1 commit into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion cmake/imex-version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6c2e414a953b9a118bce6adac21cf9d42630e674
20f2eef4f6c10fcbd68d358591c8b3ef4d1b97d2
4 changes: 2 additions & 2 deletions include/gc/Transforms/Passes.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ namespace func {
class FuncOp;
} // namespace func


namespace LLVM {
class LLVMDialect;
}
Expand Down Expand Up @@ -116,7 +115,8 @@ void populateFrontendPasses(mlir::OpPassManager &);
void populateCPUPipeline(mlir::OpPassManager &);

#ifdef GC_USE_IMEX
void populateGPUPipeline(mlir::OpPassManager &);
struct GPUPipelineOption;
void populateGPUPipeline(mlir::OpPassManager &, const GPUPipelineOption &);
#endif

#define GEN_PASS_DECL
Expand Down
24 changes: 19 additions & 5 deletions lib/gc/Transforms/GPU/Pipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,17 @@

namespace mlir::gc {

void populateGPUPipeline(mlir::OpPassManager &pm) {
struct GPUPipelineOption : PassPipelineOptions<GPUPipelineOption> {
PassOptions::Option<bool> isUsmArgs{
*this, "is-usm-args",
llvm::cl::desc("Whether to use USM(unified shared memory) func args, in "
"which the host and device could access the same buffer "
"and there is no need to add memcpy explicitly"),
llvm::cl::init(true)};
};

void populateGPUPipeline(mlir::OpPassManager &pm,
const GPUPipelineOption &pipelineOption) {
pm.addNestedPass<func::FuncOp>(createIterativeTilingAndFusion());

pm.addPass(bufferization::createEmptyTensorEliminationPass());
Expand Down Expand Up @@ -76,7 +86,11 @@ void populateGPUPipeline(mlir::OpPassManager &pm) {
pm.addNestedPass<func::FuncOp>(createGpuMapParallelLoopsPass());
pm.addNestedPass<func::FuncOp>(createParallelLoopToGpuPass());

pm.addNestedPass<func::FuncOp>(imex::createInsertGPUAllocsPass("opencl"));
imex::InsertGPUAllocsOptions insertGPUAllocsOption{
/*clientAPI*/ "opencl", /*inRegions*/ false,
/*isUsmArgs*/ pipelineOption.isUsmArgs.getValue()};
pm.addNestedPass<func::FuncOp>(
imex::createInsertGPUAllocsPass(insertGPUAllocsOption));
pm.addPass(createGpuKernelOutliningPass());
pm.addPass(createCanonicalizerPass());
pm.addPass(imex::createSetSPIRVCapabilitiesPass());
Expand Down Expand Up @@ -112,9 +126,9 @@ void populateGPUPipeline(mlir::OpPassManager &pm) {
}

void registerGPUPipeline() {
PassPipelineRegistration<>("gc-gpu-pipeline",
"The GPU pipeline for Graph Compiler with IMEX",
populateGPUPipeline);
PassPipelineRegistration<GPUPipelineOption>(
"gc-gpu-pipeline", "The GPU pipeline for Graph Compiler with IMEX",
populateGPUPipeline);
}

} // namespace mlir::gc
Loading