[PATCH] D60455: [SYCL] Add support for SYCL device attributes

Alexey Bader via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 16 09:02:24 PDT 2019


bader added a comment.

In D60455#1467279 <https://reviews.llvm.org/D60455#1467279>, @aaron.ballman wrote:

> In D60455#1464324 <https://reviews.llvm.org/D60455#1464324>, @Fznamznon wrote:
>
> > Applied comments from @aaron.ballman and @keryell
> >
> > - Introduced a C++11 and C2x style spelling in the clang namespace. I didn't find path to add two namespaces to attribute (like [[clang::sycl::device]]) so [[clang::sycl_device]] spelling is added.
> > - Since both attributes have spellings and possible can be used as some "standard" outlining in Clang/LLVM I added documetation.
> > - Added more test cases.
> > - As @bader mentioned sycl_device can be used to mark functions, which are called from the different translation units so I added simple handling of this attribute in Sema.
>
>
> I'm confused -- I thought @bader also said "...SYCL is not supposed to expose any non-standard extensions to a user." -- these attributes are not standards based (WG21 and WG14 have nothing to say about them), so are these attributes considered "non-standard extensions" or not?


@aaron.ballman sorry for confusion.
SYCL specification doesn't require user to annotate "device functions" with an attribute - it says following (from section 6.9.1 SYCL functions and methods linkage, https://www.khronos.org/registry/SYCL/specs/sycl-1.2.1.pdf, page 251):

> The default behavior in SYCL applications is that all the definitions and declarations of the functions and methods
>  are available to the SYCL compiler, in the same translation unit. When this is not the case, all the symbols that
>  need to be exported to a SYCL library or from a C++ library to a SYCL application need to be defined using the
>  macro: SYCL_EXTERNAL.
>  The SYCL_EXTERNAL macro will only be defined if the implementation supports offline linking. The macro is
>  implementation-defined, but the following restrictions apply:
> 
> • SYCL_EXTERNAL can only be used on functions;
>  • the function cannot use raw pointers as parameter or return types. Explicit pointer classes must be used instead;
>  • externally defined functions cannot call a cl::sycl::parallel_for_work_item method;
>  • externally defined functions cannot be called from a cl::sycl::parallel_for_work_group scope.
> 
> The SYCL linkage mechanism is optional and implementation defined.

The idea I had is that to define `SYCL_EXTERNAL` macro as `sycl_device` attribute.

BTW, I noticed that `SYCL_EXTERNAL` puts additional requirements `sycl_device` doesn't meet:

> • SYCL_EXTERNAL can only be used on functions;

I think our implementation doesn't have such limitations and able to support more use cases.
Anyway, we can make `sycl_device` attribute implicit for now and return to the implementation of cross translation unit dependencies later.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D60455/new/

https://reviews.llvm.org/D60455





More information about the cfe-commits mailing list