Skip to content

Commit 40ce2a7

Browse files
romanovvladbader
authored andcommitted
[SYCL] Align get_profiling_info behavior with the specification
Wait for event in get_profiling_info. Signed-off-by: Vlad Romanov <[email protected]>
1 parent a287f9d commit 40ce2a7

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

sycl/source/event.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,19 @@ event::get_info<info::event::command_execution_status>() const {
7070
template <>
7171
cl_ulong
7272
event::get_profiling_info<info::event_profiling::command_submit>() const {
73+
impl->wait(impl);
7374
return impl->get_profiling_info<info::event_profiling::command_submit>();
7475
}
7576
template <>
7677
cl_ulong
7778
event::get_profiling_info<info::event_profiling::command_start>() const {
79+
impl->wait(impl);
7880
return impl->get_profiling_info<info::event_profiling::command_start>();
7981
}
8082

8183
template <>
8284
cl_ulong event::get_profiling_info<info::event_profiling::command_end>() const {
85+
impl->wait(impl);
8386
return impl->get_profiling_info<info::event_profiling::command_end>();
8487
}
8588

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// RUN: %clang -std=c++11 -fsycl %s -o %t.out -lstdc++ -lOpenCL -lsycl
2+
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
3+
// RUN: %CPU_RUN_PLACEHOLDER %t.out
4+
// RUN: %GPU_RUN_PLACEHOLDER %t.out
5+
// RUN: %ACC_RUN_PLACEHOLDER %t.out
6+
//==------------------- event_profiling_info.cpp ---------------------------==//
7+
//
8+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
9+
// See https://llvm.org/LICENSE.txt for license information.
10+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
11+
//
12+
//===----------------------------------------------------------------------===//
13+
14+
#include <CL/sycl.hpp>
15+
16+
using namespace cl;
17+
18+
// The test checks that get_profiling_info waits for command asccociated with
19+
// event to complete execution.
20+
int main() {
21+
sycl::queue Q{sycl::property::queue::enable_profiling()};
22+
sycl::event Event = Q.submit([&](sycl::handler &CGH) {
23+
CGH.single_task<class EmptyKernel>([=]() {});
24+
});
25+
26+
Event.get_profiling_info<sycl::info::event_profiling::command_start>();
27+
28+
bool Fail = sycl::info::event_command_status::complete !=
29+
Event.get_info<sycl::info::event::command_execution_status>();
30+
31+
return Fail;
32+
}

0 commit comments

Comments
 (0)