-
Notifications
You must be signed in to change notification settings - Fork 795
[SYCL] add clang diagnostic for illegal types of kernel free function arguments #19244
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
Merged
steffenlarsen
merged 26 commits into
intel:sycl
from
dklochkov-emb:sycl-free-function-illegal-types
Aug 21, 2025
Merged
Changes from 13 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
6a61f36
[SYCL] add clang diagnostic for illegal data types of kernel free fun…
dklochkov-emb 54d198e
[SYCL] fix syntax
dklochkov-emb 778314d
Merge branch 'sycl' into sycl-free-function-illegal-types
dklochkov-emb e57c90c
[SYCL] do not emit diagnostics if class with virtual method is used a…
dklochkov-emb e4036ad
[SYCL] fix formatting
dklochkov-emb dedadc1
[SYCL] remove unnecessary change
dklochkov-emb d9c209d
[SYCL][E2E] do not save integration header
dklochkov-emb 208e1a8
[SYCL] do not serialize string number into integer if mangled name is…
dklochkov-emb a96965e
Merge remote-tracking branch 'upstream/sycl' into sycl-free-function-…
dklochkov-emb 18a7adb
[SYCL] use visitor infrastructure to emit clang diagnostics
dklochkov-emb bc1ae10
Merge remote-tracking branch 'upstream/sycl' into sycl-free-function-…
dklochkov-emb 61e3b45
[SYCL][E2E] remove redudant const
dklochkov-emb bf79a78
Merge remote-tracking branch 'upstream/sycl' into sycl-free-function-…
dklochkov-emb a33a06a
[SYCL] use SyclKernelFieldChecker to check for virtual inheritance
dklochkov-emb 7cdd945
Merge remote-tracking branch 'upstream/sycl' into sycl-free-function-…
dklochkov-emb 375485e
[SYCL] do not recurse withh on whole method
dklochkov-emb 6f9ef69
[SYCL] use leaveStruct method to check on virtual inheritance
dklochkov-emb 5722de2
[SYCL] fix formatting
dklochkov-emb c9f944c
[SYCL] fix coding style
dklochkov-emb 9adf700
[SYCL] use checker constructor to pass free function location
dklochkov-emb 1779409
[SYCL] update diagostic error name
dklochkov-emb df2523d
[SYCL] add new tests to check virtual inhertance
dklochkov-emb e2e229b
[SYCL] more tests
dklochkov-emb 56e8997
[SYCL] fix empty line
dklochkov-emb b221357
Merge remote-tracking branch 'upstream/sycl' into sycl-free-function-…
dklochkov-emb 361c0fa
[SYCL] remove unused variables and arguments
dklochkov-emb File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,101 @@ | ||
| // RUN: %{build} -o %t.out | ||
| // RUN: %{run} %t.out | ||
|
|
||
dklochkov-emb marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| /* | ||
| * Test to check class/struct type with virtual methods as SYCL free function | ||
| * kernel arguments. | ||
| */ | ||
|
|
||
| #include <iostream> | ||
| #include <sycl/detail/core.hpp> | ||
| #include <sycl/ext/oneapi/free_function_queries.hpp> | ||
| #include <sycl/kernel_bundle.hpp> | ||
| #include <sycl/usm.hpp> | ||
|
|
||
| namespace syclext = sycl::ext::oneapi; | ||
| namespace syclexp = sycl::ext::oneapi::experimental; | ||
|
|
||
| static constexpr size_t NUM = 1024; | ||
| static constexpr size_t WGSIZE = 16; | ||
| static constexpr auto FFTestMark = "Free function Kernel Test:"; | ||
| static constexpr float offset = 1.1f; | ||
|
|
||
| class Base { | ||
| public: | ||
| virtual void virtual_method(float start) = 0; | ||
| virtual ~Base() = default; | ||
| }; | ||
|
|
||
| class TestClass : public Base { | ||
| float data = 0.0f; | ||
|
|
||
| public: | ||
| void virtual_method(float start) override {} | ||
|
|
||
| float calculate(float start, size_t id) { | ||
| return start + static_cast<float>(id) + data; | ||
| } | ||
|
|
||
| void setData(float value) { data = value; } | ||
| }; | ||
|
|
||
| SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclexp::nd_range_kernel<2>)) | ||
| void func_range(TestClass *acc, float *ptr) { | ||
| size_t id = syclext::this_work_item::get_nd_item<1>().get_global_linear_id(); | ||
| ptr[id] = acc->calculate(3.14f, id); | ||
| } | ||
|
|
||
| SYCL_EXT_ONEAPI_FUNCTION_PROPERTY((syclexp::single_task_kernel)) | ||
| void func_single(TestClass *acc, float *ptr) { | ||
| size_t id = syclext::this_work_item::get_nd_item<1>().get_global_linear_id(); | ||
| ptr[id] = acc->calculate(3.14f, id); | ||
| } | ||
|
|
||
| int check_result(float *ptr) { | ||
| for (size_t i = 0; i < NUM; ++i) { | ||
| const float expected = 3.14f + static_cast<float>(i) + offset; | ||
| if (ptr[i] != expected) | ||
| return 1; | ||
| } | ||
| return 0; | ||
| } | ||
|
|
||
| int call_kernel_code(sycl::queue &q, sycl::kernel &kernel) { | ||
| float *ptr = sycl::malloc_shared<float>(NUM, q); | ||
| TestClass *obj = sycl::malloc_shared<TestClass>(1, q); | ||
| obj->setData(offset); | ||
|
|
||
| q.submit([&](sycl::handler &cgh) { | ||
| cgh.set_args(obj, ptr); | ||
| sycl::nd_range ndr{{NUM}, {WGSIZE}}; | ||
| cgh.parallel_for(ndr, kernel); | ||
| }).wait(); | ||
| int ret = check_result(ptr); | ||
| sycl::free(ptr, q); | ||
| sycl::free(obj, q); | ||
| return ret; | ||
| } | ||
|
|
||
| template <auto *Func> | ||
| int test_arg_with_virtual_method(sycl::queue &q, sycl::context &ctxt, | ||
| std::string_view name) { | ||
| auto exe_bndl = | ||
| syclexp::get_kernel_bundle<Func, sycl::bundle_state::executable>(ctxt); | ||
| sycl::kernel k_func = exe_bndl.template ext_oneapi_get_kernel<Func>(); | ||
| int ret = call_kernel_code(q, k_func); | ||
| if (ret != 0) | ||
| std::cerr << FFTestMark << name << " failed\n"; | ||
| return ret; | ||
| } | ||
|
|
||
| int main() { | ||
| sycl::queue q; | ||
| sycl::context ctxt = q.get_context(); | ||
| sycl::device dev = q.get_device(); | ||
|
|
||
| int ret = | ||
| test_arg_with_virtual_method<func_range>(q, ctxt, "virtual_method_range"); | ||
| ret |= test_arg_with_virtual_method<func_single>(q, ctxt, | ||
| "virtual_method_single"); | ||
| return ret; | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.