-
Notifications
You must be signed in to change notification settings - Fork 96
[SYCLomatic] Add braces around kernel call that use root-group #2398
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| // UNSUPPORTED: cuda-8.0 | ||
| // UNSUPPORTED: v8.0 | ||
| // RUN: dpct --format-range=none -out-root %T/root_group_braces %s --cuda-include-path="%cuda-path/include" --use-experimental-features=root-group -- -x cuda --cuda-host-only -std=c++14 | ||
| // RUN: FileCheck %s --match-full-lines --input-file %T/root_group_braces/root_group_braces.dp.cpp | ||
| // RUN: %if build_lit %{icpx -c -fsycl %T/root_group_braces/root_group_braces.dp.cpp -o %T/root_group_braces/root_group_braces.dp.o %} | ||
|
|
||
| #include <cuda_runtime.h> | ||
|
|
||
| __global__ void kernel1() {} | ||
| __global__ void kernel2() {} | ||
|
|
||
| int main() { | ||
| int a = 0; | ||
| // CHECK: case 1: | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync}; | ||
| // CHECK: } | ||
| // CHECK-NEXT break; | ||
| // CHECK: case 2: | ||
| // CHECK-NEXT: { | ||
| // CHECK-NEXT: auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync}; | ||
| // CHECK: } | ||
| // CHECK-NEXT break; | ||
| switch (a) { | ||
| case 1: | ||
| kernel1<<<1, 1>>>(); | ||
| break; | ||
| case 2: | ||
| kernel2<<<1, 1>>>(); | ||
| break; | ||
| default: | ||
| break; | ||
| }; | ||
| return 0; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -106,12 +106,15 @@ __global__ void kernel() { | |
| } | ||
|
|
||
| int main() { | ||
| // CHECK: auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync}; | ||
| // CHECK: { | ||
| // CHECK-NEXT: auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync}; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about insert the exp_pros when on demand? In this case, it is not required. |
||
| // CHECK-EMPTY: | ||
| // CHECK-NEXT: dpct::get_in_order_queue().parallel_for( | ||
| // CHECK-NEXT: sycl::nd_range<3>(sycl::range<3>(1, 1, 2) * sycl::range<3>(1, 1, 2), sycl::range<3>(1, 1, 2)), | ||
| // CHECK-NEXT: exp_props, [=](sycl::nd_item<3> item_ct1) { | ||
| // CHECK-NEXT: kernel(item_ct1); | ||
| // CHECK-NEXT: }); | ||
| // CHECK-NEXT: } | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. if there is only one kernel in the code block, then no need to insert {}. |
||
| // CHECK-NEXT: dpct::get_current_device().queues_wait_and_throw(); | ||
| kernel<<<2, 2>>>(); | ||
| cudaDeviceSynchronize(); | ||
|
|
@@ -193,12 +196,16 @@ __global__ void foo_tile32() { | |
| } | ||
|
|
||
| int foo3() { | ||
| //CHECK: auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync}; | ||
| //CHECK-NEXT: dpct::get_in_order_queue().parallel_for( | ||
| //CHECK-NEXT: sycl::nd_range<3>(sycl::range<3>(1, 1, 1), sycl::range<3>(1, 1, 1)), | ||
| //CHECK-NEXT: exp_props, [=](sycl::nd_item<3> item_ct1) {{\[\[}}intel::reqd_sub_group_size(32){{\]\]}} { | ||
| //CHECK-NEXT: foo2(item_ct1); | ||
| //CHECK-NEXT: }); | ||
| // CHECK: { | ||
| // CHECK-NEXT: auto exp_props = sycl::ext::oneapi::experimental::properties{sycl::ext::oneapi::experimental::use_root_sync}; | ||
| // CHECK-NEXT: dpct::get_device(dpct::get_device_id(dpct::get_in_order_queue().get_device())).has_capability_or_fail({sycl::aspect::fp64}); | ||
| // CHECK-EMPTY: | ||
| // CHECK-NEXT: dpct::get_in_order_queue().parallel_for( | ||
| // CHECK-NEXT: sycl::nd_range<3>(sycl::range<3>(1, 1, 1), sycl::range<3>(1, 1, 1)), | ||
| // CHECK-NEXT: exp_props, [=](sycl::nd_item<3> item_ct1) {{\[\[}}intel::reqd_sub_group_size(32){{\]\]}} { | ||
| // CHECK-NEXT: foo2(item_ct1); | ||
| // CHECK-NEXT: }); | ||
| // CHECK-NEXT: } | ||
| foo2<<<1,1>>>(); | ||
| return 0; | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we inline the exp_props in parallel_for?