Skip to content

Implemented tiling and fusion path for GPU #383

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

Merged
merged 1 commit into from
Nov 26, 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
30 changes: 30 additions & 0 deletions include/gc/Transforms/Passes.td
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,36 @@ def GpuToGpuOcl : Pass<"gpu-to-gpuocl", "ModuleOp"> {
"Call finish() after each kernel launch.">
];
}

def GpuTilingAndFusion : Pass<"gpu-tiling", "func::FuncOp"> {
let summary = "GPU tiling and fusion path.";
let description = [{
This pass tiles linalg operations and creates two nested scf.forall loops. When converting to gpu.launch,
the inner loop is mapped to the block sizes and the outer - to grid sizes. The tiles calculation is based
on the GPU device properties, retrieved from the DLTI attributes. If the DLTI attributes are not specified,
defaults to the pass options.
}];
let options = [
Option<"numEus", "num-eus", "size_t",
/*default=*/"448",
"Number of Execution Units.">,
Option<"numEusPerSlice", "num-eus-per-slice", "size_t",
/*default=*/"8",
"Number of Execution Units per slice.">,
Option<"numThreadsPerEu", "num-threads-per-eu", "size_t",
/*default=*/"8",
"Number of threads per Execution Unit.">,
Option<"localMemSize", "local-mem-size", "size_t",
/*default=*/"131072",
"The size of the local memory, shared across a work-group.">,
Option<"vectorWidth", "vector-width", "size_t",
/*default=*/"512",
"The maximum width of EU's vector registers.">,
Option<"workGroupSize", "work-group-size", "size_t",
/*default=*/"64",
"The maximum workgroup size.">
];
}
#endif // GC_USE_IMEX

def IterativeTilingAndFusion : Pass<"iterative-tiling-and-fusion",
Expand Down
3 changes: 1 addition & 2 deletions lib/gc/ExecutionEngine/GPURuntime/ocl/GpuOclRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -876,8 +876,7 @@ OclModuleBuilder::build(const OclRuntime::Ext &ext) {
{CL_DEVICE_MAX_COMPUTE_UNITS, "num_exec_units"},
{CL_DEVICE_NUM_EUS_PER_SUB_SLICE_INTEL, "num_exec_units_per_slice"},
{CL_DEVICE_NUM_THREADS_PER_EU_INTEL, "num_threads_per_eu"},
// Assuming the cache size is equal to the local mem
{CL_DEVICE_LOCAL_MEM_SIZE, "L1_cache_size_in_bytes"},
{CL_DEVICE_LOCAL_MEM_SIZE, "local_mem_size"},
};

unsigned i = 0;
Expand Down
1 change: 1 addition & 0 deletions lib/gc/Transforms/GPU/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ set_property(GLOBAL APPEND PROPERTY IMEX_LIBS ${IMEX_LIBS})
gc_add_mlir_library(GcGpuPasses
AddContextArg.cpp
AllocsToSLM.cpp
GpuTilingAndFusion.cpp
GpuToGpuOcl.cpp
LinalgToXeGPU.cpp
Pipeline.cpp
Expand Down
Loading