2 Replies Latest reply on Jul 21, 2012 1:07 PM by ante

    2D kernel problem

    ante

      Hi all

       

      I've been having trouble when running 2 dimensional kernels.

      I tried to use the matrix multiplication kernel (mmmKernel_local2) provided in ATi OpenCL samples in my code, but the output was all zeros.

      I traced the problem down to the get_global_id(1) - it returns some strange numbers. So I made a simple kernel just to check:

       

      __kernel void foo(__global float4 *out)

      {

                out[get_global_id(0)] = (float4)get_global_id(1);

      }

       

      The output for a 4x4 (global range) kernel looks like this:

       

      3.43597e+009, 3.43597e+009, 3.43597e+009, 3.43597e+009, 3.43597e+009, 3.43597e+009, 3.43597e+009, 3.43597e+009,

      3.43597e+009, 3.43597e+009, 3.43597e+009, 3.43597e+009, 3.43597e+009, 3.43597e+009, 3.43597e+009, 3.43597e+009,

      0, 0, 0, 0, 0, 0, 0, 0,

      0, 0, 0, 0, 0, 0, 0, 0,

      0, 0, 0, 0, 0, 0, 0, 0,

      0, 0, 0, 0, 0, 0, 0, 0,

      0, 0, 0, 0, 0, 0, 0, 0,

      0, 0, 0, 0, 0, 0, 0, 0,


      If I replace out[get_global_id(0)] = (float4)get_global_id(0); with out[get_global_id(0)] = (float4)get_global_id(1); everything works fine:

       

      0, 0, 0, 0, 1, 1, 1, 1,

      2, 2, 2, 2, 3, 3, 3, 3,

      0, 0, 0, 0, 0, 0, 0, 0,

      0, 0, 0, 0, 0, 0, 0, 0,

      0, 0, 0, 0, 0, 0, 0, 0,

      0, 0, 0, 0, 0, 0, 0, 0,

      0, 0, 0, 0, 0, 0, 0, 0,

      0, 0, 0, 0, 0, 0, 0, 0,

       

      When I collect the application trace the results verify that the kernel is run with the dimensions that I've specified. I really have no idea what the problem could be, especially because the example where I got the kernel from works fine, and multiplies matrices just as it should. Could it be  VS project configuration issue, or something else I'm overlooking? Please help.

       

      Thanks.

        • Re: 2D kernel problem
          binying

          How about switching to the kernel of the AMD APP matrix multiplication sample?

          1 of 1 people found this helpful
            • Re: 2D kernel problem
              ante

              It's 0K. I fixed it. Although, I don't know how I did it. I've tampered with project settings, borrowed some code from AMD's samples, and rewritten some of my code. Somewhere along the line, everything started working just fine. I wish I knew what made the difference so I wouldn't repeat the same mistake again, but right now I'm happy just to see it work - I lost more than a week trying to figure out what's wrong and was at the end of my wits' when I posted the question.

               

              Thank's for the quick responses.