-
Notifications
You must be signed in to change notification settings - Fork 752
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
Add sycl ext intel kernel queries extension #16834
base: sycl
Are you sure you want to change the base?
Add sycl ext intel kernel queries extension #16834
Conversation
sycl/doc/extensions/proposed/sycl_ext_intel_kernel_queries.asciidoc
Outdated
Show resolved
Hide resolved
sycl/doc/extensions/proposed/sycl_ext_intel_kernel_queries.asciidoc
Outdated
Show resolved
Hide resolved
sycl/source/detail/kernel_info.hpp
Outdated
inline ext::intel::info::kernel::spill_mem_size::return_type | ||
get_kernel_device_specific_info<ext::intel::info::kernel::spill_mem_size>( | ||
ur_kernel_handle_t Kernel, ur_device_handle_t Device, | ||
const AdapterPtr &Adapter) { |
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 it possible to check for the aspect here as well?
sycl/source/detail/kernel_info.hpp
Outdated
// Retrieve the associated device list | ||
size_t URDevicesSize = 0; | ||
Adapter->call<UrApiKind::urProgramGetInfo>(Program, UR_PROGRAM_INFO_DEVICES, | ||
0, nullptr, &URDevicesSize); | ||
|
||
std::vector<ur_device_handle_t> URDevices(URDevicesSize / | ||
sizeof(ur_device_handle_t)); | ||
Adapter->call<UrApiKind::urProgramGetInfo>(Program, UR_PROGRAM_INFO_DEVICES, | ||
URDevicesSize, URDevices.data(), | ||
nullptr); | ||
assert(Result.size() == URDevices.size()); | ||
|
||
// Map the result back to the program devices | ||
for (size_t idx = 0; idx < URDevices.size(); ++idx) { | ||
if (URDevices[idx] == Device) | ||
return Result[idx]; | ||
} |
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.
The mapping to devices relies on UR providing the same order within a single application (see oneapi-src/unified-runtime#2614 for details). There was a problem inside UR implementation that demanded the API to return an array of values for spills instead of a single value (due to device pointer unavailability). This implementation hides that inconvenience from SYCL users.
sycl/source/detail/kernel_info.hpp
Outdated
throw exception(make_error_code(errc::runtime), | ||
"ext::intel::info::kernel::spill_mem_size failed to retrieve " | ||
"the requested value"); |
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 this the right type of exception?
sycl/test-e2e/Basic/kernel_info.cpp
Outdated
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.
There might be a better way to test the thing. This would just return zero. Any suggestions?
Here is my proposal for how the specification should be.
Hi @kurapov-peter, I hope you don't mind, but I pushed a commit with my proposal for how the specification should look in b027f87. Feel free to revert this commit if you are opposed, or to add comments in this PR. Here is my rationale for some of the changes:
Note that I did not update the implementation, so that will need to be changed to match the spec. |
All the changes look reasonable to me. I'll update the implementation. |
=== Spill memory size | ||
|
||
This query returns the kernel's spill memory size that is allocated by the | ||
compiler, as reported by 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.
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
#16810 is merged, so this has no dependencies. Putting it to ready for review. |
@@ -128,6 +128,7 @@ attributes #2 = { nounwind } | |||
!77 = !{!"ext_oneapi_bindless_images_sample_2d_usm", i32 79} | |||
!78 = !{!"ext_oneapi_atomic16", i32 80} | |||
!79 = !{!"ext_oneapi_virtual_functions", i32 81} | |||
!79 = !{!"ext_intel_spill_memory_size", i32 82} |
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.
I doubt that this line has any effect on the test, so you may as well drop it. Moreover, I'm not sure what are the rules of redefining metadata, it may not be a valid change at all
const size_t spillMemSz = | ||
krn.get_info<ext::intel::info::kernel_device_specific::spill_memory_size>( | ||
dev); | ||
assert(spillMemSz >= 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.
This should be hidden under an if
, the query is not guaranteed to be supported everywhere. The same goes for other change in this file.
@Pennycook could you review this for @intel/dpcpp-specification-reviewers ? I'm the author of the spec in this PR. |
This is a draft for the extension and its implementation. In a nutshell, the extension adds compiled kernel traits for the intel backend. The traits can be queried using the usual
kernel::get_info()
calls (andget_kernel_info
). A new device aspect tells whether the query is supported on the device.