Creating custom atomic CUDA functions

Greetings all,

I am currently working on a project that has me evaluating pathfinding algorithms (both SSSP and APSP) in a cluster environment. If I am evaluating the performance of an implementation using the nodes’ CPUs, then I do not need to utilize an atomicMin function when comparing the cost values (I’m just using 1 core/node). If, however, I am utilizing a GPU to do the processing (be it on one node or many), then an atomicMin is necessary. The catch is that I am wanting to record both the cost AND the predecessor values.

My question then is, since the atomicMin function in the CUDA library only supports ints (as far as I can tell), is there a way to write a custom atomic function? Alternately, is there a way to -link- 2 atomic functions? For reference, I’m keeping track of the costs and predecessors in an array of structs. Each struct consists of (2) ints - cost and predecessor. I only actually need the atomicMin function for the cost, but I need to make sure that the appropriate predecessor value is stored with it.

I appreciate any and all help and suggestions!

Charles Johnson

PS For the record, when I say ‘project’ above, I am not referring to a class project. Unless, that is, you consider a Master’s thesis a class project ;-)

I may be grepping the header files incorrectly, but it seems to me that atomicMin is an overloaded function that exists in int, unsigned int, long long, and unsigned long long variants.

Worth looking into, because with a 64-bit variant it would seem you can put the cost in the high-order 32 bits and the predecessor in the low-order 32 bits to perform the desired operation (you did not specify what should happen in case of identical cost).