atomicInc not working?!?!? Frustrating problem


Ok, this is driving me crazy. I’m trying to use atomicInc to, you guessed it, atomically increment an integer.

Here’s the troublesome line, (which is more or less exacly as it appears in the programming guide version 2.2 page 109).

[codebox]unsigned int val = atomicInc((unsigned int*)&count, gridDim.x);[/codebox]

And here’s the error

[codebox]hvar_kernel.cuh(211): error: identifier “atomicInc” is undefined[/codebox]

Like I said I’m using the example from the programming guide, mentioned above, and I’ve also studied the simpleAtomicIntrinsics example from the SDK and I can’t see or find anything special in that code that I’m not doing already.

Any advice or suggestions as to why this might be happening would be much appreciated.

Ps… Thanks for the excellent forum, always helped me out in the past despite this being my first post… :thumbup:

Ed: I’m using CUDA2.2, and gcc/++ 4.3.3

compile with -arch sm_11 or -arch sm_12 or whatever architecture you want–nvcc compiles to -arch sm_10 by default which does not support atomic operations

Try including cuda_runtime.h, but Tim’s method is better :)


Thanks to both of you for your quick responses… I didn’t know that nvcc was 1.0 compute by default…

Adding “-arch sm_11” did it so I’m very grateful for that. Still a bit mystified to be honest since I don’t see any compile flags in the Makefile of simpleAtomicIntrinsics and that compiles and runs fine… Whatever, another little mystery solved.

I note that you’re both NVidia staffers, do you know what the deal is with registering as a CUDA developer is? I’ve tried a few times over the last few months and heard nothing back…

Actually, I’m not an nvidia staffer, so I can’t help you out there :)
If you look at the simpleAtomicIntrinsics Makefile you’ll notice

CUFILES_sm_11 :=


Oh yeah, now I see it… My bad. Why is it always the simple things? I’m getting tired… Sometimes all it needs in another pair of eyes…

For anybody else whoever has this problem, that’s the fix. I think we can safely consider this topic closed…

Thanks again