Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 10:06:57

0001     /* multiple iterations used to make kernel have roughly
0002         same granulairty as other Scimark kernels. */
0003 
0004     double SparseCompRow_num_flops(int N, int nz, int num_iterations)
0005     {
0006         /* Note that if nz does not divide N evenly, then the
0007            actual number of nonzeros used is adjusted slightly.
0008         */
0009         int actual_nz = (nz/N) * N;
0010         return ((double)actual_nz) * 2.0 * ((double) num_iterations);
0011     }
0012 
0013 
0014     /* computes  a matrix-vector multiply with a sparse matrix
0015         held in compress-row format.  If the size of the matrix
0016         in MxN with nz nonzeros, then the val[] is the nz nonzeros,
0017         with its ith entry in column col[i].  The integer vector row[]
0018         is of size M+1 and row[i] points to the begining of the
0019         ith row in col[].  
0020     */
0021 
0022     void SparseCompRow_matmult( int M, double *y, double *val, int *row,
0023         int *col, double *x, int NUM_ITERATIONS)
0024     {
0025         int reps;
0026         int r;
0027         int i;
0028 
0029         for (reps=0; reps<NUM_ITERATIONS; reps++)
0030         {
0031         
0032             for (r=0; r<M; r++)
0033             {
0034                 double sum = 0.0; 
0035                 int rowR = row[r];
0036                 int rowRp1 = row[r+1];
0037                 for (i=rowR; i<rowRp1; i++)
0038                     sum += x[ col[i] ] * val[i];
0039                 y[r] = sum;
0040             }
0041         }
0042     }
0043