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

Attach opencl.kernels metadata #2869

Open
victor-eds opened this issue Nov 28, 2024 · 1 comment · May be fixed by #2923
Open

Attach opencl.kernels metadata #2869

victor-eds opened this issue Nov 28, 2024 · 1 comment · May be fixed by #2923
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers performance

Comments

@victor-eds
Copy link
Contributor

It's codegen's responsibility to add OCL's kernels metadata to the LLVM module. We are failing to do so and this prevents further optimizations via kernel metadata like setting a constant work-group size. Add MD in a similar way to https://github.com/intel/llvm/blob/a024380e33151b8d1e0d3abb937ff089ec1f24ba/llvm/test/CodeGen/AMDGPU/sampler-resource-id.ll#L44:

!opencl.kernels = !{!0, !1, !2}

!0 = !{ptr @test_0, !10, !20, !30, !40, !50}
!10 = !{!"kernel_arg_addr_space", i32 0, i32 1}
!20 = !{!"kernel_arg_access_qual", !"none", !"none"}
!30 = !{!"kernel_arg_type", !"sampler_t", !"int*"}
!40 = !{!"kernel_arg_base_type", !"sampler_t", !"int*"}
!50 = !{!"kernel_arg_type_qual", !"", !""}

!1 = !{ptr @test_1, !11, !21, !31, !41, !51}
!11 = !{!"kernel_arg_addr_space", i32 0, i32 0, i32 1}
!21 = !{!"kernel_arg_access_qual", !"none", !"none", !"none"}
!31 = !{!"kernel_arg_type", !"sampler_t", !"sampler_t", !"int*"}
!41 = !{!"kernel_arg_base_type", !"sampler_t", !"sampler_t", !"int*"}
!51 = !{!"kernel_arg_type_qual", !"", !"", !""}

!2 = !{ptr @test_2, !12, !22, !32, !42, !52}
!12 = !{!"kernel_arg_addr_space", i32 0, i32 0, i32 0, i32 1}
!22 = !{!"kernel_arg_access_qual", !"none", !"none", !"none", !"none"}
!32 = !{!"kernel_arg_type", !"sampler_t", !"sampler_t", !"sampler_t", !"int*"}
!42 = !{!"kernel_arg_base_type", !"sampler_t", !"sampler_t", !"sampler_t", !"int*"}
!52 = !{!"kernel_arg_type_qual", !"", !"", !"", !""}

What MD nodes to add is yet to be decided. At least the opencl.kernels and the nodes with the kernel references should be added.

We can do this by adding the required metadata to the function before lowering to LLVM dialect as a triton_gen attribute and handling the attribute in https://github.com/intel/intel-xpu-backend-for-triton/blob/main/third_party/intel/lib/Target/LLVMIR/Dialect/TritonGEN/TritonGENToLLVMIRTranslation.cpp.

@victor-eds
Copy link
Contributor Author

Blocked by backend bug. May not be needed. Check after bug is fixed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers performance
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants