Skip to content

Commit 2898db5

Browse files
Added C-API DPCTLQueue_HasEnableProfiling
This calls sycl::queue::has_property<sycl::property::queue::enable_profiling>()
1 parent 8a55469 commit 2898db5

File tree

3 files changed

+64
-9
lines changed

3 files changed

+64
-9
lines changed

dpctl-capi/include/dpctl_sycl_queue_interface.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,17 @@ void DPCTLQueue_MemAdvise(__dpctl_keep DPCTLSyclQueueRef QRef,
333333
DPCTL_API
334334
bool DPCTLQueue_IsInOrder(__dpctl_keep const DPCTLSyclQueueRef QRef);
335335

336+
/*!
337+
* @brief C-API wrapper for
338+
* sycl::queue::has_property<sycl::property::queue::enable_profiling>() that
339+
* indicates whether the referenced queue was constructed with this property.
340+
*
341+
* @param QRef An opaque pointer to the ``sycl::queue``.
342+
* @ingroup QueueInterface
343+
*/
344+
DPCTL_API
345+
bool DPCTLQueue_HasEnableProfiling(__dpctl_keep const DPCTLSyclQueueRef QRef);
346+
336347
/*!
337348
* @brief C-API wrapper for std::hash<sycl::queue>'s operator().
338349
*

dpctl-capi/source/dpctl_sycl_queue_interface.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,16 @@ bool DPCTLQueue_IsInOrder(__dpctl_keep const DPCTLSyclQueueRef QRef)
520520
return false;
521521
}
522522

523+
bool DPCTLQueue_HasEnableProfiling(__dpctl_keep const DPCTLSyclQueueRef QRef)
524+
{
525+
auto Q = unwrap(QRef);
526+
if (Q) {
527+
return Q->has_property<sycl::property::queue::enable_profiling>();
528+
}
529+
else
530+
return false;
531+
}
532+
523533
size_t DPCTLQueue_Hash(__dpctl_keep const DPCTLSyclQueueRef QRef)
524534
{
525535
auto Q = unwrap(QRef);

dpctl-capi/tests/test_sycl_queue_interface.cpp

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ TEST(TestDPCTLSyclQueueInterface, CheckCopy)
115115
EXPECT_NO_FATAL_FAILURE(DPCTLDevice_Delete(DRef));
116116
}
117117

118-
TEST(TestDPCTLSyclQueueInterface, CheckCopy_Invalid)
118+
TEST(TestDPCTLSyclQueueInterface, CheckCopyInvalid)
119119
{
120120
DPCTLSyclQueueRef Q1 = nullptr;
121121
DPCTLSyclQueueRef Q2 = nullptr;
@@ -125,7 +125,7 @@ TEST(TestDPCTLSyclQueueInterface, CheckCopy_Invalid)
125125
EXPECT_NO_FATAL_FAILURE(DPCTLQueue_Delete(Q2));
126126
}
127127

128-
TEST(TestDPCTLSyclQueueInterface, CheckAreEq_False)
128+
TEST(TestDPCTLSyclQueueInterface, CheckAreEqFalse)
129129
{
130130
DPCTLSyclDeviceSelectorRef DSRef = nullptr;
131131
DPCTLSyclDeviceRef DRef = nullptr;
@@ -152,7 +152,7 @@ TEST(TestDPCTLSyclQueueInterface, CheckAreEq_False)
152152
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceSelector_Delete(DSRef));
153153
}
154154

155-
TEST(TestDPCTLSyclQueueInterface, CheckAreEq_True)
155+
TEST(TestDPCTLSyclQueueInterface, CheckAreEqTrue)
156156
{
157157
DPCTLSyclDeviceSelectorRef DSRef = nullptr;
158158
DPCTLSyclDeviceRef DRef = nullptr;
@@ -172,7 +172,7 @@ TEST(TestDPCTLSyclQueueInterface, CheckAreEq_True)
172172
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceSelector_Delete(DSRef));
173173
}
174174

175-
TEST(TestDPCTLSyclQueueInterface, CheckAreEq_Invalid)
175+
TEST(TestDPCTLSyclQueueInterface, CheckAreEqInvalid)
176176
{
177177
DPCTLSyclDeviceSelectorRef DSRef = nullptr;
178178
DPCTLSyclDeviceRef DRef = nullptr;
@@ -192,31 +192,31 @@ TEST(TestDPCTLSyclQueueInterface, CheckAreEq_Invalid)
192192
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceSelector_Delete(DSRef));
193193
}
194194

195-
TEST(TestDPCTLSyclQueueInterface, CheckHash_Invalid)
195+
TEST(TestDPCTLSyclQueueInterface, CheckHashInvalid)
196196
{
197197
DPCTLSyclQueueRef Q1 = nullptr;
198198
DPCTLSyclQueueRef Q2 = nullptr;
199199
EXPECT_TRUE(DPCTLQueue_Hash(Q1) == 0);
200200
EXPECT_TRUE(DPCTLQueue_Hash(Q2) == 0);
201201
}
202202

203-
TEST(TestDPCTLSyclQueueInterface, CheckGetBackend_Invalid)
203+
TEST(TestDPCTLSyclQueueInterface, CheckGetBackendInvalid)
204204
{
205205
DPCTLSyclQueueRef Q = nullptr;
206206
DPCTLSyclBackendType Bty = DPCTL_UNKNOWN_BACKEND;
207207
EXPECT_NO_FATAL_FAILURE(Bty = DPCTLQueue_GetBackend(Q));
208208
EXPECT_TRUE(Bty == DPCTL_UNKNOWN_BACKEND);
209209
}
210210

211-
TEST(TestDPCTLSyclQueueInterface, CheckGetContext_Invalid)
211+
TEST(TestDPCTLSyclQueueInterface, CheckGetContextInvalid)
212212
{
213213
DPCTLSyclQueueRef Q = nullptr;
214214
DPCTLSyclContextRef CRef = nullptr;
215215
EXPECT_NO_FATAL_FAILURE(CRef = DPCTLQueue_GetContext(Q));
216216
EXPECT_TRUE(CRef == nullptr);
217217
}
218218

219-
TEST(TestDPCTLSyclQueueInterface, CheckGetDevice_Invalid)
219+
TEST(TestDPCTLSyclQueueInterface, CheckGetDeviceInvalid)
220220
{
221221
DPCTLSyclQueueRef Q = nullptr;
222222
DPCTLSyclDeviceRef DRef = nullptr;
@@ -250,14 +250,48 @@ TEST(TestDPCTLSyclQueueInterface, CheckIsInOrder)
250250
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceSelector_Delete(DSRef));
251251
}
252252

253-
TEST(TestDPCTLSyclQueueInterface, CheckIsInOrder_Invalid)
253+
TEST(TestDPCTLSyclQueueInterface, CheckIsInOrderInvalid)
254254
{
255255
bool ioq = true;
256256
DPCTLSyclQueueRef Q1 = nullptr;
257257
EXPECT_NO_FATAL_FAILURE(ioq = DPCTLQueue_IsInOrder(Q1));
258258
EXPECT_FALSE(ioq);
259259
}
260260

261+
TEST(TestDPCTLSyclQueueInterface, CheckHasEnableProfiling)
262+
{
263+
bool ioq = true;
264+
DPCTLSyclDeviceSelectorRef DSRef = nullptr;
265+
DPCTLSyclDeviceRef DRef = nullptr;
266+
DPCTLSyclQueueRef Q1 = nullptr;
267+
DPCTLSyclQueueRef Q2 = nullptr;
268+
269+
EXPECT_NO_FATAL_FAILURE(DSRef = DPCTLDefaultSelector_Create());
270+
EXPECT_NO_FATAL_FAILURE(DRef = DPCTLDevice_CreateFromSelector(DSRef));
271+
EXPECT_NO_FATAL_FAILURE(
272+
Q1 = DPCTLQueue_CreateForDevice(DRef, nullptr, DPCTL_DEFAULT_PROPERTY));
273+
EXPECT_NO_FATAL_FAILURE(ioq = DPCTLQueue_HasEnableProfiling(Q1));
274+
EXPECT_FALSE(ioq);
275+
276+
EXPECT_NO_FATAL_FAILURE(
277+
Q2 = DPCTLQueue_CreateForDevice(DRef, nullptr, DPCTL_ENABLE_PROFILING));
278+
EXPECT_NO_FATAL_FAILURE(ioq = DPCTLQueue_HasEnableProfiling(Q2));
279+
EXPECT_TRUE(ioq);
280+
281+
EXPECT_NO_FATAL_FAILURE(DPCTLQueue_Delete(Q1));
282+
EXPECT_NO_FATAL_FAILURE(DPCTLQueue_Delete(Q2));
283+
EXPECT_NO_FATAL_FAILURE(DPCTLDevice_Delete(DRef));
284+
EXPECT_NO_FATAL_FAILURE(DPCTLDeviceSelector_Delete(DSRef));
285+
}
286+
287+
TEST(TestDPCTLSyclQueueInterface, CheckHasEnableProfilingInvalid)
288+
{
289+
bool ioq = true;
290+
DPCTLSyclQueueRef Q1 = nullptr;
291+
EXPECT_NO_FATAL_FAILURE(ioq = DPCTLQueue_HasEnableProfiling(Q1));
292+
EXPECT_FALSE(ioq);
293+
}
294+
261295
TEST_P(TestDPCTLQueueMemberFunctions, CheckGetBackend)
262296
{
263297
auto q = unwrap(QRef);

0 commit comments

Comments
 (0)