Skip to content
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
9 changes: 9 additions & 0 deletions dpctl-capi/include/dpctl_sycl_event_interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,15 @@ __dpctl_give DPCTLSyclEventRef DPCTLEvent_Create(void);
DPCTL_API
void DPCTLEvent_Wait(__dpctl_keep DPCTLSyclEventRef ERef);

/*!
* @brief C-API wrapper for 'sycl::event.wait_and_throw'.
Comment thread
oleksandr-pavlyk marked this conversation as resolved.
Resolved
*
* @param ERef Opaque pointer to a ``sycl::event``
* @ingroup EventInterface
*/
DPCTL_API
void DPCTLEvent_WaitAndThrow(__dpctl_keep DPCTLSyclEventRef ERef);

/*!
* @brief Deletes the DPCTLSyclEventRef after casting it to a ``sycl::event``.
*
Expand Down
14 changes: 14 additions & 0 deletions dpctl-capi/source/dpctl_sycl_event_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,20 @@ void DPCTLEvent_Wait(__dpctl_keep DPCTLSyclEventRef ERef)
}
}

void DPCTLEvent_WaitAndThrow(__dpctl_keep DPCTLSyclEventRef ERef)
{
if (ERef) {
auto SyclEvent = unwrap(ERef);
if (SyclEvent)
SyclEvent->wait_and_throw();
}
else {
std::cerr << "Cannot wait_and_throw for the event. DPCTLSyclEventRef "
"as input is "
"a nullptr\n";
}
}

void DPCTLEvent_Delete(__dpctl_take DPCTLSyclEventRef ERef)
{
delete unwrap(ERef);
Expand Down
12 changes: 12 additions & 0 deletions dpctl-capi/tests/test_sycl_event_interface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,18 @@ TEST_F(TestDPCTLSyclEventInterface, CheckWait_Invalid)
EXPECT_NO_FATAL_FAILURE(DPCTLEvent_Delete(E));
}

TEST_F(TestDPCTLSyclEventInterface, CheckEvent_WaitAndThrow)
{
EXPECT_NO_FATAL_FAILURE(DPCTLEvent_WaitAndThrow(ERef));
}

TEST_F(TestDPCTLSyclEventInterface, CheckWaitAndThrow_Invalid)
{
DPCTLSyclEventRef E = nullptr;
EXPECT_NO_FATAL_FAILURE(DPCTLEvent_WaitAndThrow(E));
EXPECT_NO_FATAL_FAILURE(DPCTLEvent_Delete(E));
}

TEST_F(TestDPCTLSyclEventInterface, CheckEvent_Copy)
{
DPCTLSyclEventRef Copied_ERef = nullptr;
Expand Down