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

[SYCL] Change SPIR-V Enum token type from unsigned int to int for barrier builtins #17438

Merged

Conversation

wenju-he
Copy link
Contributor

@wenju-he wenju-he commented Mar 13, 2025

Motivation is unifying SPIR-V builtin mangling to enhance SYCL AOT support for backend targets that bypass SPIR-V generation. Changing to signed int type aligns with

  • SPV-IR output of llvm-spirv translator.
  • Default underlying type of enum being int, e.g. enum defined in tablegened LLVM SPIR-V backend header and standard SPIR-V header.

Changes are mainly made to following places:

  • clang/lib/Sema/SPIRVBuiltins.td
  • libclc/libspirv

…rier builtins

Motivation is unifying SPIR-V builtin mangling to enhance SYCL AOT
support for backend targets that bypass SPIR-V generation.
Changing to signed int type aligns with
* SPV-IR output of llvm-spirv translator.
* Default underlying type of enum being int, e.g. enum defined in
  tablegened LLVM SPIR-V backend header and standard SPIR-V header.

Changes are mainly made to following places:
* sycl/include/sycl/__spirv/spirv_ops.hpp
* clang/lib/Sema/SPIRVBuiltins.td
* libclc/libspirv
@wenju-he wenju-he requested review from a team as code owners March 13, 2025 05:34
@wenju-he wenju-he requested a review from Naghasan March 13, 2025 05:40
Copy link
Contributor

@sommerlukas sommerlukas left a comment

Choose a reason for hiding this comment

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

SYCL-JIT changes LGTM.

wenju-he added a commit to wenju-he/llvm that referenced this pull request Mar 13, 2025
wenju-he added a commit to wenju-he/llvm that referenced this pull request Mar 13, 2025
…ups builtins

Motivation is the same as PR intel#17438, i.e. unifying SPIR-V builtin
mangling to enhance SYCL AOT support for backend targets that bypass
SPIR-V generation.
Copy link
Contributor

@npmiller npmiller left a comment

Choose a reason for hiding this comment

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

ptx/gcn changes LGTM

__SYCL_EXPORT void __spirv_ControlBarrier(__spv::Scope Execution,
__spv::Scope Memory,
uint32_t Semantics) noexcept {
__SYCL_EXPORT void __spirv_ControlBarrier(int32_t Execution, int32_t Memory,
Copy link
Contributor

Choose a reason for hiding this comment

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

These are for the old host device support, I'd advise to not touch these as it creates an ABI break and that's only for the host.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks @Naghasan, reverted the ABI change

@wenju-he wenju-he requested a review from Naghasan March 14, 2025 00:39
wenju-he added a commit to wenju-he/llvm that referenced this pull request Mar 14, 2025
…PIRVBuiltins.td

Also change scope and memory semantics type from Enum from int, similar
as PR intel#17438
volatile is removed from pointer parameter type, to align with SVP-IR and
clang/lib/Sema/SPIRVBuiltins.td.
wenju-he added a commit to wenju-he/llvm that referenced this pull request Mar 14, 2025
…PIRVBuiltins.td

Also change scope and memory semantics type from Enum from int, similar
as PR intel#17438
volatile is removed from pointer parameter type, to align with SVP-IR and
clang/lib/Sema/SPIRVBuiltins.td.
wenju-he added a commit to wenju-he/llvm that referenced this pull request Mar 14, 2025
…PIRVBuiltins.td

Also change scope and memory semantics type from Enum from int, similar
as PR intel#17438
volatile is removed from pointer parameter type, to align with SVP-IR and
clang/lib/Sema/SPIRVBuiltins.td.
wenju-he added a commit to wenju-he/llvm that referenced this pull request Mar 14, 2025
…PIRVBuiltins.td

Change scope and memory semantics type from Enum from int, similar
as in PR intel#17438.
volatile is removed from function parameter pointer type, to align with
SVP-IR and clang/lib/Sema/SPIRVBuiltins.td.
Copy link
Contributor

@uditagarwal97 uditagarwal97 left a comment

Choose a reason for hiding this comment

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

Changes in sycl/test/check_device_code/ LGTM.

Copy link
Contributor

@AllanZyne AllanZyne left a comment

Choose a reason for hiding this comment

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

Looks good on "sanitizer_defs.hpp"

@wenju-he wenju-he requested a review from hvdijk March 18, 2025 04:47
@wenju-he
Copy link
Contributor Author

kindly ping @intel/dpcpp-tools-reviewers, @intel/dpcpp-cfe-reviewers for review

// TODO: Allow enum flags instead of UInt ?
// TODO: We should enforce that the UInt must be a literal.
def : SPVBuiltin<name, [Void, UInt, UInt, UInt], Attr.Convergent>;
// TODO: Allow enum flags instead of Int ?
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this also have a clang test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

updated clang test in 49d9641

Copy link
Contributor

@frasercrmck frasercrmck left a comment

Choose a reason for hiding this comment

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

libclc LGTM

@wenju-he wenju-he requested a review from Fznamznon March 18, 2025 12:50
Copy link
Contributor

@maksimsab maksimsab left a comment

Choose a reason for hiding this comment

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

SYCLLowerIR LGTM.

@wenju-he
Copy link
Contributor Author

@intel/llvm-gatekeepers please merge, thanks

@uditagarwal97 uditagarwal97 merged commit 7f2971a into intel:sycl Mar 19, 2025
22 checks passed
@wenju-he wenju-he deleted the barrier-spirv-token-unsigned-to-signed branch March 19, 2025 00:51
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.

10 participants