LRLRLong Reach Long Riders
Copyright 1988-2018, All rights reserved.
References in periodicals archive ?
Clearly there are some savings in using the UIP code for append/3 rather than the LRLR code.
Note that together Last and Pos indicate a field of a reused cell that would be made into a free variable in LRLR. We call this field the output reference associated with the corresponding output.
Even when a destructive update must be performed on an output reference, UIP outperforms LRLR. Under LRLR, this case requires that the field identified by our output reference first be written to make it a free variable when the cell containing it is reused.
(The same call to setarg/3 is made in the second clause of take_first_stray_1/4 to perform a local assignment to the cell reallocated in t hat clause.) Local assignments are supported by LRLR. In contrast, the assignment to the cell picked up in the first invocation at position 2 is nonlocal, being delayed until the second invocation (setarg(Pos1,Last1,NewLast1) in the second clause for take_first_stray_1/4).
This is fairly straightforward and is the sort of thing done in LRLR. So we do not discuss it here; see Section 6.2.6 for further details.
By contrast, LRLR allocates [H|NT] and binds NT in the recursive call for a total of two stores (initialization and binding) in the second field as compared with UIP's one.
The structural reuse problem formalizes LRLR. We show that the structural reuse problem remains NP-complete when reuse is simple.
To compare the performance of LRLR and UIP code against standard, untransformed code, we measured the runtimes of 16 different programs.
Performance Comparison of Standard Prolog, LRLR, UIP Using setarg/3, and UIP Using Macros.
Of course, this is easily remedied by either UIP or LRLR. It has the advantage that the Aquarius compiler can detect that no choicepoints need be created.
For all the benchmarks, UIP implemented by using macros (labeled "w/macros" in Table I) lead to more speedup over the standard code than did LRLR. This is what we expected, since LRLR performs at least as many destructive updates as UIP.