1
0
Fork 0
cl-sites/www.cs.cmu.edu/Groups/AI/html/cltl/clm/node356.html
2023-10-25 11:23:21 +02:00

66 lines
4.3 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3O//DTD W3 HTML 2.0//EN">
<!Converted with LaTeX2HTML 0.6.5 (Tue Nov 15 1994) by Nikos Drakos (nikos@cbl.leeds.ac.uk), CBLU, University of Leeds >
<HEAD>
<TITLE>A.3. Optimization</TITLE>
</HEAD>
<BODY>
<meta name="description" value=" Optimization">
<meta name="keywords" value="clm">
<meta name="resource-type" value="document">
<meta name="distribution" value="global">
<P>
<b>Common Lisp the Language, 2nd Edition</b>
<BR> <HR><A NAME=tex2html6150 HREF="node357.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html6148 HREF="node347.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html6142 HREF="node355.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html6152 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html6153 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html6151 HREF="node357.html"> Basic Restrictions</A>
<B>Up:</B> <A NAME=tex2html6149 HREF="node347.html"> Series</A>
<B> Previous:</B> <A NAME=tex2html6143 HREF="node355.html"> Alteration of Series</A>
<HR> <P>
<H1><A NAME=SECTION003430000000000000000>A.3. Optimization</A></H1>
<P>
<img align=bottom alt="change_begin" src="gif/change_begin.gif"><br>
<A NAME=SERIESESECTION>Series</A>
expressions are transformed into loops by pipelining them-the
computation is converted from a form where entire series are computed one
after the other to a form where the series are incrementally computed in
parallel. In the resulting loop, each individual element is computed just
once, used, and then discarded before the next element is computed. For
this pipelining to be possible, a number of restrictions have to be
satisfied. Before these restrictions are explained, it will be useful to consider
a related issue.
<P>
The composition of two series functions cannot be pipelined unless the
destination function consumes series elements in the same order that the source
function produces them. Taken together, the series functions guarantee
that this will always be true, because they all follow the same fixed
processing order. In particular, they are all <i>preorder</i>
functions-they process the elements of their series inputs and outputs in
ascending order starting with the first element. Further, while it is easy
for users to define new series functions, it is impossible to define one
that is not a preorder function.
<P>
It turns out that most series operations can easily be implemented in a
preorder fashion, the most notable exceptions being reversal and sorting. As
a result, little is lost by outlawing non-preorder series functions. If some
non-preorder operation has to be applied to a series, the series can be
collected into a list or vector and the operation applied to this new data
structure. (This is inefficient, but no less efficient than what would be
required if non-preorder series functions were supported.)
<br><img align=bottom alt="change_end" src="gif/change_end.gif">
<P>
<HR>
<UL>
<LI> <A NAME=tex2html6154 HREF="node357.html#SECTION003431000000000000000"> Basic Restrictions</A>
<LI> <A NAME=tex2html6155 HREF="node358.html#SECTION003432000000000000000"> Constraint Cycles</A>
<LI> <A NAME=tex2html6156 HREF="node359.html#SECTION003433000000000000000"> Defining New Series Functions</A>
<LI> <A NAME=tex2html6157 HREF="node360.html#SECTION003434000000000000000"> Declarations</A>
</UL>
<BR> <HR><A NAME=tex2html6150 HREF="node357.html"><IMG ALIGN=BOTTOM ALT="next" SRC="icons/next_motif.gif"></A> <A NAME=tex2html6148 HREF="node347.html"><IMG ALIGN=BOTTOM ALT="up" SRC="icons/up_motif.gif"></A> <A NAME=tex2html6142 HREF="node355.html"><IMG ALIGN=BOTTOM ALT="previous" SRC="icons/previous_motif.gif"></A> <A NAME=tex2html6152 HREF="node1.html"><IMG ALIGN=BOTTOM ALT="contents" SRC="icons/contents_motif.gif"></A> <A NAME=tex2html6153 HREF="index.html"><IMG ALIGN=BOTTOM ALT="index" SRC="icons/index_motif.gif"></A> <BR>
<B> Next:</B> <A NAME=tex2html6151 HREF="node357.html"> Basic Restrictions</A>
<B>Up:</B> <A NAME=tex2html6149 HREF="node347.html"> Series</A>
<B> Previous:</B> <A NAME=tex2html6143 HREF="node355.html"> Alteration of Series</A>
<HR> <P>
<HR>
<P><ADDRESS>
AI.Repository@cs.cmu.edu
</ADDRESS>
</BODY>