Files
clang-p2996/mlir/test/Conversion/GPUCommon/lower-wait-to-gpu-runtime-calls.mlir
Christian Sigg f03826f896 Pass GPU events instead of streams across async regions.
Lower !gpu.async.tokens returned from async.execute regions to events instead of streams.

Make !gpu.async.token returned from !async.execute single-use.
This allows creating one event per use and destroying them without leaking or ref-counting.
Technically we only need this for stream/event-based lowering. I kept the code separate
from the rest of the gpu-async-region pass so that we can make this optional or move
to a separate pass as needed.

Reviewed By: herhut

Differential Revision: https://reviews.llvm.org/D96965
2021-02-25 13:18:18 +01:00

22 lines
760 B
MLIR

// RUN: mlir-opt %s --gpu-to-llvm | FileCheck %s
module attributes {gpu.container_module} {
func @foo() {
// CHECK: %[[t0:.*]] = llvm.call @mgpuStreamCreate
// CHECK: %[[e0:.*]] = llvm.call @mgpuEventCreate
// CHECK: llvm.call @mgpuEventRecord(%[[e0]], %[[t0]])
%t0 = gpu.wait async
// CHECK: %[[t1:.*]] = llvm.call @mgpuStreamCreate
// CHECK: llvm.call @mgpuStreamWaitEvent(%[[t1]], %[[e0]])
// CHECK: llvm.call @mgpuEventDestroy(%[[e0]])
%t1 = gpu.wait async [%t0]
// CHECK: llvm.call @mgpuStreamSynchronize(%[[t0]])
// CHECK: llvm.call @mgpuStreamDestroy(%[[t0]])
// CHECK: llvm.call @mgpuStreamSynchronize(%[[t1]])
// CHECK: llvm.call @mgpuStreamDestroy(%[[t1]])
gpu.wait [%t0, %t1]
return
}
}