diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 51 |
1 files changed, 51 insertions, 0 deletions
@@ -6,8 +6,12 @@ double min(double, double); double dotvec2_sse(Point2, Point2); double dotvec2_sse4(Point2, Point2); double dotvec2_avx(Point2, Point2); +double dotvec2_sse_a(Point2*, Point2*); +double dotvec2_sse4_a(Point2*, Point2*); +double dotvec2_avx_a(Point2*, Point2*); double dotvec3_sse4(Point3, Point3); double dotvec3_avx(Point3, Point3); +double dotvec3_sse4_a(Point3*, Point3*); Point2 Pt2b(double, double, double); Point3 crossvec3_sse(Point3, Point3); double hsubpd(double, double); @@ -18,6 +22,21 @@ Point3 addpt3_avx(Point3, Point3); void addsub_sse(double*,double*); double round(double); +void * +amalloc(ulong n, ulong a) +{ + void *p; + + assert(a > 1 && (a&1) == 0); + + a--; + p = malloc(n+a); + if(p == nil) + sysfatal("malloc: %r"); + p = (void*)(((uintptr)p + a)&~a); + return p; +} + void addsub(double *a, double *b) { @@ -44,6 +63,8 @@ main(int argc, char *argv[]) double va[2], vb[2]; Point2 p0, p1, pr; Point3 p0t, p1t, prt; + Point2 *ap0, *ap1, *apr; + Point3 *ap0t, *ap1t, *aprt; GEOMfmtinstall(); ARGBEGIN{default:sysfatal("shit");}ARGEND @@ -52,6 +73,14 @@ main(int argc, char *argv[]) a = strtod(argv[0], nil); b = strtod(argv[1], nil); + ap0 = amalloc(sizeof(Point2), 16); + ap1 = amalloc(sizeof(Point2), 16); + apr = amalloc(sizeof(Point2), 16); + + ap0t = amalloc(sizeof(Point3), 16); + ap1t = amalloc(sizeof(Point3), 16); + aprt = amalloc(sizeof(Point3), 16); + r = 0; r = fmin(a, b); print("fmin(%g, %g) = %g\n", a, b, r); @@ -78,6 +107,20 @@ main(int argc, char *argv[]) print("\n"); + *ap0 = Pt2b(a, 1, 1); + *ap1 = Pt2b(b, 3, 1); + r = 0; + r = dotvec2_sse_a(ap0, ap1); + print("dotvec2_sse_a(%v, %v) = %g\n", *ap0, *ap1, r); + r = 0; + r = dotvec2_sse4_a(ap0, ap1); + print("dotvec2_sse4_a(%v, %v) = %g\n", *ap0, *ap1, r); + r = 0; + r = dotvec2_avx_a(ap0, ap1); + print("dotvec2_avx_a(%v, %v) = %g\n", *ap0, *ap1, r); + + print("\n"); + p0t = Pt3(a, 1, 9, 1); p1t = Pt3(b, 3, 4, 1); r = 0; @@ -92,6 +135,14 @@ main(int argc, char *argv[]) print("\n"); + *ap0t = Pt3(a, 1, 9, 1); + *ap1t = Pt3(b, 3, 4, 1); + r = 0; + r = dotvec3_sse4_a(ap0t, ap1t); + print("dotvec3_sse4_a(%V, %V) = %g\n", *ap0t, *ap1t, r); + + print("\n"); + r = 0; r = hsubpd(a, b); print("hsubpd(%g, %g) = %g\n", a, b, r); |