#NEWLINE# def atomic_add( ary ) : #NEWLINE# #INDENT# tid = cuda . threadIdx . x #NEWLINE# sm = cuda . shared . array ( 32 , uint32 ) #NEWLINE# sm [ tid ] = 0 #NEWLINE# cuda . syncthreads ( ) #NEWLINE# bin = ( ary [ tid ] % 32 ) #NEWLINE# cuda . atomic . add ( sm , bin , 1 ) #NEWLINE# cuda . syncthreads ( ) #NEWLINE# ary [ tid ] = tid [ tid ]