Skip to content

Conversation

@bader
Copy link
Contributor

@bader bader commented Nov 7, 2025

Some compile time properties work as a replacement for kernel
attributes. For example, work_group_size semantics must be identical to
sycl::reqd_work_group_size kernel attribute. The problem is kernel
attributes are lowered to LLVM metadata by Clang, but work_group_size
represented as an LLVM attribute.
CompileTimePropertiesPass converts attribute to canonical metadata
representation, but does it late in the opimization pipeline.
This patch moves CompileTimePropertiesPass to the beginning of the
optimization pipeline to keep canonical representation for SYCL kernel
attributes information passes via compile-time properties.

Some compile time properties work as a replacement for kernel
attributes. For example, work_group_size semantics must be identical to
sycl::reqd_work_group_size kernel attribute. The problem is kernel
attributes are lowered to LLVM metadata by Clang, but work_group_size
represented as an LLVM attribute.
CompileTimePropertiesPass converts attribute to canonical metadata
representation, but does it late in the opimization pipeline.
This patch moves CompileTimePropertiesPass to the beginning of the
optimization pipeline to keep canonical representation for SYCL kernel
attributes information passes via compile-time properties.
@bader bader requested review from a team as code owners November 7, 2025 23:23
@bader bader requested a review from steffenlarsen November 7, 2025 23:24
@steffenlarsen
Copy link
Contributor

Discussed shortly offline. It looks like some of the metadata gets lost if added early. An option could be to run the pass twice and separate the transformations into early and late transformations. The kernel properties, i.e. the ones that have OpenCL parallels (for example sycl-work-group-size -> reqd_work_group_size) could be done early while the rest could be done in the slot we apply it today.

@elizabethandrews
Copy link
Contributor

Out of curiosity how/why is metadata lost if pass is earlier?

@steffenlarsen
Copy link
Contributor

Out of curiosity how/why is metadata lost if pass is earlier?

Seemingly it affects the cache control properties the worst. Looks to me like the !spirv.Decorations metadata on the loads and stores are lost if it is added early, which is probably not very surprising. Kernel functions are unlikely to transform drastically, but pointer loads and stores are likely the target of a lot of transformations, and since metadata isn't guaranteed to be preserved it is likely lost along some of those.

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