Multiplication of CUDA matrices of arbitrary dimensions