-
Notifications
You must be signed in to change notification settings - Fork 1
/
matrix.h
48 lines (37 loc) · 928 Bytes
/
matrix.h
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/* This program is basically the one in the paper /What Every
Programmer Should Know About Memory/, by Ulrich Drepper, section
6.2. See the paper for more information. */
#ifndef MATRIX_H
#define MATRIX_H
/* for memset */
#include <string.h>
#define N (1000)
double res[N][N] __attribute__ ((aligned (64)));
double mul1[N][N] __attribute__ ((aligned (64)));
double mul2[N][N] __attribute__ ((aligned (64)));
#ifdef CHECK_RESULT
static void
init_matrix (double matrix[N][N])
{
int i, j;
for (i = 0; i < N; i++)
for (j = 0; j < N; j++)
matrix[i][j] = (i + 1) * (j + 1);
}
static void
reset_matrix (double matrix[N][N])
{
memset (matrix, 0, sizeof (double) * N * N);
}
static double
sum_matrix (double matrix[N][N])
{
int i, j;
double sum = 0.0;
for (i = 0; i < N; i++)
for (j = 0; j < N; j++)
sum += matrix[i][j];
return sum;
}
#endif /* CHECK_RESULT */
#endif /* !MATRIX_H */