Skip to content

Commit cbbe5e0

Browse files
committed
Add parent to SyclQueue struct
1 parent 50c45de commit cbbe5e0

File tree

3 files changed

+8
-3
lines changed

3 files changed

+8
-3
lines changed

numba_dpex/core/datamodel/models.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ def __init__(self, dmm, fe_type):
148148
"meminfo",
149149
types.MemInfoPointer(types.pyobject),
150150
),
151+
(
152+
"parent",
153+
types.pyobject,
154+
),
151155
(
152156
"queue_ref",
153157
types.CPointer(types.int8),

numba_dpex/core/runtime/_dpexrt_python.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1256,6 +1256,7 @@ static int DPEXRT_sycl_queue_from_python(NRT_api_functions *nrt,
12561256
Py_INCREF(queue_obj);
12571257
queue_struct->meminfo =
12581258
nrt->manage_memory(queue_obj, NRT_MemInfo_pyobject_dtor);
1259+
queue_struct->parent = queue_obj;
12591260
queue_struct->queue_ref = queue_ref;
12601261

12611262
return 0;
@@ -1287,9 +1288,7 @@ static int DPEXRT_sycl_queue_from_python(NRT_api_functions *nrt,
12871288
static PyObject *DPEXRT_sycl_queue_to_python(NRT_api_functions *nrt,
12881289
queuestruct_t *queuestruct)
12891290
{
1290-
PyObject *queue_obj = NULL;
1291-
1292-
queue_obj = nrt->get_data(queuestruct->meminfo);
1291+
PyObject *queue_obj = queuestruct->parent;
12931292

12941293
if (queue_obj == NULL) {
12951294
// Make create copy of queue_ref so we don't need to manage nrt lifetime

numba_dpex/core/runtime/_queuestruct.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,11 @@
1212
#pragma once
1313

1414
#include "numba/core/runtime/nrt_external.h"
15+
#include <Python.h>
1516

1617
typedef struct
1718
{
1819
NRT_MemInfo *meminfo;
20+
PyObject *parent;
1921
void *queue_ref;
2022
} queuestruct_t;

0 commit comments

Comments
 (0)