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

[GC-STAGING][InsertGPUAllocs] Recognize integer address spaces as GPU memory #957

Merged
merged 3 commits into from
Nov 10, 2024
Merged
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
18 changes: 16 additions & 2 deletions lib/Transforms/InsertGPUAllocs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,8 +277,20 @@ class InsertGPUAllocsPass final
// address space.
auto isGpuAddrSpace = [&](mlir::Value memref) {
if (auto type = mlir::dyn_cast<mlir::MemRefType>(memref.getType())) {
return mlir::isa_and_nonnull<mlir::gpu::AddressSpaceAttr>(
type.getMemorySpace());
auto memSpace = type.getMemorySpace();
if (!memSpace)
return false;

if (mlir::dyn_cast<mlir::gpu::AddressSpaceAttr>(memSpace))
return true;

// HACK: XeGPU dialect only understands integer memory spaces, meaning
// that we also have to check for them in order for XeGPU pipelines to
// work properly. MemSpace = 3 (gpu::Private) is used to describe SLM
// (shared local memory on GPU).
if (auto intAttr = mlir::dyn_cast<mlir::IntegerAttr>(memSpace))
return intAttr.getValue() ==
static_cast<int64_t>(mlir::gpu::AddressSpace::Private);
}
return false;
};
Expand Down Expand Up @@ -410,6 +422,8 @@ class InsertGPUAllocsPass final
if (m_clientAPI == "opencl") {
for (const auto &it : gpuBufferAllocs) {
auto alloc = mlir::cast<mlir::memref::AllocOp>(it.first);
if (isGpuAddrSpace(alloc))
continue;
auto access = getAccessType(alloc);
auto loc = alloc.getLoc();
builder.setInsertionPoint(alloc);
Expand Down
Loading