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
|
#include <u.h>
#include <libmath.h>
// -----------------------------------------------------------------------
// Templates
#include "loop.h"
#define BODY_XY() \
LOOP(UNROLL, 0, INIT); \
n = ROUNDBY(len, UNROLL); \
if (incx == 1 && incy == 1) { \
for (i = 0; i < n; i+=UNROLL) { \
LOOP(UNROLL,0,KERNEL,1,1); \
} \
} else { \
for (i = 0; i < n; i+=UNROLL) { \
LOOP(UNROLL,0,KERNEL,incx,incy);\
} \
} \
\
for (; i < len; i++) { \
LOOP(1,0,KERNEL,incx,incy); \
}
#define BODY_X() \
LOOP(UNROLL, 0, INIT); \
n = ROUNDBY(len, UNROLL); \
if (incx == 1) { \
for (i = 0; i < n; i+=UNROLL) { \
LOOP(UNROLL,0,KERNEL,1); \
} \
} else { \
for (i = 0; i < n; i+=UNROLL) { \
LOOP(UNROLL,0,KERNEL,incx); \
} \
} \
\
for (; i < len; i++) { \
LOOP(1,0,KERNEL,incx); \
}
// -----------------------------------------------------------------------
// Implementation
#define UNROLL 8
#define INT int
#define FLOAT double
#define func(name) blas·d##name
#include "blas1body"
#undef FLOAT
#undef func
#define FLOAT float
#define func(name) blas·f##name
#include "blas1body"
#undef FLOAT
|