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
[mlir][spirv] Support function argument decorations #76106
Comments
@llvm/issue-subscribers-mlir-spirv Author: Jakub Kuderski (kuhar)
We need to support function argument decorations in `spirv.func` to allow for some pointer types. For example, the spec requires the following:
> If an OpFunctionParameter is a pointer (or array of pointers) in PhysicalStorageBuffer storage class, then the function parameter must be decorated with exactly one of Aliased or Restrict. > If an OpFunctionParameter is a pointer (or array of pointers) and its pointee type is a pointer in PhysicalStorageBuffer storage class, then the function parameter must be decorated with exactly one of AliasedPointer or RestrictPointer. Note that this is already supported with the %3 = spirv.Variable {aliased_pointer} :
!spirv.ptr<!spirv.ptr<f32, PhysicalStorageBuffer>, Function> |
Hi! This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below. |
@llvm/issue-subscribers-good-first-issue Author: Jakub Kuderski (kuhar)
We need to support function argument decorations in `spirv.func` to allow for some pointer types. For example, the spec requires the following:
> If an OpFunctionParameter is a pointer (or array of pointers) in PhysicalStorageBuffer storage class, then the function parameter must be decorated with exactly one of Aliased or Restrict. > If an OpFunctionParameter is a pointer (or array of pointers) and its pointee type is a pointer in PhysicalStorageBuffer storage class, then the function parameter must be decorated with exactly one of AliasedPointer or RestrictPointer. Note that this is already supported with the %3 = spirv.Variable {aliased_pointer} :
!spirv.ptr<!spirv.ptr<f32, PhysicalStorageBuffer>, Function> |
Hi, I'm new to the SPIRV dialect, so I'd like to work on this issue. |
Sure @sott0n, feel free to ping me if you need any pointers. |
A good starting point would be func.func @interface_var(
%arg0 : f32 {spirv.interface_var_abi = #spirv.interface_var_abi<(0, 1), Uniform>}
) { return } so what we need to do is to enable the same thing for decoration attributes and make sure we serialize them as spirv.module PhysicalStorageBuffer64 GLSL450 requires #spirv.vce<v1.3,
[Shader, PhysicalStorageBufferAddresses], [SPV_KHR_physical_storage_buffer]> {
spirv.func @access(%arg0 : !spirv.ptr<!spirv.struct<(f32)>, PhysicalStorageBuffer> { spirv.decoration = #spirv.decoration<Aliased>}) -> f32 "None" {
%idx = spirv.Constant 0 : i32
%result = spirv.AccessChain %arg0[%idx] : !spirv.ptr<!spirv.struct<(f32)>, PhysicalStorageBuffer>, i32
%ptr = spirv.Load "PhysicalStorageBuffer" %result : f32
spirv.ReturnValue %ptr : f32
}
} and pass validation with: bin/mlir-translate --no-implicit-module --serialize-spirv test.mlir -o test.spv
spirv-val test.spv |
I'm working on #76353 I have completed support for function argument decoration (I'm going to refactor it) and am now working on implementing serialization to pass SPIR-V's validation via spirv-val. |
I've finished implementing the serializer and deserializer. However, spirv-val is causing an error with the OpLoad. For the physical buffer pointer, the SPIR-V dialect needs to add the SPIRV validation tool's error:
This PR supported the decoration for the function's parameters (
|
Good point @sott0n, I think it's just a bug in my example though, isn't it? The input mlir should have been: %ptr = spirv.Load "PhysicalStorageBuffer" %result ["Aligned", 4] : f32 |
Yes, I think it's correct. I updated your example and this error is no longer there. |
…lvm#76353) Closes llvm#76106 --------- Co-authored-by: Lei Zhang <antiagainst@gmail.com>
We need to support function argument decorations in
spirv.func
to allow for some pointer types. For example, the spec requires the following:Note that this is already supported with the
spirv.Variable
op using the following syntax:The text was updated successfully, but these errors were encountered: