Skip to content

Commit 31ec311

Browse files
authored
Merge pull request #1002 from IntelPython/fix/nrt_debug_print
2 parents f9a77a2 + 0f3b135 commit 31ec311

File tree

3 files changed

+44
-44
lines changed

3 files changed

+44
-44
lines changed

numba_dpex/core/runtime/_dpexrt_python.c

Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ static PyObject *DPEXRT_sycl_queue_to_python(queuestruct_t *queuestruct);
6565
/*
6666
* Debugging printf function used internally
6767
*/
68-
void nrt_debug_print(char *fmt, ...)
68+
void drt_debug_print(const char *fmt, ...)
6969
{
7070
va_list args;
7171

@@ -134,12 +134,12 @@ static void *DPEXRTQueue_CreateFromFilterString(const char *device)
134134
DPCTLSyclDeviceRef dref = NULL;
135135
DPCTLSyclQueueRef qref = NULL;
136136

137-
DPEXRT_DEBUG(nrt_debug_print(
137+
DPEXRT_DEBUG(drt_debug_print(
138138
"DPEXRT-DEBUG: Inside DPEXRT_get_sycl_queue %s, line %d\n", __FILE__,
139139
__LINE__));
140140

141141
if (!(dselector = DPCTLFilterSelector_Create(device))) {
142-
DPEXRT_DEBUG(nrt_debug_print(
142+
DPEXRT_DEBUG(drt_debug_print(
143143
"DPEXRT-ERROR: Could not create a sycl::device_selector from "
144144
"filter string: %s at %s %d.\n",
145145
device, __FILE__, __LINE__));
@@ -155,7 +155,7 @@ static void *DPEXRTQueue_CreateFromFilterString(const char *device)
155155
DPCTLDeviceSelector_Delete(dselector);
156156
DPCTLDevice_Delete(dref);
157157

158-
DPEXRT_DEBUG(nrt_debug_print(
158+
DPEXRT_DEBUG(drt_debug_print(
159159
"DPEXRT-DEBUG: Created sycl::queue on device %s at %s, line %d\n",
160160
device, __FILE__, __LINE__));
161161

@@ -181,7 +181,7 @@ static void DpexrtQueue_SubmitRange(const void *KRef,
181181
DPCTLSyclEventRef eref = NULL;
182182
DPCTLSyclQueueRef qref = NULL;
183183

184-
DPEXRT_DEBUG(nrt_debug_print(
184+
DPEXRT_DEBUG(drt_debug_print(
185185
"DPEXRT-DEBUG: Inside DpexrtQueue_SubmitRange %s, line %d\n", __FILE__,
186186
__LINE__));
187187

@@ -194,7 +194,7 @@ static void DpexrtQueue_SubmitRange(const void *KRef,
194194
DPCTLEvent_Wait(eref);
195195
DPCTLEvent_Delete(eref);
196196

197-
DPEXRT_DEBUG(nrt_debug_print(
197+
DPEXRT_DEBUG(drt_debug_print(
198198
"DPEXRT-DEBUG: Done with DpexrtQueue_SubmitRange %s, line %d\n",
199199
__FILE__, __LINE__));
200200
}
@@ -226,13 +226,13 @@ NRT_ExternalAllocator_new_for_usm(DPCTLSyclQueueRef qref, size_t usm_type)
226226
allocator = (NRT_ExternalAllocator *)malloc(sizeof(NRT_ExternalAllocator));
227227
if (allocator == NULL) {
228228
DPEXRT_DEBUG(
229-
nrt_debug_print("DPEXRT-ERROR: failed to allocate memory for "
229+
drt_debug_print("DPEXRT-ERROR: failed to allocate memory for "
230230
"NRT_ExternalAllocator at %s, line %d.\n",
231231
__FILE__, __LINE__));
232232
goto error;
233233
}
234234
DPEXRT_DEBUG(
235-
nrt_debug_print("DPEXRT-DEBUG: usm type = %d at %s, line %d.\n",
235+
drt_debug_print("DPEXRT-DEBUG: usm type = %d at %s, line %d.\n",
236236
usm_type, __FILE__, __LINE__));
237237

238238
switch (usm_type) {
@@ -246,7 +246,7 @@ NRT_ExternalAllocator_new_for_usm(DPCTLSyclQueueRef qref, size_t usm_type)
246246
allocator->malloc = usm_host_malloc;
247247
break;
248248
default:
249-
DPEXRT_DEBUG(nrt_debug_print("DPEXRT-ERROR: Encountered an unknown usm "
249+
DPEXRT_DEBUG(drt_debug_print("DPEXRT-ERROR: Encountered an unknown usm "
250250
"allocation type (%d) at %s, line %d\n",
251251
usm_type, __FILE__, __LINE__));
252252
goto error;
@@ -292,7 +292,7 @@ static void usmndarray_meminfo_dtor(void *ptr, size_t size, void *info)
292292

293293
// Sanity-check to make sure the mi_dtor_info is an actual pointer.
294294
if (!(mi_dtor_info = (MemInfoDtorInfo *)info)) {
295-
DPEXRT_DEBUG(nrt_debug_print(
295+
DPEXRT_DEBUG(drt_debug_print(
296296
"DPEXRT-ERROR: MemInfoDtorInfo object might be corrupted. Aborting "
297297
"MemInfo destruction at %s, line %d\n",
298298
__FILE__, __LINE__));
@@ -347,7 +347,7 @@ static MemInfoDtorInfo *MemInfoDtorInfo_new(NRT_MemInfo *mi, PyObject *owner)
347347
MemInfoDtorInfo *mi_dtor_info = NULL;
348348

349349
if (!(mi_dtor_info = (MemInfoDtorInfo *)malloc(sizeof(MemInfoDtorInfo)))) {
350-
DPEXRT_DEBUG(nrt_debug_print("DPEXRT-ERROR: Could not allocate a new "
350+
DPEXRT_DEBUG(drt_debug_print("DPEXRT-ERROR: Could not allocate a new "
351351
"MemInfoDtorInfo object at %s, line %d\n",
352352
__FILE__, __LINE__));
353353
return NULL;
@@ -382,15 +382,15 @@ static NRT_MemInfo *NRT_MemInfo_new_from_usmndarray(PyObject *ndarrobj,
382382

383383
// Allocate a new NRT_MemInfo object
384384
if (!(mi = (NRT_MemInfo *)malloc(sizeof(NRT_MemInfo)))) {
385-
DPEXRT_DEBUG(nrt_debug_print(
385+
DPEXRT_DEBUG(drt_debug_print(
386386
"DPEXRT-ERROR: Could not allocate a new NRT_MemInfo "
387387
"object at %s, line %d\n",
388388
__FILE__, __LINE__));
389389
goto error;
390390
}
391391

392392
if (!(cref = DPCTLQueue_GetContext(qref))) {
393-
DPEXRT_DEBUG(nrt_debug_print(
393+
DPEXRT_DEBUG(drt_debug_print(
394394
"DPEXRT-ERROR: Could not get the DPCTLSyclContext from "
395395
"the queue object at %s, line %d\n",
396396
__FILE__, __LINE__));
@@ -403,15 +403,15 @@ static NRT_MemInfo *NRT_MemInfo_new_from_usmndarray(PyObject *ndarrobj,
403403
// Allocate a new NRT_ExternalAllocator
404404
if (!(ext_alloca = NRT_ExternalAllocator_new_for_usm(qref, usm_type))) {
405405
DPEXRT_DEBUG(
406-
nrt_debug_print("DPEXRT-ERROR: Could not allocate a new "
406+
drt_debug_print("DPEXRT-ERROR: Could not allocate a new "
407407
"NRT_ExternalAllocator object at %s, line %d\n",
408408
__FILE__, __LINE__));
409409
goto error;
410410
}
411411

412412
// Allocate a new MemInfoDtorInfo
413413
if (!(midtor_info = MemInfoDtorInfo_new(mi, ndarrobj))) {
414-
DPEXRT_DEBUG(nrt_debug_print("DPEXRT-ERROR: Could not allocate a new "
414+
DPEXRT_DEBUG(drt_debug_print("DPEXRT-ERROR: Could not allocate a new "
415415
"MemInfoDtorInfo object at %s, line %d\n",
416416
__FILE__, __LINE__));
417417
goto error;
@@ -425,14 +425,14 @@ static NRT_MemInfo *NRT_MemInfo_new_from_usmndarray(PyObject *ndarrobj,
425425
mi->size = nitems * itemsize;
426426
mi->external_allocator = ext_alloca;
427427

428-
DPEXRT_DEBUG(nrt_debug_print(
428+
DPEXRT_DEBUG(drt_debug_print(
429429
"DPEXRT-DEBUG: NRT_MemInfo_init mi=%p external_allocator=%p\n", mi,
430430
ext_alloca));
431431

432432
return mi;
433433

434434
error:
435-
DPEXRT_DEBUG(nrt_debug_print(
435+
DPEXRT_DEBUG(drt_debug_print(
436436
"DPEXRT-ERROR: Failed inside NRT_MemInfo_new_from_usmndarray clean up "
437437
"and return NULL at %s, line %d\n",
438438
__FILE__, __LINE__));
@@ -460,20 +460,20 @@ DPEXRT_MemInfo_alloc(npy_intp size, size_t usm_type, const char *device)
460460
MemInfoDtorInfo *midtor_info = NULL;
461461
DPCTLSyclQueueRef qref = NULL;
462462

463-
DPEXRT_DEBUG(nrt_debug_print(
463+
DPEXRT_DEBUG(drt_debug_print(
464464
"DPEXRT-DEBUG: Inside DPEXRT_MemInfo_alloc %s, line %d\n", __FILE__,
465465
__LINE__));
466466
// Allocate a new NRT_MemInfo object
467467
if (!(mi = (NRT_MemInfo *)malloc(sizeof(NRT_MemInfo)))) {
468-
DPEXRT_DEBUG(nrt_debug_print(
468+
DPEXRT_DEBUG(drt_debug_print(
469469
"DPEXRT-ERROR: Could not allocate a new NRT_MemInfo object.\n"));
470470
goto error;
471471
}
472472

473473
if (!(qref = (DPCTLSyclQueueRef)DPEXRTQueue_CreateFromFilterString(device)))
474474
{
475475
DPEXRT_DEBUG(
476-
nrt_debug_print("DPEXRT-ERROR: Could not create a sycl::queue from "
476+
drt_debug_print("DPEXRT-ERROR: Could not create a sycl::queue from "
477477
"filter string: %s at %s %d.\n",
478478
device, __FILE__, __LINE__));
479479
goto error;
@@ -496,7 +496,7 @@ DPEXRT_MemInfo_alloc(npy_intp size, size_t usm_type, const char *device)
496496

497497
mi->size = size;
498498
mi->external_allocator = ext_alloca;
499-
DPEXRT_DEBUG(nrt_debug_print(
499+
DPEXRT_DEBUG(drt_debug_print(
500500
"DPEXRT-DEBUG: DPEXRT_MemInfo_alloc mi=%p "
501501
"external_allocator=%p for usm_type %zu on device %s, %s at %d\n",
502502
mi, ext_alloca, usm_type, device, __FILE__, __LINE__));
@@ -562,13 +562,13 @@ static NRT_MemInfo *DPEXRT_MemInfo_fill(NRT_MemInfo *mi,
562562
exp++;
563563
count = (unsigned int)(size >> exp);
564564

565-
DPEXRT_DEBUG(nrt_debug_print(
565+
DPEXRT_DEBUG(drt_debug_print(
566566
"DPEXRT-DEBUG: mi->size = %u, itemsize = %u, count = %u, "
567567
"value = %u, Inside DPEXRT_MemInfo_fill %s, line %d\n",
568568
mi->size, itemsize << exp, count, value, __FILE__, __LINE__));
569569

570570
if (mi->data == NULL) {
571-
DPEXRT_DEBUG(nrt_debug_print("DPEXRT-DEBUG: mi->data is NULL, "
571+
DPEXRT_DEBUG(drt_debug_print("DPEXRT-DEBUG: mi->data is NULL, "
572572
"Inside DPEXRT_MemInfo_fill %s, line %d\n",
573573
__FILE__, __LINE__));
574574
goto error;
@@ -755,20 +755,20 @@ static int DPEXRT_sycl_usm_ndarray_from_python(PyObject *obj,
755755
// collecting the array.
756756
Py_IncRef(obj);
757757

758-
DPEXRT_DEBUG(nrt_debug_print(
758+
DPEXRT_DEBUG(drt_debug_print(
759759
"DPEXRT-DEBUG: In DPEXRT_sycl_usm_ndarray_from_python.\n"));
760760

761761
// Check if the PyObject obj has an _array_obj attribute that is of
762762
// dpctl.tensor.usm_ndarray type.
763763
if (!(arrayobj = PyUSMNdArray_ARRAYOBJ(obj))) {
764-
DPEXRT_DEBUG(nrt_debug_print(
764+
DPEXRT_DEBUG(drt_debug_print(
765765
"DPEXRT-ERROR: PyUSMNdArray_ARRAYOBJ check failed %d\n", __FILE__,
766766
__LINE__));
767767
goto error;
768768
}
769769

770770
if (!(ndim = UsmNDArray_GetNDim(arrayobj))) {
771-
DPEXRT_DEBUG(nrt_debug_print(
771+
DPEXRT_DEBUG(drt_debug_print(
772772
"DPEXRT-ERROR: UsmNDArray_GetNDim returned 0 at %s, line %d\n",
773773
__FILE__, __LINE__));
774774
goto error;
@@ -779,7 +779,7 @@ static int DPEXRT_sycl_usm_ndarray_from_python(PyObject *obj,
779779
nitems = product_of_shape(shape, ndim);
780780
itemsize = (npy_intp)UsmNDArray_GetElementSize(arrayobj);
781781
if (!(qref = UsmNDArray_GetQueueRef(arrayobj))) {
782-
DPEXRT_DEBUG(nrt_debug_print(
782+
DPEXRT_DEBUG(drt_debug_print(
783783
"DPEXRT-ERROR: UsmNDArray_GetQueueRef returned NULL at "
784784
"%s, line %d.\n",
785785
__FILE__, __LINE__));
@@ -789,7 +789,7 @@ static int DPEXRT_sycl_usm_ndarray_from_python(PyObject *obj,
789789
if (!(arystruct->meminfo = NRT_MemInfo_new_from_usmndarray(
790790
obj, data, nitems, itemsize, qref)))
791791
{
792-
DPEXRT_DEBUG(nrt_debug_print(
792+
DPEXRT_DEBUG(drt_debug_print(
793793
"DPEXRT-ERROR: NRT_MemInfo_new_from_usmndarray failed "
794794
"at %s, line %d.\n",
795795
__FILE__, __LINE__));
@@ -837,7 +837,7 @@ static int DPEXRT_sycl_usm_ndarray_from_python(PyObject *obj,
837837
// code of -1.
838838
// Decref the Pyobject of the array
839839
// ensure the GIL
840-
DPEXRT_DEBUG(nrt_debug_print(
840+
DPEXRT_DEBUG(drt_debug_print(
841841
"DPEXRT-ERROR: Failed to unbox dpnp ndarray into a Numba "
842842
"arraystruct at %s, line %d\n",
843843
__FILE__, __LINE__));
@@ -871,7 +871,7 @@ static PyObject *box_from_arystruct_parent(arystruct_t *arystruct,
871871
struct PyUSMArrayObject *arrayobj = NULL;
872872
npy_intp itemsize = 0;
873873

874-
DPEXRT_DEBUG(nrt_debug_print("DPEXRT-DEBUG: In try_to_return_parent.\n"));
874+
DPEXRT_DEBUG(drt_debug_print("DPEXRT-DEBUG: In try_to_return_parent.\n"));
875875

876876
if (!(arrayobj = PyUSMNdArray_ARRAYOBJ(arystruct->parent)))
877877
return NULL;
@@ -917,7 +917,7 @@ static PyObject *box_from_arystruct_parent(arystruct_t *arystruct,
917917
// parent, we need to increment the reference count of the parent here.
918918
Py_IncRef(array);
919919

920-
DPEXRT_DEBUG(nrt_debug_print(
920+
DPEXRT_DEBUG(drt_debug_print(
921921
"DPEXRT-DEBUG: try_to_return_parent found a valid parent.\n"));
922922

923923
/* Yes, it is the same array return a new reference */
@@ -957,7 +957,7 @@ DPEXRT_sycl_usm_ndarray_to_python_acqref(arystruct_t *arystruct,
957957
int exp = 0;
958958
npy_intp itemsize = 0;
959959

960-
DPEXRT_DEBUG(nrt_debug_print(
960+
DPEXRT_DEBUG(drt_debug_print(
961961
"DPEXRT-DEBUG: In DPEXRT_sycl_usm_ndarray_to_python_acqref.\n"));
962962

963963
if (descr == NULL) {
@@ -976,7 +976,7 @@ DPEXRT_sycl_usm_ndarray_to_python_acqref(arystruct_t *arystruct,
976976
// If the arystruct has a parent attribute, try to box the parent and
977977
// return it.
978978
if (arystruct->parent) {
979-
DPEXRT_DEBUG(nrt_debug_print(
979+
DPEXRT_DEBUG(drt_debug_print(
980980
"DPEXRT-DEBUG: arystruct has a parent, therefore "
981981
"trying to box and return the parent at %s, line %d\n",
982982
__FILE__, __LINE__));
@@ -1014,7 +1014,7 @@ DPEXRT_sycl_usm_ndarray_to_python_acqref(arystruct_t *arystruct,
10141014
NRT_MemInfo_acquire(arystruct->meminfo);
10151015
status = MemInfo_init(miobj, args, NULL);
10161016
if (status != 0) {
1017-
DPEXRT_DEBUG(nrt_debug_print("MemInfo_init failed at %s, line %d\n",
1017+
DPEXRT_DEBUG(drt_debug_print("MemInfo_init failed at %s, line %d\n",
10181018
__FILE__, __LINE__));
10191019
Py_DECREF(args);
10201020
PyErr_Format(PyExc_ValueError,
@@ -1106,7 +1106,7 @@ DPEXRT_sycl_usm_ndarray_to_python_acqref(arystruct_t *arystruct,
11061106
return (PyObject *)NULL;
11071107
}
11081108

1109-
DPEXRT_DEBUG(nrt_debug_print(
1109+
DPEXRT_DEBUG(drt_debug_print(
11101110
"Returning from DPEXRT_sycl_usm_ndarray_to_python_acqref "
11111111
"at %s, line %d\n",
11121112
__FILE__, __LINE__));
@@ -1145,10 +1145,10 @@ static int DPEXRT_sycl_queue_from_python(PyObject *obj,
11451145
queue_obj = (struct PySyclQueueObject *)obj;
11461146

11471147
DPEXRT_DEBUG(
1148-
nrt_debug_print("DPEXRT-DEBUG: In DPEXRT_sycl_queue_from_python.\n"));
1148+
drt_debug_print("DPEXRT-DEBUG: In DPEXRT_sycl_queue_from_python.\n"));
11491149

11501150
if (!(queue_ref = SyclQueue_GetQueueRef(queue_obj))) {
1151-
DPEXRT_DEBUG(nrt_debug_print(
1151+
DPEXRT_DEBUG(drt_debug_print(
11521152
"DPEXRT-ERROR: SyclQueue_GetQueueRef returned NULL at "
11531153
"%s, line %d.\n",
11541154
__FILE__, __LINE__));
@@ -1165,7 +1165,7 @@ static int DPEXRT_sycl_queue_from_python(PyObject *obj,
11651165
// code of -1.
11661166
// Decref the Pyobject of the array
11671167
// ensure the GIL
1168-
DPEXRT_DEBUG(nrt_debug_print(
1168+
DPEXRT_DEBUG(drt_debug_print(
11691169
"DPEXRT-ERROR: Failed to unbox dpctl SyclQueue into a Numba "
11701170
"queuestruct at %s, line %d\n",
11711171
__FILE__, __LINE__));

numba_dpex/core/runtime/_nrt_helper.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ static struct NRT_MemSys TheMSys;
5151
// following funcs are copied from numba/core/runtime/nrt.cpp
5252
void *NRT_MemInfo_external_allocator(NRT_MemInfo *mi)
5353
{
54-
NRT_Debug(nrt_debug_print(
54+
NRT_Debug(drt_debug_print(
5555
"NRT_MemInfo_external_allocator meminfo: %p external_allocator: %p\n",
5656
mi, mi->external_allocator));
5757
return mi->external_allocator;
@@ -70,7 +70,7 @@ void NRT_MemInfo_release(NRT_MemInfo *mi)
7070

7171
void NRT_MemInfo_call_dtor(NRT_MemInfo *mi)
7272
{
73-
NRT_Debug(nrt_debug_print("NRT_MemInfo_call_dtor %p\n", mi));
73+
NRT_Debug(drt_debug_print("NRT_MemInfo_call_dtor %p\n", mi));
7474
if (mi->dtor && !TheMSys.shutting)
7575
/* We have a destructor and the system is not shutting down */
7676
mi->dtor(mi->data, mi->size, mi->dtor_info);
@@ -80,7 +80,7 @@ void NRT_MemInfo_call_dtor(NRT_MemInfo *mi)
8080

8181
void NRT_MemInfo_acquire(NRT_MemInfo *mi)
8282
{
83-
// NRT_Debug(nrt_debug_print("NRT_MemInfo_acquire %p refct=%zu\n", mi,
83+
// NRT_Debug(drt_debug_print("NRT_MemInfo_acquire %p refct=%zu\n", mi,
8484
// mi->refct.load()));
8585
assert(mi->refct > 0 && "RefCt cannot be zero");
8686
mi->refct++;
@@ -102,7 +102,7 @@ size_t NRT_MemInfo_refcount(NRT_MemInfo *mi)
102102

103103
void NRT_Free(void *ptr)
104104
{
105-
NRT_Debug(nrt_debug_print("NRT_Free %p\n", ptr));
105+
NRT_Debug(drt_debug_print("NRT_Free %p\n", ptr));
106106
TheMSys.allocator.free(ptr);
107107
if (TheMSys.stats.enabled) {
108108
TheMSys.stats.free++;
@@ -112,7 +112,7 @@ void NRT_Free(void *ptr)
112112
void NRT_dealloc(NRT_MemInfo *mi)
113113
{
114114
NRT_Debug(
115-
nrt_debug_print("NRT_dealloc meminfo: %p external_allocator: %p\n", mi,
115+
drt_debug_print("NRT_dealloc meminfo: %p external_allocator: %p\n", mi,
116116
mi->external_allocator));
117117
if (mi->external_allocator) {
118118
mi->external_allocator->free(mi, mi->external_allocator->opaque_data);

numba_dpex/core/runtime/_nrt_python_helper.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ int MemInfo_init(MemInfoObject *self, PyObject *args, PyObject *kwds)
2828
}
2929
raw_ptr = PyLong_AsVoidPtr(raw_ptr_obj);
3030
NRT_Debug(
31-
nrt_debug_print("MemInfo_init self=%p raw_ptr=%p\n", self, raw_ptr));
31+
drt_debug_print("MemInfo_init self=%p raw_ptr=%p\n", self, raw_ptr));
3232

3333
if (PyErr_Occurred())
3434
return -1;

0 commit comments

Comments
 (0)