Skip to content

Conversation

@hvdijk
Copy link
Contributor

@hvdijk hvdijk commented Jul 23, 2025

In #17408, NativeCPU became a target in order to be able to pick the ABI for its own libclc functions consistently, without having targets affect this. This was, and is, required to be able to use libclc independent of target and target options. However, it breaks some calls into libc. Therefore, this PR allows the calling convention to be explicitly specified, ensures it is specified for any libclc functions, and ensures it is not specified for any libc functions.

Fixes the SYCL-E2E acos, cmath, and exp-std-complex tests.

In intel#17408, NativeCPU became a target in order to be able to pick the ABI
for its own libclc functions consistently, without having targets affect
this. This was, and is, required to be able to use libclc independent of
target and target options. However, it breaks some calls into libc.
Therefore, this PR allows the calling convention to be explicitly
specified, ensures it is specified for any libclc functions, and ensures
it is not specified for any libc functions.

Fixes the SYCL-E2E acos, cmath, and exp-std-complex tests.
@hvdijk hvdijk requested review from a team as code owners July 23, 2025 16:26
@hvdijk hvdijk requested review from aelovikov-intel and ldrumm July 23, 2025 16:26
@hvdijk
Copy link
Contributor Author

hvdijk commented Jul 23, 2025

This needs compiler tests, I will work on adding some I've added one.

@hvdijk hvdijk temporarily deployed to WindowsCILock July 23, 2025 17:33 — with GitHub Actions Inactive
@hvdijk hvdijk temporarily deployed to WindowsCILock July 23, 2025 18:14 — with GitHub Actions Inactive
@hvdijk hvdijk temporarily deployed to WindowsCILock July 23, 2025 18:14 — with GitHub Actions Inactive
@hvdijk
Copy link
Contributor Author

hvdijk commented Jul 25, 2025

Just a heads up that after today I will be on holiday. I am not expecting reviews to be done today, that is fine, but it will be a little while before I'll be able to respond to any issues or concerns.

Copy link
Contributor

@premanandrao premanandrao left a comment

Choose a reason for hiding this comment

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

FE changes LGTM

Comment on lines +178 to +182
// Note: These signatures for parallel_for_work_item are intentionally
// non-conforming. The spec says this should take const WorkItemFunctionT &,
// but we take it by value, and rely on passing by value being done as passing
// a copy by reference (ptr byval) to ensure that the special handling in
// SYCLLowerWGScopePass to mutate the passed functor object works.
Copy link
Contributor

Choose a reason for hiding this comment

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

Hierarchical parallelism is deprecated in SYCL 2020, so nobody cares, I guess.

@sarnex
Copy link
Contributor

sarnex commented Aug 25, 2025

It seems weird, but this PR hung twice on Windows BMG where other PRs passed, I don't expect it would effect GPU since this is NativeCPU. Are there any changes here that could cause this?

@hvdijk
Copy link
Contributor Author

hvdijk commented Aug 25, 2025

It seems weird, but this PR hung twice on Windows BMG where other PRs passed, I don't expect it would effect GPU since this is NativeCPU. Are there any changes here that could cause this?

No, nothing; I would be surprised if it's caused by anything in this PR. I'll retry a few more times.

@hvdijk
Copy link
Contributor Author

hvdijk commented Aug 25, 2025

@intel/llvm-gatekeepers This is ready to be merged, thanks.

@againull againull merged commit 5b5fd84 into intel:sycl Aug 26, 2025
48 of 53 checks passed
@aelovikov-intel
Copy link
Contributor

We suspect this or something related is responsible for the CI struggles. Looks like libclc compilation produces enormous amount of warnings like

2025-09-03T17:58:29.2406279Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:38:1: warning: unknown attribute 'libclc_call' ignored [-Wunknown-attributes]
2025-09-03T17:58:29.2406520Z    38 | __CLC_DECLARE_ATOMIC(global)
2025-09-03T17:58:29.2406725Z       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
2025-09-03T17:58:29.2407700Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:22:17: note: expanded from macro '__CLC_DECLARE_ATOMIC'
2025-09-03T17:58:29.2408369Z    22 |   _CLC_OVERLOAD _CLC_DECL void FUNCTION(volatile ADDRSPACE __CLC_GENTYPE *Ptr, \
2025-09-03T17:58:29.2408650Z       |                 ^~~~~~~~~
2025-09-03T17:58:29.2409389Z /__w/llvm/llvm/src/libclc/clc/include/clc/clcfunc.h:28:34: note: expanded from macro '_CLC_DECL'
2025-09-03T17:58:29.2410190Z    28 | #define _CLC_DECL __attribute__((libclc_call))
2025-09-03T17:58:29.2410767Z       |                                  ^~~~~~~~~~~

and then Github Actions struggle processing all that output. @hvdijk please make take a look ASAP.

@hvdijk
Copy link
Contributor Author

hvdijk commented Sep 3, 2025

Can you point me to where you are seeing these warnings, please? This PR adds both the definition of the libclc_call attribute in Clang, and the use of it in libclc. The warning would be expected if libclc was getting compiled with a compiler that did not support this attribute, but I cannot imagine why that would happen, and I am not seeing that in the CI for the SYCL nightly.

@aelovikov-intel
Copy link
Contributor

aelovikov-intel commented Sep 3, 2025

We're seeing that in pre-commit build jobs, e.g. https://github.com/intel/llvm/actions/runs/17445027793/job/49537268401

And a bit more copy-paste context:

2025-09-03T17:58:29.2342178Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:39:1: warning: 'libclc_call' calling convention is not supported for this target [-Wignored-attributes]
2025-09-03T17:58:29.2342626Z    39 | __CLC_DECLARE_ATOMIC(local)
2025-09-03T17:58:29.2347000Z       | ^
2025-09-03T17:58:29.2348090Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:22:17: note: expanded from macro '__CLC_DECLARE_ATOMIC'
2025-09-03T17:58:29.2348907Z    22 |   _CLC_OVERLOAD _CLC_DECL void FUNCTION(volatile ADDRSPACE __CLC_GENTYPE *Ptr, \
2025-09-03T17:58:29.2349101Z       |                 ^
2025-09-03T17:58:29.2349825Z /__w/llvm/llvm/src/libclc/clc/include/clc/clcfunc.h:28:34: note: expanded from macro '_CLC_DECL'
2025-09-03T17:58:29.2350408Z    28 | #define _CLC_DECL __attribute__((libclc_call))
2025-09-03T17:58:29.2350701Z       |                                  ^
2025-09-03T17:58:29.2351352Z In file included from /__w/llvm/llvm/src/libclc/clc/lib/generic/atomic/clc_atomic_store.cl:9:
2025-09-03T17:58:29.2352396Z In file included from /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/clc_atomic_store.h:21:
2025-09-03T17:58:29.2353079Z In file included from /__w/llvm/llvm/src/libclc/clc/include/clc/math/gentype.inc:163:
2025-09-03T17:58:29.2354041Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:39:1: warning: unknown attribute 'libclc_call' ignored [-Wunknown-attributes]
2025-09-03T17:58:29.2354355Z    39 | __CLC_DECLARE_ATOMIC(local)
2025-09-03T17:58:29.2354608Z       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
2025-09-03T17:58:29.2356143Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:22:17: note: expanded from macro '__CLC_DECLARE_ATOMIC'
2025-09-03T17:58:29.2356686Z    22 |   _CLC_OVERLOAD _CLC_DECL void FUNCTION(volatile ADDRSPACE __CLC_GENTYPE *Ptr, \
2025-09-03T17:58:29.2356892Z       |                 ^~~~~~~~~
2025-09-03T17:58:29.2357581Z /__w/llvm/llvm/src/libclc/clc/include/clc/clcfunc.h:28:34: note: expanded from macro '_CLC_DECL'
2025-09-03T17:58:29.2357871Z    28 | #define _CLC_DECL __attribute__((libclc_call))
2025-09-03T17:58:29.2358311Z       |                                  ^~~~~~~~~~~
2025-09-03T17:58:29.2359070Z In file included from /__w/llvm/llvm/src/libclc/clc/lib/generic/atomic/clc_atomic_store.cl:9:
2025-09-03T17:58:29.2359653Z In file included from /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/clc_atomic_store.h:21:
2025-09-03T17:58:29.2360168Z In file included from /__w/llvm/llvm/src/libclc/clc/include/clc/math/gentype.inc:163:
2025-09-03T17:58:29.2361222Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:39:1: warning: unknown attribute 'libclc_call' ignored [-Wunknown-attributes]
2025-09-03T17:58:29.2361593Z    39 | __CLC_DECLARE_ATOMIC(local)
2025-09-03T17:58:29.2362060Z       | ^~~~~~~~~~~~~~~~~~~~~~~~~~~
2025-09-03T17:58:29.2363042Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:22:17: note: expanded from macro '__CLC_DECLARE_ATOMIC'
2025-09-03T17:58:29.2363533Z    22 |   _CLC_OVERLOAD _CLC_DECL void FUNCTION(volatile ADDRSPACE __CLC_GENTYPE *Ptr, \
2025-09-03T17:58:29.2363831Z       |                 ^~~~~~~~~
2025-09-03T17:58:29.2364753Z /__w/llvm/llvm/src/libclc/clc/include/clc/clcfunc.h:28:34: note: expanded from macro '_CLC_DECL'
2025-09-03T17:58:29.2365108Z    28 | #define _CLC_DECL __attribute__((libclc_call))
2025-09-03T17:58:29.2365545Z       |                                  ^~~~~~~~~~~
2025-09-03T17:58:29.2366528Z In file included from /__w/llvm/llvm/src/libclc/clc/lib/generic/atomic/clc_atomic_store.cl:9:
2025-09-03T17:58:29.2367422Z In file included from /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/clc_atomic_store.h:21:
2025-09-03T17:58:29.2368032Z In file included from /__w/llvm/llvm/src/libclc/clc/include/clc/math/gentype.inc:163:
2025-09-03T17:58:29.2369117Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:41:1: warning: 'libclc_call' calling convention is not supported for this target [-Wignored-attributes]
2025-09-03T17:58:29.2369464Z    41 | __CLC_DECLARE_ATOMIC()
2025-09-03T17:58:29.2369652Z       | ^
2025-09-03T17:58:29.2370324Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:22:17: note: expanded from macro '__CLC_DECLARE_ATOMIC'
2025-09-03T17:58:29.2371203Z    22 |   _CLC_OVERLOAD _CLC_DECL void FUNCTION(volatile ADDRSPACE __CLC_GENTYPE *Ptr, \
2025-09-03T17:58:29.2371610Z       |                 ^
2025-09-03T17:58:29.2372331Z /__w/llvm/llvm/src/libclc/clc/include/clc/clcfunc.h:28:34: note: expanded from macro '_CLC_DECL'
2025-09-03T17:58:29.2372618Z    28 | #define _CLC_DECL __attribute__((libclc_call))
2025-09-03T17:58:29.2373020Z       |                                  ^
2025-09-03T17:58:29.2373809Z In file included from /__w/llvm/llvm/src/libclc/clc/lib/generic/atomic/clc_atomic_store.cl:9:
2025-09-03T17:58:29.2374396Z In file included from /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/clc_atomic_store.h:21:
2025-09-03T17:58:29.2375275Z In file included from /__w/llvm/llvm/src/libclc/clc/include/clc/math/gentype.inc:163:
2025-09-03T17:58:29.2376251Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:41:1: warning: unknown attribute 'libclc_call' ignored [-Wunknown-attributes]
2025-09-03T17:58:29.2376547Z    41 | __CLC_DECLARE_ATOMIC()
2025-09-03T17:58:29.2376754Z       | ^~~~~~~~~~~~~~~~~~~~~~
2025-09-03T17:58:29.2377623Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:22:17: note: expanded from macro '__CLC_DECLARE_ATOMIC'
2025-09-03T17:58:29.2378295Z    22 |   _CLC_OVERLOAD _CLC_DECL void FUNCTION(volatile ADDRSPACE __CLC_GENTYPE *Ptr, \
2025-09-03T17:58:29.2378861Z       |                 ^~~~~~~~~
2025-09-03T17:58:29.2379595Z /__w/llvm/llvm/src/libclc/clc/include/clc/clcfunc.h:28:34: note: expanded from macro '_CLC_DECL'
2025-09-03T17:58:29.2380082Z    28 | #define _CLC_DECL __attribute__((libclc_call))
2025-09-03T17:58:29.2380595Z       |                                  ^~~~~~~~~~~
2025-09-03T17:58:29.2381673Z In file included from /__w/llvm/llvm/src/libclc/clc/lib/generic/atomic/clc_atomic_store.cl:9:
2025-09-03T17:58:29.2382379Z In file included from /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/clc_atomic_store.h:21:
2025-09-03T17:58:29.2383072Z In file included from /__w/llvm/llvm/src/libclc/clc/include/clc/math/gentype.inc:163:
2025-09-03T17:58:29.2384090Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:41:1: warning: unknown attribute 'libclc_call' ignored [-Wunknown-attributes]
2025-09-03T17:58:29.2384394Z    41 | __CLC_DECLARE_ATOMIC()
2025-09-03T17:58:29.2384771Z       | ^~~~~~~~~~~~~~~~~~~~~~
2025-09-03T17:58:29.2385596Z /__w/llvm/llvm/src/libclc/clc/include/clc/atomic/atomic_decl.inc:22:17: note: expanded from macro '__CLC_DECLARE_ATOMIC'
2025-09-03T17:58:29.2386272Z    22 |   _CLC_OVERLOAD _CLC_DECL void FUNCTION(volatile ADDRSPACE __CLC_GENTYPE *Ptr, \
2025-09-03T17:58:29.2386769Z       |                 ^~~~~~~~~
2025-09-03T17:58:29.2387573Z /__w/llvm/llvm/src/libclc/clc/include/clc/clcfunc.h:28:34: note: expanded from macro '_CLC_DECL'
2025-09-03T17:58:29.2388003Z    28 | #define _CLC_DECL __attribute__((libclc_call))
2025-09-03T17:58:29.2388551Z       |                                  ^~~~~~~~~~~

@hvdijk
Copy link
Contributor Author

hvdijk commented Sep 3, 2025

Ah, thanks. The warning follows "warning: 'libclc_call' calling convention is not supported for this target" in files such as /__w/llvm/llvm/src/libclc/clc/lib/ptx-nvidiacl/workitem/clc_get_group_id.cl, and indeed, for ptx-nvidiacl things, this attribute should not be used. However, the #define _CLC_DECL __attribute__((libclc_call)) is inside #elif defined(CLC_NATIVE_CPU), and CLC_NATIVE_CPU is only meant to be defined for Native CPU.

The libclc CMake is not setting MACRO_ARCH for nvptx(64) or amdgcn, causing the previous value of MACRO_ARCH to be wrongly re-used.

@hvdijk
Copy link
Contributor Author

hvdijk commented Sep 3, 2025

Untested fix: #19971. I'll look at the CI output when it's ready to see if this works as intended.

@hvdijk hvdijk deleted the libclc-call branch September 4, 2025 09:36
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.

9 participants