Changeset fa8d17f for doc/theses
- Timestamp:
- Aug 17, 2025, 9:33:48 PM (5 weeks ago)
- Branches:
- master
- Children:
- 6fe4a7f
- Parents:
- b8ef863
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mike_brooks_MMath/list.tex
rb8ef863 rfa8d17f 88 88 \subsection{Core Design Issues} 89 89 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.90 The 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. 91 91 This design covers system and data management issues stated in \VRef{toc:lst:issue}. 92 92 … … 101 101 \begin{figure} 102 102 \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]{ 104 104 Demonstration of the running \lstinline{req} example, done using the \CFA list library. 105 105 This example is equivalent to the three approaches in \VRef[Figure]{fig:lst-issues-attach}. … … 128 128 \end{figure} 129 129 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). 131 131 The declaration of @req@ has two inline-inheriting @dlink@ occurrences. 132 132 The first of these gives a type named @req.by_pri@, @req@ inherits from it, and it inherits from @dlink@. … … 150 150 151 151 \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. 153 153 The right example is from \VRef[Figure]{fig:lst-issues-multi-static}. 154 154 The left \CFA example does the same job. … … 158 158 159 159 The 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 directionas it uses the default type in the definition of @dlist@;160 Returning 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@; 161 161 in contrast, the LQ list in \VRef[Figure]{f:Intrusive} adds the unnecessary field name @d@. 162 In \CFA, a single directionlist 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.162 In \CFA, a single axis 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 axes and operations that do not take the list head, the list axis can be ambiguous. 165 165 For example, a call like @insert_after( r1, r2 )@ does not have enough information to know which axes to select implicitly. 166 166 Is @r2@ supposed to be the next-priority request after @r1@, or is @r2@ supposed to join the same-requester list of @r1@? … … 171 171 To mitigate this issue, the list library provides a hook for applying the \CFA language's scoping and priority rules. 172 172 \begin{cfa} 173 with ( DLINK_VIA( 173 with ( DLINK_VIA( req, req.pri ) ) insert_after( r1, r2 ); 174 174 \end{cfa} 175 175 Here, 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.176 hence, the @DLINK_VIA@ result causes one of the list axes to become a more attractive candidate to \CFA's overload resolution. 177 177 This boost can be applied across multiple statements in a block or an entire function body. 178 178 \begin{cquote} … … 192 192 \end{tabular} 193 193 \end{cquote} 194 Within the @with@, the code acts as if there is only one list direction.194 Within the @with@, the code acts as if there is only one list axis, without explicit casting. 195 195 196 196 Unlike the \CC template container-types, the \CFA library works completely within the type system; 197 197 both @dlink@ and @dlist@ are ordinary types, not language macros. 198 198 There 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 .199 Hence, errors in user code are reported only with mention of the library's declarations, versus long template names in error messages. 200 200 Finally, the library is separately compiled from the usage code, modulo inlining. 201 201 … … 361 361 \end{tabular} 362 362 \end{cquote} 363 Iterating forward and reverse through the entire list using the shorthand start at the list head and pick a direction.363 Iterating forward and reverse through the entire list using the shorthand start at the list head and pick a axis. 364 364 In this case, @advance@ and @recede@ return a boolean, like \CC @while ( cin >> i )@. 365 365 \begin{cquote} … … 629 629 After each round, a counter is incremented by $n$ (for throughput). 630 630 Time is measured outside the loop because a large $n$ can overrun the time duration before the @CONTINUE@ flag is tested. 631 Hence, there is minimum of one outer (@CONTINUE@) loop iteration for large lists. 631 632 The loop duration is divided by the counter and this throughput is reported. 632 633 In a scatter-plot, each dot is one throughput, which means insert + remove + harness overhead. … … 636 637 To 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. 637 638 Unfortunately, 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. 639 To eliminate the iterator, a trick is used for random insertions without replacement. 640 The @i@ fields in each node are initialized from @0..n-1@. 641 These @i@ values are then shuffled in the nodes, and the @i@ value is used to represent an indirection to that node for insertion. 642 hence, the nodes are inserted in random order and removed in the same random order. 640 643 $\label{p:Shuffle}$ 641 644 \begin{c++} … … 644 647 645 648 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}$ 647 655 for ( i; n ) pass( &remove_first( lst ) ); $\C{// tear down}$ 648 656 totalOpsDone += n; 649 657 } 650 658 \end{c++} 651 This approach works across intrusive and wrapped lists. 659 Note, insertion is traversing the list of nodes linearly, @node[i]@. 660 For intrusive lists, the inserted (random) node is always touched because its link fields are read/written for insertion into the list. 661 Hence, the array of nodes is being accessed both linearly and randomly during the traversal. 662 For 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. 663 Hence, the traversal is the same as the non-random traversal above. 664 To level the experiments, an explicit access to the random node is inserted after the insertion, @temp.j = 0@, for the wrapped experiment. 665 Furthermore, it is rare to insert/remove nodes and not access them. 652 666 653 667 % \emph{Interleaving} allows for movements other than pure stack and queue. … … 770 784 As a result, these memory layouts result in high spatial and temporal locality for both kinds of lists during the linear array traversal. 771 785 With 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.786 Hence, 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 788 In detail, \VRef[Figure]{f:Shuffled} shows shuffle insertion and removal of the nodes. 775 789 As for linear, there are issues with the wrapped list and memory allocation. 776 790 For 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.