CUDA memory issues

I have a CUDA core that I compile into a Cuban file without any special flags:

nvcc text.cu -cubin

It compiles, although with this post:

Consultation: I can not indicate which pointer points, taking the global memory space

and a link to a line in some temporary cpp file. I can get this to work by commenting on some seemingly arbitrary code that makes no sense to me.

The core is as follows:

__global__ void string_search(char** texts, int* lengths, char* symbol, int* matches, int symbolLength)
{
    int localMatches = 0;
    int blockId = blockIdx.x + blockIdx.y * gridDim.x;
    int threadId = threadIdx.x + threadIdx.y * blockDim.x;
    int blockThreads = blockDim.x * blockDim.y;

    __shared__ int localMatchCounts[32];

    bool breaking = false;
    for(int i = 0; i < (lengths[blockId] - (symbolLength - 1)); i += blockThreads)
    {
        if(texts[blockId][i] == symbol[0])
        {
            for(int j = 1; j < symbolLength; j++)
            {
                if(texts[blockId][i + j] != symbol[j])
                {
                    breaking = true;
                    break;
                }
            }
            if (breaking) continue;
            localMatches++;
        }
    }

    localMatchCounts[threadId] = localMatches;

    __syncthreads();

    if(threadId == 0)
    {
        int sum = 0;
        for(int i = 0; i < 32; i++)
        {
            sum += localMatchCounts[i];
        }
        matches[blockId] = sum;
    }
}

If I replace the string

localMatchCounts[threadId] = localMatches;

after the first loop for this line

localMatchCounts[threadId] = 5;

It compiles without notice. This can also be achieved by commenting on seemingly random parts of the loop above the line. I also tried replacing the local memory array with a normal array for no effect. Can someone tell me what the problem is?

Vista 64bit, .

: , , . , , , ( ).

+5
2

char ** , .
, .
1D, , , 1D, 2 * numberOfStrings, :

, :

char * buffer = st [0] + st [1] + st [2] +....;
int * metadata = new int [numberOfStrings * 2];
int lastpos = 0;
for (int cnt = 0; cnt < 2 * numberOfStrings; cnt + = 2)
{    [cnt] = lastpos;   lastpos + = length (st [cnt]);   metadata [cnt] = length (st [cnt]);
}
:
currentIndex = threadId + blockId * numberOfBlocks;
char * currentString =  +  [2 * currentIndex];
int currentStringLength =  [2 * currentIndex + 1];
+1

, , char **. char * , , cuda . , cuda , 2D cuda. ​​

0

All Articles