i were very happy when I saw, that the cudaStreams have been implemented. But I've got the following problem: We have a linear system A * AB = B, where A has 400 x 400 Elements and B 400 x 10. Both are sparse matrices and we want to calculate AB. I decided to test your gmres algorithm with this Problem. If I don't call magma_queue_create all is fine. But when I call it, gmres needs more than 30s and produces a huge error in the result Matrix within the range of e^-1 and e^0. But it doesn't throw any error, either in the magma_queue_create nor in magma_sgmres. I think i'm doing something wrong but i don't know what. Can somebody help me, please? A short example code stands below.
Thank you in advance and greetings
Noran
Code: Select all
int
myFunction( magma_int_t rowsMatrixA,
magma_int_t colsMatrixA,
magma_index_t *rowPointerA,
magma_index_t *colIndA,
float *valA,
magma_int_t colsMatrixB,
float *valB,
float *valAB)
{
int nonZeroElementsA = rowPointerA[rowsMatrixA];
int elementsB = colsMatrixA * colsMatrixB;
int elementsAB = rowsMatrixA * colsMatrixB;
magma_s_sparse_matrix d_A;
magma_index_t *d_rowPointerA;
magma_index_t *d_colIndA;
magma_s_vector d_b;
magma_s_vector d_ab;
magma_s_solver_par solverPar;
DEBUG_LOG("initializing magma_queues");
magma_queue_t queue;
magma_queue_create(&queue);
DEBUG_LOG("Allocating GPU Memory...");
float *d_valA;
float *d_valB;
float *d_valAB;
magma_index_malloc (&d_rowPointerA, rowsMatrixA + 1);
magma_index_malloc (&d_colIndA, nonZeroElementsA);
magma_smalloc (&d_valA, nonZeroElementsA);
magma_smalloc (&d_valB, elementsB);
magma_smalloc (&d_valAB, elementsAB);
magma_index_setvector( rowsMatrixA + 1,
rowPointerA,
1,
d_rowPointerA,
1);
magma_index_setvector(nonZeroElementsA, colIndA, 1, d_colIndA, 1);
magma_ssetvector(nonZeroElementsA, valA, 1, d_valA, 1);
magma_ssetmatrix( colsMatrixA,
colsMatrixB,
valB,
colsMatrixA,
d_valB,
colsMatrixA);
magma_ssetmatrix( rowsMatrixA,
colsMatrixB,
valAB,
rowsMatrixA,
d_valAB,
rowsMatrixA);
DEBUG_LOG("Initializing matrix and vectors");
d_A.col = d_colIndA;
d_A.row = d_rowPointerA;
d_A.val = d_valA;
d_A.memory_location = Magma_DEV;
d_A.storage_type = Magma_CSR;
d_A.nnz = nonZeroElementsA;
d_A.num_rows = rowsMatrixA;
d_A.num_cols = colsMatrixA;
d_b.memory_location = Magma_DEV;
d_b.nnz = colsMatrixA;
d_b.num_rows = colsMatrixA;
d_b.val = d_valB;
d_ab.memory_location = Magma_DEV;
d_ab.nnz = rowsMatrixA;
d_ab.num_rows = rowsMatrixA;
d_ab.val = d_valAB;
DEBUG_LOG("Initializing solver_par");
solverPar.solver = Magma_GMRES;
solverPar.epsilon = 10e-8;
solverPar.maxiter = 1000;
solverPar.restart = 40;
solverPar.version = 0;
solverPar.verbose = 0;
solverPar.num_eigenvalues = 0;
solverPar.res_vec = (double*) (malloc (sizeof(double)));
DEBUG_LOG("Running solver for each column of B...");
for (int col = 0; col < colsMatrixB; col++)
{
magma_sgmres (d_A, d_b, &d_ab, &solverPar, queue);
d_b.val = d_b.val + colsMatrixA;
d_ab.val = d_ab.val + rowsMatrixA;
}
magma_sgetmatrix( rowsMatrixA,
colsMatrixB,
d_valAB,
rowsMatrixA,
valAB,
rowsMatrixA);
DEBUG_LOG("Destroy magma_queue_t queue");
cudaStreamDestroy (queue);*/
DEBUG_LOG("Free memory");
magma_free(d_valA);
magma_free(d_valB);
magma_free(d_valAB);
magma_free(d_colIndA);
magma_free(d_rowPointerA);
return error;
}