summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Turner <mattst88@gmail.com>2008-05-12 19:55:21 +0000
committerMatt Turner <mattst88@gmail.com>2008-05-12 19:55:21 +0000
commit5117e7e647d2f380a883661571e441ce603220a9 (patch)
tree329caea1a1f50e4cd6d72fee8157fc80de378d3e
parentf5c37567f57b4f8281a43a23a1458a5f34312662 (diff)
import testsuite
git-svn-id: svn://mattst88.com/svn/alpha_mmintrin/trunk@3 f7d56953-e76f-4e43-a77e-20d50f6c004e
-rw-r--r--testsuite/Makefile15
-rw-r--r--testsuite/ctlz.c74
-rw-r--r--testsuite/maxub8.c108
-rw-r--r--testsuite/maxuw4.c111
-rw-r--r--testsuite/minmax.h4
-rw-r--r--testsuite/minub8.c111
-rw-r--r--testsuite/minuw4.c108
7 files changed, 531 insertions, 0 deletions
diff --git a/testsuite/Makefile b/testsuite/Makefile
new file mode 100644
index 0000000..3a1d2ce
--- /dev/null
+++ b/testsuite/Makefile
@@ -0,0 +1,15 @@
+CC=gcc
+CFLAGS=-O2 -mcpu=ev67 #-funroll-loops -pipe
+
+EXES=maxub8.exe maxuw4.exe minub8.exe minuw4.exe addusw4.exe ctlz.exe
+
+all: ${EXES}
+
+clean:
+ rm -f ${EXES}
+
+rebuild: clean all
+remake: rebuild
+
+%.exe: %.c
+ ${CC} ${CFLAGS} -o $@ $< ${OBJ}
diff --git a/testsuite/ctlz.c b/testsuite/ctlz.c
new file mode 100644
index 0000000..1fc0cf1
--- /dev/null
+++ b/testsuite/ctlz.c
@@ -0,0 +1,74 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <time.h>
+#include <string.h>
+
+#include "../alpha_mmintrin.h"
+
+#define ITERATIONS 10000
+
+int main(int argc, char ** argv) {
+ uint64_t a[512], b[512], c[512];
+ uint64_t l1, l2;
+ uint64_t start, end, overhead;
+ uint64_t cix_total = 0, noncix_total = 0;
+ int i, j, count = 0;
+
+ start = __rpcc();
+ end = __rpcc();
+ overhead = end - start;
+
+ srand(time(NULL));
+
+ for (i = 0; i < 512; i++) {
+ a[i] = rand();
+ }
+
+ for (j = 0; j < ITERATIONS; j++) {
+ start = __rpcc();
+
+ for (i = 0; i < 512; i++) {
+ l1 = a[i];
+
+ l2 = 1 << (64 - __ctlz(l1));
+
+ b[i] = l2;
+ }
+
+ end = __rpcc();
+ cix_total += end - start - overhead;
+ memset(b, 4096, 0);
+ }
+
+ for (j = 0; j < ITERATIONS; j++) {
+ start = __rpcc();
+
+ for (i = 0; i < 512; i++) {
+ l1 = a[i];
+ while (l1 != 0) {
+ l1 >>= 1;
+ count += 1;
+ }
+ l2 = 1 << count;
+ c[i] = l2;
+ // printf("nextpow2 of %lu is %lu\n", i, l2);
+ count = 0;
+ }
+
+ end = __rpcc();
+ noncix_total += end - start - overhead;
+ memset(c, 4096, 0);
+ }
+
+ noncix_total /= ITERATIONS;
+ cix_total /= ITERATIONS;
+
+ if (memcmp(b, c, 4096) == 0) {
+ printf("%s:\n", argv[0]);
+ printf(" CIX time: %9lu nanoseconds\n non-CIX time: %9lu nanoseconds\n", cix_total, noncix_total);
+ } else {
+ puts("Final arrays are not equal. Something happened.");
+ }
+
+ return 0;
+}
diff --git a/testsuite/maxub8.c b/testsuite/maxub8.c
new file mode 100644
index 0000000..de2a9e7
--- /dev/null
+++ b/testsuite/maxub8.c
@@ -0,0 +1,108 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <time.h>
+
+#include "../alpha_mmintrin.h"
+#include "minmax.h"
+
+#define ITERATIONS 10000
+
+int main(int argc, char ** argv[]) {
+ static uint64_t a[512], b[512];
+ static uint64_t c[512] = {0}, d[512] = {0};
+
+ uint64_t l64_0, l64_1, l64_2;
+ uint64_t *a64, *b64, *c64, *d64;
+
+ uint64_t start, end, overhead;
+ uint64_t simd_total = 0, no_simd_total = 0;
+
+ uint8_t l8_0, l8_1, l8_2;
+ uint8_t *a8, *b8, *c8;
+
+ int i, j;
+
+ start = __rpcc();
+ end = __rpcc();
+ overhead = end - start;
+
+ srand(time(NULL));
+
+ a8 = (uint8_t *)a;
+ b8 = (uint8_t *)b;
+
+ for (i = 0; i < 4096; i++) {
+ *a8 = rand() % 255;
+ *b8 = rand() % 255;
+
+ a8++;
+ b8++;
+ }
+
+ for (j = 0; j < ITERATIONS; j++) {
+ a8 = (uint8_t *)a;
+ b8 = (uint8_t *)b;
+ c8 = (uint8_t *)c;
+
+ start = __rpcc();
+
+ for (i = 0; i < 4096; i++ ) {
+ l8_1 = *a8;
+ l8_2 = *b8;
+
+ l8_0 = MAX(l8_1, l8_2);
+
+ *c8 = l8_0;
+
+ a8++;
+ b8++;
+ c8++;
+ }
+
+ end = __rpcc() - overhead;
+ no_simd_total += end - start;
+
+ memset(c, 4096, 0);
+ }
+
+ no_simd_total /= ITERATIONS;
+
+
+ for (j = 0; j < ITERATIONS; j++) {
+ a64 = a;
+ b64 = b;
+ d64 = d;
+
+ start = __rpcc();
+
+ for (i = 0; i < 512; i++) {
+ l64_1 = *a64;
+ l64_2 = *b64;
+
+ l64_0 = __maxub8(l64_1, l64_2);
+
+ *d64 = l64_0;
+
+ a64++;
+ b64++;
+ d64++;
+ }
+
+ end = __rpcc() - overhead;
+ simd_total += end - start;
+
+ memset(d, 4096, 0);
+ }
+
+ simd_total /= ITERATIONS;
+
+ if (memcmp(c, d, 4096) == 0) {
+ printf("%s:\n", argv[0]);
+ printf(" SIMD time: %9lu nanoseconds\nnon-SIMD time: %9lu nanoseconds\n", simd_total, no_simd_total);
+ } else {
+ puts("Final arrays are not equal. Something happened.");
+ }
+
+ return 0;
+}
diff --git a/testsuite/maxuw4.c b/testsuite/maxuw4.c
new file mode 100644
index 0000000..3b8e942
--- /dev/null
+++ b/testsuite/maxuw4.c
@@ -0,0 +1,111 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <time.h>
+
+#include "../alpha_mmintrin.h"
+#include "minmax.h"
+
+#define ITERATIONS 10000
+
+int main(int argc, char ** argv[]) {
+ static uint64_t a[512], b[512];
+ static uint64_t c[512] = {0}, d[512] = {0};
+
+ uint64_t l64_0, l64_1, l64_2;
+ uint64_t *a64, *b64, *c64, *d64;
+
+ uint64_t start, end, overhead;
+ uint64_t simd_total = 0, no_simd_total = 0;
+
+ uint16_t l16_0, l16_1, l16_2;
+ uint16_t *a16, *b16, *c16;
+
+ uint8_t l8_0, l8_1, l8_2;
+ uint8_t *a8, *b8, *c8;
+
+ int i, j;
+
+ start = __rpcc();
+ end = __rpcc();
+ overhead = end - start;
+
+ srand(time(NULL));
+
+ a8 = (uint8_t *)a;
+ b8 = (uint8_t *)b;
+
+ for (i = 0; i < 4096; i++) {
+ *a8 = rand() % 255;
+ *b8 = rand() % 255;
+
+ a8++;
+ b8++;
+ }
+
+ for (j = 0; j < ITERATIONS; j++) {
+ a16 = (uint16_t *)a;
+ b16 = (uint16_t *)b;
+ c16 = (uint16_t *)c;
+
+ start = __rpcc();
+
+ for (i = 0; i < 2048; i++ ) {
+ l16_1 = *a16;
+ l16_2 = *b16;
+
+ l16_0 = MAX(l16_1, l16_2);
+
+ *c16 = l16_0;
+
+ a16++;
+ b16++;
+ c16++;
+ }
+
+ end = __rpcc() - overhead;
+ no_simd_total += end - start;
+
+ memset(c, 4096, 0);
+ }
+
+ no_simd_total /= ITERATIONS;
+
+
+ for (j = 0; j < ITERATIONS; j++) {
+ a64 = a;
+ b64 = b;
+ d64 = d;
+
+ start = __rpcc();
+
+ for (i = 0; i < 512; i++) {
+ l64_1 = *a64;
+ l64_2 = *b64;
+
+ l64_0 = __maxuw4(l64_1, l64_2);
+
+ *d64 = l64_0;
+
+ a64++;
+ b64++;
+ d64++;
+ }
+
+ end = __rpcc() - overhead;
+ simd_total += end - start;
+
+ memset(d, 4096, 0);
+ }
+
+ simd_total /= ITERATIONS;
+
+ if (memcmp(c, d, 4096) == 0) {
+ printf("%s:\n", argv[0]);
+ printf(" SIMD time: %9lu nanoseconds\nnon-SIMD time: %9lu nanoseconds\n", simd_total, no_simd_total);
+ } else {
+ puts("Final arrays are not equal. Something happened.");
+ }
+
+ return 0;
+}
diff --git a/testsuite/minmax.h b/testsuite/minmax.h
new file mode 100644
index 0000000..bead827
--- /dev/null
+++ b/testsuite/minmax.h
@@ -0,0 +1,4 @@
+
+#define MAX(a, b) (a > b ? a : b)
+#define MIN(a, b) (a < b ? a : b)
+
diff --git a/testsuite/minub8.c b/testsuite/minub8.c
new file mode 100644
index 0000000..5b54e0a
--- /dev/null
+++ b/testsuite/minub8.c
@@ -0,0 +1,111 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <time.h>
+
+#include "../alpha_mmintrin.h"
+#include "minmax.h"
+
+#define ITERATIONS 10000
+
+int main(int argc, char ** argv[]) {
+ static uint64_t a[512], b[512];
+ static uint64_t c[512] = {0}, d[512] = {0};
+
+ uint64_t l64_0, l64_1, l64_2;
+ uint64_t *a64, *b64, *c64, *d64;
+
+ uint64_t start, end, overhead;
+ uint64_t simd_total = 0, no_simd_total = 0;
+
+ uint8_t l8_0, l8_1, l8_2;
+ uint8_t *a8, *b8, *c8;
+
+ int i, j;
+
+ start = __rpcc();
+ end = __rpcc();
+ overhead = end - start;
+
+ srand(time(NULL));
+
+ a8 = (uint8_t *)a;
+ b8 = (uint8_t *)b;
+
+ for (i = 0; i < 4096; i++) {
+ *a8 = rand() % 255;
+ *b8 = rand() % 255;
+
+ a8++;
+ b8++;
+ }
+
+ for (j = 0; j < ITERATIONS; j++) {
+ a8 = (uint8_t *)a;
+ b8 = (uint8_t *)b;
+ c8 = (uint8_t *)c;
+
+ start = __rpcc();
+
+ for (i = 0; i < 4096; i++ ) {
+ l8_1 = *a8;
+ l8_2 = *b8;
+
+ l8_0 = MIN(l8_1, l8_2);
+
+ *c8 = l8_0;
+
+ //printf("MIN of %3u and %3u is %3u\n", l8_1, l8_2, l8_0);
+
+ a8++;
+ b8++;
+ c8++;
+ }
+
+ end = __rpcc() - overhead;
+ //printf("%d - %lu nanoseconds\n", j, end - start);
+ no_simd_total += end - start;
+
+ memset(c, 4096, 0);
+ }
+
+ no_simd_total /= ITERATIONS;
+
+
+ for (j = 0; j < ITERATIONS; j++) {
+ a64 = a;
+ b64 = b;
+ d64 = d;
+
+ start = __rpcc();
+
+ for (i = 0; i < 512; i++) {
+ l64_1 = *a64;
+ l64_2 = *b64;
+
+ l64_0 = __minub8(l64_1, l64_2);
+
+ *d64 = l64_0;
+
+ a64++;
+ b64++;
+ d64++;
+ }
+
+ end = __rpcc() - overhead;
+ simd_total += end - start;
+
+ memset(d, 4096, 0);
+ }
+
+ simd_total /= ITERATIONS;
+
+ if (memcmp(c, d, 4096) == 0) {
+ printf("%s:\n", argv[0]);
+ printf(" SIMD time: %9lu nanoseconds\nnon-SIMD time: %9lu nanoseconds\n", simd_total, no_simd_total);
+ } else {
+ puts("Final arrays are not equal. Something happened.");
+ }
+
+ return 0;
+}
diff --git a/testsuite/minuw4.c b/testsuite/minuw4.c
new file mode 100644
index 0000000..205d32e
--- /dev/null
+++ b/testsuite/minuw4.c
@@ -0,0 +1,108 @@
+#include <stdio.h>
+#include <stdint.h>
+#include <string.h>
+#include <time.h>
+
+#include "../alpha_mmintrin.h"
+#include "minmax.h"
+
+#define ITERATIONS 10000
+
+int main(int argc, char ** argv[]) {
+ static uint64_t a[512], b[512];
+ static uint64_t c[512] = {0}, d[512] = {0};
+
+ uint64_t l64_0, l64_1, l64_2;
+ uint64_t *a64, *b64, *c64, *d64;
+
+ uint64_t start, end, overhead;
+ uint64_t simd_total = 0, no_simd_total = 0;
+
+ uint16_t l16_0, l16_1, l16_2, l16_3, l16_4, l16_5, l16_6, l16_7, l16_8, l16_9, l16_10, l16_11, l16_12;
+ uint16_t *a16, *b16, *c16;
+
+ uint8_t l8_0, l8_1, l8_2;
+ uint8_t *a8, *b8, *c8;
+
+ int i, j;
+
+ start = __rpcc();
+ end = __rpcc();
+ overhead = end - start;
+
+ srand(time(NULL));
+
+ a8 = (uint8_t *)a;
+ b8 = (uint8_t *)b;
+
+ for (i = 0; i < 4096; i++) {
+ *a8 = rand() % 255;
+ *b8 = rand() % 255;
+
+ a8++;
+ b8++;
+ }
+
+ for (j = 0; j < ITERATIONS; j++) {
+ a16 = (uint16_t *)a;
+ b16 = (uint16_t *)b;
+ c16 = (uint16_t *)c;
+
+ start = __rpcc();
+
+ for (i = 0; i < 2048; i++) {
+ l16_1 = *a16;
+ l16_2 = *b16;
+ l16_0 = MIN(l16_1, l16_2);
+ *c16 = l16_0;
+ a16++;
+ b16++;
+ c16++;
+ }
+
+ end = __rpcc() - overhead;
+ no_simd_total += end - start;
+
+ memset(c, 4096, 0);
+ }
+
+ no_simd_total /= ITERATIONS;
+
+
+ for (j = 0; j < ITERATIONS; j++) {
+ a64 = a;
+ b64 = b;
+ d64 = d;
+
+ start = __rpcc();
+
+ for (i = 0; i < 512; i++) {
+ l64_1 = *a64;
+ l64_2 = *b64;
+
+ l64_0 = __minuw4(l64_1, l64_2);
+
+ *d64 = l64_0;
+
+ a64++;
+ b64++;
+ d64++;
+ }
+
+ end = __rpcc() - overhead;
+ simd_total += end - start;
+
+ memset(d, 4096, 0);
+ }
+
+ simd_total /= ITERATIONS;
+
+ if (memcmp(c, d, 4096) == 0) {
+ printf("%s:\n", argv[0]);
+ printf(" SIMD time: %9lu nanoseconds\nnon-SIMD time: %9lu nanoseconds\n", simd_total, no_simd_total);
+ } else {
+ puts("Final arrays are not equal. Something happened.");
+ }
+
+ return 0;
+}