SpMdM: Big steps towards supporting row-major and col-major layout for both result and factor.

CPU version working, OpenCL and CUDA versions work for row-major only.