خرید بک لینک

Vote count: 0

I have a global function in which I am passing a 1D array of lengths, int *d_arrayOfLengths. In the keel, I am calculating a variable "cellNo" and want to use this "cellNo" as an index for above array. Whenever I try to get the value of "d_arrayOfLengths[cellNo]", program shows an error saying "illegal memory access was encountered". However, when I use some constant index say 1 or 2 or anything within the limit, "d_arrayOfLengths[1]" retus the correct value stored for that index. I am not able to understand why this is happening? Please tell the reason and solution. I am attaching part of the code.

__global__ void funcName(..., int *d_arrayOfLengths, ...)
{
   int id = threadIdx.x + BlockIdx.x * BlockDim.x;
   if(id < numPoints)
   {
        int cellNo;
        //code for calculating cellNo
        for(int i=0; i<27; i++)
        {
            int ti = x + d_flatMoveArray[i*3 + 0];
            int tj = y + d_flatMoveArray[i*3 + 1];
            int tk = z + d_flatMoveArray[i*3 + 2];

            if(ti < 0 || ti > length_X || tj < 0 || tj > length_Y || tk < 0 || tk > length_Z)
                continue;
            else
            {
                cellno = ti*a + tj*b + tk;
                neighbourParticlesCount += d_arrayOfLengths[cellNo]; //shows error
                neighbourParticleCount += d_arrayOfLengths[1]; //give correct count 
            }
        }
        d_out[id] = neighbourParticleCount;
   }
}

I am using nvidia GEFORCE GTX 660 Ti. All my input arrays are flat 1D array and I am not allocating huge amount of memory.

asked 59 secs ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 17 تير 1395 ساعت: 8:19

صفحه بندی