How to use magma_*customspmv in the program?
-
- Posts: 10
- Joined: Mon Oct 10, 2016 4:47 am
How to use magma_*customspmv in the program?
Dear all,
magma_*customspmv give me to use a custom function to calculate spmv.
Do I need to edit the file "magma_*customspmv.cpp" to implement the function and recompile magma library?
Is there any more convenient method to achieve it?
Can I use two different custom spmv methods in one program?
Thanks,
Mike
magma_*customspmv give me to use a custom function to calculate spmv.
Do I need to edit the file "magma_*customspmv.cpp" to implement the function and recompile magma library?
Is there any more convenient method to achieve it?
Can I use two different custom spmv methods in one program?
Thanks,
Mike
-
- Posts: 90
- Joined: Tue Sep 02, 2014 5:44 pm
Re: How to use magma_*customspmv in the program?
Dear Mike,
magma_*customspmv.cpp currently does nothing. The idea is that there you call your function.
Assume you have you awesome spmv library. Then, you add in this file:
#include awesome_spmv.h
...
awesome_spmv( alpha, A x, beta, b, );
Does this make sense?
Thanks, Hartwig
magma_*customspmv.cpp currently does nothing. The idea is that there you call your function.
Assume you have you awesome spmv library. Then, you add in this file:
#include awesome_spmv.h
...
awesome_spmv( alpha, A x, beta, b, );
Does this make sense?
Thanks, Hartwig
-
- Posts: 10
- Joined: Mon Oct 10, 2016 4:47 am
Re: How to use magma_*customspmv in the program?
Dear Hartwig,
Sorry about the unclear declaration.
The wrapper of BLAS will use the magma_*customspmv when the storage_type is Magma_SPMVFUNCTION.
I also want to use the CG solver of MAGMA on the custom spmv function.
Thus, I think I can not just build a new function.
Thanks,
Mike
Sorry about the unclear declaration.
The wrapper of BLAS will use the magma_*customspmv when the storage_type is Magma_SPMVFUNCTION.
I also want to use the CG solver of MAGMA on the custom spmv function.
Thus, I think I can not just build a new function.
Thanks,
Mike
-
- Posts: 90
- Joined: Tue Sep 02, 2014 5:44 pm
Re: How to use magma_*customspmv in the program?
Mike,
I am not sure I understand correctly. You can use any SpMV inside the CG solver, the solver does not imply any restrictions on the matrix storage format or SpMV kernel.
Please specify.
Thanks!
I am not sure I understand correctly. You can use any SpMV inside the CG solver, the solver does not imply any restrictions on the matrix storage format or SpMV kernel.
Please specify.
Thanks!
-
- Posts: 10
- Joined: Mon Oct 10, 2016 4:47 am
Re: How to use magma_*customspmv in the program?
Dear Hartwig,
According to your first reply, I need to add awesome_spmv into magma_*customspmv.cpp.
And set magma_*_matrix type as the Magma_SPMVFUNCTION.
And I can use some routine like CG as I did before.
By doing so, I can not use two different spmv methods at the same time.
Is that correct?
Thanks,
Mike
According to your first reply, I need to add awesome_spmv into magma_*customspmv.cpp.
And set magma_*_matrix type as the Magma_SPMVFUNCTION.
And I can use some routine like CG as I did before.
By doing so, I can not use two different spmv methods at the same time.
Is that correct?
Thanks,
Mike
-
- Posts: 90
- Joined: Tue Sep 02, 2014 5:44 pm
Re: How to use magma_*customspmv in the program?
Mike,
sorry for late reply!
I think I do know what you mean now: you have two spmv kernels: spmv1 and spmv2, and you want to use them inside CG, time it, quickly switch between them. This would require recompiling magma-sparse.
So, yes, unfortunately it is currently not possible to use multiple SpMV at a time.
The only workaround I currently see is to define a second CUSTOMSPMV, but you would then have to introduce this into the magma_z_blaswrapper.cpp.
I will make sure we provide this possibility in future!
Thanks, Hartwig
sorry for late reply!
I think I do know what you mean now: you have two spmv kernels: spmv1 and spmv2, and you want to use them inside CG, time it, quickly switch between them. This would require recompiling magma-sparse.
So, yes, unfortunately it is currently not possible to use multiple SpMV at a time.
The only workaround I currently see is to define a second CUSTOMSPMV, but you would then have to introduce this into the magma_z_blaswrapper.cpp.
I will make sure we provide this possibility in future!
Thanks, Hartwig
-
- Posts: 10
- Joined: Mon Oct 10, 2016 4:47 am
Re: How to use magma_*customspmv in the program?
Dear Hartwig,
Thanks a lot!
Mike
Thanks a lot!
Mike
-
- Posts: 10
- Joined: Mon Oct 10, 2016 4:47 am
Re: How to use magma_*customspmv in the program?
Dear Hartwig,
I use the function pointer to handle these things.
I also add Magma_USERSPMV = 633 in magma_storage_t and Magma_USERPRECOND = 430 in magma_solver_type for using them in wrapper.
USERSPMV will use userkernel to store the variables and userspmv to get the function.
USERPRECOND will also userkernel to store the variables and applyuserprecond_l, applyuserprecond_l_t, applyuserprecond_r, and applyuserprecond_r_t to get the functions.
For using USERSPMV,
Define some structures and some functions whose types are same as those in magma_*_spmv in program.
The original file (sparse/blas/magma_z_blaswrapper.cpp) might be wrong.
I also do other changes besides the userspmv.
Add the "}" between line 211 and line 212, and delete the first "}" in line 226 or line 225 for Magma_CSC spmv (multiple vectors).
is it correct?
The attachments include the files I changed and a file for trying USERSPMV. Copy the files in "change" folder into the magma-2.3.0 folder for using them. Thanks,
Mike
I use the function pointer to handle these things.
I also add Magma_USERSPMV = 633 in magma_storage_t and Magma_USERPRECOND = 430 in magma_solver_type for using them in wrapper.
USERSPMV will use userkernel to store the variables and userspmv to get the function.
USERPRECOND will also userkernel to store the variables and applyuserprecond_l, applyuserprecond_l_t, applyuserprecond_r, and applyuserprecond_r_t to get the functions.
For using USERSPMV,
Define some structures and some functions whose types are same as those in magma_*_spmv in program.
Using the user preconditioner is similar.magma_*_matrix A;
A.userkernel = (void*) &kernel; // users define own structures
A.userspmv = &spmv; // spmv types are same as magma_*_spmv's.
A.storage_type = Magma_USERSPMV;
magma_*_spmv(..., A, ....); // it will run the user's spmv.
// magma_*userspmv(..., A, ...); // it is also okay.
The original file (sparse/blas/magma_z_blaswrapper.cpp) might be wrong.
I also do other changes besides the userspmv.
Add the "}" between line 211 and line 212, and delete the first "}" in line 226 or line 225 for Magma_CSC spmv (multiple vectors).
is it correct?
The attachments include the files I changed and a file for trying USERSPMV. Copy the files in "change" folder into the magma-2.3.0 folder for using them. Thanks,
Mike
-
- Posts: 1
- Joined: Sun Aug 16, 2015 4:40 pm
Re: How to use magma_*customspmv in the program?
Dear,
I am not sure I understand correctly. You can use any SpMV inside the CG solver, the solver does not imply any restrictions on the matrix storage format or SpMV kernel.
Please specify.
Thanks!
I am not sure I understand correctly. You can use any SpMV inside the CG solver, the solver does not imply any restrictions on the matrix storage format or SpMV kernel.
Please specify.
Thanks!