Skip to content

Commit 87fefee

Browse files
added DPCTLQueue_IsInOrder
1 parent c22dbe9 commit 87fefee

File tree

3 files changed

+51
-7
lines changed

3 files changed

+51
-7
lines changed

dpctl-capi/include/dpctl_sycl_queue_interface.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,4 +312,14 @@ void DPCTLQueue_MemAdvise(__dpctl_keep DPCTLSyclQueueRef QRef,
312312
size_t Count,
313313
int Advice);
314314

315+
/*!
316+
* @brief C-API wrapper for sycl::queue::is_in_order that indicates whether
317+
* the referenced queue is in-order or out-of-order.
318+
*
319+
* @param QRef An opaque pointer to the sycl queue.
320+
* @ingroup QueueInterface
321+
*/
322+
DPCTL_API
323+
bool DPCTLQueue_IsInOrder(__dpctl_keep const DPCTLSyclQueueRef QRef);
324+
315325
DPCTL_C_EXTERN_C_END

dpctl-capi/source/dpctl_sycl_queue_interface.cpp

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,8 @@ void DPCTLQueue_Wait(__dpctl_keep DPCTLSyclQueueRef QRef)
450450
// \todo what happens if the QRef is null or a pointer to a valid sycl
451451
// queue
452452
auto SyclQueue = unwrap(QRef);
453-
SyclQueue->wait();
453+
if (SyclQueue)
454+
SyclQueue->wait();
454455
}
455456

456457
void DPCTLQueue_Memcpy(__dpctl_keep const DPCTLSyclQueueRef QRef,
@@ -459,17 +460,21 @@ void DPCTLQueue_Memcpy(__dpctl_keep const DPCTLSyclQueueRef QRef,
459460
size_t Count)
460461
{
461462
auto Q = unwrap(QRef);
462-
auto event = Q->memcpy(Dest, Src, Count);
463-
event.wait();
463+
if (Q) {
464+
auto event = Q->memcpy(Dest, Src, Count);
465+
event.wait();
466+
}
464467
}
465468

466469
void DPCTLQueue_Prefetch(__dpctl_keep DPCTLSyclQueueRef QRef,
467470
const void *Ptr,
468471
size_t Count)
469472
{
470473
auto Q = unwrap(QRef);
471-
auto event = Q->prefetch(Ptr, Count);
472-
event.wait();
474+
if (Q) {
475+
auto event = Q->prefetch(Ptr, Count);
476+
event.wait();
477+
}
473478
}
474479

475480
void DPCTLQueue_MemAdvise(__dpctl_keep DPCTLSyclQueueRef QRef,
@@ -478,6 +483,19 @@ void DPCTLQueue_MemAdvise(__dpctl_keep DPCTLSyclQueueRef QRef,
478483
int Advice)
479484
{
480485
auto Q = unwrap(QRef);
481-
auto event = Q->mem_advise(Ptr, Count, static_cast<pi_mem_advice>(Advice));
482-
event.wait();
486+
if (Q) {
487+
auto event =
488+
Q->mem_advise(Ptr, Count, static_cast<pi_mem_advice>(Advice));
489+
event.wait();
490+
}
491+
}
492+
493+
bool DPCTLQueue_IsInOrder(__dpctl_keep const DPCTLSyclQueueRef QRef)
494+
{
495+
auto Q = unwrap(QRef);
496+
if (Q) {
497+
return Q->is_in_order();
498+
}
499+
else
500+
return false;
483501
}

dpctl-capi/tests/test_sycl_queue_interface.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,22 @@ TEST_P(TestDPCTLQueueMemberFunctions, CheckGetDevice)
255255
DPCTLDevice_Delete(D);
256256
}
257257

258+
TEST_P(TestDPCTLQueueMemberFunctions, CheckIsInOrder)
259+
{
260+
bool ioq = true;
261+
262+
EXPECT_NO_FATAL_FAILURE(ioq = DPCTLQueue_IsInOrder(QRef));
263+
EXPECT_FALSE(ioq);
264+
265+
DPCTLSyclQueueRef QRef_ioq = nullptr;
266+
EXPECT_NO_FATAL_FAILURE(
267+
QRef_ioq = DPCTLQueue_CreateForDevice(DRef, nullptr, DPCTL_IN_ORDER));
268+
EXPECT_TRUE(QRef_ioq);
269+
EXPECT_NO_FATAL_FAILURE(ioq = DPCTLQueue_IsInOrder(QRef_ioq));
270+
EXPECT_TRUE(ioq);
271+
EXPECT_NO_FATAL_FAILURE(DPCTLQueue_Delete(QRef_ioq));
272+
}
273+
258274
INSTANTIATE_TEST_SUITE_P(DPCTLQueueMemberFuncTests,
259275
TestDPCTLQueueMemberFunctions,
260276
::testing::Values("opencl:gpu:0",

0 commit comments

Comments
 (0)