Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ _Returns:_ An event that is associated with context `ctxt`. The event has

_Throws:_ An `exception` with the `errc::feature_not_supported` error code if
`PropertyListT` contains an `enable_profiling` property that enables profiling
timestamps and if the platform containing `ctxt` does not support creation of
such events as reported by the `event_profiling` information descriptor.
timestamps and not all devices in `ctxt` have
`aspect::ext_oneapi_per_event_profiling`.
Comment thread
slawekptak marked this conversation as resolved.

'''

Expand Down Expand Up @@ -195,28 +195,28 @@ indicating whether the event captures profiling timestamp information.

'''

=== New information descriptor for the platform class
=== New device aspect

This extension adds the following information descriptor that can be used as the
`Param` template parameter to `platform::get_info`.
This extension adds the following device aspect.

'''

[source,c++]
----
namespace sycl::ext::oneapi::experimental::info::platform {
namespace sycl {

struct event_profiling {
using return_type = bool;
enum class aspect {
ext_oneapi_per_event_profiling
// ...
};

} // namespace sycl::ext::oneapi::experimental::info::platform
} // namespace sycl
----

_Remarks:_ Template parameter to `platform::get_info`.

_Returns:_ The value `true` if this platform allows events to be created with
profiling enabled via `make_event`.
When a device has this aspect, it allows events to be created with profiling
enabled. In order for the `make_event` function to create an event with
profiling enabled, all of the devices in a context provided to that function
need to have this aspect.

'''

Expand Down Expand Up @@ -294,8 +294,8 @@ _Throws:_
have the same context.
* An `exception` with the `errc::feature_not_supported` error code if `evt`
was created with the `enable_profiling` property that enables profiling
timestamps and if the platform associated with `q` does not support creation
of such events as reported by the `event_profiling` information descriptor.
timestamps and if the device associated with `q` does not have
`aspect::ext_oneapi_per_event_profiling`.

[_Note:_ In order to understand why the "command_start" and "command_end"
timestamps are encouraged to be the same, think of the tag operation as an empty
Expand Down Expand Up @@ -384,18 +384,20 @@ static constexpr size_t N = 1024;

int main() {
sycl::queue q;
sycl::context ctxt = q.get_context();

// This example creates a queue that does not enable profiling and then
// creates events that do enable profiling. This is an optional feature, so
// check if the platform supports this.
sycl::platform p = q.get_platform();
if (!p.get_info<syclex::info::platform::event_profiling>) {
std::cout << "Cannot time kernels without enabling profiling on queue\n";
return;
// check if all devices in a context support it.
for (sycl::device dev : ctxt.get_devices()) {
if (!dev.has(sycl::aspect::ext_oneapi_per_event_profiling)) {
std::cout << "Cannot time kernels without per-event profiling support\n";
return 0;
}
}

sycl::event start = syclex::make_event(syclex::enable_profiling{true});
sycl::event end = syclex::make_event(syclex::enable_profiling{true});
sycl::event start = syclex::make_event(ctxt, syclex::enable_profiling{true});
sycl::event end = syclex::make_event(ctxt, syclex::enable_profiling{true});

syclex::enqueue_signal_event(q, start);
sycl::parallel_for(q, {N}, [=](auto i) { /* first kernel */ });
Expand All @@ -422,8 +424,8 @@ using counter-based events:
* The `make_event` function maps to `zeEventCounterBasedCreate`.
If the `enable_profiling` property is specified to `make_event`, the event
should have the corresponding Level Zero flag set.
* Platforms on the Level Zero backend can return `true` for the
`event_profiling` information descriptor.
* Devices on the Level Zero backend can return `true` for
`aspect::ext_oneapi_per_event_profiling`.
* The `enqueue_wait_event` function maps to `zeCommandListAppendWaitOnEvents`.
* The `enqueue_signal_event` function maps to `zeCommandListAppendSignalEvent`.
* The SYCL `event` passed to `enqueue_signal_event` will contain a
Expand All @@ -439,8 +441,8 @@ event when a command is submitted, rather than taking an event as input.
* The `make_event` function has no direct mapping to OpenCL.
Instead, this function just creates SYCL `event` object with no underlying
OpenCL event.
* Platforms on the OpenCL backend are expected to return `false` for the
`event_profiling` information descriptor, unless we create some OpenCL
* Devices on the OpenCL backend are expected to return `false` for
`aspect::ext_oneapi_per_event_profiling`, unless we create some OpenCL
extension that makes this possible.
* The `enqueue_wait_event` function maps to either `clEnqueueMarkerWithWaitList`
(for in-order queues) or to `clEnqueueBarrierWithWaitList` (for out-of-order
Expand Down
Loading