Skip to content

Commit

Permalink
[SYCL] Align get_profiling_info behavior with the specification
Browse files Browse the repository at this point in the history
Wait for event in get_profiling_info.

Signed-off-by: Vlad Romanov <[email protected]>
  • Loading branch information
romanovvlad authored and bader committed May 27, 2019
1 parent a287f9d commit 40ce2a7
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
3 changes: 3 additions & 0 deletions sycl/source/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,19 @@ event::get_info<info::event::command_execution_status>() const {
template <>
cl_ulong
event::get_profiling_info<info::event_profiling::command_submit>() const {
impl->wait(impl);
return impl->get_profiling_info<info::event_profiling::command_submit>();
}
template <>
cl_ulong
event::get_profiling_info<info::event_profiling::command_start>() const {
impl->wait(impl);
return impl->get_profiling_info<info::event_profiling::command_start>();
}

template <>
cl_ulong event::get_profiling_info<info::event_profiling::command_end>() const {
impl->wait(impl);
return impl->get_profiling_info<info::event_profiling::command_end>();
}

Expand Down
32 changes: 32 additions & 0 deletions sycl/test/basic_tests/event_profiling_info.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
// RUN: %clang -std=c++11 -fsycl %s -o %t.out -lstdc++ -lOpenCL -lsycl
// RUN: env SYCL_DEVICE_TYPE=HOST %t.out
// RUN: %CPU_RUN_PLACEHOLDER %t.out
// RUN: %GPU_RUN_PLACEHOLDER %t.out
// RUN: %ACC_RUN_PLACEHOLDER %t.out
//==------------------- event_profiling_info.cpp ---------------------------==//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include <CL/sycl.hpp>

using namespace cl;

// The test checks that get_profiling_info waits for command asccociated with
// event to complete execution.
int main() {
sycl::queue Q{sycl::property::queue::enable_profiling()};
sycl::event Event = Q.submit([&](sycl::handler &CGH) {
CGH.single_task<class EmptyKernel>([=]() {});
});

Event.get_profiling_info<sycl::info::event_profiling::command_start>();

bool Fail = sycl::info::event_command_status::complete !=
Event.get_info<sycl::info::event::command_execution_status>();

return Fail;
}

0 comments on commit 40ce2a7

Please sign in to comment.