-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathex1.c~
59 lines (48 loc) · 987 Bytes
/
ex1.c~
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
49
50
51
52
53
54
55
56
57
58
59
/* gcc -Wall -Wextra -lrt -msse2 -O2 sum.c -o sum */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <assert.h>
#include <x86intrin.h>
#ifndef N
#define N 3200
#endif
double A[N][N];
double B[N][N];
double C[N][N];
void mul(a,) {
int i, j, k;
for (i = 0; i < N; ++i) {
for (j = 0; j < N; ++j) {
for (k = 0; k < N; ++k) {
C[i][j] += A[i][k]*B[k][j];
}
}
}
}
int main() {
struct timespec t0, t1;
double tmp;
assert (N%2 == 0);
#ifdef DEBUG
for (int i=0; i<N; ++i)
{
A[i] = drand48();
B[i] = drand48();
C[i] = 0.0;
}
#endif
clock_gettime(CLOCK_REALTIME, &t0);
somme();
clock_gettime(CLOCK_REALTIME, &t1);
tmp = 1000.*(t1.tv_sec-t0.tv_sec) + (t1.tv_nsec-t0.tv_nsec)/1000000. ;
#ifdef DEBUG
for (i=0; i<N; ++i) {
fprintf(stderr, "[ ");
fprintf(stderr, "%d ", C[i]);
fprintf(stderr, "]\n");
}
#endif
printf("%d %lf\n", N, tmp);
return 0;
}