Commits

Maciej Fijalkowski  committed 31a15fa

fix the test - it fails because stuff does not work when not compiled
(why???)

  • Participants
  • Parent commits f002fbc
  • Branches backend-vector-ops

Comments (0)

Files changed (5)

File pypy/jit/backend/llsupport/descr.py

     def repr_of_descr(self):
         return '<Array%s %s>' % (self.flag, self.itemsize)
 
-    def get_item_size(self):
+    def get_field_size(self):
         return self.itemsize
 
+    def get_width(self):
+        return self.itemsize
 
 def get_array_descr(gccache, ARRAY_OR_STRUCT):
     cache = gccache._cache_array
     def repr_of_descr(self):
         return '<InteriorFieldDescr %s>' % self.fielddescr.repr_of_descr()
 
-    def get_item_size(self):
+    def get_field_size(self):
         return self.fielddescr.field_size
 
     def get_width(self):

File pypy/jit/backend/x86/assembler.py

         src_addr = addr_add(base_loc, ofs_loc, 0, scale)
         self.mc.MOVDQA(resloc, src_addr)
 
+    def genop_getinteriorfield_vector_raw(self, op, arglocs, resloc):
+        (base_loc, ofs_loc, itemsize_loc, fieldsize_loc,
+            index_loc, temp_loc, sign_loc) = arglocs
+        self.genop_getarrayitem_vector_raw(op, [base_loc, ofs_loc,
+                                                itemsize_loc, None, sign_loc],
+                                           resloc)
+
     def _get_interiorfield_addr(self, temp_loc, index_loc, itemsize_loc,
                                 base_loc, ofs_loc):
         assert isinstance(itemsize_loc, ImmedLoc)
         dest_addr = AddressLoc(base_loc, ofs_loc, scale, 0)
         self.mc.MOVDQA(dest_addr, value_loc)
 
+    def genop_discard_setinteriorfield_vector_raw(self, op, arglocs):
+        (base_loc, ofs_loc, itemsize_loc, fieldsize_loc,
+            index_loc, temp_loc, value_loc) = arglocs
+        self.genop_discard_setarrayitem_vector_raw(op, [base_loc, ofs_loc,
+             value_loc, itemsize_loc, None])
+
     def genop_discard_strsetitem(self, op, arglocs):
         base_loc, ofs_loc, val_loc = arglocs
         basesize, itemsize, ofs_length = symbolic.get_array_token(rstr.STR,

File pypy/jit/backend/x86/regalloc.py

                                  index_loc, temp_loc, value_loc])
 
     consider_setinteriorfield_raw = consider_setinteriorfield_gc
+    consider_setinteriorfield_vector_raw = consider_setinteriorfield_gc
 
     def consider_strsetitem(self, op):
         args = op.getarglist()
                           index_loc, temp_loc, sign_loc], result_loc)
 
     consider_getinteriorfield_raw = consider_getinteriorfield_gc
+    consider_getinteriorfield_vector_raw = consider_getinteriorfield_gc
 
     def consider_int_is_true(self, op, guard_op):
         # doesn't need arg to be in a register

File pypy/jit/backend/x86/test/test_vectorize.py

             return r
 
         assert self.meta_interp(f, [20]) == f(20)
+        self.check_simple_loop(float_vector_add=1, getarrayitem_vector_raw=2,
+                               setarrayitem_vector_raw=1)
 
     def test_vector_ops_libffi(self):
-        TP = rffi.CArray(lltype.Float)
+        TP = lltype.Array(lltype.Float, hints={'nolength': True,
+                                               'memory_position_alignment': 16})
         elem_size = rffi.sizeof(lltype.Float)
         ftype = clibffi.cast_type_to_ffitype(lltype.Float)
 
         driver = jit.JitDriver(greens = [], reds = ['a', 'i', 'b', 'size'])
 
         def read_item(arr, item):
-            return libffi.array_getitem(ftype, elem_size, arr, item, 0)
+            return libffi.array_getitem(ftype, 1, arr, item, 0)
 
         def store_item(arr, item, v):
-            libffi.array_setitem(ftype, elem_size, arr, item, 0, v)
+            libffi.array_setitem(ftype, 1, arr, item, 0, v)
 
         def initialize(arr, size):
             for i in range(size):
             initialize(a, size)
             initialize(b, size)
             i = 0
-            while i < size:
+            while i < size * elem_size:
                 driver.jit_merge_point(a=a, i=i, size=size, b=b)
                 jit.assert_aligned(a, i)
                 jit.assert_aligned(b, i)
                 store_item(b, i, read_item(a, i) + read_item(a, i))
-                i += 1
+                i += elem_size
                 store_item(b, i, read_item(a, i) + read_item(a, i))
-                i += 1
+                i += elem_size
             r = sum(b, size)
             lltype.free(a, flavor='raw')
             lltype.free(b, flavor='raw')
             return r
 
         res = f(20)
-        assert self.meta_interp(f, [20]) == res
+        res2 = self.meta_interp(f, [20])
+        self.check_simple_loop(float_vector_add=1,
+                               getinteriorfield_vector_raw=2,
+                               setinteriorfield_vector_raw=1)
+        assert res2 == res
         

File pypy/jit/metainterp/optimizeopt/__init__.py

             ('pure', OptPure),
             ('heap', OptHeap),
             ('ffi', None),
-            ('vectorize', OptVectorize), # XXX check if CPU supports that maybe
+            ('vectorize', OptVectorize), # XXX check if CPU supports that
             ('unroll', None),
             ]
 # no direct instantiation of unroll