Changeset 75d874a


Ignore:
Timestamp:
Mar 24, 2023, 4:51:11 PM (13 months ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, master
Children:
512d937c
Parents:
0e16a2d (diff), 1633e04 (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Files:
1 deleted
20 edited

Legend:

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

    r0e16a2d r75d874a  
    1313
    1414
    15 
    1615\section{Design Issues}
    1716\label{toc:lst:issue}
     
    2019
    2120All design-issue discussions assume the following invariants.
    22 They are stated here to clarify that none of the discussed design issues refers to one of these.
     21\PAB{They are stated here to clarify that none of the discussed design issues refers to one of these.}
    2322Alternatives to the assumptions are discussed under Future Work (Section~\ref{toc:lst:futwork}).
    2423\begin{itemize}
     
    3029          The system has freedom over how to represent these links.
    3130          The library is not providing applied wrapper operations that consume a user's hand-implemented list primitives.
    32     \item These issues are compared at a requirement/functional level.
     31    \item \PAB{These issues are compared at a requirement/functional level.}
    3332\end{itemize}
    3433
    3534Two preexisting linked-list libraries are used throughout, to show examples of the concepts being defined,
    3635and further libraries are introduced as needed.
    37 A general comparison of libraries' abilities is given under Related Work (Section~\ref{toc:lst:relwork}).
    3836\begin{description}
    3937    \item[LQ] Linux Queue library\cite{lst:linuxq} of @<sys/queue.h>@.
    4038    \item[STL] C++ Standard Template Library's @std::list@\cite{lst:stl}
    4139\end{description}
     40A general comparison of libraries' abilities is given under Related Work (Section~\ref{toc:lst:relwork}).
    4241
    4342The fictional type @req@ (request) is the user's payload in examples.
     
    5857
    5958The wrapped style admits the further distinction between wrapping a reference and wrapping a value.
    60 This distinction is pervasive in all STL collections; @list<req*>@ wraps a reference; @list<req>@ wraps a value.
    61 (For this discussion, @list<req&>@ is similar to @list<req*>@.)
     59This distinction is pervasive in all STL collections; @list<req *>@ wraps a reference; @list<req>@ wraps a value.
     60(For this discussion, @list<req &>@ is similar to @list<req *>@.)
    6261This difference is one of user style, not framework capability.
    63 
     62Figure~\ref{fig:lst-issues-attach} compares the three styles.
     63
     64\begin{comment}
    6465\begin{figure}
    6566    \begin{tabularx}{\textwidth}{Y|Y|Y}\lstinputlisting[language=C  , firstline=20, lastline=39]{lst-issues-intrusive.run.c}
     
    7778        (a) & (b) & (c)
    7879    \end{tabularx}
    79     \caption{
     80\caption{
    8081        Three styles of link attachment: (a)~intrusive, (b)~wrapped reference, and (c)~wrapped value.
    8182        The diagrams show the memory layouts that result after the code runs, eliding the head object \lstinline{reqs};
     
    8788        (TODO: cite? found in  /usr/include/c++/7/bits/stl\_list.h )
    8889    }
     90     \label{fig:lst-issues-attach}
     91\end{figure}
     92\end{comment}
     93
     94\begin{figure}
     95\centering
     96\newsavebox{\myboxA}                                    % used with subfigure
     97\newsavebox{\myboxB}
     98\newsavebox{\myboxC}
     99
     100\begin{lrbox}{\myboxA}
     101\begin{tabular}{@{}l@{}}
     102\lstinputlisting[language=C, firstline=20, lastline=39]{lst-issues-intrusive.run.c} \\
     103\ \\
     104\includegraphics[page=1]{lst-issues-attach.pdf}
     105\end{tabular}
     106\end{lrbox}
     107
     108\begin{lrbox}{\myboxB}
     109\begin{tabular}{@{}l@{}}
     110\lstinputlisting[language=C++, firstline=20, lastline=39]{lst-issues-wrapped-byref.run.cpp} \\
     111\ \\
     112\includegraphics[page=2]{lst-issues-attach.pdf}
     113\end{tabular}
     114\end{lrbox}
     115
     116\begin{lrbox}{\myboxC}
     117\begin{tabular}{@{}l@{}}
     118\lstinputlisting[language=C++, firstline=20, lastline=39]{lst-issues-wrapped-emplaced.run.cpp} \\
     119\ \\
     120\includegraphics[page=3]{lst-issues-attach.pdf}
     121\end{tabular}
     122\end{lrbox}
     123
     124\subfloat[Intrusive]{\label{f:Intrusive}\usebox\myboxA}
     125\hspace{10pt}
     126\vrule
     127\hspace{10pt}
     128\subfloat[Wrapped reference]{\label{f:WrappedRef}\usebox\myboxB}
     129\hspace{10pt}
     130\vrule
     131\hspace{10pt}
     132\subfloat[Wrapped value]{\label{f:WrappedValue}\usebox\myboxC}
     133
     134\caption{
     135        Three styles of link attachment: \protect\subref*{f:Intrusive}~intrusive, \protect\subref*{f:WrappedRef}~wrapped
     136        reference, and \protect\subref*{f:WrappedValue}~wrapped value.
     137        The diagrams show the memory layouts that result after the code runs, eliding the head object \lstinline{reqs};
     138        head objects are discussed in Section~\ref{toc:lst:issue:ident}.
     139        In \protect\subref*{f:Intrusive}, the field \lstinline{req.x} names a list direction;
     140        these are discussed in Section~\ref{toc:lst:issue:derection}.
     141        In \protect\subref*{f:WrappedRef} and \protect\subref*{f:WrappedValue}, the type \lstinline{node} represents a
     142        system-internal type, which is \lstinline{std::_List_node} in the GNU implementation.
     143        (TODO: cite? found in  /usr/include/c++/7/bits/stl\_list.h )
     144    }
    89145    \label{fig:lst-issues-attach}
    90146\end{figure}
    91 
    92 
    93 Figure~\ref{fig:lst-issues-attach} compares the three styles.
    94147
    95148The advantage of intrusive attachment is the control that it gives the user over memory layout.
     
    97150Both wrapped attachment styles imply system-induced heap allocations.
    98151Such an allocation has a lifetime that matches the item's membership in the list.
    99 In (a) and (b), one @req@ object can enter and leave a list many times.
    100 In (b), doing do implies a dynamic allocation for each time joining; in (a), it does not.
     152In \subref*{f:Intrusive} and \subref*{f:WrappedRef}, one @req@ object can enter and leave a list many times.
     153In \subref*{f:WrappedRef}, it implies a dynamic allocation/deallocation for each enter/leave; in \subref*{f:Intrusive}, it does not.
    101154
    102155A further aspect of layout control is allowing the user to specify the location of the link fields within the @req@ object.
     
    110163Another subtle advantage of intrusive arrangement is that
    111164a reference to a user-level item (@req@) is sufficient to navigate or manage the item's membership.
    112 In LQ, (a), a @req@ pointer is the right argument type for operations @LIST_NEXT@ or @LIST_REMOVE@;
     165In LQ, \subref*{f:Intrusive}, a @req@ pointer is the right argument type for operations @LIST_NEXT@ or @LIST_REMOVE@;
    113166there is no distinguishing a @req@ from ``a @req@ in a list.''
    114 The same is not true of STL, (b) or (c).
     167The same is not true of STL, \subref*{f:WrappedRef} or \subref*{f:WrappedValue}.
    115168There, the analogous operations work on a parameter of type @list<T>::iterator@;
    116169they are @iterator::operator++()@, @iterator::operator*()@, and @list::erase(iterator)@.
    117 There is no mapping from @req&@ to @list<req>::iterator@, except for linear search.
     170There is no mapping from @req &@ to @list<req>::iterator@, except for linear search.
    118171
    119172The advantage of wrapped attachment is the abstraction of a data item from its list membership(s).
    120173In the wrapped style, the @req@ type can come from a library that serves many independent uses,
    121174which generally have no need for listing.
    122 Then, a novel use can still put @req@ in a (further) list, without requiring any upstream change in the @re@ library.
     175Then, a novel use can still put @req@ in a (further) list, without requiring any upstream change in the @req@ library.
    123176In intrusive attachment, the ability to be listed must be planned during the definition of @req@.
    124 Similarly, style (b) allows for one @req@ to occur at several positions in one list.
    125 Styles (a) and (c) do not support this ability.
     177Similarly, style \subref*{f:WrappedRef} allows for one @req@ to occur at several positions in one list.
     178Styles \subref*{f:Intrusive} and \subref*{f:WrappedValue} do not support this ability.
     179\PAB{But style \subref*{f:WrappedValue} can sort of mimic this effect by have multiple copies of \lstinline{req} in the list, modulo changes to the copies are not seen by the original.}
    126180
    127181\begin{figure}
     
    135189        the LQ C macros do not expand to valid C++ when instantiated with template parameters---there is no \lstinline{struct El}.
    136190        When using a custom-patched version of LQ to work around this issue,
    137         the programs of Figure~\ref{fig:lst-issues-attach}~(b) and (c) work with this shim in place of real STL.
     191        the programs of Figure~\ref{f:WrappedRef} and \protect\subref*{f:WrappedValue} work with this shim in place of real STL.
    138192        Their executions lead to the same memory layouts.
    139193    }
     
    147201
    148202So intrusion is a lower-level listing primitive.
    149 And so, the system design choice is not between forcing users to use intrusion and forcing them to use wrapping.
     203And so, the system design choice is not between forcing users to use intrusion or wrapping.
    150204The choice is whether or not to provide access to an allocation-free layer of functionality.
    151205A wrapped-primitive library like STL forces users to incur the costs of wrapping, whether or not they access its benefits.
     
    153207
    154208
    155 
    156 
    157209\subsection{Directionality: Single vs.\ Multi-Static vs.\ Dynamic}
    158210\label{toc:lst:issue:derection}
    159211
     212\PAB{I'm not sure about the term \newterm{Directionality}. Directionality to me, means going forward or backwards through a list.
     213Would \newterm{dimensionality} work? Think of each list containing the node as a different dimension in which the node sits.}
     214
    160215Directionality deals with the question:
    161216In how many different lists can an item be stored, at a given time?
    162217
    163 
    164 Consider STL in the wrapped-value arrangement of Figure~\ref{fig:lst-issues-attach}~(c).
     218Consider STL in the wrapped-value arrangement of Figure~\ref{f:WrappedValue}.
    165219The STL API completely hides its @node@ type from a user; the user cannot configure this choice or impose a custom one.
    166220STL's @node@ type offers the sole set of links shown in the diagram.
    167 Therefore, every @req@ in existence was allocated either to belong to an occurrence of the diagrammed arrangement,
     221Therefore, every @req@ in existence is allocated either to belong to an occurrence of the diagrammed arrangement,
    168222or to be apart from all occurrences of it.
    169223In the first case, the @req@ belongs to exactly one list (of the style in question).
     
    171225
    172226\begin{figure}
    173     \label{fig:lst-issues-multi-static}
    174227    \parbox[t]{3.5in} {
    175228        \lstinputlisting[language=C++, firstline=20, lastline=60]{lst-issues-multi-static.run.c}
     
    187240        The zoomed-in diagram portion shows the field-level state that results from running the LQ code.
    188241    }
     242    \label{fig:lst-issues-multi-static}
    189243\end{figure}
    190244
     
    205259The corresponding flexibility of wrapped attachment means
    206260the STL wrapped-reference arrangement supports an item being a member of arbitrarily many lists.
    207 This support also applies to the hybrid in which an item's allocation is within a wrapped-value list,
     261This support also applies to the wrapped-value list because the @req@ is copied,
    208262but wrapped-reference lists provide further link directions.
     263\PAB{Explain how}
    209264STL with wrapped references supports dynamic link directions.
    210 
    211 When allowing multiple static directions,frameworks differ in their ergonomics for
    212 the typical case, when the user needs only one direction, vs.\ the atypical case, when the user needs several.
    213 
     265\PAB{Expand}
     266
     267When allowing multiple static directions, frameworks differ in their ergonomics for
     268the typical case: when the user needs only one direction, vs.\ the atypical case, when the user needs several.
    214269LQ's ergonomics are well-suited to the uncommon case of multiple list directions.
    215270Its intrusion declaration and insertion operation both use a mandatory explicit parameter naming the direction.
    216271This decision works well in Figure~\ref{fig:lst-issues-multi-static}, where the names @by_pri@ and @by_rqr@ work well,
    217 but it clutters Figure~\ref{fig:lst-issues-attach}~(a), where a contrived name must be invented and used.
    218 The example uses @x@; @reqs@ would be a more readily ignored choice.
     272but it clutters Figure~\ref{f:Intrusive}, where a contrived name must be invented and used.
     273The example uses @x@; @reqs@ would be a more readily ignored choice. \PAB{wording?}
    219274
    220275\uCpp offers an intrusive list that makes the opposite choice.  TODO: elaborate on inheritance for first direction and acrobatics for subsequent directions.
    221276
    222277
    223 
    224 
    225278\subsection{User integration: Preprocessed vs.\ Type-System Mediated}
    226279
    227280% example of poor error message due to LQ's preprocessed integration
    228 % programs/lst-issues-multi-static.run.c:46:1: error: expected identifier or ‘(’ before ‘do’
     281% programs/lst-issues-multi-static.run.c:46:1: error: expected identifier or '(' before 'do'
    229282%    46 | LIST_INSERT_HEAD(&reqs_rtr_42, &r42b, by_rqr);
    230283%       | ^~~~~~~~~~~~~~~~
     
    239292an item found in a list (type @req@, of variables like @r1@), and
    240293a list (type @reql@ or @list<req>@, of variables like @reqs@ or @reqs_rqr_42@).
    241 The latter type is a head, and these examples are of are headed lists.
     294\see{Figure~\ref{fig:lst-issues-attach} and Figure~\ref{fig:lst-issues-multi-static}}
     295The latter type is a head, and these examples are of headed lists.
    242296
    243297A bespoke ``pointer to next @req@'' implementation often omits the latter type.
     
    246300In headed thinking, there are length-zero lists (heads with no elements), and an element can be listed or not listed.
    247301In ad-hoc thinking, there are no length-zero lists and every element belongs to a list of length at least one.
     302\PAB{Create a figure for this.}
    248303
    249304By omitting the head, elements can enter into an adjacency relationship,
     
    283338identifies a list using an explicit head.
    284339
    285 
    286 \begin{figure}
    287     \label{fig:lst-features-intro}
    288     \lstinputlisting[language=CFA, firstline=20, lastline=32]{lst-features-intro.run.cfa}
    289     \caption[Multiple link directions in \CFA list library]{
    290         Demonstration of the running \lstinline{req} example, done using the \CFA list library\protect\footnotemark.
    291         This example does the same job that Figure~\ref{fig:lst-issues-attach} shows three ways.
    292     }
    293 \end{figure}
    294 \footnotetext{
     340The \CFA list library's version of the running @req@ example is in Figure~\ref{fig:lst-features-intro}.
     341Its link attachment is intrusive and the resulting memory layout is pure-stack, just as for the LQ version of Figure~\ref{f:Intrusive}.
     342The framework-provided type @dlink(...)@ provides the links.
     343The user inserts the links into the @req@ structure by using \CFA inline-inheritance (TODO: reference introduction).
     344Inline inheritance means the type of the field is @dlink(req)@, the field is unnamed, a reference to a @req@ is implicitly convertible to @dlink@.\footnote{
    295345    The \CFA list examples elide the \lstinline{P9_EMBEDDED} annotations that (TODO: xref P9E future work) proposes to obviate.
    296346    Thus, these examples illustrate a to-be state, free of what is to be historic clutter.
    297347    The elided portions are immaterial to the discussion and the examples work with the annotations provided.
    298     The \CFA test suite (TODO:cite?) includes equivalent demonstrations, with the annotations included.
    299 }.
    300 
    301 My \CFA list library's version of the running @req@ example is in Figure~\ref{fig:lst-features-intro}.
    302 Its link attachment is intrusive and the resulting memory layout is pure-stack, just as for the LQ version of Figure~\ref{fig:lst-issues-attach}-(a).
    303 The framework-provided type @dlink(-)@ provides the links.
    304 The user puts links into the @req@ structure by inline-inheriting (TODO: reference introduction) this type.
    305 Which means: the type of the field is @dlink(req)@; the field is unnamed; a reference to a @req@ is implicitly convertible to @dlink@.
    306 As these links have a nontrivial, user-specified location within the @req@ structure, this conversion also encapsulates the implied pointer arithmetic safely.
    307 
    308 \begin{figure}
    309     \label{fig:lst-features-multidir}
    310     \lstinputlisting[language=CFA, firstline=20, lastline=25]{lst-features-multidir.run.cfa}
     348    The \CFA test suite (TODO:cite?) includes equivalent demonstrations, with the annotations included.}
     349These links have a nontrivial, user-specified location within the @req@ structure;
     350this convention encapsulates the implied pointer arithmetic safely.
     351
     352\begin{figure}
     353    \lstinputlisting[language=CFA, firstline=20, lastline=32]{lst-features-intro.run.cfa}
     354    \caption[Multiple link directions in \CFA list library]{
     355        Demonstration of the running \lstinline{req} example, done using the \CFA list library.
     356        This example does the same job that Figure~\ref{fig:lst-issues-attach} shows three ways.
     357    }
     358    \label{fig:lst-features-intro}
     359\end{figure}
     360
     361\begin{figure}
     362\centering
     363\begin{tabular}{@{}ll@{}}
     364\begin{tabular}{@{}l@{}}
     365    \lstinputlisting[language=CFA, firstline=20, lastline=25]{lst-features-multidir.run.cfa} \\
    311366    \lstinputlisting[language=CFA, firstline=40, lastline=67]{lst-features-multidir.run.cfa}
    312     \caption{
     367    \end{tabular}
     368        &
     369        \lstinputlisting[language=C++, firstline=20, lastline=60]{lst-issues-multi-static.run.c}
     370        \end{tabular}
     371
     372\caption{
    313373        Demonstration of multiple static link directions done in the \CFA list library.
    314374        This example does the same job as Figure~\ref{fig:lst-issues-multi-static}.
    315375    }
    316 \end{figure}
    317 
    318 The \CFA library supports multi-static link directionality.  Figure~\ref{fig:lst-features-multidir} illustrates how.
     376    \label{fig:lst-features-multidir}
     377\end{figure}
     378
     379Figure~\ref{fig:lst-features-multidir} shows how the \CFA library supports multi-static link directionality.
    319380The declaration of @req@ now has two inline-inheriting @dlink@ occurrences.
    320 The first of these lines gives a type named @req.by_pri@; @req@ inherits from it; it inherits from @dlink@.
    321 The second line gives a similar @req.by_rqr@.
     381The first of these lines gives a type named @req.by_pri@, @req@ inherits from it, and it inherits from @dlink@.
     382The second line @req.by_rqr@ is similar to @req.by_pri@.
    322383Thus, there is a diamond, non-virtual, inheritance from @req@ to @dlink@, with @by_pri@ and @by_rqr@ being the mid-level types.
    323384Disambiguation occurs in the declarations of the list-head objects.
    324385The type of the variable @reqs_pri_global@ is @dlist(req, req.by_pri)@,
    325386meaning operations called on @reqs_pri_global@ are implicitly disambiguated.
    326 In the example, the calls @insert_first(reqs_pri_global, ...)@ imply, ``here, we're working by priority.''
     387In the example, the calls @insert_first(reqs_pri_global, ...)@ imply, ``here, we are working by priority.''
    327388
    328389The \CFA library also supports the common case, of single directionality, more naturally than LQ. 
    329390Figure~\ref{fig:lst-features-intro} shows a single-direction list done with no contrived name for the link direction,
    330 where Figure~\ref{fig:lst-issues-attach}-(a) adds the unnecessary name, @x@.
     391where Figure~\ref{f:Intrusive} adds the unnecessary name, @x@.
    331392In \CFA, a user doing a single direction (Figure~\ref{fig:lst-features-intro})
    332 sets up a simple inheritance with @dlink@, and declares a list head to have the simpler type @dlist(-)@.
     393sets up a simple inheritance with @dlink@, and declares a list head to have the simpler type @dlist(...)@.
    333394While a user doing multiple link directions (Figure~\ref{fig:lst-features-multidir})
    334 sets up a diamond inheritance with @dlink@, and declares a list head to have the more-informed type @dlist(-, DIR)@.
     395sets up a diamond inheritance with @dlink@, and declares a list head to have the more-informed type @dlist(..., DIR)@.
    335396
    336397The \CFA library offers a type-system mediated integration with user code.
     
    348409
    349410
    350 
    351 
    352 
    353411\subsection{Iteration}
    354412
  • doc/theses/mike_brooks_MMath/uw-ethesis.tex

    r0e16a2d r75d874a  
    6060% For hyperlinked PDF, suitable for viewing on a computer, use this:
    6161\documentclass[letterpaper,12pt,titlepage,oneside,final]{book}
     62\usepackage{times}
    6263\usepackage[T1]{fontenc}        % Latin-1 => 256-bit characters, => | not dash, <> not Spanish question marks
    6364
     
    8788\usepackage{comment} % Removes large sections of the document.
    8889\usepackage{tabularx}
    89 \usepackage{subfigure}
     90\usepackage[labelformat=simple,aboveskip=0pt,farskip=0pt,font=normalsize]{subfig}
     91\renewcommand\thesubfigure{(\alph{subfigure})}
    9092
    9193\usepackage{algorithm}
    9294\usepackage{algpseudocode}
    93 
    94 \usepackage{pbox}
    9595
    9696% Hyperlinks make it very easy to navigate an electronic document.
     
    117117    citecolor=blue,        % color of links to bibliography
    118118    filecolor=magenta,      % color of file links
    119     urlcolor=blue           % color of external links
     119    urlcolor=blue,           % color of external links
     120    breaklinks=true
    120121}
    121122\ifthenelse{\boolean{PrintVersion}}{   % for improved print quality, change some hyperref options
     
    180181\CFAStyle                                               % CFA code-style
    181182\lstset{language=CFA}                                   % default language
    182 \lstset{basicstyle=\linespread{0.9}\tt}                 % CFA typewriter font
     183\lstset{basicstyle=\linespread{0.9}\sf}                 % CFA typewriter font
    183184\lstset{inputpath={programs}}
    184185\newcommand{\PAB}[1]{{\color{red}PAB: #1}}
    185186
    186 
    187 \newcommand{\uCpp}{$\mu${C}{\kern-.1em\hbox{\large\texttt{+\kern-.25em+}}}}
     187\newcommand{\uCpp}{$\mu$\CC}
    188188
    189189%======================================================================
  • libcfa/src/bits/random.hfa

    r0e16a2d r75d874a  
    1010// Created On       : Fri Jan 14 07:18:11 2022
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar 20 10:01:40 2023
    13 // Update Count     : 180
     12// Last Modified On : Mon Mar 20 21:45:24 2023
     13// Update Count     : 186
    1414//
    1515
     
    131131#ifdef __cforall                                                                                // don't include in C code (invoke.h)
    132132
    133 // Splitmix64
    134133// https://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64
    135 // Splitmix64 is not recommended for demanding random number requirements,
    136 // but is often used to calculate initial states for other more complex
    137 // pseudo-random number generators.                             
     134//
     135// Splitmix64 is not recommended for demanding random number requirements, but is often used to calculate initial states
     136// for other more complex pseudo-random number generators (see https://prng.di.unimi.it).
     137// Also https://rosettacode.org/wiki/Pseudo-random_numbers/Splitmix64.
    138138static inline uint64_t splitmix64( uint64_t & state ) {
    139139    state += 0x9e3779b97f4a7c15;
     
    149149} // splitmix64_set_seed
    150150
    151 // Splitmix32
    152151// https://github.com/bryc/code/blob/master/jshash/PRNGs.md#splitmix32
    153 // Splitmix32 is not recommended for demanding random number requirements,
    154 // but is often used to calculate initial states for other more complex
    155 // pseudo-random number generators.
    156 // SplitMix32 is a 32 bit variant of Splitmix64
     152//
     153// Splitmix32 is not recommended for demanding random number requirements, but is often used to calculate initial states
     154// for other more complex pseudo-random number generators (see https://prng.di.unimi.it).
     155
    157156static inline uint32_t splitmix32( uint32_t & state ) {
    158157    state += 0x9e3779b9;
     
    169168
    170169#ifdef __SIZEOF_INT128__
    171         //--------------------------------------------------
    172         static inline uint64_t lehmer64( __uint128_t & state ) {
    173                 __uint128_t ret = state;
    174                 state *= 0x_da94_2042_e4dd_58b5;
    175                 return ret >> 64;
    176         } // lehmer64
    177 
    178         static inline void lehmer64_set_seed( __uint128_t & state, uint64_t seed ) {
    179                 // The seed needs to be coprime with the 2^64 modulus to get the largest period, so no factors of 2 in the seed.
    180                 state = seed;
    181                 lehmer64( state );                                                              // prime
    182         } // lehmer64_set_seed
    183 
    184         //--------------------------------------------------
    185         static inline uint64_t wyhash64( uint64_t & state ) {
    186                 uint64_t ret = state;
    187                 state += 0x_60be_e2be_e120_fc15;
    188                 __uint128_t tmp;
    189                 tmp = (__uint128_t) ret * 0x_a3b1_9535_4a39_b70d;
    190                 uint64_t m1 = (tmp >> 64) ^ tmp;
    191                 tmp = (__uint128_t)m1 * 0x_1b03_7387_12fa_d5c9;
    192                 uint64_t m2 = (tmp >> 64) ^ tmp;
    193                 return m2;
    194         } // wyhash64
     170//--------------------------------------------------
     171static inline uint64_t lehmer64( __uint128_t & state ) {
     172        __uint128_t ret = state;
     173        state *= 0x_da94_2042_e4dd_58b5;
     174        return ret >> 64;
     175} // lehmer64
     176
     177static inline void lehmer64_set_seed( __uint128_t & state, uint64_t seed ) {
     178        // The seed needs to be coprime with the 2^64 modulus to get the largest period, so no factors of 2 in the seed.
     179        state = splitmix64( seed );                                                     // prime
     180} // lehmer64_set_seed
     181
     182//--------------------------------------------------
     183static inline uint64_t wyhash64( uint64_t & state ) {
     184        uint64_t ret = state;
     185        state += 0x_60be_e2be_e120_fc15;
     186        __uint128_t tmp;
     187        tmp = (__uint128_t) ret * 0x_a3b1_9535_4a39_b70d;
     188        uint64_t m1 = (tmp >> 64) ^ tmp;
     189        tmp = (__uint128_t)m1 * 0x_1b03_7387_12fa_d5c9;
     190        uint64_t m2 = (tmp >> 64) ^ tmp;
     191        return m2;
     192} // wyhash64
     193
     194static inline void wyhash64_set_seed( uint64_t & state, uint64_t seed ) {
     195        state = splitmix64( seed );                                                     // prime
     196} // wyhash64_set_seed
    195197#endif // __SIZEOF_INT128__
    196198
     
    227229
    228230static inline void xoshiro256pp_set_seed( xoshiro256pp_t & state, uint64_t seed ) {
    229     // these are done explicitly in this order to attain repeatable seeding.
    230     // do not call splitmix64 directly in the state init since order of argument evaluation
    231     // may not be consistent leading to irreproducible seeding
    232     uint64_t seed1 = splitmix64( seed );
     231    // To attain repeatable seeding, compute seeds separately because the order of argument evaluation is undefined.
     232    uint64_t seed1 = splitmix64( seed );                                // prime
    233233    uint64_t seed2 = splitmix64( seed );
    234234    uint64_t seed3 = splitmix64( seed );
    235235    uint64_t seed4 = splitmix64( seed );
    236236        state = (xoshiro256pp_t){ seed1, seed2, seed3, seed4 };
    237         xoshiro256pp( state );                                                          // prime
    238237} // xoshiro256pp_set_seed
    239238
     
    269268
    270269static inline void xoshiro128pp_set_seed( xoshiro128pp_t & state, uint32_t seed ) {
    271     // these are done explicitly in this order to attain repeatable seeding.
    272     // do not call splitmix32 directly in the state init since order of argument evaluation
    273     // may not be consistent leading to irreproducible seeding
    274     uint32_t seed1 = splitmix32( seed );
     270    // To attain repeatable seeding, compute seeds separately because the order of argument evaluation is undefined.
     271    uint32_t seed1 = splitmix32( seed );                                // prime
    275272    uint32_t seed2 = splitmix32( seed );
    276273    uint32_t seed3 = splitmix32( seed );
    277274    uint32_t seed4 = splitmix32( seed );
    278275        state = (xoshiro128pp_t){ seed1, seed2, seed3, seed4 };
    279         xoshiro128pp( state );                                                          // prime
    280276} // xoshiro128pp_set_seed
    281277
     
    290286
    291287static inline void xorshift_13_7_17_set_seed( uint64_t & state, uint64_t seed ) {
    292         state = seed;
    293         xorshift_13_7_17( state );                                                      // prime
     288        state = splitmix64( seed );                                                     // prime
    294289} // xorshift_13_7_17_set_seed
    295290
     
    308303
    309304static inline void xorshift_6_21_7_set_seed( uint32_t & state, uint32_t seed ) {
    310         state = seed;
    311         xorshift_6_21_7( state );                                                       // prime
     305    state = splitmix32( seed );                                                 // prime
    312306} // xorshift_6_21_7_set_seed
    313307
     
    323317
    324318static inline void xorshift_12_25_27_set_seed( uint64_t & state, uint64_t seed ) {
    325         state = seed;
    326         xorshift_12_25_27( state );                                                     // prime
     319        state = splitmix64( seed );                                                     // prime
    327320} // xorshift_12_25_27_set_seed
    328321
     
    345338
    346339static inline void kiss_64_set_seed( kiss_64_t & rs, uint64_t seed ) with(rs) {
    347         z = 1; w = 1; jsr = 4; jcong = seed;
    348         kiss_64( rs );                                                                          // prime
     340        z = 1; w = 1; jsr = 4; jcong = splitmix64( seed );      // prime
    349341} // kiss_64_set_seed
    350342
     
    374366
    375367static inline void xorwow_set_seed( xorwow_t & rs, uint32_t seed ) {
    376     // these are done explicitly in this order to attain repeatable seeding.
    377     // do not call splitmix32 directly in the state init since order of argument evaluation
    378     // may not be consistent leading to irreproducible seeding
    379     uint32_t seed1 = splitmix32( seed );
     368    // To attain repeatable seeding, compute seeds separately because the order of argument evaluation is undefined.
     369    uint32_t seed1 = splitmix32( seed );                                // prime
    380370    uint32_t seed2 = splitmix32( seed );
    381371    uint32_t seed3 = splitmix32( seed );
    382372    uint32_t seed4 = splitmix32( seed );
    383373        rs = (xorwow_t){ seed1, seed2, seed3, seed4, 0 };
    384         xorwow( rs );                                                                           // prime
    385374} // xorwow_set_seed
    386375
     
    388377// Used in __tls_rand_fwd
    389378#define M  (1_l64u << 48_l64u)
    390 #define A  (25214903917_l64u)
    391 #define AI (18446708753438544741_l64u)
     379#define A  (25_214_903_917_l64u)
     380#define AI (18_446_708_753_438_544_741_l64u)
    392381#define C  (11_l64u)
    393382#define D  (16_l64u)
  • libcfa/src/concurrency/channel.hfa

    r0e16a2d r75d874a  
    22
    33#include <locks.hfa>
    4 
    5 struct no_reacq_lock {
    6     inline exp_backoff_then_block_lock;
    7 };
    8 
    9 // have to override these by hand to get around plan 9 inheritance bug where resolver can't find the appropriate routine to call
    10 static inline void   ?{}( no_reacq_lock & this ) { ((exp_backoff_then_block_lock &)this){}; }
    11 static inline bool   try_lock(no_reacq_lock & this) { return try_lock(((exp_backoff_then_block_lock &)this)); }
    12 static inline void   lock(no_reacq_lock & this) { lock(((exp_backoff_then_block_lock &)this)); }
    13 static inline void   unlock(no_reacq_lock & this) { unlock(((exp_backoff_then_block_lock &)this)); }
    14 static inline void   on_notify(no_reacq_lock & this, struct thread$ * t ) { on_notify(((exp_backoff_then_block_lock &)this), t); }
    15 static inline size_t on_wait(no_reacq_lock & this) { return on_wait(((exp_backoff_then_block_lock &)this)); }
    16 // override wakeup so that we don't reacquire the lock if using a condvar
    17 static inline void   on_wakeup( no_reacq_lock & this, size_t recursion ) {}
    18 
    19 #define __PREVENTION_CHANNEL
     4#include <list.hfa>
     5
     6#define __COOP_CHANNEL
    207#ifdef __PREVENTION_CHANNEL
    218forall( T ) {
    229struct channel {
    23     size_t size;
    24     size_t front, back, count;
     10    size_t size, count, front, back;
    2511    T * buffer;
    2612    thread$ * chair;
     
    8773        return;
    8874    }
    89     else insert_( chan, elem );
     75    insert_( chan, elem );
    9076
    9177    unlock( mutex_lock );
     
    11096
    11197    // wait if buffer is empty, work will be completed by someone else
    112     if ( count == 0 ) { 
     98    if ( count == 0 ) {
    11399        chair = active_thread();
    114100        chair_elem = &retval;
     
    121107    memcpy((void *)&retval, (void *)&buffer[front], sizeof(T));
    122108    count -= 1;
    123     front = (front + 1) % size;
     109    front++;
     110    if ( front == size ) front = 0;
    124111
    125112    if ( chair != 0p ) {
     
    142129
    143130#ifdef __COOP_CHANNEL
     131
     132// link field used for threads waiting on channel
     133struct wait_link {
     134    // used to put wait_link on a dl queue
     135    inline dlink(wait_link);
     136
     137    // waiting thread
     138    struct thread$ * t;
     139
     140    // shadow field
     141    void * elem;
     142};
     143P9_EMBEDDED( wait_link, dlink(wait_link) )
     144
     145static inline void ?{}( wait_link & this, thread$ * t, void * elem ) {
     146    this.t = t;
     147    this.elem = elem;
     148}
     149
    144150forall( T ) {
     151
    145152struct channel {
    146153    size_t size;
    147154    size_t front, back, count;
    148155    T * buffer;
    149     fast_cond_var( no_reacq_lock ) prods, cons;
    150     no_reacq_lock mutex_lock;
     156    dlist( wait_link ) prods, cons;
     157    exp_backoff_then_block_lock mutex_lock;
    151158};
    152159
     
    164171static inline size_t get_count( channel(T) & chan ) with(chan) { return count; }
    165172static inline size_t get_size( channel(T) & chan ) with(chan) { return size; }
    166 static inline bool has_waiters( channel(T) & chan ) with(chan) { return !empty( cons ) || !empty( prods ); }
    167 static inline bool has_waiting_consumers( channel(T) & chan ) with(chan) { return !empty( cons ); }
    168 static inline bool has_waiting_producers( channel(T) & chan ) with(chan) { return !empty( prods ); }
     173static inline bool has_waiters( channel(T) & chan ) with(chan) { return !cons`isEmpty || !prods`isEmpty; }
     174static inline bool has_waiting_consumers( channel(T) & chan ) with(chan) { return !cons`isEmpty; }
     175static inline bool has_waiting_producers( channel(T) & chan ) with(chan) { return !prods`isEmpty; }
    169176
    170177static inline void insert_( channel(T) & chan, T & elem ) with(chan) {
     
    175182}
    176183
     184static inline void wake_one( dlist( wait_link ) & queue ) {
     185    wait_link & popped = try_pop_front( queue );
     186    unpark( popped.t );
     187}
     188
     189static inline void block( dlist( wait_link ) & queue, void * elem_ptr, exp_backoff_then_block_lock & lock ) {
     190    wait_link w{ active_thread(), elem_ptr };
     191    insert_last( queue, w );
     192    unlock( lock );
     193    park();
     194}
    177195
    178196static inline void insert( channel(T) & chan, T elem ) with(chan) {
     
    180198
    181199    // have to check for the zero size channel case
    182     if ( size == 0 && !empty( cons ) ) {
    183         memcpy((void *)front( cons ), (void *)&elem, sizeof(T));
    184         notify_one( cons );
     200    if ( size == 0 && !cons`isEmpty ) {
     201        memcpy(cons`first.elem, (void *)&elem, sizeof(T));
     202        wake_one( cons );
    185203        unlock( mutex_lock );
    186204        return;
     
    188206
    189207    // wait if buffer is full, work will be completed by someone else
    190     if ( count == size ) { 
    191         wait( prods, mutex_lock, (uintptr_t)&elem );
     208    if ( count == size ) {
     209        block( prods, &elem, mutex_lock );
    192210        return;
    193211    } // if
    194212
    195     if ( count == 0 && !empty( cons ) )
    196         // do waiting consumer work
    197         memcpy((void *)front( cons ), (void *)&elem, sizeof(T));
    198     else insert_( chan, elem );
     213    if ( count == 0 && !cons`isEmpty ) {
     214        memcpy(cons`first.elem, (void *)&elem, sizeof(T)); // do waiting consumer work
     215        wake_one( cons );
     216    } else insert_( chan, elem );
    199217   
    200     notify_one( cons );
    201218    unlock( mutex_lock );
    202219}
     
    207224
    208225    // have to check for the zero size channel case
    209     if ( size == 0 && !empty( prods ) ) {
    210         memcpy((void *)&retval, (void *)front( prods ), sizeof(T));
    211         notify_one( prods );
     226    if ( size == 0 && !prods`isEmpty ) {
     227        memcpy((void *)&retval, (void *)prods`first.elem, sizeof(T));
     228        wake_one( prods );
    212229        unlock( mutex_lock );
    213230        return retval;
     
    215232
    216233    // wait if buffer is empty, work will be completed by someone else
    217     if (count == 0) { 
    218         wait( cons, mutex_lock, (uintptr_t)&retval );
     234    if (count == 0) {
     235        block( cons, &retval, mutex_lock );
    219236        return retval;
    220237    }
     
    225242    front = (front + 1) % size;
    226243
    227     if (count == size - 1 && !empty( prods ) )
    228         insert_( chan, *((T *)front( prods )) );  // do waiting producer work
    229 
    230     notify_one( prods );
     244    if (count == size - 1 && !prods`isEmpty ) {
     245        insert_( chan, *(T *)prods`first.elem );  // do waiting producer work
     246        wake_one( prods );
     247    }
     248
    231249    unlock( mutex_lock );
    232250    return retval;
    233251}
    234 
    235252} // forall( T )
    236253#endif
  • libcfa/src/concurrency/io.cfa

    r0e16a2d r75d874a  
    295295                                // make sure the target hasn't stopped existing since last time
    296296                                HELP: if(target < ctxs_count) {
    297                                         // calculate it's age and how young it could be before we give ip on helping
     297                                        // calculate it's age and how young it could be before we give up on helping
    298298                                        const __readyQ_avg_t cutoff = calc_cutoff(ctsc, ctx->cq.id, ctxs_count, io.data, io.tscs, __shard_factor.io, false);
    299299                                        const __readyQ_avg_t age = moving_average(ctsc, io.tscs[target].t.tv, io.tscs[target].t.ma, false);
  • libcfa/src/concurrency/io/call.cfa.in

    r0e16a2d r75d874a  
    8989#if defined(CFA_HAVE_PREADV2)
    9090        struct iovec;
    91         extern ssize_t preadv2 (int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags);
     91        extern ssize_t preadv2 (int fd, const struct iovec * iov, int iovcnt, off_t offset, int flags);
    9292#endif
    9393#if defined(CFA_HAVE_PWRITEV2)
    9494        struct iovec;
    95         extern ssize_t pwritev2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags);
     95        extern ssize_t pwritev2(int fd, const struct iovec * iov, int iovcnt, off_t offset, int flags);
    9696#endif
    9797
     
    108108        struct msghdr;
    109109        struct sockaddr;
    110         extern ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags);
    111         extern ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags);
    112         extern ssize_t send(int sockfd, const void *buf, size_t len, int flags);
    113         extern ssize_t recv(int sockfd, void *buf, size_t len, int flags);
     110        extern ssize_t sendmsg(int sockfd, const struct msghdr * msg, int flags);
     111        extern ssize_t recvmsg(int sockfd, struct msghdr * msg, int flags);
     112        extern ssize_t send(int sockfd, const void * buf, size_t len, int flags);
     113        extern ssize_t recv(int sockfd, void * buf, size_t len, int flags);
    114114
    115115        extern int fallocate(int fd, int mode, off_t offset, off_t len);
    116116        extern int posix_fadvise(int fd, off_t offset, off_t len, int advice);
    117         extern int madvise(void *addr, size_t length, int advice);
    118 
    119         extern int openat(int dirfd, const char *pathname, int flags, mode_t mode);
     117        extern int madvise(void * addr, size_t length, int advice);
     118
     119        extern int openat(int dirfd, const char * pathname, int flags, mode_t mode);
    120120        extern int close(int fd);
    121121
    122         extern ssize_t read (int fd, void *buf, size_t count);
     122        extern ssize_t read (int fd, void * buf, size_t count);
    123123
    124124        struct epoll_event;
    125         extern int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event);
    126 
    127         extern ssize_t splice(int fd_in, __off64_t *off_in, int fd_out, __off64_t *off_out, size_t len, unsigned int flags);
     125        extern int epoll_ctl(int epfd, int op, int fd, struct epoll_event * event);
     126
     127        extern ssize_t splice(int fd_in, __off64_t * off_in, int fd_out, __off64_t * off_out, size_t len, unsigned int flags);
    128128        extern ssize_t tee(int fd_in, int fd_out, size_t len, unsigned int flags);
    129129}
     
    224224calls = [
    225225        # CFA_HAVE_IORING_OP_READV
    226         Call('READV', 'ssize_t preadv2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags)', {
     226        Call('READV', 'ssize_t preadv2(int fd, const struct iovec * iov, int iovcnt, off_t offset, int flags)', {
    227227                'fd'  : 'fd',
     228                'addr': '(typeof(sqe->addr))iov',
     229                'len' : 'iovcnt',
    228230                'off' : 'offset',
    229                 'addr': '(uintptr_t)iov',
    230                 'len' : 'iovcnt',
     231                'rw_flags' : 'flags'
    231232        }, define = 'CFA_HAVE_PREADV2'),
    232233        # CFA_HAVE_IORING_OP_WRITEV
    233         Call('WRITEV', 'ssize_t pwritev2(int fd, const struct iovec *iov, int iovcnt, off_t offset, int flags)', {
     234        Call('WRITEV', 'ssize_t pwritev2(int fd, const struct iovec * iov, int iovcnt, off_t offset, int flags)', {
    234235                'fd'  : 'fd',
     236                'addr': '(typeof(sqe->addr))iov',
     237                'len' : 'iovcnt',
    235238                'off' : 'offset',
    236                 'addr': '(uintptr_t)iov',
    237                 'len' : 'iovcnt'
     239                'rw_flags' : 'flags'
    238240        }, define = 'CFA_HAVE_PWRITEV2'),
    239241        # CFA_HAVE_IORING_OP_FSYNC
     
    242244        }),
    243245        # CFA_HAVE_IORING_OP_EPOLL_CTL
    244         Call('EPOLL_CTL', 'int epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)', {
     246        Call('EPOLL_CTL', 'int epoll_ctl(int epfd, int op, int fd, struct epoll_event * event)', {
    245247                'fd': 'epfd',
     248                'len': 'op',
    246249                'addr': 'fd',
    247                 'len': 'op',
    248                 'off': '(uintptr_t)event'
     250                'off': '(typeof(sqe->off))event'
    249251        }),
    250252        # CFA_HAVE_IORING_OP_SYNC_FILE_RANGE
     
    256258        }),
    257259        # CFA_HAVE_IORING_OP_SENDMSG
    258         Call('SENDMSG', 'ssize_t sendmsg(int sockfd, const struct msghdr *msg, int flags)', {
    259                 'fd': 'sockfd',
    260                 'addr': '(uintptr_t)(struct msghdr *)msg',
     260        Call('SENDMSG', 'ssize_t sendmsg(int sockfd, const struct msghdr * msg, int flags)', {
     261                'fd': 'sockfd',
     262                'addr': '(typeof(sqe->addr))(struct msghdr *)msg',
    261263                'len': '1',
    262264                'msg_flags': 'flags'
    263265        }),
    264266        # CFA_HAVE_IORING_OP_RECVMSG
    265         Call('RECVMSG', 'ssize_t recvmsg(int sockfd, struct msghdr *msg, int flags)', {
    266                 'fd': 'sockfd',
    267                 'addr': '(uintptr_t)(struct msghdr *)msg',
     267        Call('RECVMSG', 'ssize_t recvmsg(int sockfd, struct msghdr * msg, int flags)', {
     268                'fd': 'sockfd',
     269                'addr': '(typeof(sqe->addr))(struct msghdr *)msg',
    268270                'len': '1',
    269271                'msg_flags': 'flags'
    270272        }),
    271273        # CFA_HAVE_IORING_OP_SEND
    272         Call('SEND', 'ssize_t send(int sockfd, const void *buf, size_t len, int flags)', {
    273                 'fd': 'sockfd',
    274                 'addr': '(uintptr_t)buf',
     274        Call('SEND', 'ssize_t send(int sockfd, const void * buf, size_t len, int flags)', {
     275                'fd': 'sockfd',
     276                'addr': '(typeof(sqe->addr))buf',
    275277                'len': 'len',
    276278                'msg_flags': 'flags'
    277279        }),
    278280        # CFA_HAVE_IORING_OP_RECV
    279         Call('RECV', 'ssize_t recv(int sockfd, void *buf, size_t len, int flags)', {
    280                 'fd': 'sockfd',
    281                 'addr': '(uintptr_t)buf',
     281        Call('RECV', 'ssize_t recv(int sockfd, void * buf, size_t len, int flags)', {
     282                'fd': 'sockfd',
     283                'addr': '(typeof(sqe->addr))buf',
    282284                'len': 'len',
    283285                'msg_flags': 'flags'
     
    286288        Call('ACCEPT', 'int accept4(int sockfd, __SOCKADDR_ARG addr, socklen_t * restrict addrlen, int flags)', {
    287289                'fd': 'sockfd',
    288                 'addr': '(uintptr_t)&addr',
    289                 'addr2': '(uintptr_t)addrlen',
     290                'addr': '(typeof(sqe->addr))&addr',
     291                'addr2': '(typeof(sqe->addr2))addrlen',
    290292                'accept_flags': 'flags'
    291293        }),
     
    293295        Call('CONNECT', 'int connect(int sockfd, __CONST_SOCKADDR_ARG addr, socklen_t addrlen)', {
    294296                'fd': 'sockfd',
    295                 'addr': '(uintptr_t)&addr',
     297                'addr': '(typeof(sqe->addr))&addr',
    296298                'off': 'addrlen'
    297299        }),
     
    299301        Call('FALLOCATE', 'int fallocate(int fd, int mode, off_t offset, off_t len)', {
    300302                'fd': 'fd',
    301                 'addr': '(uintptr_t)len',
    302303                'len': 'mode',
    303                 'off': 'offset'
     304                'off': 'offset',
     305                'addr': 'len'
    304306        }),
    305307        # CFA_HAVE_IORING_OP_FADVISE
     
    311313        }),
    312314        # CFA_HAVE_IORING_OP_MADVISE
    313         Call('MADVISE', 'int madvise(void *addr, size_t length, int advice)', {
    314                 'addr': '(uintptr_t)addr',
     315        Call('MADVISE', 'int madvise(void * addr, size_t length, int advice)', {
     316                'addr': '(typeof(sqe->addr))addr',
    315317                'len': 'length',
    316318                'fadvise_advice': 'advice'
    317319        }),
    318320        # CFA_HAVE_IORING_OP_OPENAT
    319         Call('OPENAT', 'int openat(int dirfd, const char *pathname, int flags, mode_t mode)', {
     321        Call('OPENAT', 'int openat(int dirfd, const char * pathname, int flags, mode_t mode)', {
    320322                'fd': 'dirfd',
    321                 'addr': '(uintptr_t)pathname',
    322                 'len': 'mode',
    323                 'open_flags': 'flags;'
     323                'addr': '(typeof(sqe->addr))pathname',
     324                'open_flags': 'flags;',
     325                'len': 'mode'
    324326        }),
    325327        # CFA_HAVE_IORING_OP_OPENAT2
    326         Call('OPENAT2', 'int openat2(int dirfd, const char *pathname, struct open_how * how, size_t size)', {
     328        Call('OPENAT2', 'int openat2(int dirfd, const char * pathname, struct open_how * how, size_t size)', {
    327329                'fd': 'dirfd',
    328                 'addr': 'pathname',
    329                 'len': 'sizeof(*how)',
    330                 'off': '(uintptr_t)how',
     330                'addr': '(typeof(sqe->addr))pathname',
     331                'off': '(typeof(sqe->off))how',
     332                'len': 'sizeof(*how)'
    331333        }, define = 'CFA_HAVE_OPENAT2'),
    332334        # CFA_HAVE_IORING_OP_CLOSE
     
    335337        }),
    336338        # CFA_HAVE_IORING_OP_STATX
    337         Call('STATX', 'int statx(int dirfd, const char *pathname, int flags, unsigned int mask, struct statx *statxbuf)', {
     339        Call('STATX', 'int statx(int dirfd, const char * pathname, int flags, unsigned int mask, struct statx * statxbuf)', {
    338340                'fd': 'dirfd',
    339                 'off': '(uintptr_t)statxbuf',
    340                 'addr': 'pathname',
     341                'addr': '(typeof(sqe->addr))pathname',
     342                'statx_flags': 'flags',
    341343                'len': 'mask',
    342                 'statx_flags': 'flags'
     344                'off': '(typeof(sqe->off))statxbuf'
    343345        }, define = 'CFA_HAVE_STATX'),
    344346        # CFA_HAVE_IORING_OP_READ
    345347        Call('READ', 'ssize_t read(int fd, void * buf, size_t count)', {
    346348                'fd': 'fd',
    347                 'addr': '(uintptr_t)buf',
     349                'addr': '(typeof(sqe->addr))buf',
    348350                'len': 'count'
    349351        }),
     
    351353        Call('WRITE', 'ssize_t write(int fd, void * buf, size_t count)', {
    352354                'fd': 'fd',
    353                 'addr': '(uintptr_t)buf',
     355                'addr': '(typeof(sqe->addr))buf',
    354356                'len': 'count'
    355357        }),
    356358        # CFA_HAVE_IORING_OP_SPLICE
    357         Call('SPLICE', 'ssize_t splice(int fd_in, __off64_t *off_in, int fd_out, __off64_t *off_out, size_t len, unsigned int flags)', {
     359        Call('SPLICE', 'ssize_t splice(int fd_in, __off64_t * off_in, int fd_out, __off64_t * off_out, size_t len, unsigned int flags)', {
    358360                'splice_fd_in': 'fd_in',
    359                 'splice_off_in': 'off_in ? (__u64)*off_in : (__u64)-1',
     361                'splice_off_in': 'off_in ? (typeof(sqe->splice_off_in))*off_in : (typeof(sqe->splice_off_in))-1',
    360362                'fd': 'fd_out',
    361                 'off': 'off_out ? (__u64)*off_out : (__u64)-1',
     363                'off': 'off_out ? (typeof(sqe->off))*off_out : (typeof(sqe->off))-1',
    362364                'len': 'len',
    363365                'splice_flags': 'flags'
  • libcfa/src/concurrency/locks.hfa

    r0e16a2d r75d874a  
    253253static inline void on_wakeup(clh_lock & this, size_t recursion ) { lock(this); }
    254254
    255 
    256255//-----------------------------------------------------------------------------
    257256// Exponential backoff then block lock
     
    272271        this.lock_value = 0;
    273272}
    274 static inline void ^?{}( exp_backoff_then_block_lock & this ) {}
    275 // static inline void ?{}( exp_backoff_then_block_lock & this, exp_backoff_then_block_lock this2 ) = void;
    276 // static inline void ?=?( exp_backoff_then_block_lock & this, exp_backoff_then_block_lock this2 ) = void;
    277273
    278274static inline bool internal_try_lock(exp_backoff_then_block_lock & this, size_t & compare_val) with(this) {
    279         if (__atomic_compare_exchange_n(&lock_value, &compare_val, 1, false, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED)) {
    280                 return true;
    281         }
    282         return false;
     275        return __atomic_compare_exchange_n(&lock_value, &compare_val, 1, false, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED);
    283276}
    284277
     
    286279
    287280static inline bool try_lock_contention(exp_backoff_then_block_lock & this) with(this) {
    288         if (__atomic_exchange_n(&lock_value, 2, __ATOMIC_ACQUIRE) == 0) {
    289                 return true;
    290         }
    291         return false;
     281        return !__atomic_exchange_n(&lock_value, 2, __ATOMIC_ACQUIRE);
    292282}
    293283
    294284static inline bool block(exp_backoff_then_block_lock & this) with(this) {
    295         lock( spinlock __cfaabi_dbg_ctx2 ); // TODO change to lockfree queue (MPSC)
    296         if (lock_value != 2) {
    297                 unlock( spinlock );
    298                 return true;
    299         }
    300         insert_last( blocked_threads, *active_thread() );
    301         unlock( spinlock );
     285    lock( spinlock __cfaabi_dbg_ctx2 );
     286    if (__atomic_load_n( &lock_value, __ATOMIC_SEQ_CST) != 2) {
     287        unlock( spinlock );
     288        return true;
     289    }
     290    insert_last( blocked_threads, *active_thread() );
     291    unlock( spinlock );
    302292        park( );
    303293        return true;
     
    307297        size_t compare_val = 0;
    308298        int spin = 4;
     299
    309300        // linear backoff
    310301        for( ;; ) {
     
    324315static inline void unlock(exp_backoff_then_block_lock & this) with(this) {
    325316    if (__atomic_exchange_n(&lock_value, 0, __ATOMIC_RELEASE) == 1) return;
    326         lock( spinlock __cfaabi_dbg_ctx2 );
    327         thread$ * t = &try_pop_front( blocked_threads );
    328         unlock( spinlock );
    329         unpark( t );
     317    lock( spinlock __cfaabi_dbg_ctx2 );
     318    thread$ * t = &try_pop_front( blocked_threads );
     319    unlock( spinlock );
     320    unpark( t );
    330321}
    331322
  • src/AST/Print.cpp

    r0e16a2d r75d874a  
    369369                                --indent;
    370370                        }
     371                }
     372
     373                if ( ! node->withExprs.empty() ) {
     374                        // Not with a clause, but the 'with clause'.
     375                        ++indent;
     376                        os << " with clause" << endl << indent;
     377                        printAll( node->withExprs );
     378                        --indent;
    371379                }
    372380
  • src/Common/module.mk

    r0e16a2d r75d874a  
    2020        Common/CodeLocationTools.hpp \
    2121        Common/CodeLocationTools.cpp \
    22         Common/Debug.h \
    2322        Common/DeclStats.hpp \
    2423        Common/DeclStats.cpp \
  • src/Common/utility.h

    r0e16a2d r75d874a  
    190190}
    191191
    192 template< typename... Params >
    193 void warn( const Params & ... params ) {
    194         std::cerr << "Warning: ";
    195         toString_single( std::cerr, params... );
    196         std::cerr << std::endl;
    197 }
    198 
    199192// determines if pref is a prefix of str
    200193static inline bool isPrefix( const std::string & str, const std::string & pref, unsigned int start = 0 ) {
  • src/InitTweak/FixInit.cc

    r0e16a2d r75d874a  
    12331233                }
    12341234
    1235                 template< typename Visitor, typename... Params >
    1236                 void error( Visitor & v, CodeLocation loc, const Params &... params ) {
    1237                         SemanticErrorException err( loc, toString( params... ) );
    1238                         v.errors.append( err );
    1239                 }
    1240 
    12411235                template< typename... Params >
    12421236                void GenStructMemberCalls::emit( CodeLocation loc, const Params &... params ) {
    1243                         // toggle warnings vs. errors here.
    1244                         // warn( params... );
    1245                         error( *this, loc, params... );
     1237                        SemanticErrorException err( loc, toString( params... ) );
     1238                        errors.append( err );
    12461239                }
    12471240
  • src/InitTweak/FixInitNew.cpp

    r0e16a2d r75d874a  
    13031303        }
    13041304
    1305         template< typename Visitor, typename... Params >
    1306         void error( Visitor & v, CodeLocation loc, const Params &... params ) {
    1307                 SemanticErrorException err( loc, toString( params... ) );
    1308                 v.errors.append( err );
    1309         }
    1310 
    13111305        template< typename... Params >
    13121306        void GenStructMemberCalls::emit( CodeLocation loc, const Params &... params ) {
    1313                 // toggle warnings vs. errors here.
    1314                 // warn( params... );
    1315                 error( *this, loc, params... );
     1307                SemanticErrorException err( loc, toString( params... ) );
     1308                errors.append( err );
    13161309        }
    13171310
  • src/Parser/parser.yy

    r0e16a2d r75d874a  
    1010// Created On       : Sat Sep  1 20:22:55 2001
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 14 09:37:58 2023
    13 // Update Count     : 5990
     12// Last Modified On : Wed Mar 22 21:26:01 2023
     13// Update Count     : 6002
    1414//
    1515
     
    270270        SemanticError( yylloc, ::toString( "Identifier \"", identifier, "\" cannot appear before a ", kind, ".\n"
    271271                                   "Possible cause is misspelled storage/CV qualifier, misspelled typename, or missing generic parameter." ) );
     272} // IdentifierBeforeType
     273
     274static bool TypedefForall( DeclarationNode * decl ) {
     275        if ( decl->type->forall || (decl->type->kind == TypeData::Aggregate && decl->type->aggregate.params) ) {
     276                SemanticError( yylloc, "forall qualifier in typedef is currently unimplemented." );
     277                return true;
     278        } // if
     279        return false;
    272280} // IdentifierBeforeType
    273281
     
    496504%type<decl> typedef_name typedef_declaration typedef_expression
    497505
    498 %type<decl> variable_type_redeclarator type_ptr type_array type_function
     506%type<decl> variable_type_redeclarator variable_type_ptr variable_type_array variable_type_function
     507%type<decl> general_function_declarator function_type_redeclarator function_type_array function_type_no_ptr function_type_ptr
    499508
    500509%type<decl> type_parameter_redeclarator type_parameter_ptr type_parameter_array type_parameter_function
     
    19571966        TYPEDEF type_specifier declarator
    19581967                {
    1959                         // if type_specifier is an anon aggregate => name
    19601968                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "4" );
    1961                         $$ = $3->addType( $2 )->addTypedef();           // watchout frees $2 and $3
     1969                        if ( TypedefForall( $2 ) ) $$ = nullptr;
     1970                        else $$ = $3->addType( $2 )->addTypedef();              // watchout frees $2 and $3
    19621971                }
    19631972        | typedef_declaration pop ',' push declarator
     
    19691978                {
    19701979                        typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "6" );
    1971                         $$ = $4->addQualifiers( $1 )->addType( $3 )->addTypedef();
     1980                        if ( TypedefForall( $1 ) ) $$ = nullptr;
     1981                        else $$ = $4->addQualifiers( $1 )->addType( $3 )->addTypedef();
    19721982                }
    19731983        | type_specifier TYPEDEF declarator
    19741984                {
    19751985                        typedefTable.addToEnclosingScope( *$3->name, TYPEDEFname, "7" );
    1976                         $$ = $3->addType( $1 )->addTypedef();
     1986                        if ( TypedefForall( $1 ) ) $$ = nullptr;
     1987                        else $$ = $3->addType( $1 )->addTypedef();
    19771988                }
    19781989        | type_specifier TYPEDEF type_qualifier_list declarator
    19791990                {
    19801991                        typedefTable.addToEnclosingScope( *$4->name, TYPEDEFname, "8" );
    1981                         $$ = $4->addQualifiers( $1 )->addType( $1 )->addTypedef();
     1992                        if ( TypedefForall( $3 ) ) $$ = nullptr;
     1993                        else $$ = $4->addQualifiers( $1 )->addType( $1 )->addTypedef();
    19821994                }
    19831995        ;
     
    20162028                // A semantic check is required to ensure asm_name only appears on declarations with implicit or explicit static
    20172029                // storage-class
    2018         declarator asm_name_opt initializer_opt
     2030        variable_declarator asm_name_opt initializer_opt
    20192031                { $$ = $1->addAsmName( $2 )->addInitializer( $3 ); }
     2032        | variable_type_redeclarator asm_name_opt initializer_opt
     2033                { $$ = $1->addAsmName( $2 )->addInitializer( $3 ); }
     2034
     2035        | general_function_declarator asm_name_opt
     2036                { $$ = $1->addAsmName( $2 )->addInitializer( nullptr ); }
     2037        | general_function_declarator asm_name_opt '=' VOID
     2038                { $$ = $1->addAsmName( $2 )->addInitializer( new InitializerNode( true ) ); }
     2039
    20202040        | declaring_list ',' attribute_list_opt declarator asm_name_opt initializer_opt
    20212041                { $$ = $1->appendList( $4->addQualifiers( $3 )->addAsmName( $5 )->addInitializer( $6 ) ); }
     2042        ;
     2043
     2044general_function_declarator:
     2045        function_type_redeclarator
     2046        | function_declarator
    20222047        ;
    20232048
     
    25432568                // A semantic check is required to ensure bit_subrange only appears on integral types.
    25442569                { $$ = $1->addBitfield( $2 ); }
     2570        | function_type_redeclarator bit_subrange_size_opt
     2571                // A semantic check is required to ensure bit_subrange only appears on integral types.
     2572                { $$ = $1->addBitfield( $2 ); }
    25452573        ;
    25462574
     
    31953223                        $$ = $2->addFunctionBody( $4, $3 )->addType( $1 );
    31963224                }
    3197         | declaration_specifier variable_type_redeclarator with_clause_opt compound_statement
     3225        | declaration_specifier function_type_redeclarator with_clause_opt compound_statement
    31983226                {
    31993227                        rebindForall( $1, $2 );
     
    32313259        | variable_type_redeclarator
    32323260        | function_declarator
     3261        | function_type_redeclarator
    32333262        ;
    32343263
     
    34813510        ;
    34823511
    3483 // This pattern parses a declaration for a variable or function prototype that redefines a type name, e.g.:
     3512// This pattern parses a declaration for a variable that redefines a type name, e.g.:
    34843513//
    34853514//              typedef int foo;
     
    34873516//                 int foo; // redefine typedef name in new scope
    34883517//              }
    3489 //
    3490 // The pattern precludes declaring an array of functions versus a pointer to an array of functions, and returning arrays
    3491 // and functions versus pointers to arrays and functions.
    34923518
    34933519paren_type:
     
    35043530        paren_type attribute_list_opt
    35053531                { $$ = $1->addQualifiers( $2 ); }
    3506         | type_ptr
    3507         | type_array attribute_list_opt
     3532        | variable_type_ptr
     3533        | variable_type_array attribute_list_opt
    35083534                { $$ = $1->addQualifiers( $2 ); }
    3509         | type_function attribute_list_opt
     3535        | variable_type_function attribute_list_opt
    35103536                { $$ = $1->addQualifiers( $2 ); }
    35113537        ;
    35123538
    3513 type_ptr:
     3539variable_type_ptr:
    35143540        ptrref_operator variable_type_redeclarator
    35153541                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
    35163542        | ptrref_operator type_qualifier_list variable_type_redeclarator
    35173543                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
    3518         | '(' type_ptr ')' attribute_list_opt                           // redundant parenthesis
     3544        | '(' variable_type_ptr ')' attribute_list_opt          // redundant parenthesis
    35193545                { $$ = $2->addQualifiers( $4 ); }
    3520         | '(' attribute_list type_ptr ')' attribute_list_opt // redundant parenthesis
     3546        | '(' attribute_list variable_type_ptr ')' attribute_list_opt // redundant parenthesis
    35213547                { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); }
    35223548        ;
    35233549
    3524 type_array:
     3550variable_type_array:
    35253551        paren_type array_dimension
    35263552                { $$ = $1->addArray( $2 ); }
    3527         | '(' type_ptr ')' array_dimension
     3553        | '(' variable_type_ptr ')' array_dimension
    35283554                { $$ = $2->addArray( $4 ); }
    3529         | '(' attribute_list type_ptr ')' array_dimension
     3555        | '(' attribute_list variable_type_ptr ')' array_dimension
    35303556                { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    3531         | '(' type_array ')' multi_array_dimension                      // redundant parenthesis
     3557        | '(' variable_type_array ')' multi_array_dimension     // redundant parenthesis
    35323558                { $$ = $2->addArray( $4 ); }
    3533         | '(' attribute_list type_array ')' multi_array_dimension // redundant parenthesis
     3559        | '(' attribute_list variable_type_array ')' multi_array_dimension // redundant parenthesis
    35343560                { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
    3535         | '(' type_array ')'                                                            // redundant parenthesis
     3561        | '(' variable_type_array ')'                                           // redundant parenthesis
    35363562                { $$ = $2; }
    3537         | '(' attribute_list type_array ')'                                     // redundant parenthesis
     3563        | '(' attribute_list variable_type_array ')'            // redundant parenthesis
    35383564                { $$ = $3->addQualifiers( $2 ); }
    35393565        ;
    35403566
    3541 type_function:
     3567variable_type_function:
     3568        '(' variable_type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3569                { $$ = $2->addParamList( $6 ); }
     3570        | '(' attribute_list variable_type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3571                { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
     3572        | '(' variable_type_function ')'                                        // redundant parenthesis
     3573                { $$ = $2; }
     3574        | '(' attribute_list variable_type_function ')'         // redundant parenthesis
     3575                { $$ = $3->addQualifiers( $2 ); }
     3576        ;
     3577
     3578// This pattern parses a declaration for a function prototype that redefines a type name.  It precludes declaring an
     3579// array of functions versus a pointer to an array of functions, and returning arrays and functions versus pointers to
     3580// arrays and functions.
     3581
     3582function_type_redeclarator:
     3583        function_type_no_ptr attribute_list_opt
     3584                { $$ = $1->addQualifiers( $2 ); }
     3585        | function_type_ptr
     3586        | function_type_array attribute_list_opt
     3587                { $$ = $1->addQualifiers( $2 ); }
     3588        ;
     3589
     3590function_type_no_ptr:
    35423591        paren_type '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
    35433592                { $$ = $1->addParamList( $4 ); }
    3544         | '(' type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3593        | '(' function_type_ptr ')' '(' push parameter_type_list_opt pop ')'
    35453594                { $$ = $2->addParamList( $6 ); }
    3546         | '(' attribute_list type_ptr ')' '(' push parameter_type_list_opt pop ')' // empty parameter list OBSOLESCENT (see 3)
     3595        | '(' attribute_list function_type_ptr ')' '(' push parameter_type_list_opt pop ')'
    35473596                { $$ = $3->addQualifiers( $2 )->addParamList( $7 ); }
    3548         | '(' type_function ')'                                                         // redundant parenthesis
     3597        | '(' function_type_no_ptr ')'                                          // redundant parenthesis
    35493598                { $$ = $2; }
    3550         | '(' attribute_list type_function ')'                          // redundant parenthesis
     3599        | '(' attribute_list function_type_no_ptr ')'           // redundant parenthesis
     3600                { $$ = $3->addQualifiers( $2 ); }
     3601        ;
     3602
     3603function_type_ptr:
     3604        ptrref_operator function_type_redeclarator
     3605                { $$ = $2->addPointer( DeclarationNode::newPointer( nullptr, $1 ) ); }
     3606        | ptrref_operator type_qualifier_list function_type_redeclarator
     3607                { $$ = $3->addPointer( DeclarationNode::newPointer( $2, $1 ) ); }
     3608        | '(' function_type_ptr ')' attribute_list_opt
     3609                { $$ = $2->addQualifiers( $4 ); }
     3610        | '(' attribute_list function_type_ptr ')' attribute_list_opt
     3611                { $$ = $3->addQualifiers( $2 )->addQualifiers( $5 ); }
     3612        ;
     3613
     3614function_type_array:
     3615        '(' function_type_ptr ')' array_dimension
     3616                { $$ = $2->addArray( $4 ); }
     3617        | '(' attribute_list function_type_ptr ')' array_dimension
     3618                { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
     3619        | '(' function_type_array ')' multi_array_dimension     // redundant parenthesis
     3620                { $$ = $2->addArray( $4 ); }
     3621        | '(' attribute_list function_type_array ')' multi_array_dimension // redundant parenthesis
     3622                { $$ = $3->addQualifiers( $2 )->addArray( $5 ); }
     3623        | '(' function_type_array ')'                                           // redundant parenthesis
     3624                { $$ = $2; }
     3625        | '(' attribute_list function_type_array ')'            // redundant parenthesis
    35513626                { $$ = $3->addQualifiers( $2 ); }
    35523627        ;
  • src/SynTree/FunctionDecl.cc

    r0e16a2d r75d874a  
    8787        } // if
    8888
     89        if ( !withExprs.empty() ) {
     90                os << indent << "... with clause" << std::endl;
     91                os << indent + 1;
     92                printAll( withExprs, os, indent + 1 );
     93        }
     94
    8995        if ( statements ) {
    9096                os << indent << "... with body" << endl << indent+1;
  • tests/.expect/PRNG.x64.txt

    r0e16a2d r75d874a  
    11
    22                    PRNG()     PRNG(5)   PRNG(0,5)
    3        2629641414891406278           3           0
    4       11972157801652581900           3           5
    5        9470682093934978437           2           2
    6         316134424938305673           2           2
    7        5572275127081588144           0           3
    8       12394954141290188855           2           2
    9       15386440704589550620           2           1
    10        5760167266331356361           2           5
    11        8021670258373873290           2           5
    12        8813161879342109574           1           4
    13       10525294799876107814           2           0
    14       14801827301969351008           3           0
    15       17016612914230924215           0           0
    16        5485205801221744751           3           2
    17        6143666691223938511           4           0
    18       15086131934315954459           4           5
    19        4547668615176940328           4           5
    20       17718351571399359777           0           5
    21        2636252641646208341           4           0
    22       12820158953704882599           0           4
     3      13944458589275087071           3           2
     4        129977468648444256           0           4
     5       2357727400298891021           2           2
     6       8855179187835660146           3           3
     7       9957620185645882382           4           1
     8      13396406983727409795           0           5
     9       3342782395220265920           0           5
     10       1707651271867677937           1           0
     11      16402561450140881681           0           1
     12      17838519215740313729           4           2
     13       7425936020594490136           4           0
     14       4174865704721714670           3           5
     15      16055269689200152092           0           2
     16      15091270195803594018           1           5
     17      11807315541476180798           1           1
     18      10697186588988060306           4           1
     19      14665526411527044929           3           2
     20      11289342279096164771           2           5
     21      16126980828050300615           1           4
     22       7821578301767524260           4           1
    2323seed 1009
    2424
     
    3333
    3434                    prng()     prng(5)   prng(0,5)
    35        2629641414891406278           3           0
    36       11972157801652581900           3           5
    37        9470682093934978437           2           2
    38         316134424938305673           2           2
    39        5572275127081588144           0           3
    40       12394954141290188855           2           2
    41       15386440704589550620           2           1
    42        5760167266331356361           2           5
    43        8021670258373873290           2           5
    44        8813161879342109574           1           4
    45       10525294799876107814           2           0
    46       14801827301969351008           3           0
    47       17016612914230924215           0           0
    48        5485205801221744751           3           2
    49        6143666691223938511           4           0
    50       15086131934315954459           4           5
    51        4547668615176940328           4           5
    52       17718351571399359777           0           5
    53        2636252641646208341           4           0
    54       12820158953704882599           0           4
     35      13944458589275087071           3           2
     36        129977468648444256           0           4
     37       2357727400298891021           2           2
     38       8855179187835660146           3           3
     39       9957620185645882382           4           1
     40      13396406983727409795           0           5
     41       3342782395220265920           0           5
     42       1707651271867677937           1           0
     43      16402561450140881681           0           1
     44      17838519215740313729           4           2
     45       7425936020594490136           4           0
     46       4174865704721714670           3           5
     47      16055269689200152092           0           2
     48      15091270195803594018           1           5
     49      11807315541476180798           1           1
     50      10697186588988060306           4           1
     51      14665526411527044929           3           2
     52      11289342279096164771           2           5
     53      16126980828050300615           1           4
     54       7821578301767524260           4           1
    5555seed 1009
    5656
     
    6565
    6666                   prng(t)   prng(t,5) prng(t,0,5)
    67        2629641414891406278           3           0
    68       11972157801652581900           3           5
    69        9470682093934978437           2           2
    70         316134424938305673           2           2
    71        5572275127081588144           0           3
    72       12394954141290188855           2           2
    73       15386440704589550620           2           1
    74        5760167266331356361           2           5
    75        8021670258373873290           2           5
    76        8813161879342109574           1           4
    77       10525294799876107814           2           0
    78       14801827301969351008           3           0
    79       17016612914230924215           0           0
    80        5485205801221744751           3           2
    81        6143666691223938511           4           0
    82       15086131934315954459           4           5
    83        4547668615176940328           4           5
    84       17718351571399359777           0           5
    85        2636252641646208341           4           0
    86       12820158953704882599           0           4
     67      13944458589275087071           3           2
     68        129977468648444256           0           4
     69       2357727400298891021           2           2
     70       8855179187835660146           3           3
     71       9957620185645882382           4           1
     72      13396406983727409795           0           5
     73       3342782395220265920           0           5
     74       1707651271867677937           1           0
     75      16402561450140881681           0           1
     76      17838519215740313729           4           2
     77       7425936020594490136           4           0
     78       4174865704721714670           3           5
     79      16055269689200152092           0           2
     80      15091270195803594018           1           5
     81      11807315541476180798           1           1
     82      10697186588988060306           4           1
     83      14665526411527044929           3           2
     84      11289342279096164771           2           5
     85      16126980828050300615           1           4
     86       7821578301767524260           4           1
    8787seed 1009
    8888
  • tests/.expect/PRNG.x86.txt

    r0e16a2d r75d874a  
    11
    22                    PRNG()     PRNG(5)   PRNG(0,5)
    3                     130161           1           1
    4                 4074541490           0           0
    5                  927506267           0           3
    6                 1991273445           1           3
    7                  669918146           2           3
    8                  519546860           1           1
    9                 1136699882           4           3
    10                 2130185384           3           1
    11                  992239050           0           5
    12                 2250903111           0           1
    13                 1544429724           3           2
    14                 1591091660           3           3
    15                 2511657707           2           4
    16                 1065770984           2           4
    17                 2412763405           4           4
    18                 1834447239           4           2
    19                  360289337           0           4
    20                 2449452027           1           1
    21                 3370425396           2           1
    22                 3109103043           0           3
     3                2884683541           0           0
     4                3465286746           2           4
     5                3268922916           0           1
     6                2396374907           3           0
     7                2135076892           4           1
     8                 944377718           3           1
     9                2204845346           3           3
     10                3736609533           0           4
     11                4063231336           0           2
     12                1075394776           0           2
     13                 712844808           4           0
     14                4246343110           3           1
     15                3793873837           2           1
     16                3690340337           1           4
     17                 319207944           1           4
     18                1815791072           3           5
     19                2581617261           1           5
     20                3873329448           1           3
     21                 832631329           4           0
     22                 651551615           3           5
    2323seed 1009
    2424
    2525Sequential
    26 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
     26trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
    2727
    2828Concurrent
    29 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
    30 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
    31 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
    32 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
     29trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
     30trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
     31trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
     32trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
    3333
    3434                    prng()     prng(5)   prng(0,5)
    35                     130161           1           1
    36                 4074541490           0           0
    37                  927506267           0           3
    38                 1991273445           1           3
    39                  669918146           2           3
    40                  519546860           1           1
    41                 1136699882           4           3
    42                 2130185384           3           1
    43                  992239050           0           5
    44                 2250903111           0           1
    45                 1544429724           3           2
    46                 1591091660           3           3
    47                 2511657707           2           4
    48                 1065770984           2           4
    49                 2412763405           4           4
    50                 1834447239           4           2
    51                  360289337           0           4
    52                 2449452027           1           1
    53                 3370425396           2           1
    54                 3109103043           0           3
     35                2884683541           0           0
     36                3465286746           2           4
     37                3268922916           0           1
     38                2396374907           3           0
     39                2135076892           4           1
     40                 944377718           3           1
     41                2204845346           3           3
     42                3736609533           0           4
     43                4063231336           0           2
     44                1075394776           0           2
     45                 712844808           4           0
     46                4246343110           3           1
     47                3793873837           2           1
     48                3690340337           1           4
     49                 319207944           1           4
     50                1815791072           3           5
     51                2581617261           1           5
     52                3873329448           1           3
     53                 832631329           4           0
     54                 651551615           3           5
    5555seed 1009
    5656
    5757Sequential
    58 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
     58trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
    5959
    6060Concurrent
    61 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
    62 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
    63 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
    64 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
     61trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
     62trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
     63trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
     64trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
    6565
    6666                   prng(t)   prng(t,5) prng(t,0,5)
    67                     130161           1           1
    68                 4074541490           0           0
    69                  927506267           0           3
    70                 1991273445           1           3
    71                  669918146           2           3
    72                  519546860           1           1
    73                 1136699882           4           3
    74                 2130185384           3           1
    75                  992239050           0           5
    76                 2250903111           0           1
    77                 1544429724           3           2
    78                 1591091660           3           3
    79                 2511657707           2           4
    80                 1065770984           2           4
    81                 2412763405           4           4
    82                 1834447239           4           2
    83                  360289337           0           4
    84                 2449452027           1           1
    85                 3370425396           2           1
    86                 3109103043           0           3
     67                2884683541           0           0
     68                3465286746           2           4
     69                3268922916           0           1
     70                2396374907           3           0
     71                2135076892           4           1
     72                 944377718           3           1
     73                2204845346           3           3
     74                3736609533           0           4
     75                4063231336           0           2
     76                1075394776           0           2
     77                 712844808           4           0
     78                4246343110           3           1
     79                3793873837           2           1
     80                3690340337           1           4
     81                 319207944           1           4
     82                1815791072           3           5
     83                2581617261           1           5
     84                3873329448           1           3
     85                 832631329           4           0
     86                 651551615           3           5
    8787seed 1009
    8888
    8989Sequential
    90 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
     90trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
    9191
    9292Concurrent
    93 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
    94 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
    95 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
    96 trials 100000000 buckets 100000 min 867 max 1135 avg 1000.0 std 31.7 rstd 3.2%
     93trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
     94trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
     95trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
     96trials 100000000 buckets 100000 min 858 max 1147 avg 1000.0 std 31.5 rstd 3.2%
  • tests/.expect/nested_function.x86.txt

    r0e16a2d r75d874a  
    1 total 105
     1total 245
  • tests/concurrent/channels/parallel_harness.hfa

    r0e16a2d r75d874a  
    100100
    101101int test( size_t Processors, size_t Channels, size_t Producers, size_t Consumers, size_t ChannelSize ) {
    102     size_t Clusters = 1;
     102    size_t Clusters = Processors;
    103103    // create a cluster
    104104    cluster clus[Clusters];
     
    108108    }
    109109
    110     channels = anew( Channels );
     110    channels = aalloc( Channels );
    111111
    112112    // sout | "Processors: " | Processors | " ProdsPerChan: " | Producers | " ConsPerChan: " | Consumers | "Channels: " | Channels | " Channel Size: " | ChannelSize;
     
    150150       
    151151    }
    152     // for ( i; Channels ) {
    153     //     // sout | get_count( channels[i] );
    154     //     if ( get_count( channels[i] ) < Consumers ){
    155     //         #ifdef BIG
    156     //         bigObject b{0};
    157     //         #endif
    158     //         for ( j; Consumers ) {
    159     //             #ifdef BIG
    160     //             insert( channels[i], b );
    161     //             #else
    162     //             insert( channels[i], 0 );
    163     //             #endif
    164     //         }
    165     //     }
    166     // }
     152
    167153    sout | "cons";
    168154    for ( i; Consumers * Channels ) {
  • tests/concurrent/pthread/.expect/bounded_buffer.x64.txt

    r0e16a2d r75d874a  
    1 producer total value is 38160
    2 consumer total value is 38160
     1producer total value is 39780
     2consumer total value is 39780
  • tests/concurrent/pthread/.expect/bounded_buffer.x86.txt

    r0e16a2d r75d874a  
    1 producer total value is 45060
    2 consumer total value is 45060
     1producer total value is 1770
     2consumer total value is 1770
Note: See TracChangeset for help on using the changeset viewer.