coprthr_dwrite and coprthr_mem_t

Moderator: dar

coprthr_dwrite and coprthr_mem_t

Postby nickoppen » Mon Apr 18, 2016 11:41 am

Hi,

I've gotten my coprthr_mpiexec working but I thought I'd get coprthr_dexec working as well to make my next blog post a bit more general.

I'm using a struct to pass in my arguments and with coprthr_mpiexec I just use a point to a normal structure in main memory and that works fine.

With coprthr_dexec all the examples show arrays being copied into shared memory and then the pointer to shared memory is passed to the kernel in and array. I still want to pass in two "non-array" variables so I'm trying to pass in my structure thus:

Code: Select all
   my_args_t args = {
      .n = 2.0,                      // .n is a float
      .width = WIDTH,         // .width is an int, WIDTH is #defined as 64
   };
   coprthr_mem_t p_args_mem = coprthr_dmalloc(dd, sizeof(my_args_t), 0);
   coprthr_dwrite(dd, p_args_mem, 0, &args, sizeof(my_args_t),COPRTHR_E_WAIT);


I get a seg fault when I try to use p_args_mem in my dexec.

Is this the right way to do it?

I can't even tell if the data is correctly copied to shared memory because when I try to access it I don't get 2.0 and 64. Similarly I copy an array of floats to shared memory (my "data") and when I point a new variable at the coprthr_mem_t pointer and read it back I get very different results but the correct data arrives in the kernel.

nick
Sharing is what makes the internet Great!
User avatar
nickoppen
 
Posts: 266
Joined: Mon Dec 17, 2012 3:21 am
Location: Sydney NSW, Australia

Re: coprthr_dwrite and coprthr_mem_t

Postby jar » Mon Apr 18, 2016 1:40 pm

If you want to use a normal struct, use the MPI interface. The low-level dexec command requires the array of arrays. You can allocate two chunks of memory for one value and dereference the pointer on the device code.

Also, in this case, since these appears to be compile-time constants in the host code, why not just compile them into the device code?
User avatar
jar
 
Posts: 295
Joined: Mon Dec 17, 2012 3:27 am

Re: coprthr_dwrite and coprthr_mem_t

Postby nickoppen » Tue Apr 19, 2016 1:47 am

Thank you yet again James,

I've got it working now and enough to write my next blog post. I want to give enough of an overview to show at least a few of the options that the programmer has when using coprthr.

nick
Sharing is what makes the internet Great!
User avatar
nickoppen
 
Posts: 266
Joined: Mon Dec 17, 2012 3:21 am
Location: Sydney NSW, Australia


Return to OpenCL

Who is online

Users browsing this forum: No registered users and 1 guest