Fast Auxiliary Space Preconditioning 2.7.7 Aug/28/2022
Loading...
Searching...
No Matches
BlaSpmvCSRL.c
Go to the documentation of this file.
1
18#include "fasp.h"
19
20/*---------------------------------*/
21/*-- Public Functions --*/
22/*---------------------------------*/
23
37 const REAL *x,
38 REAL *y)
39{
40 const INT dif = A -> dif;
41 const INT *nz_diff = A -> nz_diff;
42 const INT *rowindex = A -> index;
43 const INT *rowstart = A -> start;
44 const INT *ja = A -> ja;
45 const REAL *a = A -> val;
46
47 INT i;
48 INT row, col=0;
49 INT len, rowlen;
50 INT firstrow, lastrow;
51
52 REAL val0, val1;
53
54 for (len = 0; len < dif; len ++) {
55 firstrow = rowstart[len];
56 lastrow = rowstart[len+1] - 1;
57 rowlen = nz_diff[len];
58
59 if (lastrow > firstrow ) {
60 //----------------------------------------------------------
61 // Fully-unrolled code for special case (i.g.,rowlen = 5)
62 // Note: you can also set other special case
63 //----------------------------------------------------------
64 if (rowlen == 5) {
65 for (row = firstrow; row < lastrow; row += 2) {
66 val0 = a[col]*x[ja[col]];
67 val1 = a[col+5]*x[ja[col+5]];
68 col ++;
69
70 val0 += a[col]*x[ja[col]];
71 val1 += a[col+5]*x[ja[col+5]];
72 col ++;
73
74 val0 += a[col]*x[ja[col]];
75 val1 += a[col+5]*x[ja[col+5]];
76 col ++;
77
78 val0 += a[col]*x[ja[col]];
79 val1 += a[col+5]*x[ja[col+5]];
80 col ++;
81
82 val0 += a[col]*x[ja[col]];
83 val1 += a[col+5]*x[ja[col+5]];
84 col ++;
85
86 y[rowindex[row]] = val0;
87 y[rowindex[row+1]] = val1;
88
89 col += 5;
90 }
91 }
92 else {
93 //------------------------------------------------------------------
94 // Unroll-and-jammed code for handling two rows at a time
95 //------------------------------------------------------------------
96
97 for (row = firstrow; row < lastrow; row += 2) {
98 val0 = 0.0;
99 val1 = 0.0;
100 for (i = 0; i < rowlen; i ++) {
101 val0 += a[col]*x[ja[col]];
102 val1 += a[col+rowlen]*x[ja[col+rowlen]];
103 col ++;
104 }
105 y[rowindex[row]] = val0;
106 y[rowindex[row+1]] = val1;
107 col += rowlen;
108 }
109 }
110 firstrow = row;
111 }
112
113 //-----------------------------------------------------------
114 // Handle leftover rows that can't be handled in bundles
115 // in the unroll-and -jammed loop
116 //-----------------------------------------------------------
117
118 for (row = firstrow; row <= lastrow; row ++) {
119 val0 = 0.0;
120 for (i = 0; i < rowlen; i ++) {
121 val0 += a[col]*x[ja[col]];
122 col ++;
123 }
124 y[rowindex[row]] = val0;
125 }
126
127 }
128
129}
130
131/*---------------------------------*/
132/*-- End of File --*/
133/*---------------------------------*/
void fasp_blas_dcsrl_mxv(const dCSRLmat *A, const REAL *x, REAL *y)
Compute y = A*x for a sparse matrix in CSRL format.
Definition: BlaSpmvCSRL.c:36
Main header file for the FASP project.
#define REAL
Definition: fasp.h:75
#define INT
Definition: fasp.h:72
Sparse matrix of REAL type in CSRL format.
Definition: fasp.h:277