Added argmax function.
Added a missing cudaThreadSynchronize();