Hi Richard. I read it. but I don't quite understand, want to discuss on IRC?
On Tue, Apr 14, 2015 at 1:16 PM, Richard Plangger <r...@pasra.at> wrote: > Hi, > > I have recently managed to correctly transform a trace to a vectorized > trace that includes a guard. I'm hoping that this might be merged into > the code base of pypy (when it is finished), thus it would be nice to > get feedback and iron out some problems I currently have. Of course this > needs explanation (hope that does not lead to tl;dr): > > Consider the following trace: > short version (pseudo syntax): > > ``` > label(...,i,...) > store(c,i) = load(a,i) + load(b,i) > j = i+1 > guard(j<MAX) > jump(...,j,...) > ``` > long version: http://pastebin.com/e24s1vZg > > By unrolling this short trace, it is _NOT_ possible to vectorize it. The > guard prohibits the store operation to be executed after the guard. I > solved this problem by introducing a new guard (called 'early-exit'). It > saves the live variables at the beginning of the trace. By finding the > index calculations + guards and moving them above the early exit the > following is possible: > > short version (pseudo syntax): > > ``` > label(...,i,...) > j = i + 1 > guard(j<MAX) > k = j + 1 > guard(k<MAX) > guard_early_exit() # will not be emitted > va = vec_load(a,i,2) > vb = vec_load(b,i,2) > vc = vec_add(va,vb) > vec_store(c, i, 2) = vc > jump(...,k,...) > ``` > long version http://pastebin.com/vc3HaZCn > > My assumptions: Any guard that fails before the early exit must guide > blackhole to the original loop at instruction 0. Only pure operations > and the guards protecting the index are allowed to move before early-exit. > > The previous and the use of the live variables of the early exit (at the > guard instructions) preserve correctness. > > I'm not quite sure how to handle the following problems: > > 1) I had the problem that uneven iterations moved to the blackhole > interpreter and executed the loop from the beginning. I fixed it by > resetting the blackhole interpreter position to the jitcode index 0. > Is this the right way to start from the beginning? > > 2) Is there a better way to tell the blackhole interpreter to resume > from the beginning of the trace, or even do not blackhole and just jump > into the normal interpreter? > > 3) Are there any objections to do it this way (guard early-exit)? > > Best, > Richard > > _______________________________________________ > pypy-dev mailing list > pypy-dev@python.org > https://mail.python.org/mailman/listinfo/pypy-dev > _______________________________________________ pypy-dev mailing list pypy-dev@python.org https://mail.python.org/mailman/listinfo/pypy-dev