Null pointer exception when solving

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)
Post Reply
dariofigueira
Posts: 16
Joined: Wed Oct 31, 2018 12:06 pm

Null pointer exception when solving

Post by dariofigueira » Thu Nov 08, 2018 2:35 pm

// Inputs:
// Eigen::SparseMatrix<double> A
// Eigen::VectorXd b

magma_dopts opts;
// Choose a solver, preconditioner, etc. - see documentation for options.
opts.solver_par.solver = Magma_PIDRMERGE;
opts.solver_par.restart = 8;
opts.solver_par.maxiter = 1000;
opts.solver_par.rtol = 1e-10;
opts.solver_par.maxiter = 1000;
opts.precond_par.solver = Magma_ILU;
opts.precond_par.levels = 0;
opts.precond_par.trisolver = Magma_CUSOLVE;

magma_d_matrix mA = { Magma_CSR };
magma_d_matrix mb = { Magma_CSR };
magma_d_matrix mx = { Magma_CSR };

magma_queue_t queue; // opaque queue structure
magma_queue_create(0, &queue);

cout << "Solving A(" << A.rows() << ", " << A.cols() << ") . x = b(" << b.size() << ", 1)" << endl;

// Pass the system to MAGMA.
magma_dcsrset(A.rows(), A.cols(), Arows.data(), Acols.data(), Avals.data(), &mA, queue);
magma_dvset(b.rows(), 1, b.data(), &mb, queue);

// Generate the preconditioner.
//magma_d_precondsetup(mA, mb, &opts.solver_par, &opts.precond_par, queue);

magma_dlsqr(mA, mb, &mx, &opts.solver_par, &opts.precond_par, queue);

cout << "Solved." << endl;
Hi, the above prints to stdout

Code: Select all

Solving A(732, 380) . x = b(732, 1)
Memory Free Error.
Memory Free Error.
Memory Free Error.
and throws an exception when seemingly trying to access the NULL memory location ("Access violation reading location 0x0000000000000000.")

Can you quickly spot something that is "obviously" missing?

Thank you

hartwig anzt
Posts: 90
Joined: Tue Sep 02, 2014 5:44 pm

Re: Null pointer exception when solving

Post by hartwig anzt » Thu Nov 08, 2018 3:16 pm

Dario,
from your codelet, I can not see how the data of your matrix looks like. But I would assume all the data is on the host? Then you may have to copy it to the GPU before invoking the solve...

> magma_dmtransfer(A, dA, Magma_CPU, Magma_DEV, queue);

Same for the vector.

Let me know whether this helps.

Hartwig

dariofigueira
Posts: 16
Joined: Wed Oct 31, 2018 12:06 pm

Re: Null pointer exception when solving

Post by dariofigueira » Thu Nov 08, 2018 3:26 pm

Oh!

I saw that in the example_sparse example, but I didn't understand it at the time due to missing this
"All iterative solvers and eigensolvers included in the MAGMA-sparse package work on the device. Hence, it is required to send the respective data structures to the device for solving, and back to access the solution."
Question: for the solvers in the non-sparse package, functions like magma_dgetrf do not require explicitly passing the data to the device correct? And in some cases, when solving MAGMA will do it totally on the CPU, correct?

Post Reply