[mlir] Make GpuAsyncRegion pass depend on async dialect.

Do not cache gpu.async.token type so that the pass can be created before the GPU dialect is registered.

Reviewed By: ftynse

Differential Revision: https://reviews.llvm.org/D94397
This commit is contained in:
Christian Sigg 2021-01-11 13:56:35 +01:00
parent 4fe7b16ae3
commit 4c372a35cd
3 changed files with 5 additions and 1 deletions

View File

@ -19,6 +19,7 @@ def GpuKernelOutlining : Pass<"gpu-kernel-outlining", "ModuleOp"> {
def GpuAsyncRegionPass : FunctionPass<"gpu-async-region"> {
let summary = "Make GPU ops async";
let constructor = "mlir::createGpuAsyncRegionPass()";
let dependentDialects = ["async::AsyncDialect"];
}
#endif // MLIR_DIALECT_GPU_PASSES

View File

@ -78,6 +78,8 @@ private:
if (op->getNumRegions() > 0)
return op->emitOpError("regions are not supported");
auto tokenType = builder.getType<gpu::AsyncTokenType>();
// If there is no current token, insert a `gpu.wait async` without
// dependencies to create one.
if (!currentToken)
@ -108,7 +110,7 @@ private:
}
OpBuilder builder;
const Type tokenType = builder.getType<gpu::AsyncTokenType>();
// The token that represents the current asynchronous dependency. It's valid
// range starts with a `gpu.wait async` op, and ends with a `gpu.wait` op.
// In between, each gpu::AsyncOpInterface depends on the current token and

View File

@ -9,6 +9,7 @@
#ifndef DIALECT_GPU_TRANSFORMS_PASSDETAIL_H_
#define DIALECT_GPU_TRANSFORMS_PASSDETAIL_H_
#include "mlir/Dialect/Async/IR/Async.h"
#include "mlir/Pass/Pass.h"
namespace mlir {