This is an archive of the discontinued LLVM Phabricator instance.

[mlir][GPU] Add gpu.create_stream op and add stream as an optional argument to gpu ops
Needs ReviewPublic

Authored by nbpatel on Mar 21 2023, 11:44 AM.

Details

Summary

The above PR introduces a new op called gpu.create_stream and adds stream as an optional arg to some gpu dialect
ops. This will give the user the flexibility to launch kernels on their custom stream. We require this to enable
the MLIR pipeline on Intel GPU.

The link to the discussion is:
https://discourse.llvm.org/t/proposal-to-add-stream-queue-as-an-optional-argument-to-few-gpu-dialect-ops/67920/13

Diff Detail

Event Timeline

nbpatel created this revision.Mar 21 2023, 11:44 AM
nbpatel requested review of this revision.Mar 21 2023, 11:44 AM
rengolin added inline comments.
mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
973

If streams are optional, you should have builders without them, but this will force all builder calls to pass a nullptr or something for the stream, and could break existing downstream code.

Is there a reason to drop the existing default builders?

1425

What creates a device? How can I get hold of it?

mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
744

No validation for what a device is or should be?

mlir/test/Dialect/GPU/ops.mlir
134

You add functionality to pass a device but offers no test to how a device should be created, used or destroyed.

But the gpu.wait async op already creates a stream. Can you expand the commit summary on why this is needed? If you already have a custom stream that you want to pass to your IR, a !gpu.async_token type could be passed.

But the gpu.wait async op already creates a stream. Can you expand the commit summary on why this is needed? If you already have a custom stream that you want to pass to your IR, a !gpu.async_token type could be passed.

Stream is separate concept from synchronization, please see my comment in https://discourse.llvm.org/t/proposal-to-add-stream-queue-as-an-optional-argument-to-few-gpu-dialect-ops/67920/17?u=hardcode84

nbpatel added inline comments.Mar 31 2023, 10:42 AM
mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
1425

Device is optional and just a placeholder for now. The user can pass an opaque pointer as device which will be used by create_stream op. We are just exposing the API.

mlir/test/Dialect/GPU/ops.mlir
134

Will add a test.

nbpatel updated this revision to Diff 510084.Mar 31 2023, 10:52 AM

Added a test for creating stream with device

nbpatel added inline comments.Mar 31 2023, 10:55 AM
mlir/lib/Dialect/GPU/IR/GPUDialect.cpp
744

what sort of validation you expect here?

Ping for review

bondhugula added inline comments.Apr 3 2023, 7:17 PM
mlir/include/mlir/Dialect/GPU/IR/GPUBase.td
97–101

Both of these need proper doc comments.

mlir/include/mlir/Dialect/GPU/IR/GPUOps.td
1418–1420

Reflow - use whole width.

1425

Please document what device's type is/can be and how it's created.

What's the current behavior if a gpu dialect op with the stream argument is passed to the gpu-to-llvm pass? Please ensure it doesn't assert/crash.

mlir/test/Dialect/GPU/ops.mlir
228

Drop blank line.