summaryrefslogtreecommitdiff
path: root/GEMV/baselines/cpu/gemv_utils.h
blob: de55f19548aced887af465ea97ddbe39b2a96e63 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
void allocate_dense(size_t rows,size_t  cols, T*** dense) {

#if NUMA
  *dense = numa_alloc(sizeof(void*)*rows);
  **dense = numa_alloc(sizeof(T)*rows*cols);
#else
  *dense = malloc(sizeof(void*)*rows);
  **dense = malloc(sizeof(T)*rows*cols);
#endif

  for (size_t i=0; i < rows; i++ ) {
    (*dense)[i] = (*dense)[0] + i*cols;
  }

}

void print_mat(T** A, size_t rows, size_t cols) {
  for (size_t i = 0; i < rows; i++) {
    for (size_t j = 0; j < cols; j++) {
      printf("%f ", A[i][j]);
    }
    printf("\n");
  }
}

void print_vec(T* b, size_t rows) {
  for (size_t i = 0; i < rows; i++) {
    printf("%f\n", b[i]);
  }
}

void gemv(T** A, T* x, size_t rows, size_t cols, T** b);
void make_hilbert_mat(size_t rows, size_t cols, T*** A);
T sum_vec(T* vec, size_t rows);