[PATCH] D60455: [SYCL] Implement SYCL device code outlining
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 18 15:15:25 PDT 2019
aaron.ballman added inline comments.
================
Comment at: clang/test/SemaSYCL/device-attributes.cpp:3
+
+[[clang::sycl_kernel]] int gv2 = 0; // expected-warning {{'sycl_kernel' attribute only applies to functions}}
+__attribute((sycl_kernel)) int gv3 = 0; // expected-warning {{'sycl_kernel' attribute only applies to functions}}
----------------
Fznamznon wrote:
> aaron.ballman wrote:
> > I'd like to see some more tests covering less obvious scenarios. Can I add this attribute to a lambda? What about a member function? How does it work with virtual functions? That sort of thing.
> Actually there is no restrictions for adding this attribute to any function to outline device code so I just checked the simplest variant.
>
> But I'm working on new patch which will put some requirements on function which is marked with `sycl_kernel` attribute.
> This new patch will add generation of OpenCL kernel from function marked with `sycl_kernel` attribute. The main idea of this approach is described in this [[ https://github.com/intel/llvm/blob/sycl/sycl/doc/SYCL_compiler_and_runtime_design.md#lowering-of-lambda-function-objects-and-named-function-objects | document ]] (in this document generated kernel is called "kernel wrapper").
> And to be able to generate OpenCL kernel using function marked with `sycl_kernel` attribute we put some requirements on this function, for example it must be a template function. You can find these requirements and example of proper function which can be marked with `sycl_kernel` in this [[ https://github.com/intel/llvm/pull/177#discussion_r290451286 | comment ]] .
>
>
> Actually there is no restrictions for adding this attribute to any function to outline device code so I just checked the simplest variant.
So there are no concerns about code like:
```
struct Base {
__attribute__((sycl_kernel)) virtual void foo();
virtual void bar();
};
struct Derived : Base {
void foo() override;
__attribute__((sycl_kernel)) void bar() override;
};
void f(Base *B, Derived *D) {
// Will all of these "do the right thing"?
B->foo();
B->bar();
D->foo();
D->bar();
}
```
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