summaryrefslogtreecommitdiff
path: root/testsuite/minub8.c
diff options
context:
space:
mode:
Diffstat (limited to 'testsuite/minub8.c')
-rw-r--r--testsuite/minub8.c111
1 files changed, 111 insertions, 0 deletions
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;
+}