Code: Select all
magma_int_t info = 0;
magma_init();
magma_dopts opts;
magma_queue_t queue = NULL;
magma_queue_create( &queue );
magma_d_matrix A={Magma_CSR}, d_A={Magma_CSR};
magma_d_vector b, d_b, d_x;
// Set A and b from CSR vectors
magma_dcsrset( Mesh.dofTotal, Mesh.dofTotal, &rowPTR[0], &matJs[0], &matVals[0], &A, queue );
magma_dvset( Mesh.dofTotal, 1, &force[0], &b, queue );
printf( "\n%% matrix info: %d-by-%d with %d nonzeros\n\n",
(int) A.num_rows,(int) A.num_cols,(int) A.nnz );
// magma setup
magma_dsolverinfo_init( &opts.solver_par, &opts.precond_par, queue );
opts.solver_par.solver = Magma_GMRES;
opts.precond_par.solver = Magma_ILU;
magma_dmtransfer( A, &d_A, Magma_CPU, Magma_DEV, queue );
magma_dmtransfer( b, &d_b, Magma_CPU, Magma_DEV, queue );
magma_dvinit( &d_x, Magma_DEV, Solution.size(), 1, Solution[0], queue );
magma_d_precondsetup( d_A, d_b, &opts.solver_par, &opts.precond_par, queue );
// solve the system
magma_d_solver( d_A, d_b, &d_x, &opts, queue );
magma_dsolverinfo( &opts.solver_par, &opts.precond_par, queue );
magma_int_t mout, nout;
double * valout;
// bring the solution back to host, fill std::vector solution
magma_dvget( d_x, &mout, &nout, &valout, queue );
Code: Select all
error: linear algebra objects are not located in same memory!
memory locations are: 32728 572 0
% iter || residual-nrm2 || runtime || SpMV-count || info
%=================================================================================%
1 1.286840e-316 4.292634 532 0
%=================================================================================%
%=================================================================================%
% PGMRES(32728) solver summary:
% initial residual: 1.732051e+00
% preconditioner setup: 0.0001 sec
% iterations: 1
% SpMV-count: 532
% exact final residual: 1.653523e-13
% runtime: 4.2926 sec
% preconditioner runtime: 0.0000 sec
%=================================================================================%