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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
#include <u.h>
#include <libc.h>
#include <geometry.h>
double min(double, double);
double dotvec2_sse4(Point2, Point2);
double dotvec2_avx(Point2, Point2);
double dotvec3_sse4(Point3, Point3);
double dotvec3_avx(Point3, Point3);
Point2 Pt2b(double, double, double);
Point3 crossvec3_sse(Point3, Point3);
double hsubpd(double, double);
double fma(double, double, double);
Point2 addpt2_avx(Point2, Point2);
Point3 addpt3_avx(Point3, Point3);
double
fmin(double a, double b)
{
return a<b? a: b;
}
double
madd(double a, double b, double c)
{
return a + b*c;
}
void
main(int argc, char *argv[])
{
double a, b, r;
Point2 p0, p1, pr;
Point3 p0t, p1t, prt;
GEOMfmtinstall();
ARGBEGIN{default:sysfatal("shit");}ARGEND
if(argc != 2)
sysfatal("shit");
a = strtod(argv[0], nil);
b = strtod(argv[1], nil);
r = fmin(a, b);
print("fmin(%g, %g) = %g\n", a, b, r);
r = min(a, b);
print("min(%g, %g) = %g\n", a, b, r);
print("\n");
p0 = Pt2b(a, 1, 1);
p1 = Pt2b(b, 3, 1);
r = dotvec2_sse4(p0, p1);
print("dotvec2_sse4(%v, %v) = %g\n", p0, p1, r);
r = dotvec2(p0, p1);
print("dotvec2(%v, %v) = %g\n", p0, p1, r);
r = dotvec2_avx(p0, p1);
print("dotvec2_avx(%v, %v) = %g\n", p0, p1, r);
print("\n");
p0t = Pt3(a, 1, 9, 1);
p1t = Pt3(b, 3, 4, 1);
r = dotvec3_sse4(p0t, p1t);
print("dotvec3_sse4(%V, %V) = %g\n", p0t, p1t, r);
r = dotvec3(p0t, p1t);
print("dotvec3(%V, %V) = %g\n", p0t, p1t, r);
r = dotvec3_avx(p0t, p1t);
print("dotvec3_avx(%V, %V) = %g\n", p0t, p1t, r);
print("\n");
r = hsubpd(a, b);
print("hsubpd(%g, %g) = %g\n", a, b, r);
print("\n");
p0t = Pt3(a, 1, 9, 1);
p1t = Pt3(b, 3, 4, 1);
prt = crossvec3_sse(p0t, p1t);
print("crossvec3_sse(%V, %V) = %V\n", p0t, p1t, prt);
prt = crossvec3(p0t, p1t);
print("crossvec3(%V, %V) = %V\n", p0t, p1t, prt);
print("\n");
r = madd(a, b, 21);
print("madd(%g, %g, 21) = %g\n", a, b, r);
r = fma(a, b, 21);
print("fma(%g, %g, 21) = %g\n", a, b, r);
print("\n");
p0 = Pt2b(a, 1, 1);
p1 = Pt2b(b, 3, 1);
pr = addpt2(p0, p1);
print("addpt2(%v, %v) = %v\n", p0, p1, pr);
pr = addpt2_avx(p0, p1);
print("addpt2_avx(%v, %v) = %v\n", p0, p1, pr);
print("\n");
p0t = Pt3(a, 1, 1, b);
p1t = Pt3(b, 3, 1, a);
prt = addpt3(p0t, p1t);
print("addpt3(%V, %V) = %V\n", p0t, p1t, prt);
prt = addpt3_avx(p0t, p1t);
print("addpt3_avx(%V, %V) = %V\n", p0t, p1t, prt);
exits(nil);
}
|