-
Notifications
You must be signed in to change notification settings - Fork 796
[SYCL][COMPAT] Ensure launched kernels are fully inlined
#15941
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
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7dc5195
Ensure `launch`ed kernels are fully inlined
joeatodd 5fefc0e
Formatting
joeatodd c96eca6
Fix kernel_properties.cpp test
joeatodd 457f307
Test for inlining
joeatodd 89eec99
Simplify test
joeatodd f640e40
Provide work-group & global size
joeatodd fa563c2
inline dummy_fn
joeatodd 719ff74
Remove dummy_fn
joeatodd 3e43f4c
Formatting
joeatodd 2425903
Don't specify (unused) target triple
joeatodd 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /*************************************************************************** | ||
| * | ||
| * Copyright (C) Codeplay Software Ltd. | ||
| * | ||
| * Part of the LLVM Project, under the Apache License v2.0 with LLVM | ||
| * Exceptions. See https://llvm.org/LICENSE.txt for license information. | ||
| * SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| * | ||
| * SYCLcompat API | ||
| * | ||
| * launch_inlining.cpp | ||
| * | ||
| * Description: | ||
| * Ensure kernels are inlined | ||
| **************************************************************************/ | ||
| // RUN: %clangxx -fsycl -fgpu-inline-threshold=0 %if cl_options %{/clang:-S /clang:-emit-llvm%} %else %{-S -emit-llvm%} %s -o - | FileCheck %s | ||
| // We set -fgpu-inline-threshold=0 to disable heuristic inlining for the | ||
| // purposes of the test | ||
| #include <sycl/detail/core.hpp> | ||
| #include <sycl/group_barrier.hpp> | ||
| #include <syclcompat/launch.hpp> | ||
| #include <syclcompat/memory.hpp> | ||
|
|
||
| namespace compat_exp = syclcompat::experimental; | ||
| namespace sycl_exp = sycl::ext::oneapi::experimental; | ||
| namespace sycl_intel_exp = sycl::ext::intel::experimental; | ||
|
|
||
| static constexpr int LOCAL_MEM_SIZE = 1024; | ||
|
|
||
| // CHECK: define {{.*}}spir_kernel{{.*}}write_mem_kernel{{.*}} { | ||
| // CHECK-NOT: call {{.*}}write_mem_kernel | ||
| // CHECK: } | ||
|
|
||
| template <typename T> void write_mem_kernel(T *data, int num_elements) { | ||
| const int id = | ||
| sycl::ext::oneapi::this_work_item::get_nd_item<1>().get_global_id(0); | ||
| if (id < num_elements) { | ||
| data[id] = static_cast<T>(id); | ||
| } | ||
| }; | ||
|
|
||
| // CHECK: define {{.*}}spir_kernel{{.*}}dynamic_local_mem_typed_kernel{{.*}} { | ||
| // CHECK-NOT: call {{.*}}dynamic_local_mem_typed_kernel | ||
| // CHECK: } | ||
| template <typename T> | ||
| void dynamic_local_mem_typed_kernel(T *data, char *local_mem) { | ||
| constexpr size_t num_elements = LOCAL_MEM_SIZE / sizeof(T); | ||
| T *typed_local_mem = reinterpret_cast<T *>(local_mem); | ||
|
|
||
| const int id = | ||
| sycl::ext::oneapi::this_work_item::get_nd_item<1>().get_global_id(0); | ||
| if (id < num_elements) { | ||
| typed_local_mem[id] = static_cast<T>(id); | ||
| } | ||
| sycl::group_barrier(sycl::ext::oneapi::this_work_item::get_work_group<1>()); | ||
| if (id < num_elements) { | ||
| data[id] = typed_local_mem[num_elements - id - 1]; | ||
| } | ||
| }; | ||
|
|
||
| int test_write_mem() { | ||
| compat_exp::launch_policy my_dim3_config(syclcompat::dim3{32}, | ||
| syclcompat::dim3{32}); | ||
|
|
||
| const int memsize = 1024; | ||
| int *d_a = (int *)syclcompat::malloc(memsize); | ||
| compat_exp::launch<write_mem_kernel<int>>(my_dim3_config, d_a, | ||
| memsize / sizeof(int)) | ||
| .wait(); | ||
|
|
||
| syclcompat::free(d_a); | ||
| return 0; | ||
| } | ||
|
|
||
| int test_lmem_launch() { | ||
| int local_mem_size = LOCAL_MEM_SIZE; | ||
|
|
||
| size_t num_elements = local_mem_size / sizeof(int); | ||
| int *d_a = (int *)syclcompat::malloc(local_mem_size); | ||
|
|
||
| compat_exp::launch_policy my_config( | ||
| sycl::nd_range<1>{{256}, {256}}, | ||
| compat_exp::local_mem_size(local_mem_size)); | ||
|
|
||
| compat_exp::launch<dynamic_local_mem_typed_kernel<int>>(my_config, d_a) | ||
| .wait(); | ||
|
|
||
| syclcompat::free(d_a); | ||
|
|
||
| return 0; | ||
| } |
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.