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 a pass that adds shared mem space attribute to allocs in a GPU kernel #393

Closed
dchigarev opened this issue Oct 28, 2024 · 0 comments · Fixed by #397
Closed

Add a pass that adds shared mem space attribute to allocs in a GPU kernel #393

dchigarev opened this issue Oct 28, 2024 · 0 comments · Fixed by #397
Assignees

Comments

@dchigarev
Copy link
Contributor

[SUB-TASK OF #360]

We need a pass that adds shared mem space to memref being allocated in a GPU kernel (thus marking those as allocs for SLM memory).

We may also add a check, that the total amount of such allocations does not exceed the total amount of available shared memory for this specific device.

Example of how this pass is expected to work:

// INPUT:
func.func @entry() {
  %0 = memref.alloc() : memref<16x16xf16>
  gpu.launch blocks(%arg5, %arg6, %arg7) in (%arg11 = %0, %arg12 = %1, %arg13 = %c1_0) threads(%arg8, %arg9, %arg10) in (%arg14 = %2, %arg15 = %3, %arg16 = %c1_0) {
    %1 = memref.alloc() : memref<16x16xf16>
    memref.dealloc %1 : memref<16x16xf16>
    gpu.terminator
  } {SCFToGPU_visited}
  return
}

// OUTPUT:
func.func @entry() {
  %0 = memref.alloc() : memref<16x16xf16> // got nothing
  gpu.launch blocks(%arg5, %arg6, %arg7) in (%arg11 = %0, %arg12 = %1, %arg13 = %c1_0) threads(%arg8, %arg9, %arg10) in (%arg14 = %2, %arg15 = %3, %arg16 = %c1_0) {
    %1 = memref.alloc() : memref<16x16xf16, 3> // got 'shared' mem space attribute
    memref.dealloc %1 : memref<16x16xf16, 3>
    gpu.terminator
  } {SCFToGPU_visited}
  return
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant