Skip to content
Draft
Show file tree
Hide file tree
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
8 changes: 8 additions & 0 deletions sycl/include/sycl/ext/oneapi/experimental/profiling_tag.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ inline event submit_profiling_tag(queue &Queue,
const sycl::detail::code_location &CodeLoc =
sycl::detail::code_location::current()) {
if (Queue.get_device().has(aspect::ext_oneapi_queue_profiling_tag)) {
// If the queue is out-of-order and profiling is enabled, the implementation
// can save some operations by just using the required barrier event
// directly.
if (!Queue.is_in_order() &&
Queue.has_property<sycl::property::queue::enable_profiling>())
return Queue.ext_oneapi_submit_barrier();

// Otherwise, we use the internal implementation of the profiling tag.
return Queue.submit(
[=](handler &CGH) {
sycl::detail::HandlerAccess::internalProfilingTagImpl(CGH);
Expand Down
7 changes: 6 additions & 1 deletion sycl/unittests/Extensions/ProfilingTag.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,8 @@ TEST_F(ProfilingTagTest, ProfilingTagSupportedProfilingQueue) {
"urEnqueueTimestampRecordingExp", &after_urEnqueueTimestampRecordingExp);
mock::getCallbacks().set_after_callback("urEventGetProfilingInfo",
&after_urEventGetProfilingInfo);
mock::getCallbacks().set_after_callback(
"urEnqueueEventsWaitWithBarrier", &after_urEnqueueEventsWaitWithBarrier);

sycl::context Ctx{sycl::platform()};
sycl::queue Queue{Ctx,
Expand All @@ -138,8 +140,11 @@ TEST_F(ProfilingTagTest, ProfilingTagSupportedProfilingQueue) {

ASSERT_TRUE(Dev.has(sycl::aspect::ext_oneapi_queue_profiling_tag));

// As an optimization, the implementation will use a single barrier when
// submitting a profiling tag on an out-of-order queue with profiling enabled.
sycl::event E = sycl::ext::oneapi::experimental::submit_profiling_tag(Queue);
ASSERT_EQ(size_t{1}, counter_urEnqueueTimestampRecordingExp);
ASSERT_EQ(size_t{0}, counter_urEnqueueTimestampRecordingExp);
ASSERT_EQ(size_t{1}, counter_urEnqueueEventsWaitWithBarrier);

E.get_profiling_info<sycl::info::event_profiling::command_start>();
ASSERT_TRUE(LatestProfilingQuery.has_value());
Expand Down
Loading