Hello,

I recently refactored my code to use the following structure.

typedef struct {
        // __read_only image2d_t sgmf; Note: commented out, see below

   float3 so;
   float3 sbvw;
   float3 sbvh;

   float4 intrinsics;
   DualQuaternion w2c;
   DualQuaternion c2w;
} Measurement __attribute__ ((aligned (16))) ;
The python site looks something like that:
 s = \
    pack("=fff4x", *dm.screen.origin) + \
    pack("=fff4x", *dm.screen.bv1) + \
    pack("=fff4x", *dm.screen.bv2) + \
    pack("=ffff", A[0,0], A[1,1], A[0,2], A[1,2]) + \
    pack("=ffff", *dm.w2c.dq.r._v) + \
    pack("=ffff", *dm.w2c.dq.d._v) + \
    pack("=ffff", *dm.w2c.inv.dq.r._v) + \
    pack("=ffff", *dm.w2c.inv.dq.d._v)
params_buf = cl.Buffer(ctx, mf.READ_ONLY, len(s))
cl.enqueue_write_buffer(queue, params_buf, s).wait()

Before, I had to pass all arguments individually into my kernel (and I had 2-n of those structures). All is fine and dandy, except for two issues I am unable to work out and would appreciate some help:

1) How can I pack the image2d_t on the python site so that I can include it into
my structure. Currently I have to pass it individually, but it is really just
a parameter of the structure from a semantic point of view. I'd like to pass the kernel a variable number of the structures, so this would be really useful.

2) I pass the params_buf as __constant to my kernel. I have some functions doing arithmetic with DualQuaternions and I have to first copy all data from my structure before working with them: e.g.

void conjugate(const DualQuaternion * a, DualQuaternion * rv);

DualQuaternion rv;
conjugate(&measurement->w2c, &rv);
Gives this error:
passing 'DualQuaternion __attribute__((address_space(2)))const *' discards 
qualifiers, expected 'DualQuaternion const *'

DualQuaternion temp = measurement->w2c;
conjugate(&w2c, &rv);
is working okay.

I understand the reason for this I think: functions need to work in one address space only. But is there a way to pass my structures to my kernel that the explicit copy is not needed?

Thanks for your help!

Kind Regards,
Holger Rapp



_______________________________________________
PyOpenCL mailing list
[email protected]
http://lists.tiker.net/listinfo/pyopencl

Reply via email to