Skip to content

Commit 8d40dad

Browse files
author
etotmeni
committed
Merge master
2 parents a35c644 + ffd1042 commit 8d40dad

12 files changed

+305
-29
lines changed

dpctl-capi/include/dpctl_sycl_device_interface.h

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,71 @@ DPCTL_API
292292
uint32_t
293293
DPCTLDevice_GetMaxWriteImageArgs(__dpctl_keep const DPCTLSyclDeviceRef DRef);
294294

295+
/*!
296+
* @brief Wrapper over
297+
* device.get_info<info::device::image2d_max_width>().
298+
*
299+
* @param DRef Opaque pointer to a sycl::device
300+
* @return Returns the maximum width of a 2D image
301+
* or 1D image in pixels. The minimum value is
302+
* 8192 if the SYCL device has aspect::image.
303+
*/
304+
DPCTL_API
305+
size_t
306+
DPCTLDevice_GetImage2dMaxWidth(__dpctl_keep const DPCTLSyclDeviceRef DRef);
307+
308+
/*!
309+
* @brief Wrapper over
310+
* device.get_info<info::device::image2d_max_height>().
311+
*
312+
* @param DRef Opaque pointer to a sycl::device
313+
* @return Returns the maximum height of a 2D image
314+
* or 1D image in pixels. The minimum value is
315+
* 8192 if the SYCL device has aspect::image.
316+
*/
317+
DPCTL_API
318+
size_t
319+
DPCTLDevice_GetImage2dMaxHeight(__dpctl_keep const DPCTLSyclDeviceRef DRef);
320+
321+
/*!
322+
* @brief Wrapper over
323+
* device.get_info<info::device::image3d_max_width>().
324+
*
325+
* @param DRef Opaque pointer to a sycl::device
326+
* @return Returns the maximum width of a 3D image
327+
* in pixels. The minimum value is
328+
* 2048 if the SYCL device has aspect::image.
329+
*/
330+
DPCTL_API
331+
size_t
332+
DPCTLDevice_GetImage3dMaxWidth(__dpctl_keep const DPCTLSyclDeviceRef DRef);
333+
334+
/*!
335+
* @brief Wrapper over
336+
* device.get_info<info::device::image3d_max_height>().
337+
*
338+
* @param DRef Opaque pointer to a sycl::device
339+
* @return Returns the maximum height of a 3D image
340+
* The minimum value is
341+
* 2048 if the SYCL device has aspect::image.
342+
*/
343+
DPCTL_API
344+
size_t
345+
DPCTLDevice_GetImage3dMaxHeight(__dpctl_keep const DPCTLSyclDeviceRef DRef);
346+
347+
/*!
348+
* @brief Wrapper over
349+
* device.get_info<info::device::image3d_max_depth>().
350+
*
351+
* @param DRef Opaque pointer to a sycl::device
352+
* @return Returns the maximum depth of a 3D image
353+
* The minimum value is
354+
* 2048 if the SYCL device has aspect::image.
355+
*/
356+
DPCTL_API
357+
size_t
358+
DPCTLDevice_GetImage3dMaxDepth(__dpctl_keep const DPCTLSyclDeviceRef DRef);
359+
295360
/*!
296361
* @brief Returns a vector of sub devices
297362
* partitioned from this SYCL device based on the count parameter. The returned

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_device_interface.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -392,10 +392,10 @@ bool DPCTLDevice_HasAspect(__dpctl_keep const DPCTLSyclDeviceRef DRef,
392392
return hasAspect;
393393
}
394394

395-
#define declmethod(FUNC, NAME) \
396-
uint32_t DPCTLDevice_##FUNC(__dpctl_keep const DPCTLSyclDeviceRef DRef) \
395+
#define declmethod(FUNC, NAME, TYPE) \
396+
TYPE DPCTLDevice_##FUNC(__dpctl_keep const DPCTLSyclDeviceRef DRef) \
397397
{ \
398-
uint32_t result = 0; \
398+
TYPE result = 0; \
399399
auto D = unwrap(DRef); \
400400
if (D) { \
401401
try { \
@@ -406,8 +406,13 @@ bool DPCTLDevice_HasAspect(__dpctl_keep const DPCTLSyclDeviceRef DRef,
406406
} \
407407
return result; \
408408
}
409-
declmethod(GetMaxReadImageArgs, max_read_image_args);
410-
declmethod(GetMaxWriteImageArgs, max_write_image_args);
409+
declmethod(GetMaxReadImageArgs, max_read_image_args, uint32_t);
410+
declmethod(GetMaxWriteImageArgs, max_write_image_args, uint32_t);
411+
declmethod(GetImage2dMaxWidth, image2d_max_width, size_t);
412+
declmethod(GetImage2dMaxHeight, image2d_max_height, size_t);
413+
declmethod(GetImage3dMaxWidth, image3d_max_width, size_t);
414+
declmethod(GetImage3dMaxHeight, image3d_max_height, size_t);
415+
declmethod(GetImage3dMaxDepth, image3d_max_depth, size_t);
411416
#undef declmethod
412417

413418
bool DPCTLDevice_GetSubGroupIndependentForwardProgress(

dpctl-capi/source/dpctl_sycl_queue_interface.cpp

Lines changed: 35 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,16 @@ bool set_kernel_arg(handler &cgh,
119119
std::unique_ptr<property_list> create_property_list(int properties)
120120
{
121121
std::unique_ptr<property_list> propList;
122-
if (properties & (DPCTL_ENABLE_PROFILING | DPCTL_IN_ORDER)) {
123-
propList = std::make_unique<property_list>(
124-
sycl::property::queue::enable_profiling(),
125-
sycl::property::queue::in_order());
126-
}
127-
else if (properties & DPCTL_ENABLE_PROFILING) {
128-
propList = std::make_unique<property_list>(
129-
sycl::property::queue::enable_profiling());
122+
if (properties & DPCTL_ENABLE_PROFILING) {
123+
if (properties & DPCTL_IN_ORDER) {
124+
propList = std::make_unique<property_list>(
125+
sycl::property::queue::enable_profiling(),
126+
sycl::property::queue::in_order());
127+
}
128+
else {
129+
propList = std::make_unique<property_list>(
130+
sycl::property::queue::enable_profiling());
131+
}
130132
}
131133
else if (properties & DPCTL_IN_ORDER) {
132134
propList =
@@ -450,7 +452,8 @@ void DPCTLQueue_Wait(__dpctl_keep DPCTLSyclQueueRef QRef)
450452
// \todo what happens if the QRef is null or a pointer to a valid sycl
451453
// queue
452454
auto SyclQueue = unwrap(QRef);
453-
SyclQueue->wait();
455+
if (SyclQueue)
456+
SyclQueue->wait();
454457
}
455458

456459
void DPCTLQueue_Memcpy(__dpctl_keep const DPCTLSyclQueueRef QRef,
@@ -459,17 +462,21 @@ void DPCTLQueue_Memcpy(__dpctl_keep const DPCTLSyclQueueRef QRef,
459462
size_t Count)
460463
{
461464
auto Q = unwrap(QRef);
462-
auto event = Q->memcpy(Dest, Src, Count);
463-
event.wait();
465+
if (Q) {
466+
auto event = Q->memcpy(Dest, Src, Count);
467+
event.wait();
468+
}
464469
}
465470

466471
void DPCTLQueue_Prefetch(__dpctl_keep DPCTLSyclQueueRef QRef,
467472
const void *Ptr,
468473
size_t Count)
469474
{
470475
auto Q = unwrap(QRef);
471-
auto event = Q->prefetch(Ptr, Count);
472-
event.wait();
476+
if (Q) {
477+
auto event = Q->prefetch(Ptr, Count);
478+
event.wait();
479+
}
473480
}
474481

475482
void DPCTLQueue_MemAdvise(__dpctl_keep DPCTLSyclQueueRef QRef,
@@ -478,6 +485,19 @@ void DPCTLQueue_MemAdvise(__dpctl_keep DPCTLSyclQueueRef QRef,
478485
int Advice)
479486
{
480487
auto Q = unwrap(QRef);
481-
auto event = Q->mem_advise(Ptr, Count, static_cast<pi_mem_advice>(Advice));
482-
event.wait();
488+
if (Q) {
489+
auto event =
490+
Q->mem_advise(Ptr, Count, static_cast<pi_mem_advice>(Advice));
491+
event.wait();
492+
}
493+
}
494+
495+
bool DPCTLQueue_IsInOrder(__dpctl_keep const DPCTLSyclQueueRef QRef)
496+
{
497+
auto Q = unwrap(QRef);
498+
if (Q) {
499+
return Q->is_in_order();
500+
}
501+
else
502+
return false;
483503
}

dpctl-capi/tests/test_sycl_device_interface.cpp

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,61 @@ TEST_P(TestDPCTLSyclDeviceInterface, Chk_GetMaxWriteImageArgs)
297297
EXPECT_TRUE(max_write_image_args >= min_val);
298298
}
299299

300+
TEST_P(TestDPCTLSyclDeviceInterface, Chk_GetImage2dMaxWidth)
301+
{
302+
size_t image_2d_max_width = 0;
303+
EXPECT_NO_FATAL_FAILURE(image_2d_max_width =
304+
DPCTLDevice_GetImage2dMaxWidth(DRef));
305+
size_t min_val = 8192;
306+
if (DPCTLDevice_HasAspect(DRef, DPCTL_SyclAspectToDPCTLAspectType(
307+
DPCTL_StrToAspectType("image"))))
308+
EXPECT_TRUE(image_2d_max_width >= min_val);
309+
}
310+
311+
TEST_P(TestDPCTLSyclDeviceInterface, Chk_GetImage2dMaxHeight)
312+
{
313+
size_t image_2d_max_height = 0;
314+
EXPECT_NO_FATAL_FAILURE(image_2d_max_height =
315+
DPCTLDevice_GetImage2dMaxHeight(DRef));
316+
size_t min_val = 8192;
317+
if (DPCTLDevice_HasAspect(DRef, DPCTL_SyclAspectToDPCTLAspectType(
318+
DPCTL_StrToAspectType("image"))))
319+
EXPECT_TRUE(image_2d_max_height >= min_val);
320+
}
321+
322+
TEST_P(TestDPCTLSyclDeviceInterface, Chk_GetImage3dMaxWidth)
323+
{
324+
size_t image_3d_max_width = 0;
325+
EXPECT_NO_FATAL_FAILURE(image_3d_max_width =
326+
DPCTLDevice_GetImage3dMaxWidth(DRef));
327+
size_t min_val = 2048;
328+
if (DPCTLDevice_HasAspect(DRef, DPCTL_SyclAspectToDPCTLAspectType(
329+
DPCTL_StrToAspectType("image"))))
330+
EXPECT_TRUE(image_3d_max_width >= min_val);
331+
}
332+
333+
TEST_P(TestDPCTLSyclDeviceInterface, Chk_GetImage3dMaxHeight)
334+
{
335+
size_t image_3d_max_height = 0;
336+
EXPECT_NO_FATAL_FAILURE(image_3d_max_height =
337+
DPCTLDevice_GetImage3dMaxHeight(DRef));
338+
size_t min_val = 2048;
339+
if (DPCTLDevice_HasAspect(DRef, DPCTL_SyclAspectToDPCTLAspectType(
340+
DPCTL_StrToAspectType("image"))))
341+
EXPECT_TRUE(image_3d_max_height >= min_val);
342+
}
343+
344+
TEST_P(TestDPCTLSyclDeviceInterface, Chk_GetImage3dMaxDepth)
345+
{
346+
size_t image_3d_max_depth = 0;
347+
EXPECT_NO_FATAL_FAILURE(image_3d_max_depth =
348+
DPCTLDevice_GetImage3dMaxDepth(DRef));
349+
size_t min_val = 2048;
350+
if (DPCTLDevice_HasAspect(DRef, DPCTL_SyclAspectToDPCTLAspectType(
351+
DPCTL_StrToAspectType("image"))))
352+
EXPECT_TRUE(image_3d_max_depth >= min_val);
353+
}
354+
300355
INSTANTIATE_TEST_SUITE_P(DPCTLDevice_Fns,
301356
TestDPCTLSyclDeviceInterface,
302357
::testing::Values("opencl",

dpctl-capi/tests/test_sycl_device_subdevices.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ using namespace cl::sycl;
3838

3939
DEFINE_SIMPLE_CONVERSION_FUNCTIONS(device, DPCTLSyclDeviceRef);
4040

41+
const DPCTLPartitionAffinityDomainType a_dpctl_domain =
42+
DPCTLPartitionAffinityDomainType::not_applicable;
43+
4144
struct TestDPCTLSyclDeviceInterface
4245
: public ::testing::TestWithParam<const char *>
4346
{
@@ -142,7 +145,7 @@ TEST_P(TestDPCTLSyclDeviceInterface, Chk_CreateSubDevicesByAffinityNuma)
142145

143146
info::partition_affinity_domain domain =
144147
info::partition_affinity_domain::numa;
145-
DPCTLPartitionAffinityDomainType dpctl_domain;
148+
DPCTLPartitionAffinityDomainType dpctl_domain = a_dpctl_domain;
146149
EXPECT_NO_FATAL_FAILURE(
147150
dpctl_domain = DPCTL_SyclPartitionAffinityDomainToDPCTLType(domain));
148151

@@ -178,7 +181,7 @@ TEST_P(TestDPCTLSyclDeviceInterface, Chk_CreateSubDevicesByAffinityL4Cache)
178181

179182
info::partition_affinity_domain domain =
180183
info::partition_affinity_domain::L4_cache;
181-
DPCTLPartitionAffinityDomainType dpctl_domain;
184+
DPCTLPartitionAffinityDomainType dpctl_domain = a_dpctl_domain;
182185
EXPECT_NO_FATAL_FAILURE(
183186
dpctl_domain = DPCTL_SyclPartitionAffinityDomainToDPCTLType(domain));
184187

@@ -214,7 +217,7 @@ TEST_P(TestDPCTLSyclDeviceInterface, Chk_CreateSubDevicesByAffinityL3Cache)
214217

215218
info::partition_affinity_domain domain =
216219
info::partition_affinity_domain::L3_cache;
217-
DPCTLPartitionAffinityDomainType dpctl_domain;
220+
DPCTLPartitionAffinityDomainType dpctl_domain = a_dpctl_domain;
218221
EXPECT_NO_FATAL_FAILURE(
219222
dpctl_domain = DPCTL_SyclPartitionAffinityDomainToDPCTLType(domain));
220223

@@ -250,7 +253,7 @@ TEST_P(TestDPCTLSyclDeviceInterface, Chk_CreateSubDevicesByAffinityL2Cache)
250253

251254
info::partition_affinity_domain domain =
252255
info::partition_affinity_domain::L2_cache;
253-
DPCTLPartitionAffinityDomainType dpctl_domain;
256+
DPCTLPartitionAffinityDomainType dpctl_domain = a_dpctl_domain;
254257
EXPECT_NO_FATAL_FAILURE(
255258
dpctl_domain = DPCTL_SyclPartitionAffinityDomainToDPCTLType(domain));
256259

@@ -286,7 +289,7 @@ TEST_P(TestDPCTLSyclDeviceInterface, Chk_CreateSubDevicesByAffinityL1Cache)
286289

287290
info::partition_affinity_domain domain =
288291
info::partition_affinity_domain::L1_cache;
289-
DPCTLPartitionAffinityDomainType dpctl_domain;
292+
DPCTLPartitionAffinityDomainType dpctl_domain = a_dpctl_domain;
290293
EXPECT_NO_FATAL_FAILURE(
291294
dpctl_domain = DPCTL_SyclPartitionAffinityDomainToDPCTLType(domain));
292295

@@ -323,7 +326,7 @@ TEST_P(TestDPCTLSyclDeviceInterface,
323326

324327
info::partition_affinity_domain domain =
325328
info::partition_affinity_domain::next_partitionable;
326-
DPCTLPartitionAffinityDomainType dpctl_domain;
329+
DPCTLPartitionAffinityDomainType dpctl_domain = a_dpctl_domain;
327330
EXPECT_NO_FATAL_FAILURE(
328331
dpctl_domain = DPCTL_SyclPartitionAffinityDomainToDPCTLType(domain));
329332

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",

dpctl/_backend.pxd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,11 @@ cdef extern from "dpctl_sycl_device_interface.h":
182182
const DPCTLSyclDeviceRef DRef, DPCTLSyclAspectType AT)
183183
cdef uint32_t DPCTLDevice_GetMaxReadImageArgs(const DPCTLSyclDeviceRef DRef)
184184
cdef uint32_t DPCTLDevice_GetMaxWriteImageArgs(const DPCTLSyclDeviceRef DRef)
185+
cdef size_t DPCTLDevice_GetImage2dMaxWidth(const DPCTLSyclDeviceRef DRef)
186+
cdef size_t DPCTLDevice_GetImage2dMaxHeight(const DPCTLSyclDeviceRef DRef)
187+
cdef size_t DPCTLDevice_GetImage3dMaxWidth(const DPCTLSyclDeviceRef DRef)
188+
cdef size_t DPCTLDevice_GetImage3dMaxHeight(const DPCTLSyclDeviceRef DRef)
189+
cdef size_t DPCTLDevice_GetImage3dMaxDepth(const DPCTLSyclDeviceRef DRef)
185190
cdef DPCTLDeviceVectorRef DPCTLDevice_CreateSubDevicesEqually(
186191
const DPCTLSyclDeviceRef DRef, size_t count)
187192
cdef DPCTLDeviceVectorRef DPCTLDevice_CreateSubDevicesByCounts(
@@ -349,6 +354,7 @@ cdef extern from "dpctl_sycl_queue_interface.h":
349354
const void *Src,
350355
size_t Count,
351356
int Advice)
357+
cdef bool DPCTLQueue_IsInOrder(const DPCTLSyclQueueRef QRef)
352358

353359

354360
cdef extern from "dpctl_sycl_queue_manager.h":

0 commit comments

Comments
 (0)