Author: Richard Plangger <[email protected]>
Branch: vecopt-merge
Changeset: r79310:51a6240fbce7
Date: 2015-08-31 09:36 +0200
http://bitbucket.org/pypy/pypy/changeset/51a6240fbce7/
Log: slicing index must be positive adding split packs to packset added
vec_guard_ratio parameter
diff --git a/rpython/jit/metainterp/optimizeopt/schedule.py
b/rpython/jit/metainterp/optimizeopt/schedule.py
--- a/rpython/jit/metainterp/optimizeopt/schedule.py
+++ b/rpython/jit/metainterp/optimizeopt/schedule.py
@@ -940,11 +940,16 @@
node.pack_position = i
def split(self, packlist, vec_reg_size):
+ """ Combination phase creates the biggest packs that are possible.
+ In this step the pack is reduced in size to fit into an
+ vector register.
+ """
pack = self
pack_type = self.pack_type()
max_count = vec_reg_size // pack_type.getsize()
assert max_count * pack_type.getsize() == vec_reg_size
while pack.pack_byte_size() > vec_reg_size:
+ assert max_count > 0
newpack = pack.clone()
oplist = pack.operations[:max_count]
newpack.operations = pack.operations[max_count:]
@@ -952,6 +957,7 @@
pack.update_pack_of_nodes()
newpack.update_pack_of_nodes()
pack = newpack
+ packlist.append(newpack)
def rightmost_match_leftmost(self, other):
""" Check if pack A can be combined with pack B """
diff --git a/rpython/jit/metainterp/optimizeopt/vectorize.py
b/rpython/jit/metainterp/optimizeopt/vectorize.py
--- a/rpython/jit/metainterp/optimizeopt/vectorize.py
+++ b/rpython/jit/metainterp/optimizeopt/vectorize.py
@@ -97,6 +97,8 @@
resop_count = 0 # the count of operations minus debug_merge_points
vector_instr = 0
+ guard_count = 0
+ blacklist = (rop.CALL, rop.CALL_ASSEMBLER)
at_least_one_array_access = True
for i,op in enumerate(loop.operations):
if op.getopnum() == rop.DEBUG_MERGE_POINT:
@@ -110,6 +112,13 @@
if op.is_primitive_array_access():
at_least_one_array_access = True
+ if warmstate.vec_ratio > 0.0:
+ if op.getopnum() in blacklist:
+ return True
+
+ if op.is_guard():
+ guard_count += 1
+
if not at_least_one_array_access:
return True
@@ -119,6 +128,9 @@
if (float(vector_instr)/float(resop_count)) < warmstate.vec_ratio:
return True
+ if float(guard_count)/float(resop_count) > warmstate.vec_guard_ratio:
+ return True
+
return False
def cmp_pack_lt(a,b):
diff --git a/rpython/jit/metainterp/test/test_vectorize.py
b/rpython/jit/metainterp/test/test_vectorize.py
--- a/rpython/jit/metainterp/test/test_vectorize.py
+++ b/rpython/jit/metainterp/test/test_vectorize.py
@@ -289,15 +289,32 @@
res = self.meta_interp(f, [i])
assert res == f(i)
- @py.test.mark.parametrize('i,v1,v2',[(25,2.5,0.3), (15,44.0,22.2)])
+ @py.test.mark.parametrize('i,v1,v2',[(25,2.5,0.3)])
def test_list_vectorize(self,i,v1,v2):
myjitdriver = JitDriver(greens = [],
reds = 'auto')
+ class ListF(object):
+ def __init__(self, size, init=0.0):
+ self.list = [init] * size
+ def __getitem__(self, key):
+ if key < 0:
+ raise IndexError
+ if key >= len(self.list):
+ raise IndexError
+ return self.list[key]
+ def __setitem__(self, key, value):
+ if key < 0:
+ raise IndexError
+ if key >= len(self.list):
+ raise IndexError
+ self.list[key] = value
+ def append(self, value):
+ self.list.append(value)
def f(d, v1, v2):
- a = [v1] * i
- b = [v2] * i
+ a = ListF(d, v1)
+ b = ListF(d, v2)
i = 0
- while i < len(a):
+ while i < d:
myjitdriver.jit_merge_point()
a[i] = a[i] + b[i]
i += 1
diff --git a/rpython/jit/metainterp/warmspot.py
b/rpython/jit/metainterp/warmspot.py
--- a/rpython/jit/metainterp/warmspot.py
+++ b/rpython/jit/metainterp/warmspot.py
@@ -72,7 +72,7 @@
loop_longevity=0, retrace_limit=5, function_threshold=4,
enable_opts=ALL_OPTS_NAMES, max_retrace_guards=15,
max_unroll_recursion=7, vec=0, vec_all=0, vec_cost=0,
- vec_length=60, vec_ratio=2, **kwds):
+ vec_length=60, vec_ratio=2, vec_guard_ratio=3, **kwds):
from rpython.config.config import ConfigError
translator = interp.typer.annotator.translator
try:
@@ -100,6 +100,7 @@
jd.warmstate.set_param_vec_cost(vec_cost)
jd.warmstate.set_param_vec_length(vec_length)
jd.warmstate.set_param_vec_ratio(vec_ratio)
+ jd.warmstate.set_param_vec_guard_ratio(vec_guard_ratio)
warmrunnerdesc.finish()
if graph_and_interp_only:
return interp, graph
diff --git a/rpython/jit/metainterp/warmstate.py
b/rpython/jit/metainterp/warmstate.py
--- a/rpython/jit/metainterp/warmstate.py
+++ b/rpython/jit/metainterp/warmstate.py
@@ -315,6 +315,9 @@
def set_param_vec_ratio(self, value):
self.vec_ratio = value / 10.0
+ def set_param_vec_guard_ratio(self, value):
+ self.vec_guard_ratio = value / 10.0
+
def disable_noninlinable_function(self, greenkey):
cell = self.JitCell.ensure_jit_cell_at_key(greenkey)
cell.flags |= JC_DONT_TRACE_HERE
diff --git a/rpython/rlib/jit.py b/rpython/rlib/jit.py
--- a/rpython/rlib/jit.py
+++ b/rpython/rlib/jit.py
@@ -559,6 +559,8 @@
'vec_length': 'the amount of instructions allowed in "all" traces.',
'vec_ratio': 'an integer (0-10 transfored into a float by X / 10.0)
statements that have vector equivalents '
'divided by the total number of trace instructions.',
+ 'vec_guard_ratio': 'an integer (0-10 transfored into a float by X / 10.0)
divided by the'
+ ' total number of trace instructions.',
}
PARAMETERS = {'threshold': 1039, # just above 1024, prime
@@ -579,6 +581,7 @@
'vec_cost': 0,
'vec_length': 60,
'vec_ratio': 2,
+ 'vec_guard_ratio': 3,
}
unroll_parameters = unrolling_iterable(PARAMETERS.items())
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit