12 Replies Latest reply on Feb 1, 2012 7:22 AM by laobrasuca

    Build program crash, also crashes on kernel analyser

    laobrasuca

      I'm trying to use a structure to pass a pointer to buffers on the host side, e.g., cl_mem* buffs, as a pointer to pointers in the kernel side. So far, I've tried to see if the kernel code will build ok. So I did the following kernel test code.

       

      //ex ok:

      typedef struct struct_buffs{

      float **tab; //or __global float **tab;

      }struct_buffs;

       

      __kernel void test(struct_buffs buffs)

      {

          uint gid = get_global_id(0);

          float* buff = buffs.tab[gid]; //or __global float* buff = buffs.tab[gid];

          buff[0] = gid;

      }

      //

       

      This code will build fine, no problem (although I haven't tried to run it yet). So, I could be happy, but I've tried the version below which will make the .exe crash when running clBuildProgram(). It's an access violation (test.exe: 0xC0000005: access violation writing location 0x00000008) (it will also make  kernel analyser 1.10 not respond, I guess for the same reason).

       

      // ex no ok:

      typedef struct struct_buffs{

      float **tab;

      }struct_buffs;

       

      __kernel void test(__global struct_buffs* buffs)

      {

          uint gid = get_global_id(0);

          float* buff = buffs->tab[gid];

          buff[0] = gid;

      }

       

      So I have 2 questions:

       

      1- Is the second code supposed to crash??

      2- In the case of the first code, will the struct_buffs buffs variable be in the global or private memory space?. I mean, will I be able to pass things from the host as I usually do when manipulating a simple buffer (cl_mem buff on the host side and __global float* buff on the kernel side)?