Thursday, November 29, 2012

OpenCL/CUDA: How to resolve "Arguments mismatch for instruction 'mov' "

The following OpenCL kernel fails on my MacBook, CUDA 5.0/OpenCL framework:

__kernel void scalMov(const int N, __global float *x, __global float *y)
{
    const int idx = get_global_id(0);
 if (idx < N)
 {
  x[idx] = 0.1*y[idx];
 }
}

And puts out the error message

ptxas application ptx input, line 38; error : Arguments mismatch for instruction 'mov'
ptxas fatal : Ptx assembly aborted due to errors

There is one easy way to remove that:
__kernel void scalMov(const int N, __global float *x, __global float *y)
{
    const int idx = get_global_id(0);
 if (idx < N)
 {
  float beta = 0.1;
  float alpha = beta*y[idx];
  x[idx] = alpha;
 }
}

The reason for this seems to be the = operation above, which is given some wrong parameters. Funny thing is, this kernel works:

__kernel void scalMov(const int N, __global float *x, float alpha, __global float *y)
{
    const int idx = get_global_id(0);
 if (idx < N)
 {
  x[idx] = alpha*y[idx];
 }
}

So the "mov" instruction only has problems when you are using constants in it.
So if you're having the same problems, try to comment out all your assignments so you can find out which assignment is making problems, then split the assignment up. Note that you have to split it up several times otherwise the OpenCL compiler will "optimize" it back again for you.

No comments:

Post a Comment