<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Oct 18, 2021 at 3:42 PM Chang Liu via petsc-users <<a href="mailto:petsc-users@mcs.anl.gov">petsc-users@mcs.anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi Matt,<br>
<br>
I have a related question. In my code I have many matrices and I only <br>
want to have one living on GPU, the others still staying on CPU mem.<br>
<br>
I wonder if there is an easier way to copy a mpiaij matrix to <br>
mpiaijcusparse (in other words, copy data to GPUs). I can think of <br>
creating a new mpiaijcusparse matrix, and copying the data line by line. <br>
But I wonder if there is a better option.<br>
<br>
I have tried MatCopy and MatConvert but neither work.<br></blockquote><div>Did you use <span style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre"> </span><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre;color:rgb(121,94,38)">MatConvert</span><span style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre">(</span><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre;color:rgb(0,16,128)">mat</span><span style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre">,</span><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre;color:rgb(0,16,128)">matype</span><span style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre">,</span><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre;color:rgb(0,112,193)">MAT_INPLACE_MATRIX</span><span style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre">,&</span><span style="font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre;color:rgb(0,16,128)">mat</span><span style="color:rgb(0,0,0);font-family:Menlo,Monaco,"Courier New",monospace;font-size:14px;white-space:pre">)?</span></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Chang<br>
<br>
On 10/17/21 7:50 PM, Matthew Knepley wrote:<br>
> On Sun, Oct 17, 2021 at 7:12 PM Swarnava Ghosh <<a href="mailto:swarnava89@gmail.com" target="_blank">swarnava89@gmail.com</a> <br>
> <mailto:<a href="mailto:swarnava89@gmail.com" target="_blank">swarnava89@gmail.com</a>>> wrote:<br>
> <br>
> Do I need convert the MATSEQBAIJ to a cuda matrix in code?<br>
> <br>
> <br>
> You would need a call to MatSetFromOptions() to take that type from the <br>
> command line, and not have<br>
> the type hard-coded in your application. It is generally a bad idea to <br>
> hard code the implementation type.<br>
> <br>
> If I do it from command line, then are the other MatVec calls are<br>
> ported onto CUDA? I have many MatVec calls in my code, but I<br>
> specifically want to port just one call.<br>
> <br>
> <br>
> You can give that one matrix an options prefix to isolate it.<br>
> <br>
> Thanks,<br>
> <br>
> Matt<br>
> <br>
> Sincerely,<br>
> Swarnava<br>
> <br>
> On Sun, Oct 17, 2021 at 7:07 PM Junchao Zhang<br>
> <<a href="mailto:junchao.zhang@gmail.com" target="_blank">junchao.zhang@gmail.com</a> <mailto:<a href="mailto:junchao.zhang@gmail.com" target="_blank">junchao.zhang@gmail.com</a>>> wrote:<br>
> <br>
> You can do that with command line options -mat_type aijcusparse<br>
> -vec_type cuda<br>
> <br>
> On Sun, Oct 17, 2021, 5:32 PM Swarnava Ghosh<br>
> <<a href="mailto:swarnava89@gmail.com" target="_blank">swarnava89@gmail.com</a> <mailto:<a href="mailto:swarnava89@gmail.com" target="_blank">swarnava89@gmail.com</a>>> wrote:<br>
> <br>
> Dear Petsc team,<br>
> <br>
> I had a query regarding using CUDA to accelerate a matrix<br>
> vector product.<br>
> I have a sequential sparse matrix (MATSEQBAIJ type). I want<br>
> to port a MatVec call onto GPUs. Is there any code/example I<br>
> can look at?<br>
> <br>
> Sincerely,<br>
> SG<br>
> <br>
> <br>
> <br>
> -- <br>
> What most experimenters take for granted before they begin their <br>
> experiments is infinitely more interesting than any results to which <br>
> their experiments lead.<br>
> -- Norbert Wiener<br>
> <br>
> <a href="https://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">https://www.cse.buffalo.edu/~knepley/</a> <<a href="http://www.cse.buffalo.edu/~knepley/" rel="noreferrer" target="_blank">http://www.cse.buffalo.edu/~knepley/</a>><br>
<br>
-- <br>
Chang Liu<br>
Staff Research Physicist<br>
+1 609 243 3438<br>
<a href="mailto:cliu@pppl.gov" target="_blank">cliu@pppl.gov</a><br>
Princeton Plasma Physics Laboratory<br>
100 Stellarator Rd, Princeton NJ 08540, USA<br>
</blockquote></div></div>