Skip to content
This repository has been archived by the owner on May 6, 2024. It is now read-only.

Can SpMP be used by someone with a standard CSR matrix? #2

Open
RiccardoRossi opened this issue Mar 11, 2017 · 3 comments
Open

Can SpMP be used by someone with a standard CSR matrix? #2

RiccardoRossi opened this issue Mar 11, 2017 · 3 comments

Comments

@RiccardoRossi
Copy link

Hello,

my FEM code has a completely standard implementation of a CSR matrix.

let's say that i have the 3 csr arrays:
values, cols, rows

i would like to do something like

solve( values, cols, indices , x, b)

or eventually
ilu0 myILU0object(values, cols, rows )
myILU0object.solve(x,b) //x = ILU^-1*b, that is applying the preconditioner

any example of this?

@jspark1105
Copy link
Contributor

jspark1105 commented Mar 12, 2017

Hi Ricarrdo, yes in fact CSR is the default (and actually the only matrix format) currently implemented in SpMP. I have SELLPACK implementation in my private repository that has better performance in Xeon Phi but haven't had time to merge it to the main branch.
I've uploaded an example (https://github.com/IntelLabs/SpMP/blob/master/test/pcg.cpp) that is basically a CG solver with SymGS or ILU0 as the preconditioner.
I'm not sure exactly how your ilu0 object is implemented but hopefully the example makes sense. Please let me know how this works for you and feel free to ask me more questions.

@RiccardoRossi
Copy link
Author

Hi Jongsoo,
first of all thank you very much for the example. I'll definitely take an in depth look into it over the next days.

however taking a first peek at your example i think that i expressed badly my question.
the thing is that i have my own CSR structure (Actually i use the implementation available in boost ublas)
which "owns" its 3 arrays. I was wondering if it was possible for SpMp to directly work with those arrays threating them as "external data" or if you need ownership of them (which would imply copying my matrix to your CSR).

i also saw that you have a .mm reader. i will try out how is speedup over serial on a typical case and report my findings

@jspark1105
Copy link
Contributor

Hi Riccardo, it's my bad to misunderstand your question.
You can construct an instance of SpMP's CSR class with the three arrays like

CSR A(m, n, rowptr, colidx, values); // m: # of rows, n # of columns

Then, you can pass this CSR instance to SpMP routines.
It will automatically detects if the CSR is 0-based or 1-based by looking at rowptr[0], but please not that not all routines support 1-based indexing (0-based indexing is the default).

Hope this helps. Your feedback on speedup over serial will be very useful for me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants