-
Notifications
You must be signed in to change notification settings - Fork 796
Add sycl ext intel kernel queries extension #16834
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 18 commits
5434020
ae3d216
94dea19
cd0b7be
20e364c
519e2b1
1d2f7bc
2029e2b
51b9c0c
4f4e4db
ea46e7c
03ba27d
58d392d
b0f2b27
36cf3bd
3cf5c72
79f35f7
f47ba21
7e7a422
07a3b7c
597e5f0
106b1e2
34f24f3
13ff634
fd68f4d
3443815
7402507
d918044
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,139 @@ | ||
| = sycl_ext_intel_kernel_queries | ||
|
|
||
| :source-highlighter: coderay | ||
| :coderay-linenums-mode: table | ||
|
|
||
| // This section needs to be after the document title. | ||
| :doctype: book | ||
| :toc2: | ||
| :toc: left | ||
| :encoding: utf-8 | ||
| :lang: en | ||
| :dpcpp: pass:[DPC++] | ||
| :endnote: —{nbsp}end{nbsp}note | ||
|
|
||
| // Set the default source code type in this document to C++, | ||
| // for syntax highlighting purposes. This is needed because | ||
| // docbook uses c++ and html5 uses cpp. | ||
| :language: {basebackend@docbook:c++:cpp} | ||
|
|
||
|
|
||
| == Notice | ||
|
|
||
| [%hardbreaks] | ||
| Copyright (C) 2025 Intel Corporation. All rights reserved. | ||
|
|
||
| Khronos(R) is a registered trademark and SYCL(TM) and SPIR(TM) are trademarks | ||
| of The Khronos Group Inc. OpenCL(TM) is a trademark of Apple Inc. used by | ||
| permission by Khronos. | ||
|
|
||
|
|
||
| == Contact | ||
|
|
||
| To report problems with this extension, please open a new issue at: | ||
|
|
||
| https://github.com/intel/llvm/issues | ||
|
|
||
|
|
||
| == Dependencies | ||
|
|
||
| This extension is written against the SYCL 2020 revision 9 specification. | ||
| All references below to the "core SYCL specification" or to section numbers in | ||
| the SYCL specification refer to that revision. | ||
|
|
||
|
|
||
| == Status | ||
|
|
||
| This extension is implemented and fully supported by {dpcpp}. | ||
|
|
||
|
|
||
| == Overview | ||
|
|
||
| This extension contains a collection of queries that provide low-level | ||
| information about kernels. | ||
| These queries generally forward directly to the backend and expose concepts that | ||
| are specific to a particular implementation. | ||
| As a result, these queries may not be supported for all devices. | ||
| Each query has an associate device aspect, which tells whether the query is | ||
| supported on that device. | ||
|
|
||
|
|
||
| == Specification | ||
|
|
||
| === Feature test macro | ||
|
|
||
| This extension provides a feature-test macro as described in the core SYCL | ||
| specification. | ||
| An implementation supporting this extension must predefine the macro | ||
| `SYCL_EXT_INTEL_KERNEL_QUERIES` to one of the values defined in the table below. | ||
| Applications can test for the existence of this macro to determine if the | ||
| implementation supports this feature, or applications can test the macro's value | ||
| to determine which of the extension's features the implementation supports. | ||
|
|
||
| [%header,cols="1,5"] | ||
| |=== | ||
| |Value | ||
| |Description | ||
|
|
||
| |1 | ||
| |Initial version of this extension. | ||
| |=== | ||
|
|
||
| === Spill memory size | ||
|
|
||
| This query returns the kernel's spill memory size that is allocated by the | ||
| compiler, as reported by Level Zero. | ||
|
|
||
| ==== New device aspect | ||
|
|
||
| This extension adds the following new device aspect. | ||
|
|
||
| [source,c++] | ||
| ---- | ||
| namespace sycl { | ||
|
|
||
| enum class aspect { | ||
| ext_intel_spill_memory_size | ||
|
|
||
| // ... | ||
| }; | ||
|
|
||
| } | ||
| ---- | ||
|
|
||
| ''' | ||
|
|
||
| `*ext_intel_spill_memory_size*` | ||
|
|
||
| Indicates that the `spill_memory_size` kernel information descriptor may be used | ||
| to query kernels for this device. | ||
|
|
||
| ''' | ||
|
|
||
| ==== New device specific kernel information descriptor | ||
|
|
||
| This extension adds the following information descriptor that can be used with | ||
| `kernel::get_info(const device&)`. | ||
|
|
||
| ''' | ||
|
|
||
| `*ext::intel::info::kernel_device_specific::spill_memory_size*` | ||
|
|
||
| [source,c++] | ||
| ---- | ||
| namespace sycl::ext::intel::info::kernel_device_specific { | ||
| struct spill_memory_size { | ||
| using return_type = size_t; | ||
| }; | ||
| } // namespace sycl::ext::intel::info::kernel_device_specific | ||
| ---- | ||
|
|
||
| _Remarks:_ Template parameter to `kernel::get_info(const device&)`. | ||
|
|
||
| _Returns:_ The spill memory size that is allocated by the compiler for this | ||
| kernel for the given device. | ||
|
|
||
| _Throws:_ An `exception` with the `errc::feature_not_supported` error code if | ||
| the device does not have `aspect::ext_intel_spill_memory_size`. | ||
|
|
||
| ''' | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| __SYCL_PARAM_TRAITS_SPEC(ext::intel, kernel_device_specific, spill_memory_size, size_t, UR_KERNEL_INFO_SPILL_MEM_SIZE) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -146,6 +146,54 @@ uint32_t get_kernel_device_specific_info_with_input(ur_kernel_handle_t Kernel, | |||||
|
|
||||||
| return Result; | ||||||
| } | ||||||
|
|
||||||
| template <> | ||||||
| inline ext::intel::info::kernel_device_specific::spill_memory_size::return_type | ||||||
| get_kernel_device_specific_info< | ||||||
| ext::intel::info::kernel_device_specific::spill_memory_size>( | ||||||
| ur_kernel_handle_t Kernel, ur_device_handle_t Device, | ||||||
| const AdapterPtr &Adapter) { | ||||||
| size_t ResultSize = 0; | ||||||
| ur_kernel_info_t PropName = UR_KERNEL_INFO_SPILL_MEM_SIZE; | ||||||
|
||||||
|
|
||||||
| // First call to get the number of device images | ||||||
| Adapter->call<UrApiKind::urKernelGetInfo>(Kernel, PropName, 0, nullptr, | ||||||
| &ResultSize); | ||||||
|
|
||||||
| size_t DeviceCount = ResultSize / sizeof(uint32_t); | ||||||
|
|
||||||
| // Second call to retrieve the data | ||||||
| std::vector<uint32_t> Result(DeviceCount); | ||||||
|
||||||
| std::vector<uint32_t> Result(DeviceCount); | |
| std::vector<uint32_t> Device2SpillMap(DeviceCount); |
kurapov-peter marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
kurapov-peter marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
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.
Is L0 important here?
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.
Normally, we would not define a SYCL API in terms of a particular backend like this. However, it seemed to me that "spill memory size" is too vaguely defined. The reality is that SYCL is just returning whatever value comes from Level Zero. If people have questions about what it means, I'd rather direct them to Level Zero.
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.
fair enough