-
Notifications
You must be signed in to change notification settings - Fork 795
Description
Describe the bug
Here is an example of the code to demonstrate the inconsistency:
$ cat example.cpp
SYCL_EXTERNAL int mul(int x) {
return x * 42;
}
$ clang++ -fsycl-device-only example.cpp
$ clang++ -fsycl-host-only example.cpp
example.cpp:1:1: error: unknown type name 'SYCL_EXTERNAL'
1 | SYCL_EXTERNAL int mul(int x) {
| ^
1 error generated.
$ clang++ -fsycl example.cpp
example.cpp:1:1: error: unknown type name 'SYCL_EXTERNAL'
1 | SYCL_EXTERNAL int mul(int x) {
| ^
1 error generated.Device compiler defines SYCL_EXTERNAL macro, whereas host compiler does not.
To define the macro on the host, defines_elementary.hpp header must be included. https://github.com/intel/llvm/blob/sycl/sycl/include/sycl/detail/defines_elementary.hpp#L39
I found this issue while trying to create a simple library of C++ functions available from the SYCL kernels. My library code does not use any SYCL data structures or any symbols. It uses only SYCL_EXTERNAL macro.
I think the implementation should define this macro consistently either using the compiler or using the library, but not both.
@gmlueck, @tahonermann, @Fznamznon, what do you think?
My personal preference is to use the compiler to define SYCL_EXTERNAL.
To reproduce
No response
Environment
No response
Additional context
No response