Hello.
I’m trying to count how many times the char exists in a array.
The kernel that I’m using is this one.
[codebox]global void charCounter(char *string, int *charCounter, int N)
{
int idx = blockIdx.x * blockDim.x + threadIdx.x;
if (idx < N)
atomicAdd(&charCounter[(int)string[idx]], 1);
}
[/codebox]
The result with the serial code is that all the characters got the same number. But the parallel results are different they are near the correct ones.