Doc fixes

This commit is contained in:
Salvatore Filippone
2024-11-16 12:03:28 +01:00
parent eefc67bbdd
commit 9c4f4c4d15
64 changed files with 18806 additions and 17588 deletions
+214 -203
View File
@@ -15,17 +15,17 @@ href="userhtmlse11.html" >prev</a>] [<a
href="userhtmlse11.html#tailuserhtmlse11.html" >prev-tail</a>] [<a
href="userhtmlse9.html#tailuserhtmlse12.html">tail</a>] [<a
href="userhtml.html# " >up</a>] </p></div>
<h3 class="sectionHead"><span class="titlemark">12 </span> <a
id="x19-14500012"></a>Extensions</h3>
<h3 class="sectionHead"><span class="titlemark">12 </span> <a
id="x19-14600012"></a>Extensions</h3>
<!--l. 3--><p class="noindent" >The EXT, CUDA and RSB subdirectories contains a set of extensions to the base
library. The extensions provide additional storage formats beyond the ones already
contained in the base library, as well as interfaces to:
<dl class="description"><dt class="description">
<!--l. 8--><p class="noindent" >
<span
class="cmbx-10">SPGPU</span> </dt><dd
class="pplb7t-">SPGPU</span> </dt><dd
class="description">
<!--l. 8--><p class="noindent" >a CUDA library originally
<!--l. 8--><p class="noindent" >a CUDA library originally
published as <a
href="https://code.google.com/p/spgpu/" class="url" ><span
class="cmtt-10">https://code.google.com/p/spgpu/</span></a> and now included
@@ -34,11 +34,11 @@ class="cmtt-10">cuda</span></span></span> subdir, for computations on NVIDIA GPU
</dd><dt class="description">
<!--l. 11--><p class="noindent" >
<span
class="cmbx-10">LIBRSB</span> </dt><dd
class="pplb7t-">LIBRSB</span> </dt><dd
class="description">
<!--l. 11--><p class="noindent" ><a
href="http://sourceforge.net/projects/librsb/" class="url" ><span
class="cmtt-10">http://sourceforge.net/projects/librsb/</span></a>, for computations on
class="cmtt-10">http://sourceforge.net/projects/librsb/</span></a>, for computations on
multicore parallel machines.</dd></dl>
<!--l. 14--><p class="noindent" >The infrastructure laid out in the base library to allow for these extensions is detailed in
the references&#x00A0;<span class="cite">[<a
@@ -48,8 +48,8 @@ href="userhtmlli2.html#XSparse03">10</a>]</span>; the CUDA-specific data formats
in&#x00A0;<span class="cite">[<a
href="userhtmlli2.html#XOurTechRep">22</a>]</span>.
<!--l. 19--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">12.1 </span> <a
id="x19-14600012.1"></a>Using the extensions</h4>
<h4 class="subsectionHead"><span class="titlemark">12.1 </span> <a
id="x19-14700012.1"></a>Using the extensions</h4>
<!--l. 21--><p class="noindent" >A sample application using the PSBLAS extensions will contain the following
steps:
<ul class="itemize1">
@@ -60,16 +60,16 @@ class="cmtt-10">psb_ext_mod</span></span></span>, <span class="obeylines-h"><spa
class="cmtt-10">psb_cuda_mod</span></span></span>);
</li>
<li class="itemize">
<!--l. 26--><p class="noindent" >Declare a <span
class="cmti-10">mold </span>variable of the necessary type (e.g.
<!--l. 26--><p class="noindent" >Declare a <span
class="pplri7t-">mold </span>variable of the necessary type (e.g.
<span class="obeylines-h"><span class="verb"><span
class="cmtt-10">psb_d_ell_sparse_mat</span></span></span>, <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">psb_d_hlg_sparse_mat</span></span></span>, <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">psb_d_vect_cuda</span></span></span>);
</li>
<li class="itemize">
<!--l. 29--><p class="noindent" >Pass the mold variable to the base library interface where needed to ensure
the appropriate dynamic type.</li></ul>
<!--l. 29--><p class="noindent" >Pass the mold variable to the base library interface where needed to
ensure the appropriate dynamic type.</li></ul>
@@ -141,126 +141,128 @@ class="cmtt-10">test/cuda/kernel </span>subdirectories, where we provide sample
speed of the sparse matrix-vector product with the various data structures included
in the library.
<!--l. 146--><p class="noindent" >
<h4 class="subsectionHead"><span class="titlemark">12.2 </span> <a
id="x19-14700012.2"></a>Extensions&#8217; Data Structures</h4>
<h4 class="subsectionHead"><span class="titlemark">12.2 </span> <a
id="x19-14800012.2"></a>Extensions&#8217; Data Structures</h4>
<!--l. 150--><p class="noindent" >Access to the facilities provided by the EXT library is mainly achieved through
the data types that are provided within. The data classes are derived from
the base classes in PSBLAS, through the Fortran&#x00A0;2003 mechanism of <span
class="cmti-10">type</span>
class="pplri7t-">type</span>
<span
class="cmti-10">extension</span>&#x00A0;<span class="cite">[<a
class="pplri7t-">extension</span>&#x00A0;<span class="cite">[<a
href="userhtmlli2.html#XMRC:11">17</a>]</span>.
<!--l. 155--><p class="indent" > The data classes are divided between the general purpose CPU extensions, the
GPU interfaces and the RSB interfaces. In the description we will make use of the
notation introduced in Table&#x00A0;<a
href="#x19-147001r21">21<!--tex4ht:ref: tab:notation --></a>.
href="#x19-148001r23">23<!--tex4ht:ref: tab:notation --></a>.
<div class="table">
<!--l. 160--><p class="indent" > <a
id="x19-147001r21"></a><hr class="float"><div class="float"
id="x19-148001r23"></a><hr class="float"><div class="float"
>
<div class="caption"
><span class="id">Table&#x00A0;21: </span><span
class="content">Notation for parameters describing a sparse matrix</span></div><!--tex4ht:label?: x19-147001r21 -->
><span class="id">Table&#x00A0;23: </span><span
class="content">Notation for parameters describing a sparse matrix</span></div><!--tex4ht:label?: x19-148001r23 -->
<div class="center"
>
<!--l. 162--><p class="noindent" >
<div class="tabular"> <table id="TBL-23" class="tabular"
<div class="tabular"> <table id="TBL-26" class="tabular"
><colgroup id="TBL-23-1g"><col
id="TBL-23-1"><col
id="TBL-23-2"></colgroup><tr
><colgroup id="TBL-26-1g"><col
id="TBL-26-1"><col
id="TBL-26-2"></colgroup><tr
class="hline"><td><hr></td><td><hr></td></tr><tr
style="vertical-align:baseline;" id="TBL-23-1-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-1-1"
style="vertical-align:baseline;" id="TBL-26-1-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-1-1"
class="td11"><span
class="cmr-8">Name </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-1-2"
class="pplr7t-x-x-80">Name </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-1-2"
class="td11"><span
class="cmr-8">Description </span></td>
class="pplr7t-x-x-80">Description </span></td>
</tr><tr
class="hline"><td><hr></td><td><hr></td></tr><tr
style="vertical-align:baseline;" id="TBL-23-2-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-2-1"
style="vertical-align:baseline;" id="TBL-26-2-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-2-1"
class="td11"><span
class="cmr-8">M </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-2-2"
class="pplr7t-x-x-80">M </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-2-2"
class="td11"><span
class="cmr-8">Number of rows in matrix </span></td></tr><tr
style="vertical-align:baseline;" id="TBL-23-3-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-3-1"
class="pplr7t-x-x-80">Number of rows in matrix </span></td></tr><tr
style="vertical-align:baseline;" id="TBL-26-3-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-3-1"
class="td
11"><span
class="pplr7t-x-x-80">N </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-3-2"
class="td11"><span
class="cmr-8">N </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-3-2"
class="pplr7t-x-x-80">Number of columns in matrix </span></td></tr><tr
style="vertical-align:baseline;" id="TBL-26-4-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-4-1"
class="td
11"><span
class="pplr7t-x-x-80">NZ </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-4-2"
class="td11"><span
class="cmr-8">Number of columns in matrix</span></td>
class="pplr7t-x-x-80">Number of nonzeros in matrix </span></td></tr><tr
style="vertical-align:baseline;" id="TBL-26-5-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-5-1"
class="td
11"><span
class="pplr7t-x-x-80">AVGNZR </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-5-2"
class="td11"><span
class="pplr7t-x-x-80">Average number of nonzeros per row </span></td>
</tr><tr
style="vertical-align:baseline;" id="TBL-23-4-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-4-1"
style="vertical-align:baseline;" id="TBL-26-6-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-6-1"
class="td11"><span
class="cmr-8">NZ </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-4-2"
class="pplr7t-x-x-80">MAXNZR</span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-6-2"
class="td11"><span
class="cmr-8">Number of nonzeros in matrix </span></td></tr><tr
style="vertical-align:baseline;" id="TBL-23-5-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-5-1"
class="td11"><span
class="cmr-8">AVGNZR </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-5-2"
class="td11"><span
class="cmr-8">Average number of nonzeros per row</span></td>
class="pplr7t-x-x-80">Maximum number of nonzeros per row</span></td>
</tr><tr
style="vertical-align:baseline;" id="TBL-23-6-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-6-1"
style="vertical-align:baseline;" id="TBL-26-7-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-7-1"
class="td11"><span
class="cmr-8">MAXNZR</span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-6-2"
class="pplr7t-x-x-80">NDIAG </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-7-2"
class="td11"><span
class="cmr-8">Maximum number of nonzeros per row</span></td>
class="pplr7t-x-x-80">Numero of nonzero diagonals </span></td>
</tr><tr
style="vertical-align:baseline;" id="TBL-23-7-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-7-1"
style="vertical-align:baseline;" id="TBL-26-8-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-8-1"
class="td11"><span
class="cmr-8">NDIAG </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-7-2"
class="pplr7t-x-x-80">AS </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-8-2"
class="td11"><span
class="cmr-8">Numero of nonzero diagonals </span></td>
class="pplr7t-x-x-80">Coefficients array </span></td>
</tr><tr
style="vertical-align:baseline;" id="TBL-23-8-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-8-1"
style="vertical-align:baseline;" id="TBL-26-9-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-9-1"
class="td11"><span
class="cmr-8">AS </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-8-2"
class="pplr7t-x-x-80">IA </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-9-2"
class="td11"><span
class="cmr-8">Coefficients array </span></td>
class="pplr7t-x-x-80">Row indices array </span></td>
</tr><tr
style="vertical-align:baseline;" id="TBL-23-9-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-9-1"
style="vertical-align:baseline;" id="TBL-26-10-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-10-1"
class="td11"><span
class="cmr-8">IA </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-9-2"
class="pplr7t-x-x-80">JA </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-10-2"
class="td11"><span
class="cmr-8">Row indices array </span></td>
class="pplr7t-x-x-80">Column indices array </span></td>
</tr><tr
style="vertical-align:baseline;" id="TBL-23-10-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-10-1"
style="vertical-align:baseline;" id="TBL-26-11-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-11-1"
class="td11"><span
class="cmr-8">JA </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-10-2"
class="pplr7t-x-x-80">IRP </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-11-2"
class="td11"><span
class="cmr-8">Column indices array </span></td>
class="pplr7t-x-x-80">Row start pointers array </span></td>
</tr><tr
style="vertical-align:baseline;" id="TBL-23-11-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-11-1"
style="vertical-align:baseline;" id="TBL-26-12-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-12-1"
class="td11"><span
class="cmr-8">IRP </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-11-2"
class="pplr7t-x-x-80">JCP </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-12-2"
class="td11"><span
class="cmr-8">Row start pointers array </span></td>
class="pplr7t-x-x-80">Column start pointers array </span></td>
</tr><tr
style="vertical-align:baseline;" id="TBL-23-12-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-12-1"
style="vertical-align:baseline;" id="TBL-26-13-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-13-1"
class="td11"><span
class="cmr-8">JCP </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-12-2"
class="pplr7t-x-x-80">NZR </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-13-2"
class="td11"><span
class="cmr-8">Column start pointers array </span></td>
class="pplr7t-x-x-80">Number of nonzeros per row array </span></td>
</tr><tr
style="vertical-align:baseline;" id="TBL-23-13-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-13-1"
style="vertical-align:baseline;" id="TBL-26-14-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-14-1"
class="td11"><span
class="cmr-8">NZR </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-13-2"
class="pplr7t-x-x-80">OFFSET </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-26-14-2"
class="td11"><span
class="cmr-8">Number of nonzeros per row array </span></td>
</tr><tr
style="vertical-align:baseline;" id="TBL-23-14-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-14-1"
class="td11"><span
class="cmr-8">OFFSET </span></td><td style="white-space:nowrap; text-align:left;" id="TBL-23-14-2"
class="td11"><span
class="cmr-8">Offset for diagonals </span></td>
class="pplr7t-x-x-80">Offset for diagonals </span></td>
</tr><tr
class="hline"><td><hr></td><td><hr></td></tr><tr
style="vertical-align:baseline;" id="TBL-23-15-"><td style="white-space:nowrap; text-align:left;" id="TBL-23-15-1"
style="vertical-align:baseline;" id="TBL-26-15-"><td style="white-space:nowrap; text-align:left;" id="TBL-26-15-1"
class="td11"> </td></tr></table> </div>
</div>
@@ -274,7 +276,7 @@ class="td11"> </td></tr></table>
<a
id="x19-147002r5"></a>
id="x19-148002r5"></a>
@@ -283,18 +285,18 @@ src="mat.png" alt="PIC"
width="147" height="147" >
<br /> <div class="caption"
><span class="id">Figure&#x00A0;5: </span><span
class="content">Example of sparse matrix</span></div><!--tex4ht:label?: x19-147002r5 -->
class="content">Example of sparse matrix</span></div><!--tex4ht:label?: x19-148002r5 -->
<!--l. 198--><p class="indent" > </div><hr class="endfigure">
<h4 class="subsectionHead"><span class="titlemark">12.3 </span> <a
id="x19-14800012.3"></a>CPU-class extensions</h4>
<h4 class="subsectionHead"><span class="titlemark">12.3 </span> <a
id="x19-14900012.3"></a>CPU-class extensions</h4>
<!--l. 203--><p class="noindent" >
<h5 class="likesubsubsectionHead"><a
id="x19-149000"></a>ELLPACK</h5>
id="x19-150000"></a>ELLPACK</h5>
<!--l. 205--><p class="noindent" >The ELLPACK/ITPACK format (shown in Figure&#x00A0;<a
href="#x19-149001r6">6<!--tex4ht:ref: fig:ell --></a>) comprises two 2-dimensional
href="#x19-150001r6">6<!--tex4ht:ref: fig:ell --></a>) comprises two 2-dimensional
arrays <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">AS</span></span></span> and <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">JA</span></span></span> with <span class="obeylines-h"><span class="verb"><span
@@ -302,7 +304,7 @@ class="cmtt-10">M</span></span></span> rows and <span class="obeylines-h"><span
class="cmtt-10">MAXNZR</span></span></span> columns, where <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">MAXNZR</span></span></span> is the maximum
number of nonzeros in any row&#x00A0;<span class="cite">[<span
class="cmbx-10">?</span>]</span>. Each row of the arrays <span class="obeylines-h"><span class="verb"><span
class="pplb7t-">?</span>]</span>. Each row of the arrays <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">AS</span></span></span> and <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">JA</span></span></span> contains the
coefficients and column indices; rows shorter than <span class="obeylines-h"><span class="verb"><span
@@ -315,7 +317,7 @@ row.
<a
id="x19-149001r6"></a>
id="x19-150001r6"></a>
@@ -325,13 +327,13 @@ width="233" height="233" >
<br /> <div class="caption"
><span class="id">Figure&#x00A0;6: </span><span
class="content">ELLPACK compression of matrix in Figure&#x00A0;<a
href="#x19-147002r5">5<!--tex4ht:ref: fig:dense --></a></span></div><!--tex4ht:label?: x19-149001r6 -->
href="#x19-148002r5">5<!--tex4ht:ref: fig:dense --></a></span></div><!--tex4ht:label?: x19-150001r6 -->
<!--l. 225--><p class="indent" > </div><hr class="endfigure">
<a
id="x19-149002r1"></a>
id="x19-150002r1"></a>
@@ -341,9 +343,8 @@ href="#x19-147002r5">5<!--tex4ht:ref: fig:dense --></a></span></div><!--tex4ht:l
<!--l. 231-->
<pre class="lstlisting" id="listing-169"><span class="label"><a
id="x19-149003r1"></a></span><span
class="cmtt-9">&#x00A0;</span><span
<pre class="lstlisting" id="listing-198"><span class="label"><a
id="x19-150003r1"></a></span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span style="color:#000000"><span
@@ -352,8 +353,7 @@ class="cmtt-9">i</span></span><span style="color:#000000"><span
class="cmtt-9">=1,</span></span><span style="color:#000000"><span
class="cmtt-9">n</span></span>
<span class="label"><a
id="x19-149004r2"></a></span><span
class="cmtt-9">&#x00A0;</span><span
id="x19-150004r2"></a></span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span
@@ -362,8 +362,7 @@ class="cmtt-9">&#x00A0;</span><span style="color:#000000"><span
class="cmtt-9">t</span></span><span style="color:#000000"><span
class="cmtt-9">=0</span></span>
<span class="label"><a
id="x19-149005r3"></a></span><span
class="cmtt-9">&#x00A0;</span><span
id="x19-150005r3"></a></span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span
@@ -374,8 +373,7 @@ class="cmtt-9">j</span></span><span style="color:#000000"><span
class="cmtt-9">=1,</span></span><span style="color:#000000"><span
class="cmtt-9">maxnzr</span></span>
<span class="label"><a
id="x19-149006r4"></a></span><span
class="cmtt-9">&#x00A0;</span><span
id="x19-150006r4"></a></span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span
@@ -403,8 +401,7 @@ class="cmtt-9">,</span></span><span style="color:#000000"><span
class="cmtt-9">j</span></span><span style="color:#000000"><span
class="cmtt-9">))</span></span>
<span class="label"><a
id="x19-149007r5"></a></span><span
class="cmtt-9">&#x00A0;</span><span
id="x19-150007r5"></a></span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span
@@ -413,8 +410,7 @@ class="cmtt-9">&#x00A0;</span><span style="color:#000000"><span
class="cmtt-9">end</span></span><span style="color:#000000"> </span><span style="color:#000000"><span
class="cmtt-9">do</span></span>
<span class="label"><a
id="x19-149008r6"></a></span><span
class="cmtt-9">&#x00A0;</span><span
id="x19-150008r6"></a></span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span
@@ -427,8 +423,7 @@ class="cmtt-9">)</span></span><span style="color:#000000"> </span><span style="c
class="cmtt-9">=</span></span><span style="color:#000000"> </span><span style="color:#000000"><span
class="cmtt-9">t</span></span>
<span class="label"><a
id="x19-149009r7"></a></span><span
class="cmtt-9">&#x00A0;</span><span
id="x19-150009r7"></a></span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span
class="cmtt-9">&#x00A0;</span><span style="color:#000000"><span
@@ -436,35 +431,36 @@ class="cmtt-9">end</span></span><span style="color:#000000"> </span><span style=
class="cmtt-9">do</span></span></pre>
<a
id="x19-149010r1"></a>
id="x19-150010r1"></a>
<a
id="x19-149011"></a>
<span
class="cmbx-10">Algorithm</span><span
class="cmbx-10">&#x00A0;1:</span>&#x00A0; Matrix-Vector product in ELL format
id="x19-150011"></a>
<span
class="pplb7t-">Algorithm</span><span
class="pplb7t-">&#x00A0;1:</span>&#x00A0; Matrix-Vector product in ELL format
</div><hr class="endfloat" />
<!--l. 242--><p class="indent" > The matrix-vector product <span
class="cmmi-10">y </span>= <span
class="cmmi-10">Ax </span>can be computed with the code shown in
class="zplmr7m-">y </span><span
class="zplmr7t-">= </span><span
class="zplmr7m-">Ax </span>can be computed with the code shown in
Alg.&#x00A0;<a
href="#x19-149010r1">1<!--tex4ht:ref: alg:ell --></a>; it costs one memory write per outer iteration, plus three memory reads and
href="#x19-150010r1">1<!--tex4ht:ref: alg:ell --></a>; it costs one memory write per outer iteration, plus three memory reads and
two floating-point operations per inner iteration.
<!--l. 247--><p class="indent" > Unless all rows have exactly the same number of nonzeros, some of the coefficients
in the <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">AS</span></span></span> array will be zeros; therefore this data structure will have an overhead both
in terms of memory space and redundant operations (multiplications by zero). The
overhead can be acceptable if:
<!--l. 247--><p class="indent" > Unless all rows have exactly the same number of nonzeros, some of the
coefficients in the <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">AS</span></span></span> array will be zeros; therefore this data structure will have an
overhead both in terms of memory space and redundant operations (multiplications
by zero). The overhead can be acceptable if:
<ol class="enumerate1" >
<li
class="enumerate" id="x19-149013x1">
class="enumerate" id="x19-150013x1">
<!--l. 253--><p class="noindent" >The maximum number of nonzeros per row is not much larger than the
average;
</li>
<li
class="enumerate" id="x19-149015x2">
class="enumerate" id="x19-150015x2">
<!--l. 255--><p class="noindent" >The regularity of the data structure allows for faster code, e.g. by allowing
vectorization, thereby offsetting the additional storage requirements.</li></ol>
<!--l. 259--><p class="noindent" >In the extreme case where the input matrix has one full row, the ELLPACK
@@ -492,62 +488,72 @@ class="cmtt-10">psb_T_ell_sparse_mat</span></span></span>:
</pre>
<!--l. 295--><p class="nopar" > </div></div>
<h5 class="likesubsubsectionHead"><a
id="x19-150000"></a>Hacked ELLPACK</h5>
<!--l. 303--><p class="noindent" >The <span
class="cmti-10">hacked ELLPACK </span>(<span
class="cmbx-10">HLL</span>) format alleviates the main problem of the ELLPACK
format, that is, the amount of memory required by padding for sparse matrices in
which the maximum row length is larger than the average.
id="x19-151000"></a>Hacked ELLPACK</h5>
<!--l. 303--><p class="noindent" >The <span
class="pplri7t-">hacked ELLPACK </span>(<span
class="pplb7t-">HLL</span>) format alleviates the main problem of the ELLPACK
format, that is, the amount of memory required by padding for sparse matrices in
which the maximum row length is larger than the average.
<!--l. 308--><p class="indent" > The number of elements allocated to padding is
[(<span
class="cmmi-10">m</span><span
class="cmsy-10">*</span><span
class="cmmi-10">maxNR</span>) <span
class="cmsy-10">- </span>(<span
class="cmmi-10">m</span><span
class="cmsy-10">*</span><span
class="cmmi-10">avgNR</span>) = <span
class="cmmi-10">m</span><span
class="cmsy-10">* </span>(<span
class="cmmi-10">maxNR</span><span
class="cmsy-10">-</span><span
class="cmmi-10">avgNR</span>)] for both <span class="obeylines-h"><span class="verb"><span
<span
class="zplmr7t-">[(</span><span
class="zplmr7m-">m</span><span
class="zplmr7y-">*</span><span
class="zplmr7m-">maxNR</span><span
class="zplmr7t-">) </span><span
class="zplmr7y-">- </span><span
class="zplmr7t-">(</span><span
class="zplmr7m-">m</span><span
class="zplmr7y-">*</span><span
class="zplmr7m-">avgNR</span><span
class="zplmr7t-">) = </span><span
class="zplmr7m-">m</span><span
class="zplmr7y-">* </span><span
class="zplmr7t-">(</span><span
class="zplmr7m-">maxNR</span><span
class="zplmr7y-">-</span><span
class="zplmr7m-">avgNR</span><span
class="zplmr7t-">)] </span>for both <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">AS</span></span></span> and <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">JA</span></span></span> arrays,
where <span
class="cmmi-10">m </span>is equal to the number of rows of the matrix, <span
class="cmmi-10">maxNR </span>is the maximum
class="zplmr7m-">m </span>is equal to the number of rows of the matrix, <span
class="zplmr7m-">maxNR </span>is the maximum
number of nonzero elements in every row and <span
class="cmmi-10">avgNR </span>is the average number of
class="zplmr7m-">avgNR </span>is the average number of
nonzeros. Therefore a single densely populated row can seriously affect the total size
of the allocation.
<!--l. 317--><p class="indent" > To limit this effect, in the HLL format we break the original matrix into equally
sized groups of rows (called <span
class="cmti-10">hacks</span>), and then store these groups as independent
class="pplri7t-">hacks</span>), and then store these groups as independent
matrices in ELLPACK format. The groups can be arranged selecting rows in an
arbitrarily manner; indeed, if the rows are sorted by decreasing number of nonzeros
we obtain essentially the JAgged Diagonals format. If the rows are not in the original
order, then an additional vector <span
class="cmti-10">rIdx </span>is required, storing the actual row index for
each row in the data structure.
class="pplri7t-">rIdx </span>is required, storing the actual row index for each
row in the data structure.
<!--l. 327--><p class="indent" > The multiple ELLPACK-like buffers are stacked together inside a single, one
dimensional array; an additional vector <span
class="cmti-10">hackOffsets </span>is provided to keep track of the
class="pplri7t-">hackOffsets </span>is provided to keep track of the
individual submatrices. All hacks have the same number of rows <span
class="cmti-10">hackSize</span>; hence, the
class="pplri7t-">hackSize</span>; hence, the
<span
class="cmti-10">hackOffsets </span>vector is an array of (<span
class="cmmi-10">m&#x2215;hackSize</span>) + 1 elements, each one pointing to
the first index of a submatrix inside the stacked <span
class="cmti-10">cM</span>/<span
class="cmti-10">rP </span>buffers, plus an additional
class="pplri7t-">hackOffsets </span>vector is an array of <span
class="zplmr7t-">(</span><span
class="zplmr7m-">m</span><span
class="zplmr7t-">/</span><span
class="zplmr7m-">hackSize</span><span
class="zplmr7t-">) + </span>1 elements, each one pointing to the
first index of a submatrix inside the stacked <span
class="pplri7t-">cM</span>/<span
class="pplri7t-">rP </span>buffers, plus an additional
element pointing past the end of the last block, where the next one would begin. We
thus have the property that the elements of the <span
class="cmmi-10">k</span>-th <span
class="cmti-10">hack </span>are stored between
class="zplmr7m-">k</span>-th <span
class="pplri7t-">hack </span>are stored between
<span class="obeylines-h"><span class="verb"><span
class="cmtt-10">hackOffsets[k]</span></span></span> and <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">hackOffsets[k+1]</span></span></span>, similarly to what happens in the CSR
@@ -558,7 +564,7 @@ format.
<a
id="x19-150001r7"></a>
id="x19-151001r7"></a>
@@ -568,7 +574,7 @@ width="248" height="248" >
<br /> <div class="caption"
><span class="id">Figure&#x00A0;7: </span><span
class="content">Hacked ELLPACK compression of matrix in Figure&#x00A0;<a
href="#x19-147002r5">5<!--tex4ht:ref: fig:dense --></a></span></div><!--tex4ht:label?: x19-150001r7 -->
href="#x19-148002r5">5<!--tex4ht:ref: fig:dense --></a></span></div><!--tex4ht:label?: x19-151001r7 -->
@@ -595,9 +601,9 @@ class="cmtt-10">psb_T_hll_sparse_mat</span></span></span>:
</pre>
<!--l. 388--><p class="nopar" > </div></div>
<h5 class="likesubsubsectionHead"><a
id="x19-151000"></a>Diagonal storage</h5>
id="x19-152000"></a>Diagonal storage</h5>
<!--l. 396--><p class="noindent" >The DIAgonal (DIA) format (shown in Figure&#x00A0;<a
href="#x19-151001r8">8<!--tex4ht:ref: fig:dia --></a>) has a 2-dimensional array <span class="obeylines-h"><span class="verb"><span
href="#x19-152001r8">8<!--tex4ht:ref: fig:dia --></a>) has a 2-dimensional array <span class="obeylines-h"><span class="verb"><span
class="cmtt-10">AS</span></span></span>
containing in each column the coefficients along a diagonal of the matrix, and an
integer array <span class="obeylines-h"><span class="verb"><span
@@ -605,9 +611,10 @@ class="cmtt-10">OFFSET</span></span></span> that determines where each diagonal
class="cmtt-10">AS</span></span></span>
are padded with zeros as necessary.
<!--l. 402--><p class="indent" > The code to compute the matrix-vector product <span
class="cmmi-10">y </span>= <span
class="cmmi-10">Ax </span>is shown in Alg.&#x00A0;<a
href="#x19-151003r2">2<!--tex4ht:ref: alg:dia --></a>; it
class="zplmr7m-">y </span><span
class="zplmr7t-">= </span><span
class="zplmr7m-">Ax </span>is shown in Alg.&#x00A0;<a
href="#x19-152003r2">2<!--tex4ht:ref: alg:dia --></a>; it
costs one memory read per outer iteration, plus three memory reads, one memory
write and two floating-point operations per inner iteration. The accesses to
<span class="obeylines-h"><span class="verb"><span
@@ -620,7 +627,7 @@ required.
<a
id="x19-151001r8"></a>
id="x19-152001r8"></a>
@@ -630,13 +637,13 @@ width="248" height="248" >
<br /> <div class="caption"
><span class="id">Figure&#x00A0;8: </span><span
class="content">DIA compression of matrix in Figure&#x00A0;<a
href="#x19-147002r5">5<!--tex4ht:ref: fig:dense --></a></span></div><!--tex4ht:label?: x19-151001r8 -->
href="#x19-148002r5">5<!--tex4ht:ref: fig:dense --></a></span></div><!--tex4ht:label?: x19-152001r8 -->
<!--l. 419--><p class="indent" > </div><hr class="endfigure">
<a
id="x19-151002r2"></a>
id="x19-152002r2"></a>
@@ -662,12 +669,12 @@ href="#x19-147002r5">5<!--tex4ht:ref: fig:dense --></a></span></div><!--tex4ht:l
</pre>
<!--l. 450--><p class="nopar" > </div></div>
<a
id="x19-151003r2"></a>
id="x19-152003r2"></a>
<a
id="x19-151004"></a>
<span
class="cmbx-10">Algorithm</span><span
class="cmbx-10">&#x00A0;2:</span>&#x00A0; Matrix-Vector product in DIA format
id="x19-152004"></a>
<span
class="pplb7t-">Algorithm</span><span
class="pplb7t-">&#x00A0;2:</span>&#x00A0; Matrix-Vector product in DIA format
@@ -691,7 +698,7 @@ class="cmtt-10">psb_T_dia_sparse_mat</span></span></span>:
</pre>
<!--l. 486--><p class="nopar" > </div></div>
<h5 class="likesubsubsectionHead"><a
id="x19-152000"></a>Hacked DIA</h5>
id="x19-153000"></a>Hacked DIA</h5>
<!--l. 495--><p class="noindent" >Storage by DIAgonals is an attractive option for matrices whose coefficients are
located on a small set of diagonals, since they do away with storing explicitly the
indices and therefore reduce significantly memory traffic. However, having a few
@@ -705,40 +712,44 @@ class="cmtt-10">y</span></span></span> is too large to remain
in the cache memory, the associated cache miss penalty is paid multiple
times.
<!--l. 507--><p class="indent" > The <span
class="cmti-10">hacked DIA </span>(<span
class="cmbx-10">HDIA</span>) format was designed to contain the amount of padding,
class="pplri7t-">hacked DIA </span>(<span
class="pplb7t-">HDIA</span>) format was designed to contain the amount of padding,
by breaking the original matrix into equally sized groups of rows (<span
class="cmti-10">hacks</span>), and then
storing these groups as independent matrices in DIA format. This approach is similar
to that of HLL, and requires using an offset vector for each submatrix. Again,
class="pplri7t-">hacks</span>), and then
storing these groups as independent matrices in DIA format. This approach is
similar to that of HLL, and requires using an offset vector for each submatrix. Again,
similarly to HLL, the various submatrices are stacked inside a linear array to
improve memory management. The fact that the matrix is accessed in slices
helps in reducing cache misses, especially regarding accesses to the vector
<span class="obeylines-h"><span class="verb"><span
class="cmtt-10">y</span></span></span>.
<!--l. 519--><p class="indent" > An additional vector <span
class="cmti-10">hackOffsets </span>is provided to complete the matrix format; given
class="pplri7t-">hackOffsets </span>is provided to complete the matrix format; given
that <span
class="cmti-10">hackSize </span>is the number of rows of each hack, the <span
class="cmti-10">hackOffsets </span>vector is made by
an array of (<span
class="cmmi-10">m&#x2215;hackSize</span>) + 1 elements, pointing to the first diagonal offset of a
class="pplri7t-">hackSize </span>is the number of rows of each hack, the <span
class="pplri7t-">hackOffsets </span>vector is made by an
array of <span
class="zplmr7t-">(</span><span
class="zplmr7m-">m</span><span
class="zplmr7t-">/</span><span
class="zplmr7m-">hackSize</span><span
class="zplmr7t-">) + </span>1 elements, pointing to the first diagonal offset of a
submatrix inside the stacked <span
class="cmti-10">offsets </span>buffers, plus an additional element equal to the
number of nonzero diagonals in the whole matrix. We thus have the property that
the number of diagonals of the <span
class="cmmi-10">k</span>-th <span
class="cmti-10">hack </span>is given by <span
class="cmti-10">hackOffsets[k+1] -</span>
class="pplri7t-">offsets </span>buffers, plus an additional element equal to the
number of nonzero diagonals in the whole matrix. We thus have the property
that the number of diagonals of the <span
class="zplmr7m-">k</span>-th <span
class="pplri7t-">hack </span>is given by <span
class="pplri7t-">hackOffsets[k+1] -</span>
<span
class="cmti-10">hackOffsets[k]</span>.
class="pplri7t-">hackOffsets[k]</span>.
<!--l. 529--><p class="indent" > <hr class="figure"><div class="figure"
>
<a
id="x19-152001r9"></a>
id="x19-153001r9"></a>
@@ -748,7 +759,7 @@ width="248" height="248" >
<br /> <div class="caption"
><span class="id">Figure&#x00A0;9: </span><span
class="content">Hacked DIA compression of matrix in Figure&#x00A0;<a
href="#x19-147002r5">5<!--tex4ht:ref: fig:dense --></a></span></div><!--tex4ht:label?: x19-152001r9 -->
href="#x19-148002r5">5<!--tex4ht:ref: fig:dense --></a></span></div><!--tex4ht:label?: x19-153001r9 -->
@@ -792,8 +803,8 @@ class="cmtt-10">psb_T_hdia_sparse_mat</span></span></span>:
<h4 class="subsectionHead"><span class="titlemark">12.4 </span> <a
id="x19-15300012.4"></a>CUDA-class extensions</h4>
<h4 class="subsectionHead"><span class="titlemark">12.4 </span> <a
id="x19-15400012.4"></a>CUDA-class extensions</h4>
<!--l. 4--><p class="noindent" >For computing with CUDA we define a dual memorization strategy in which each
variable on the CPU (&#8220;host&#8221;) side has a GPU (&#8220;device&#8221;) side. When a GPU-type
variable is initialized, the data contained is (usually) the same on both sides. Each
@@ -801,10 +812,10 @@ operator invoked on the variable may change the data so that only the host side
the device side are up-to-date.
<!--l. 11--><p class="indent" > Keeping track of the updates to data in the variables is essential: we want to
perform most computations on the GPU, but we cannot afford the time needed to
move data between the host memory and the device memory because the bandwidth
of the interconnection bus would become the main bottleneck of the computation.
Thus, each and every computational routine in the library is built according to the
following principles:
move data between the host memory and the device memory because the
bandwidth of the interconnection bus would become the main bottleneck of the
computation. Thus, each and every computational routine in the library is built
according to the following principles:
<ul class="itemize1">
<li class="itemize">
<!--l. 18--><p class="noindent" >If the data type being handled is GPU-enabled, make sure that its device
@@ -818,20 +829,20 @@ following principles:
<dl class="description"><dt class="description">
<!--l. 25--><p class="noindent" >
<span
class="cmbx-10">explicitly</span> </dt><dd
class="pplb7t-">explicitly</span> </dt><dd
class="description">
<!--l. 25--><p class="noindent" >by invoking a synchronization method;
</dd><dt class="description">
<!--l. 26--><p class="noindent" >
<span
class="cmbx-10">implicitly</span> </dt><dd
class="pplb7t-">implicitly</span> </dt><dd
class="description">
<!--l. 26--><p class="noindent" >by invoking a method that involves other data items that are not
GPU-enabled, e.g., by assignment ov a vector to a normal array.</dd></dl>
</li></ul>
<!--l. 31--><p class="noindent" >In this way, data items are put on the GPU memory &#8220;on demand&#8221; and remain there as
long as &#8220;normal&#8221; computations are carried out. As an example, the following call to a
matrix-vector product
long as &#8220;normal&#8221; computations are carried out. As an example, the following call to
a matrix-vector product
<div class="center"
>
<!--l. 39--><p class="noindent" >
@@ -850,11 +861,11 @@ then
<!--l. 52--><p class="noindent" >The first kernel invocation will find the data in main memory, and will
copy it to the GPU memory, thus incurring a significant overhead; the
result is however <span
class="cmti-10">not </span>copied back, and therefore:
class="pplri7t-">not </span>copied back, and therefore:
</li>
<li class="itemize">
<!--l. 56--><p class="noindent" >Subsequent kernel invocations involving the same vector will find the data
on the GPU side so that they will run at full speed.</li></ul>
<!--l. 56--><p class="noindent" >Subsequent kernel invocations involving the same vector will find the
data on the GPU side so that they will run at full speed.</li></ul>
<!--l. 60--><p class="noindent" >For all invocations after the first the only data that will have to be transferred to/from
the main memory will be the scalars <code class="lstinline"><span style="color:#000000">alpha</span></code> and <code class="lstinline"><span style="color:#000000">beta</span></code>, and the return code
<code class="lstinline"><span style="color:#000000">info</span></code>.
@@ -862,7 +873,7 @@ the main memory will be the scalars <code class="lstinline"><span style="color:#
<dl class="description"><dt class="description">
<!--l. 65--><p class="noindent" >
<span
class="cmbx-10">Vectors:</span> </dt><dd
class="pplb7t-">Vectors:</span> </dt><dd
class="description">
<!--l. 65--><p class="noindent" >The data type <code class="lstinline"><span style="color:#000000">psb_T_vect_gpu</span></code> provides a GPU-enabled extension of
the inner type <code class="lstinline"><span style="color:#000000">psb_T_base_vect_type</span></code>, and must be used together with
@@ -871,23 +882,23 @@ class="description">
</dd><dt class="description">
<!--l. 69--><p class="noindent" >
<span
class="cmbx-10">CSR:</span> </dt><dd
class="pplb7t-">CSR:</span> </dt><dd
class="description">
<!--l. 69--><p class="noindent" >The data type <code class="lstinline"><span style="color:#000000">psb_T_csrg_sparse_mat</span></code> provides an interface to the GPU
version of CSR available in the NVIDIA CuSPARSE library;
</dd><dt class="description">
<!--l. 72--><p class="noindent" >
<span
class="cmbx-10">HYB:</span> </dt><dd
class="pplb7t-">HYB:</span> </dt><dd
class="description">
<!--l. 72--><p class="noindent" >The data type <code class="lstinline"><span style="color:#000000">psb_T_hybg_sparse_mat</span></code> provides an interface to the HYB
GPU storage available in the NVIDIA CuSPARSE library. The internal
GPU storage available in the NVIDIA CuSPARSE library. The internal
structure is opaque, hence the host side is just CSR; the HYB data format
is only available up to CUDA version 10.
</dd><dt class="description">
<!--l. 77--><p class="noindent" >
<span
class="cmbx-10">ELL:</span> </dt><dd
class="pplb7t-">ELL:</span> </dt><dd
class="description">
<!--l. 77--><p class="noindent" >The data type <code class="lstinline"><span style="color:#000000">psb_T_elg_sparse_mat</span></code> provides an interface to the
ELLPACK implementation from SPGPU;
@@ -897,14 +908,14 @@ class="description">
</dd><dt class="description">
<!--l. 80--><p class="noindent" >
<span
class="cmbx-10">HLL:</span> </dt><dd
class="pplb7t-">HLL:</span> </dt><dd
class="description">
<!--l. 80--><p class="noindent" >The data type <code class="lstinline"><span style="color:#000000">psb_T_hlg_sparse_mat</span></code> provides an interface to the Hacked
ELLPACK implementation from SPGPU;
<!--l. 80--><p class="noindent" >The data type <code class="lstinline"><span style="color:#000000">psb_T_hlg_sparse_mat</span></code> provides an interface to the
Hacked ELLPACK implementation from SPGPU;
</dd><dt class="description">
<!--l. 82--><p class="noindent" >
<span
class="cmbx-10">HDIA:</span> </dt><dd
class="pplb7t-">HDIA:</span> </dt><dd
class="description">
<!--l. 82--><p class="noindent" >The data type <code class="lstinline"><span style="color:#000000">psb_T_hdiag_sparse_mat</span></code> provides an interface to the
Hacked DIAgonals implementation from SPGPU;</dd></dl>