PandA-2024.02
spmv_test.c
Go to the documentation of this file.
1 //http://www.cs.berkeley.edu/~mhoemmen/matrix-seminar/slides/UCB_sparse_tutorial_1.pdf
2 #include "spmv.h"
3 
4 #define ran (TYPE)(((double) rand() / (RAND_MAX)) * (MAX-MIN) + MIN)
5 
6 void fillVal(TYPE nzval[N*L], int colind[N*L], TYPE x[N]){
7  int j, cur_indx, i;
8  srand48(8650341L);
9  for (i = 0; i < N; i++){
10  x[i] = ran;
11  cur_indx = 0;
12  for(j=0; j < L; j++){
13  //MAKE BETTER!...
15  cur_indx = (TYPE)(((double) rand() / (RAND_MAX)) * ((L-1) - cur_indx) + cur_indx);
16  printf("idx %d \n",cur_indx);
17  if(cur_indx < L){
18  nzval[i*L + j] = ran;
19  colind[i*L +j] = cur_indx;
20  }
21  }
22  }
23 }
24 
25 void initOut(TYPE y[N]){
26  int i;
27  for (i=0; i<N; i++){
28  y[i] = 0;
29  }
30 }
31 
32 int main(){
33  int colind[N*L];
34  TYPE nzval[N*L];
35  TYPE x[N];
36  TYPE y[N];
37  int i;
38 
39  srand48(8650341L);
40 
41  fillVal(nzval, colind, x);
42  initOut(y);
43 
44  ellpack(nzval, colind, x, y);
45 
46  printf("\n");
47  for(i = 0; i < N; i++){
48  printf("%d ", y[i]);
49  }
50  printf("\n");
51 
52  return 0;
53 }
#define ran
Definition: spmv_test.c:4
void ellpack(TYPE nzval[N *L], int32_t cols[N *L], TYPE vec[N], TYPE out[N])
Definition: spmv.c:8
void fillVal(TYPE A[NNZ])
Definition: spmv_test.c:6
#define TYPE
Definition: backprop.h:21
int main()
Definition: spmv_test.c:59
#define N
Definition: dfdiv.c:60
#define L
Definition: spmv.h:13
void initOut(TYPE y[N])
Definition: spmv_test.c:52
x
Return the smallest n such that 2^n >= _x.

Generated on Mon Feb 12 2024 13:02:50 for PandA-2024.02 by doxygen 1.8.13