-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_daxpy.c
49 lines (38 loc) · 1.13 KB
/
test_daxpy.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
#include <stdio.h>
#include <stdlib.h>
int ftrace_region_begin(const char *id);
int ftrace_region_end(const char *id);
#define FTRACE(N,X) do{ \
ftrace_region_begin(N); \
X; \
ftrace_region_end(N); \
} while(0)
void daxpy(int n, double alpha, double *x, int incx,
double *y, int incy);
void daxpy_unr(int n, double alpha, double *x, int incx,
double *y, int incy);
int main(int argc, char *argv[])
{
int n = 4000000;
if (argc > 1) {
n = atoi(argv[1]);
}
printf("LLVM intrinsics DAXPY on one VE core: n = %d\n", n);
double *x = (double *)malloc(n * sizeof(double));
double *y = (double *)malloc(n * sizeof(double));
if (!x || !y) {
printf("ERROR: failed to allocate memory!\n");
exit(1);
}
for (int i = 0; i < n; i++) {
x[i] = 0.1 * (double)i;
y[i] = 1.0;
}
for (int i = 0; i < 100; i++)
FTRACE("daxpy", daxpy(n, 2.0, x, 1, y, 1));
for (int i = 0; i < 100; i++)
FTRACE("daxpy_unr", daxpy_unr(n, 2.0, x, 1, y, 1));
free(x);
free(y);
return 0;
}