aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2013-10-18 11:02:02 -0700
committerAlon Zakai <alonzakai@gmail.com>2013-10-18 13:01:13 -0700
commit5c4bbda63c06e107c725d0edb90fafc169887eae (patch)
tree51cc018c6919bd60931aa48a20ef73eaf78d552a
parent2e2907e3e5a79b2bbbeeb2d06440ac885e81adb8 (diff)
add test_simd2
-rw-r--r--tests/test_other.py36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_other.py b/tests/test_other.py
index aa11c973..746c52a7 100644
--- a/tests/test_other.py
+++ b/tests/test_other.py
@@ -2013,3 +2013,39 @@ a(int [32], char [5]*)
Popen([PYTHON, EMCC, path_from_root('tests', 'linpack.c'), '-O2', '-DSP', '--llvm-opts', '''['-O3', '-vectorize', '-vectorize-loops', '-bb-vectorize-vector-bits=128', '-force-vector-width=4']''']).communicate()
self.assertContained('Unrolled Single Precision', run_js('a.out.js'))
+ def test_simd2(self):
+ self.clear()
+ open('src.cpp', 'w').write(r'''
+#include <stdio.h>
+
+#include <emscripten/vector.h>
+
+int main(int argc, char **argv) {
+ {
+ float *x = (float*)argv;
+ float32x4 *a = (float32x4*)x;
+ float32x4 *b = (float32x4*)(x+4);
+ float32x4 c, d;
+ c = *a;
+ d = *b;
+ c = c*d;
+ d = d/c;
+ printf("floats! %.2f, %.2f, %.2f, %.2f %.2f, %.2f, %.2f, %.2f\n", c[0], c[1], c[2], c[3], d[0], d[1], d[2], d[3]);
+ }
+ {
+ unsigned int *x = (unsigned int*)argv;
+ uint32x4 *a = (uint32x4*)x;
+ uint32x4 *b = (uint32x4*)(x+4);
+ uint32x4 c, d;
+ c = *a;
+ d = *b;
+ c = c*d;
+ d = d/c;
+ printf("uints! %d, %d, %d, %d %d, %d, %d, %d\n", c[0], c[1], c[2], c[3], d[0], d[1], d[2], d[3]);
+ }
+ return 0;
+}
+ ''')
+ Popen([PYTHON, EMCC, 'src.cpp', '-O2']).communicate()
+ self.assertContained('ints', run_js('a.out.js'))
+