Why does magma_dgemm silently fail?

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)
Post Reply
diyu01
Posts: 2
Joined: Fri May 02, 2014 3:21 pm

Why does magma_dgemm silently fail?

Post by diyu01 » Fri May 02, 2014 3:24 pm

Hi, I am just trying to run a small test program with my new MAGMA 1.5.0-beta1 installation. I tried a call like this:

//initialize A, B and C on host. A is all 1's, B is all 2's, and C is all 0's
magma_init();
magma_dgemm(MagmaTrans,MagmaNoTrans,m,n,k,alpha,A,m,B,n,beta,C,n); //alpha=1.0, beta=0.0
magma_finalize();

And I found that the magma_dgemm call silently failed. There was no error output at all, but C still contains all 0's.

I am not sure what I am doing wrong here. Can anybody help? (Some other magma functions actually work, so I am not sure what is so special with dgemm). Thanks!

mgates3
Posts: 918
Joined: Fri Jan 06, 2012 2:13 pm

Re: Why does magma_dgemm silently fail?

Post by mgates3 » Fri May 02, 2014 4:37 pm

magma_dgemm is simply a wrapper around cublasDgemm. As with most CUDA calls, it is an asynchronous call, so cublasDgemm cannot detect some errors when it is queued. Perhaps, errors may be returned later after it has finished, by cudaGetLastError. I've never actually checked whether that is true for any cublas functions.

In this case, you say "A, B, C on host". But cublasDgemm takes all 3 on the GPU, not on the CPU. So that would definitely be an error. I doubt it would return an error code, though. If anything, it would segfault or give CUDA kernel launch failed errors on subsequent kernels.

For a correct calling example, see the testing_dgemm.cpp code, where we allocate host matrices (h_A, h_B, h_C), initialize them, then send them to device matrices (d_A, d_B, d_C) on the GPU, call magma_dgemm, and get the results back.

-mark

diyu01
Posts: 2
Joined: Fri May 02, 2014 3:21 pm

Re: Why does magma_dgemm silently fail?

Post by diyu01 » Fri May 02, 2014 6:06 pm

Thanks! Moving A, B, C onto GPU have solved the problem.

hsahasra
Posts: 32
Joined: Mon Jun 24, 2013 3:40 pm

Re: Why does magma_dgemm silently fail?

Post by hsahasra » Sun May 04, 2014 11:31 am

You can correctly check for errors when the stream is synchronized. For example:

cudaStream_t stream;
.
.
cublasStatus_t cublas_error = cublasDgemm(stream, ....);
<check cublas_error>
cudaError_t cuda_error = cudaStreamSynchronize(stream);
<check cuda_error>

for MAGMA, just set the blas kernel stream before the multiply

magmablasSetKernelStream(stream)

Doing this will give you the complete error returned by cublasDgemm.

Post Reply