Changeset fa8d17f for doc/theses


Ignore:
Timestamp:
Aug 17, 2025, 9:33:48 PM (5 weeks ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
master
Children:
6fe4a7f
Parents:
b8ef863
Message:

more proofreading of list chapter

File:
1 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/mike_brooks_MMath/list.tex

    rb8ef863 rfa8d17f  
    8888\subsection{Core Design Issues}
    8989
    90 The doubly-linked list attaches links intrusively, supports multiple link directions, integrates with user code via the type system, treats its ends uniformly, and identifies a list using an explicit head.
     90The doubly-linked list attaches links intrusively, supports multiple link axes, integrates with user code via the type system, treats its ends uniformly, and identifies a list using an explicit head.
    9191This design covers system and data management issues stated in \VRef{toc:lst:issue}.
    9292
     
    101101\begin{figure}
    102102    \lstinput{20-30}{lst-features-intro.run.cfa}
    103     \caption[Multiple link directions in \CFA list library]{
     103    \caption[Multiple link axes in \CFA list library]{
    104104        Demonstration of the running \lstinline{req} example, done using the \CFA list library.
    105105        This example is equivalent to the three approaches in \VRef[Figure]{fig:lst-issues-attach}.
     
    128128\end{figure}
    129129
    130 \VRef[Figure]{fig:lst-features-multidir} shows how the \CFA library supports multi-inline links, so a node can be on one or more lists simultaneously.
     130\VRef[Figure]{fig:lst-features-multidir} shows how the \CFA library supports multi-inline links, so a node can be on one or more lists simultaneously (axes).
    131131The declaration of @req@ has two inline-inheriting @dlink@ occurrences.
    132132The first of these gives a type named @req.by_pri@, @req@ inherits from it, and it inherits from @dlink@.
     
    150150
    151151\caption{
    152         Demonstration of multiple static link directions done in the \CFA list library.
     152        Demonstration of multiple static link axes done in the \CFA list library.
    153153        The right example is from \VRef[Figure]{fig:lst-issues-multi-static}.
    154154                The left \CFA example does the same job.
     
    158158
    159159The list library also supports the common case of single directionality more naturally than LQ. 
    160 Returning to \VRef[Figure]{fig:lst-features-intro}, the single-direction list has no contrived name for the link direction as it uses the default type in the definition of @dlist@;
     160Returning to \VRef[Figure]{fig:lst-features-intro}, the single-axis list has no contrived name for the link axis as it uses the default type in the definition of @dlist@;
    161161in contrast, the LQ list in \VRef[Figure]{f:Intrusive} adds the unnecessary field name @d@.
    162 In \CFA, a single direction list sets up a single inheritance with @dlink@, and the default list axis is to itself.
    163 
    164 When operating on a list with several directions and operations that do not take the list head, the list axis can be ambiguous.
     162In \CFA, a single axis list sets up a single inheritance with @dlink@, and the default list axis is to itself.
     163
     164When operating on a list with several axes and operations that do not take the list head, the list axis can be ambiguous.
    165165For example, a call like @insert_after( r1, r2 )@ does not have enough information to know which axes to select implicitly.
    166166Is @r2@ supposed to be the next-priority request after @r1@, or is @r2@ supposed to join the same-requester list of @r1@?
     
    171171To mitigate this issue, the list library provides a hook for applying the \CFA language's scoping and priority rules.
    172172\begin{cfa}
    173 with ( DLINK_VIA(  req, req.pri ) ) insert_after( r1, r2 );
     173with ( DLINK_VIA( req, req.pri ) ) insert_after( r1, r2 );
    174174\end{cfa}
    175175Here, the @with@ statement opens the scope of the object type for the expression;
    176 hence, the @DLINK_VIA@ result causes one of the list directions to become a more attractive candidate to \CFA's overload resolution.
     176hence, the @DLINK_VIA@ result causes one of the list axes to become a more attractive candidate to \CFA's overload resolution.
    177177This boost can be applied across multiple statements in a block or an entire function body.
    178178\begin{cquote}
     
    192192\end{tabular}
    193193\end{cquote}
    194 Within the @with@, the code acts as if there is only one list direction.
     194Within the @with@, the code acts as if there is only one list axis, without explicit casting.
    195195
    196196Unlike the \CC template container-types, the \CFA library works completely within the type system;
    197197both @dlink@ and @dlist@ are ordinary types, not language macros.
    198198There is no textual expansion other than header-included static-inline function for performance.
    199 Hence, errors in user code are reported only with mention of the library's declarations.
     199Hence, errors in user code are reported only with mention of the library's declarations, versus long template names in error messages.
    200200Finally, the library is separately compiled from the usage code, modulo inlining.
    201201
     
    361361\end{tabular}
    362362\end{cquote}
    363 Iterating forward and reverse through the entire list using the shorthand start at the list head and pick a direction.
     363Iterating forward and reverse through the entire list using the shorthand start at the list head and pick a axis.
    364364In this case, @advance@ and @recede@ return a boolean, like \CC @while ( cin >> i )@.
    365365\begin{cquote}
     
    629629After each round, a counter is incremented by $n$ (for throughput).
    630630Time is measured outside the loop because a large $n$ can overrun the time duration before the @CONTINUE@ flag is tested.
     631Hence, there is minimum of one outer (@CONTINUE@) loop iteration for large lists.
    631632The loop duration is divided by the counter and this throughput is reported.
    632633In a scatter-plot, each dot is one throughput, which means insert + remove + harness overhead.
     
    636637To test list operations, the experiment performs the inserts/removes in different patterns, \eg insert and remove from front, insert from front and remove from back, random insert and remove, \etc.
    637638Unfortunately, the @std::list@ does \emph{not} support direct insert/remove from a node without an iterator, \ie no @erase( node )@, even though the list is doubly-linked.
    638 To eliminate this additional cost in the harness, a trick is used for random insertions without replacement.
    639 The @i@ fields in each node are initialized from @0..n-1@, these @i@ values are then shuffled in the nodes, and the @i@ value is used to represent an indirection to that node for insertion, so the nodes are inserted in random order, and hence, removed in th same random order.
     639To eliminate the iterator, a trick is used for random insertions without replacement.
     640The @i@ fields in each node are initialized from @0..n-1@.
     641These @i@ values are then shuffled in the nodes, and the @i@ value is used to represent an indirection to that node for insertion.
     642hence, the nodes are inserted in random order and removed in the same random order.
    640643$\label{p:Shuffle}$
    641644\begin{c++}
     
    644647
    645648        while ( CONTINUE ) {
    646                 for ( i; n ) insert_first( lst, nodes[ @nodes[i].i@ ] ); $\C{// build up}$
     649                for ( i; n ) {
     650                        node_t & temp = nodes[ nodes[i].i ];
     651                        @temp.j = 0;@                           $\C{// touch random node for wrapped nodes}$
     652                        insert_first( lst, temp );
     653                }
     654                insert_first( lst, nodes[ @nodes[i].i@ ] ); $\C{// build up}$
    647655                for ( i; n ) pass( &remove_first( lst ) );      $\C{// tear down}$
    648656                totalOpsDone += n;
    649657        }
    650658\end{c++}
    651 This approach works across intrusive and wrapped lists.
     659Note, insertion is traversing the list of nodes linearly, @node[i]@.
     660For intrusive lists, the inserted (random) node is always touched because its link fields are read/written for insertion into the list.
     661Hence, the array of nodes is being accessed both linearly and randomly during the traversal.
     662For wrapped lists, the wrapped nodes are traversed linearly but the random node is not accessed, only a pointer to it is inserted into the linearly accessed wrapped node.
     663Hence, the traversal is the same as the non-random traversal above.
     664To level the experiments, an explicit access to the random node is inserted after the insertion, @temp.j = 0@, for the wrapped experiment.
     665Furthermore, it is rare to insert/remove nodes and not access them.
    652666
    653667% \emph{Interleaving} allows for movements other than pure stack and queue.
     
    770784As a result, these memory layouts result in high spatial and temporal locality for both kinds of lists during the linear array traversal.
    771785With address look-ahead, the hardware does an excellent job of managing the multi-level cache.
    772 Hence, performance is largely constant for both kinds of lists, until cache and NUMA boundaries are crossed for longer lists and the costs increase consistently for both kinds of lists.
    773 
    774 In detail, \VRef[Figure]{f:Shuffled} shows shuffle insertion of all the nodes and then linear removal, both in the same direction.
     786Hence, performance is largely constant for both kinds of lists, until L3 cache and NUMA boundaries are crossed for longer lists and the costs increase consistently for both kinds of lists.
     787
     788In detail, \VRef[Figure]{f:Shuffled} shows shuffle insertion and removal of the nodes.
    775789As for linear, there are issues with the wrapped list and memory allocation.
    776790For intrusive lists, it is possible to link the nodes randomly, so consecutive nodes in memory seldom point at adjacent nodes.
Note: See TracChangeset for help on using the changeset viewer.