Changeset 06d75931 for doc/theses
- Timestamp:
- Oct 26, 2024, 8:17:20 AM (14 months ago)
- Branches:
- master
- Children:
- 14c31eb
- Parents:
- 3a08cb1 (diff), d031f7f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- doc/theses/mike_brooks_MMath
- Files:
-
- 2 edited
-
array.tex (modified) (1 diff)
-
uw-ethesis.tex (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/mike_brooks_MMath/array.tex
r3a08cb1 r06d75931 502 502 \end{itemize} 503 503 504 TODO: summarize the C rules and add the case-comparison table 505 506 TODO: Discuss Recourse 507 508 TODO: Discuss dimension hoisting, which addresses the challenge of extra unification for cost calculation 504 The traditional C rules are: 505 \begin{itemize} 506 \item 507 Reject a Statically Evaluable pair, if the expressions have two different values. 508 \item 509 Otherwise, accept. 510 \end{itemize} 511 512 513 \newcommand{\falsealarm}{{\color{orange}\small{*}}} 514 \newcommand{\allowmisuse}{{\color{red}\textbf{!}}} 515 \newcommand{\cmark}{\ding{51}} % from pifont 516 \newcommand{\xmark}{\ding{55}} 517 \begin{figure} 518 \begin{tabular}{@{}l@{\hspace{16pt}}c@{\hspace{8pt}}c@{\hspace{16pt}}c@{\hspace{8pt}}c@{\hspace{16pt}}c} 519 & \multicolumn{2}{c}{\underline{Values Equal}} 520 & \multicolumn{2}{c}{\underline{Values Unequal}} 521 & \\ 522 \textbf{Case} & C & \CFA & C & \CFA & Compat. \\ 523 Both Statically Evaluable, Same Symbol & Accept & Accept & & & \cmark \\ 524 Both Statically Evaluable, Different Symbols & Accept & Accept & Reject & Reject & \cmark \\ 525 Both Dynamic but Stable, Same Symbol & Accept & Accept & & & \cmark \\ 526 Both Dynamic but Stable, Different Symbols & Accept & Reject\,\falsealarm & Accept\,\allowmisuse & Reject & \xmark \\ 527 Both Potentially Unstable, Same Symbol & Accept & Reject\,\falsealarm & Accept\,\allowmisuse & Reject & \xmark \\ 528 Any other grouping, Different Symbol & Accept & Reject\,\falsealarm & Accept\,\allowmisuse & Reject & \xmark 529 \end{tabular} 530 531 \vspace{12pt} 532 \noindent\textbf{Legend:} 533 \begin{itemize} 534 \item 535 Each row gives the treatment of a test harness of the form 536 \begin{cfa} 537 float x[ expr1 ]; 538 float (*xp)[ expr2 ] = &x; 539 \end{cfa} 540 where \lstinline{expr1} and \lstinline{expr2} are metavariables varying according to the row's Case. 541 Each row's claim applies to other harnesses too, including, 542 \begin{itemize} 543 \item 544 calling a function with a paramter like \lstinline{x} and an argument of the \lstinline{xp} type, 545 \item 546 assignment in place of initialization, 547 \item 548 using references in place of pointers, and 549 \item 550 for the \CFA array, calling a polymorphic function on two \lstinline{T}-typed parameters with \lstinline{&x}- and \lstinline{xp}-typed arguments. 551 \end{itemize} 552 \item 553 Each case's claim is symmetric (swapping \lstinline{expr1} with \lstinline{expr2} has no effect), 554 even though most test harnesses are asymetric. 555 \item 556 The table treats symbolic identity (Same/Different on rows) 557 apart from value eqality (Equal/Unequal on columns). 558 \begin{itemize} 559 \item 560 The expressions \lstinline{1}, \lstinline{0+1} and \lstinline{n} 561 (where \lstinline{n} is a variable with value 1), 562 are all different symbols with the value 1. 563 \item 564 The column distinction expresses ground truth about whether an omniscient analysis should accept or reject. 565 \item 566 The row distinction expresses the simple static factors used by today's analyses. 567 \end{itemize} 568 \item 569 Accordingly, every Reject under Values Equal is a false alarm (\falsealarm), 570 while every Accept under Values Unequal is an allowed misuse (\allowmisuse). 571 \end{itemize} 572 \caption{Case comparison for array type compatibility, given pairs of dimension expressions. 573 TODO: get Peter's LaTeX help on overall appearance, probably including column spacing/centering and bullet indentation.} 574 \label{f:DimexprRuleCompare} 575 \end{figure} 576 577 578 Figure~\ref{f:DimexprRuleCompare} gives a case-by-case comparison of the consequences of these rule sets. 579 It demonstrates that the \CFA false alarms occur in the same cases as C treats unsafely. 580 It also shows that C-incompatibilities only occur in cases that C treats unsafely. 581 582 583 The conservatism of the new rule set can leave a programmer needing a recourse, 584 when needing to use a dimension expression whose stability argument 585 is more subtle than current-state analysis. 586 This recourse is to declare an explicit constant for the dimension value. 587 Consider these two dimension expressions, 588 whose reuses are rejected by the blunt current-state rules: 589 \begin{cfa} 590 void f( int & nr, const int nv ) { 591 float x[nr]; 592 float (*xp)[nr] = & x; // reject: nr varying (no references) 593 float y[nv + 1]; 594 float (*yp)[nv + 1] = & y; // reject: ?+? unpredicable (no functions) 595 } 596 \end{cfa} 597 Yet, both dimension expressions are reused safely. 598 (The @nr@ reference is never written, not volatile 599 and control does not leave the function between the uses. 600 The name @?+?@ resolves to a function that is quite predictable.) 601 The programmer here can add the constant declarations: 602 \begin{cfa} 603 void f( int & nr, const int nv ) { 604 @const int nx@ = nr; 605 float x[nx]; 606 float (*xp)[nx] = & x; // acept 607 @const int ny@ = nv + 1; 608 float y[ny]; 609 float (*yp)[ny] = & y; // accept 610 } 611 \end{cfa} 612 The result is the originally intended semantics, 613 achieved by adding a superfluous ``snapshot it as of now'' directive. 614 615 The snapshotting trick is also used by the translation, though to achieve a different outcome. 616 Rather obviously, every array must be subscriptable, even a bizzarre one: 617 \begin{cfa} 618 array( float, rand(10) ) x; 619 x[0]; // 10% chance of bound-check failure 620 \end{cfa} 621 Less obvious is that the mechanism of subscripting is a function call, 622 which must communicate length accurately. 623 The bound-check above (callee logic) must use the actual allocated length of @x@, 624 without mistakenly reevaluating the dimension expression, @rand(10)@. 625 Adjusting the example to make the function's use of length more explicit: 626 \begin{cfa} 627 forall ( T * ) 628 void f( T * x ) { sout | sizeof(*x); } 629 float x[ rand(10) ]; 630 f( x ); 631 \end{cfa} 632 Considering that the partly translated function declaration is, loosely, 633 \begin{cfa} 634 void f( size_t __sizeof_T, void * x ) { sout | __sizeof_T; } 635 \end{cfa} 636 the translated call must not go like: 637 \begin{cfa} 638 float x[ rand(10) ]; 639 f( rand(10), &x ); 640 \end{cfa} 641 Rather, its actual translation is like: 642 \begin{cfa} 643 size_t __dim_x = rand(10); 644 float x[ __dim_x ]; 645 f( __dim_x, &x ); 646 \end{cfa} 647 The occurrence of this dimension hoisting during translation was present in the preexisting \CFA compiler. 648 But its cases were buggy, particularly with determining, ``Can hoisting be skipped here?'' 649 For skipping this hoisting is clearly desirable in some cases, 650 not the least of which is when the programmer has already done so manually. 651 My work includes getting these cases right, harmonized with the accept/reject criteria, and tested. 652 653 654 655 TODO: Discuss the interaction of this dimension hoisting with the challenge of extra unification for cost calculation 509 656 510 657 \section{Multidimensional Arrays} -
doc/theses/mike_brooks_MMath/uw-ethesis.tex
r3a08cb1 r06d75931 87 87 \usepackage{graphicx} 88 88 \usepackage{tabularx} 89 \usepackage{pifont} 89 90 \usepackage[labelformat=simple,aboveskip=0pt,farskip=0pt,font=normalsize]{subfig} 90 91 \renewcommand\thesubfigure{(\alph{subfigure})}
Note:
See TracChangeset
for help on using the changeset viewer.