How to copy solution vector x back to my application?

Open discussion for MAGMA library (Matrix Algebra on GPU and Multicore Architectures)

How to copy solution vector x back to my application?

Postby Klausb » Thu Oct 12, 2017 3:21 pm

Hello,

I am trying to copy the soution x back to the application following the MAGMA example_sparse.c

Code: Select all
    Foam::scalarField &solution; // solution vector of the application   

    // copy MAGMA solution and back to the application code
    magma_dvget( x, n, 1, solution, queue );

I get the following compile error, I think I get something wrong with a wrapped pointer array:
Code: Select all
mGMRES_solve.C:98:38: error: invalid conversion from ‘int’ to ‘magma_int_t* {aka int*}’ [-fpermissive]
     magma_dvget( x, n, 1, solution, queue );
                                      ^
mGMRES_solve.C:98:38: error: invalid conversion from ‘int’ to ‘magma_int_t* {aka int*}’ [-fpermissive]
mGMRES_solve.C:98:38: error: cannot convert ‘Foam::scalarField {aka Foam::Field<double>}’ to ‘double**’ for argument ‘4’ to ‘magma_int_t magma_dvget(magma_d_matrix, magma_int_t*, magma_int_t*, double**, magma_queue_t)’



Does anyone see my error?

Code: Select all
     magma_dvget( x, n, 1, solution, queue ); // n = vector size; x = MAGMA solution vector



Klaus
Klausb
 
Posts: 18
Joined: Thu Oct 05, 2017 3:04 pm

Re: How to copy solution vector x back to my application?

Postby hartwig anzt » Thu Oct 12, 2017 4:20 pm

Klaus,
the error code gives you the signature of the function:
magma_int_t magma_dvget(magma_d_matrix, magma_int_t*, magma_int_t*, double**, magma_queue_t);

so your first argument is of type magma_d_matrix, the second and third are integer pointers ( magma_int_t* ), then a double** and finally the queue.

If your error tells you invalid conversion from int to magma_int_t* for argument 2, you should try:
magma_int_t one = 1;
magma_int_t n = 46;
magma_dvget( x, &n, &one, solution, queue );

depending on how Foam::scalarField is defined, you may have to do the same trick there.

Does this help?

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

Export: How to iterate over MAGMA solution vector?

Postby Klausb » Tue Oct 17, 2017 10:57 am

Hello,

export using magma_dvget( x, &m, &n, &sol, queue ); seems not to work for my application.

I created the following export function but I don't know how to iterate over the magma solution vector.
Here's my export function:

Code: Select all
void export_vector
(
    magma_d_matrix &magma_vec, // MAGMA x vector (solution)
    Foam::scalarField *foam_vec, // solution vector from the application to be filled with MAGMA slution
    magma_queue_t queue // MAGMA queue
)
{
    Foam::UList<double>::iterator it = foam_vec->begin();

    magma_int_t n = int(foam_vec->size()); // vector size
    magma_int_t one = 1; // magma vector number of columns

    for (magma_int_t i = 0; i < n; ++i, ++it)
      *it = &magma_vec[i, one]; // This does not work: How to iterate over MAGMA solution vector?
}


How to iterate over the MAGMA solution vector (&magma_vec)?

Klaus
Klausb
 
Posts: 18
Joined: Thu Oct 05, 2017 3:04 pm


Return to User discussion

Who is online

Users browsing this forum: Bing [Bot] and 5 guests

cron