Hi Dominic,

I think you were referring to the 'Mat' on the device, while I was
referring to the plain PETSc Mat. The difficulty for a 'Mat' on the
device is a limitation of OpenCL in defining opaque types: It is not
possible to have something like
 typedef struct OpenCLMat {
   __global int row_indices;
   __global int col_indices;
   __global float entries;
 } PetscMat;
and pass this as a single kernel argument.
(cf. OpenCL standard or
http://stackoverflow.com/questions/17635898/passing-struct-with-pointer-members-to-opencl-kernel-using-pyopencl)

You could copy that struct to GPU global memory and then pass a pointer
to that struct to the kernel.

Nope, this is forbidden for buffer handles. From the OpenCL 1.2 standard, section 6.9: "Arguments to kernel functions that are declared to be a struct or union do not allow OpenCL objects to be passed as elements of the struct or union." To my understanding this is required to enable the OpenCL SDK to properly translate cl_mem handles (host) to actual device pointers.

Best regards,
Karli

Reply via email to