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

Refactor handling of untyped pointers in builtins reverse translation #2924

Merged
merged 7 commits into from
Jan 31, 2025

Conversation

vmaksimo
Copy link
Contributor

@vmaksimo vmaksimo commented Dec 11, 2024

This fixes the mangling in enqueue_kernel.cl test.

Without the fix we get such mangled function:

@_Z21__spirv_EnqueueKernelP13__spirv_QueueiPciPU3AS4P19__spirv_DeviceEventS5_U13block_pointerFvvEPU3AS4cii

instead of the expected:

@_Z21__spirv_EnqueueKernelP13__spirv_Queuei9ndrange_tiPU3AS4P19__spirv_DeviceEventS5_U13block_pointerFvvEPU3AS4cii

@vmaksimo vmaksimo requested a review from MrSidims December 11, 2024 15:05
@@ -72,6 +85,8 @@ kernel void device_side_enqueue(global int *a, global int *b, int i, char c0) {
// CHECK-LLVM: [[BlockInv2:%[0-9]+]] = addrspacecast ptr @__device_side_enqueue_block_invoke_kernel to ptr addrspace(4)
// CHECK-LLVM: call spir_func i32 @__enqueue_kernel_basic(ptr {{.*}}, i32 {{.*}}, ptr {{.*}}, ptr addrspace(4) [[BlockInv2]], ptr addrspace(4) [[Block2Ptr]])
// CHECK-SPV-IR: call spir_func i32 @_Z21__spirv_EnqueueKernelP13__spirv_Queuei9ndrange_tiPU3AS4P19__spirv_DeviceEventS5_U13block_pointerFvvEPU3AS4cii(target("spirv.Queue") {{.*}}, i32 {{.*}}, ptr {{.*}}, i32 0, ptr addrspace(4) null, ptr addrspace(4) null, ptr @__device_side_enqueue_block_invoke_kernel, ptr addrspace(4) {{.*}}, i32 {{.*}}, i32 {{.*}})
// _Z21__spirv_EnqueueKernelP13__spirv_Queuei9ndrange_tiPU3AS4P19__spirv_DeviceEventS5_U13block_pointerFvvEPU3AS412structtype.0ii
// Actuallly the second mangling seems correct because the pointer really points to the structure, not to char. However, SPIR-V spec says this arg should be a pointer to char.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// Actuallly the second mangling seems correct because the pointer really points to the structure, not to char. However, SPIR-V spec says this arg should be a pointer to char.
// Actually the second mangling seems correct because the pointer really points to the structure, not to char. However, SPIR-V spec says this arg should be a pointer to char.

or was it left just for the review? :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You talk here about Param operand of OpEnqueueKernel, right? What is the type of it in the generated by the translator SPIR-V module?

About the mangling, I believe, that if the SPIR-V spec mandates, that Param is char *, the SPIR-V friendly LLVM IR must follow and hence the mangling should not encode the struct type.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, this comment was for review :)
In SPIR-V we have untyped pointer (which untyped variable points to struct type). With "usual" pointers we have the same pointer to struct, just casted to pointer to char.

I believe you're right, we should not encode the struct type in this special case.

@vmaksimo vmaksimo requested a review from MrSidims January 14, 2025 17:12
@MrSidims MrSidims requested a review from svenvh January 31, 2025 13:39
@svenvh svenvh merged commit 6675e28 into KhronosGroup:main Jan 31, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants