1 Reply Latest reply on Jul 1, 2010 5:47 AM by Illusio

    kernel lead to crash

    Fuxianjun

      Why does this kernel lead my computer crash? To assign value to matrix with the size of p*q.

      __kernel void test( __global float * matrix, __global int * p, __global int * q) { for(int i=0;i<p[0];i++) { for(int j=0;j<q[0];j++) { matrix[i]=1.0; } } }

        • kernel lead to crash
          Illusio

          If that kernel crashes it's because of errors in your host code.

          Some possible errors:

          The matrix array is too small for the arguments you pass the kernel.

          p[0] might not be initialized, or initialized to a wrong value.(That could apply to q[0] as well if you actually used it for anything beyond repeating the same assignment of 1.0 to the same memory location over and over)

          p[0] was initialized correctly, but you forgot to unmap the buffer that contains it after initializing, so the correct value only exists in the CPU cache and not on the GPU.

          and of course, any of the arguments could potentially not be set correctly in the kernel

          Anyway, you should probably post the part of your host code that initializes the kernel parameters, as well as the code that initializes the opencl buffers you pass in them if none of the suggestions above help.