SpMP icon indicating copy to clipboard operation
SpMP copied to clipboard

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

Open RiccardoRossi opened this issue 8 years ago • 3 comments

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?

RiccardoRossi avatar Mar 11 '17 17:03 RiccardoRossi

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.

jspark1105 avatar Mar 12 '17 00:03 jspark1105

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

RiccardoRossi avatar Mar 12 '17 11:03 RiccardoRossi

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.

jspark1105 avatar Mar 12 '17 18:03 jspark1105