Skip to content

Commit

Permalink
Queue used for copy operations should be optional
Browse files Browse the repository at this point in the history
  • Loading branch information
emprice committed Aug 20, 2024
1 parent 8ab4827 commit ba590a1
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions src/pocky/ext/pocky_bufpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,33 +158,41 @@ PyObject *pocky_bufpair_copy_from_device(pocky_bufpair_object *self, PyObject *a
cl_int err;
cl_uint idx;
char buf[BUFSIZ];
PyObject *device, *cap;
PyObject *device = NULL;
cl_device_id dev = NULL;

if (!PyArg_ParseTuple(args, "O!", pocky_device_type, &device)) return NULL;
if (!PyArg_ParseTuple(args, "|O!", pocky_device_type, &device)) return NULL;

cap = PyStructSequence_GetItem(device, 0);
if (!PyCapsule_CheckExact(cap))
if (device)
{
PyErr_SetString(PyExc_TypeError, pocky_ocl_msg_not_a_capsule);
return NULL;
}
PyObject *cap;

cap = PyStructSequence_GetItem(device, 0);
if (!PyCapsule_CheckExact(cap))
{
PyErr_SetString(PyExc_TypeError, pocky_ocl_msg_not_a_capsule);
return NULL;
}

dev = PyCapsule_GetPointer(cap, "DeviceID");
dev = PyCapsule_GetPointer(cap, "DeviceID");
}

for (idx = 0; idx < self->context->num_queues; ++idx)
{
cl_device_id qdev = NULL;
cl_command_queue queue = self->context->queues[idx];

err = clGetCommandQueueInfo(queue,
CL_QUEUE_DEVICE, sizeof(cl_device_id), &qdev, NULL);
if (err != CL_SUCCESS)
if (device)
{
snprintf(buf, BUFSIZ, pocky_ocl_fmt_internal,
pocky_opencl_error_to_string(err), err);
PyErr_SetString(pocky_ocl_error, buf);
return NULL;
err = clGetCommandQueueInfo(queue,
CL_QUEUE_DEVICE, sizeof(cl_device_id), &qdev, NULL);
if (err != CL_SUCCESS)
{
snprintf(buf, BUFSIZ, pocky_ocl_fmt_internal,
pocky_opencl_error_to_string(err), err);
PyErr_SetString(pocky_ocl_error, buf);
return NULL;
}
}

if (qdev == dev)
Expand Down

0 comments on commit ba590a1

Please sign in to comment.