Skip to content

Commit d95187b

Browse files
author
hartsantler
committed
fixes to SIMD and new benchmark testing float32x4.
1 parent c08bda9 commit d95187b

5 files changed

Lines changed: 22 additions & 2 deletions

File tree

pythonjs/python_to_pythonjs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -676,7 +676,7 @@ def visit_AugAssign(self, node):
676676
raise NotImplementedError
677677

678678
b = '%s %s %s' %(target, op, self.visit(node.value))
679-
if isinstance( node.target, ast.Name ) and node.target.id in self._typedef_vars and self._typedef_vars[node.target.id] in typedpython.native_number_types:
679+
if isinstance( node.target, ast.Name ) and node.target.id in self._typedef_vars and self._typedef_vars[node.target.id] in typedpython.native_number_types+typedpython.vector_types:
680680
writer.write(b)
681681

682682
else:

pythonjs/pythonjs.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,7 @@ def inline_helper_return_id(self, return_id):
349349
return "var __returns__%s = null;"%return_id
350350

351351
def _visit_call_helper_numpy_array(self, node):
352+
raise NotImplementedError('TODO numpy.array')
352353
return self.visit(node.args[0]) ## TODO typed arrays
353354

354355
def _visit_call_helper_list(self, node):

regtests/bench/simd_float32x4.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
"""simd float32x4 micro benchmark"""
2+
from time import time
3+
4+
def main():
5+
start = time()
6+
float32x4 a = numpy.array( [1.0001, 1.0002, 1.0003, 1.0004], dtype=numpy.float32 )
7+
float32x4 b = numpy.array( [1.00009, 1.00008, 1.00007, 1.00006], dtype=numpy.float32 )
8+
float32x4 c = numpy.array( [1.00005, 1.00004, 1.00003, 1.00002], dtype=numpy.float32 )
9+
10+
arr = []
11+
for i in range(20000):
12+
c *= a*b
13+
arr.append( a*b*c )
14+
15+
print(time()-start)

regtests/run.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,11 @@ def __call__(self, name):
348348
return lambda f: f
349349
webworker = webworker()
350350
351+
try:
352+
import numpy
353+
except:
354+
import numpypy as numpy
355+
351356
"""
352357

353358
def patch_python(filename, dart=False, python='PYTHONJS', backend=None):

regtests/typed/float32x4.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
"""simd float32x4"""
2-
import numpy
32

43
def main():
54
float32x4 a = numpy.array( [1.1, 1.2, 1.3, 0.4], dtype=numpy.float32 )

0 commit comments

Comments
 (0)