Identifier atomicadd not defined [SOLVED]

I’m using a gtx 1060 compute capability 6.1, visual studio 2015 and cuda 8.0.
I read all topics in this section and on the others sites of the web, but nothing helped me.
In my solution project proprieties, under CUDA C/C++ → Device → code generation i set compute_61,sm_61.

The follow partial code doesen’t compile if I decomment the atomicAdd( ) instruction

// PHASE 2: perform iterative kogge_stone_scan of the last elements of each subsections of XY loaded first in AUS
AUS[threadIdx.x] = XY[threadIdx.x * (SECTION_SIZE / blockDim.x) + (SECTION_SIZE / blockDim.x) - 1];
for (unsigned int stride = 1; stride < blockDim.x; stride *= 2) {
	if (threadIdx.x >= stride) {
		//atomicAdd(AUS[threadIdx.x], AUS[threadIdx.x - stride]);
	}
}
__syncthreads();

If I try to decomment I have the follow error: identifier “atomicAdd” not defined
And if I try to recompile after I have the follow errors:
no instance of overloaded function “atomicAdd” matches the argument list work-efficient_parallel_scan

Gravità Codice Descrizione Progetto File Riga Stato eliminazione
Errore MSB3721 uscita dal comando ““C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\bin\nvcc.exe” -gencode=arch=compute_61,code="sm_61,compute_61" --use-local-env --cl-version 2015 -ccbin “C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\x86_amd64” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include” -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0\include" --source-in-ptx -G -lineinfo --keep-dir x64\Debug -maxrregcount=0 --ptxas-options=-v --machine 64 --compile -cudart static -arch compute_61 -g -DWIN32 -DWIN64 -D_DEBUG -D_CONSOLE -D_MBCS -Xcompiler “/EHsc /W3 /nologo /Od /FS /Zi /RTC1 /MDd " -o x64\Debug\kernel.cu.obj “C:\Users\Simone\Documents\Visual Studio 2015\Projects\work-efficient_parallel_scan\work-efficient_parallel_scan\kernel.cu”” con codice 2. work-efficient_parallel_scan C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\BuildCustomizations\CUDA 8.0.targets 689

Someone can help me please?

In general, when asking for debugging help, it is best to post a minimal but complete example that other people can compile themselves.

Think about it this way: You are able to study the entire code, compile it, instrument it, etc, yet you have not been able to determine what is wrong. Logic says that it is unlikely that other people who have access to only a minimal snippet of that code and can’t compile it (i.e. have significantly less information than you) can tell you what is going on.

The first parameter of atomicAdd is a pointer.

this is almost certainly NOT correct usage for AUS in atomicAdd:

atomicAdd(AUS[threadIdx.x], AUS[threadIdx.x - stride]);
          ^^^^^

it should be:

atomicAdd(AUS+threadIdx.x, AUS[threadIdx.x - stride]);

the documentation for atomicAdd:

http://docs.nvidia.com/cuda/cuda-c-programming-guide/index.html#atomicadd

Note that this will NOT get rid of the red underline (“identifier “atomicAdd” not defined”) under atomicAdd, that is an intellisense issue. But you should be able to compile a properly crafted atomicAdd statement, even though there is a red underline.

Sorry njuffa you’re right, but I thought that the problem was about the configuration of visual studio project, so I didn’t paste the entire kernel code.

Thank you txbob, your suggestion works for me! Intellisense still underline the function, but now it compile without problem!

1 Like