-
Notifications
You must be signed in to change notification settings - Fork 796
[SYCL] Implement sycl_ext_oneapi_get_kernel_info extension #15650
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 2 commits
Commits
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| //==----- get_kernel_info.hpp --- SYCL get_kernel_info extension -------==// | ||
| // | ||
| // 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 | ||
| // | ||
| //===------------------------------------------------------------------===// | ||
|
|
||
| #pragma once | ||
| #include <sycl/context.hpp> | ||
| #include <sycl/detail/export.hpp> | ||
| #include <sycl/detail/info_desc_helpers.hpp> | ||
| #include <sycl/device.hpp> | ||
| #include <sycl/queue.hpp> | ||
|
|
||
| namespace sycl { | ||
| inline namespace _V1 { | ||
| namespace ext::oneapi { | ||
|
|
||
| template <typename KernelName, typename Param> | ||
| typename sycl::detail::is_kernel_info_desc<Param>::return_type | ||
| get_kernel_info(const context &Ctx) { | ||
| auto Bundle = | ||
| sycl::get_kernel_bundle<KernelName, sycl::bundle_state::executable>(Ctx); | ||
| return Bundle.template get_kernel<KernelName>().template get_info<Param>(); | ||
| } | ||
|
|
||
| template <typename KernelName, typename Param> | ||
| typename sycl::detail::is_kernel_device_specific_info_desc<Param>::return_type | ||
| get_kernel_info(const context &Ctx, const device &Dev) { | ||
| auto Bundle = | ||
| sycl::get_kernel_bundle<KernelName, sycl::bundle_state::executable>(Ctx); | ||
| return Bundle.template get_kernel<KernelName>().template get_info<Param>(Dev); | ||
| } | ||
|
|
||
| template <typename KernelName, typename Param> | ||
| typename sycl::detail::is_kernel_device_specific_info_desc<Param>::return_type | ||
| get_kernel_info(const queue &Q) { | ||
| auto Bundle = | ||
| sycl::get_kernel_bundle<KernelName, sycl::bundle_state::executable>( | ||
| Q.get_context()); | ||
| return Bundle.template get_kernel<KernelName>().template get_info<Param>( | ||
| Q.get_device()); | ||
| } | ||
|
|
||
| } // namespace ext::oneapi | ||
| } // namespace _V1 | ||
| } // namespace sycl | ||
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,45 @@ | ||
| // RUN: %{build} -o %t.out | ||
| // RUN: %{run} %t.out | ||
| // | ||
| // Fail is flaky for level_zero, enable when fixed. | ||
| // UNSUPPORTED: level_zero | ||
| // | ||
| // Consistently fails with opencl gpu, enable when fixed. | ||
| // XFAIL: opencl && gpu | ||
| // XFAIL-TRACKER: GSD-8971 | ||
|
|
||
| //==--- kernel_info_attr.cpp - SYCL info::kernel::attributes test ---==// | ||
| // | ||
| // 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 | ||
| // | ||
| //===---------------------------------------------------------------===// | ||
|
|
||
| #include <cassert> | ||
| #include <sycl/detail/core.hpp> | ||
| #include <sycl/ext/oneapi/get_kernel_info.hpp> | ||
|
|
||
| using namespace sycl; | ||
| namespace syclex = sycl::ext::oneapi; | ||
|
|
||
| int main() { | ||
| queue q; | ||
| auto ctx = q.get_context(); | ||
| buffer<int, 1> buf(range<1>(1)); | ||
| auto KernelID = sycl::get_kernel_id<class SingleTask>(); | ||
| auto KB = get_kernel_bundle<bundle_state::executable>(ctx, {KernelID}); | ||
| kernel krn = KB.get_kernel(KernelID); | ||
|
|
||
| q.submit([&](handler &cgh) { | ||
| auto acc = buf.get_access<access::mode::read_write>(cgh); | ||
| cgh.single_task<class SingleTask>(krn, [=]() { acc[0] = acc[0] + 1; }); | ||
| }); | ||
|
|
||
| const std::string krnAttr = krn.get_info<info::kernel::attributes>(); | ||
| assert(krnAttr.empty()); | ||
| const std::string krnAttrExt = | ||
| syclex::get_kernel_info<SingleTask, info::kernel::attributes>(ctx); | ||
| assert(krnAttr == krnAttrExt); | ||
| 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.