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!
Why does magma_dgemm silently fail?
Re: Why does magma_dgemm silently fail?
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
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
Re: Why does magma_dgemm silently fail?
Thanks! Moving A, B, C onto GPU have solved the problem.
Re: Why does magma_dgemm silently fail?
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.
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.