Skip to content

Add 3 new functions for sycl::event::get_profiling_info #519

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

Merged
Merged
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
38 changes: 38 additions & 0 deletions dpctl-capi/include/dpctl_sycl_event_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,4 +112,42 @@ DPCTL_API
DPCTLSyclEventStatusType
DPCTLEvent_GetCommandExecutionStatus(__dpctl_keep DPCTLSyclEventRef ERef);

/*!
* @brief Wrapper over
* ``event.get_profiling_info<info::event_profiling::command_submit>()``
*
* @param ERef Opaque pointer to a ``sycl::event``
* @return Returns a value describing the time in nanoseconds
* when the associated command group was submitted to the queue.
* @ingroup EventInterface
*/
DPCTL_API
uint64_t DPCTLEvent_GetProfilingInfoSubmit(__dpctl_keep DPCTLSyclEventRef ERef);

/*!
* @brief Wrapper over
* ``event.get_profiling_info<info::event_profiling::command_start>()``
*
* @param ERef Opaque pointer to a ``sycl::event``
* @return Returns a value describing the time in nanoseconds
* when the action associated with the command group (e.g. kernel invocation)
* started executing on the device.
* @ingroup EventInterface
*/
DPCTL_API
uint64_t DPCTLEvent_GetProfilingInfoStart(__dpctl_keep DPCTLSyclEventRef ERef);

/*!
* @brief Wrapper over
* ``event.get_profiling_info<info::event_profiling::command_end>()``
*
* @param ERef Opaque pointer to a ``sycl::event``
* @return Returns a value describing the time in nanoseconds
* when the action associated with the command group (e.g. kernel invocation)
* finished executing on the device.
* @ingroup EventInterface
*/
DPCTL_API
uint64_t DPCTLEvent_GetProfilingInfoEnd(__dpctl_keep DPCTLSyclEventRef ERef);

DPCTL_C_EXTERN_C_END
51 changes: 51 additions & 0 deletions dpctl-capi/source/dpctl_sycl_event_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,54 @@ DPCTLEvent_GetCommandExecutionStatus(__dpctl_keep DPCTLSyclEventRef ERef)
}
return ESTy;
}

uint64_t DPCTLEvent_GetProfilingInfoSubmit(__dpctl_keep DPCTLSyclEventRef ERef)
{
uint64_t profilingInfoSubmit = 0;
auto E = unwrap(ERef);
if (E) {
try {
E->wait();
profilingInfoSubmit = E->get_profiling_info<
sycl::info::event_profiling::command_submit>();
} catch (invalid_object_error &e) {
// \todo log error
std::cerr << e.what() << '\n';
}
}
return profilingInfoSubmit;
}

uint64_t DPCTLEvent_GetProfilingInfoStart(__dpctl_keep DPCTLSyclEventRef ERef)
{
uint64_t profilingInfoStart = 0;
auto E = unwrap(ERef);
if (E) {
try {
E->wait();
profilingInfoStart = E->get_profiling_info<
sycl::info::event_profiling::command_start>();
} catch (invalid_object_error &e) {
// \todo log error
std::cerr << e.what() << '\n';
}
}
return profilingInfoStart;
}

uint64_t DPCTLEvent_GetProfilingInfoEnd(__dpctl_keep DPCTLSyclEventRef ERef)
{
uint64_t profilingInfoEnd = 0;
auto E = unwrap(ERef);
if (E) {
try {
E->wait();
profilingInfoEnd = E->get_profiling_info<
sycl::info::event_profiling::command_end>();
} catch (invalid_object_error &e) {
// \todo log error
std::cerr << e.what() << '\n';
}
}
return profilingInfoEnd;
}
30 changes: 30 additions & 0 deletions dpctl-capi/tests/test_sycl_event_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,3 +133,33 @@ TEST_F(TestDPCTLSyclEventInterface, ChkGetCommandExecutionStatus)
EXPECT_TRUE(ESTy != DPCTLSyclEventStatusType::DPCTL_UNKNOWN_STATUS);
EXPECT_TRUE(ESTy == DPCTLSyclEventStatusType::DPCTL_COMPLETE);
}

#ifndef DPCTL_COVERAGE
TEST_F(TestDPCTLSyclEventInterface, CheckGetProfiling)
{
property_list propList{property::queue::enable_profiling()};
queue Q(cpu_selector(), propList);
auto eA = Q.submit(
[&](handler &h) { h.parallel_for(1000, [=](id<1>) { /*...*/ }); });
DPCTLSyclEventRef ERef = reinterpret_cast<DPCTLSyclEventRef>(&eA);

auto eStart = DPCTLEvent_GetProfilingInfoStart(ERef);
auto eEnd = DPCTLEvent_GetProfilingInfoEnd(ERef);
auto eSubmit = DPCTLEvent_GetProfilingInfoSubmit(ERef);

EXPECT_TRUE(eStart);
EXPECT_TRUE(eEnd);
EXPECT_TRUE(eSubmit);
}
#endif

TEST_F(TestDPCTLSyclEventInterface, CheckGetProfiling_Invalid)
{
auto eStart = DPCTLEvent_GetProfilingInfoStart(ERef);
auto eEnd = DPCTLEvent_GetProfilingInfoEnd(ERef);
auto eSubmit = DPCTLEvent_GetProfilingInfoSubmit(ERef);

EXPECT_FALSE(eStart);
EXPECT_FALSE(eEnd);
EXPECT_FALSE(eSubmit);
}