Changes in / [3b8acfb:be497c6]


Ignore:
Files:
1 deleted
14 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/andrew_beach_MMath/features.tex

    r3b8acfb rbe497c6  
    124124
    125125\section{Virtuals}
    126 \label{s:virtuals}
    127126Virtual types and casts are not part of \CFA's EHM nor are they required for
    128127any EHM.
  • doc/theses/andrew_beach_MMath/performance.tex

    r3b8acfb rbe497c6  
    22\label{c:performance}
    33
    4 Performance is of secondary importance for most of this project.
    5 Instead, the focus is to get the features working. The only performance
    6 requirement is to ensure the tests for correctness run in a reasonable
     4Performance has been of secondary importance for most of this project.
     5Instead, the focus has been to get the features working. The only performance
     6requirements is to ensure the tests for correctness run in a reasonable
    77amount of time.
    88
    99\section{Test Set-Up}
    10 Tests were run in \CFA, C++, Java and Python.
     10Tests will be run in \CFA, C++, Java and Python.
    1111In addition there are two sets of tests for \CFA,
    12 one for termination and one for resumption exceptions.
     12one for termination exceptions and once with resumption exceptions.
    1313
    1414C++ is the most comparable language because both it and \CFA use the same
    1515framework, libunwind.
    1616In fact, the comparison is almost entirely a quality of implementation
    17 comparison: \CFA's EHM has had significantly less time to be optimized and
     17comparison. \CFA's EHM has had significantly less time to be optimized and
    1818does not generate its own assembly. It does have a slight advantage in that
    19 there are some features it handles directly instead of through utility functions,
     19there are some features it does not handle, through utility functions,
    2020but otherwise \Cpp has a significant advantage.
    2121
     
    2323It is implemented in a very different environment, a virtual machine with
    2424garbage collection.
    25 It also implements the @finally@ clause on @try@ blocks allowing for a direct
     25It also implements the finally clause on try blocks allowing for a direct
    2626feature-to-feature comparison.
    27 As with \Cpp, Java's implementation is mature, optimizations
    28 and has extra features.
    29 
    30 Python is used as an alternative point of comparison because of the \CFA EHM's
    31 current performance goals, which is not to be prohibitively slow while the
     27As with \Cpp, Java's implementation is more mature, has more optimizations
     28and more extra features.
     29
     30Python was used as a point of comparison because of the \CFA EHM's
     31current performance goals, which is not be prohibitively slow while the
    3232features are designed and examined. Python has similar performance goals for
    3333creating quick scripts and its wide use suggests it has achieved those goals.
    3434
    35 Unfortunately, there are no notable modern programming languages with
    36 resumption exceptions. Even the older programming languages with resumption
    37 seem to be notable only for having resumption.
    38 So instead, resumption is compared to a less similar but much more familiar
     35Unfortunately there are no notable modern programming languages with
     36resumption exceptions. Even the older programming languages with resumptions
     37seem to be notable only for having resumptions.
     38So instead resumptions are compared to a less similar but much more familiar
    3939feature, termination exceptions.
    4040
    41 All tests are run inside a main loop that repeatedly performs a test.
    42 This approach avoids start-up or tear-down time from
     41All tests are run inside a main loop which will perform the test
     42repeatedly. This is to avoids start-up or tear-down time from
    4343affecting the timing results.
    44 Each test is run a million times.
    45 The Java versions of the test run this loop an extra 1000 times before
    46 beginning to actual test to ``warm-up" the JVM.
     44Tests ran their main loop a million times.
     45The Java versions of the test also run this loop an extra 1000 times before
     46beginning to time the results to ``warm-up" the JVM.
    4747
    4848Timing is done internally, with time measured immediately before and
    49 after the test loop. The difference is calculated and printed.
     49immediately after the test loop. The difference is calculated and printed.
     50
    5051The loop structure and internal timing means it is impossible to test
    5152unhandled exceptions in \Cpp and Java as that would cause the process to
     
    5455critical.
    5556
    56 The exceptions used in these tests are always based off of
    57 a base exception. This requirement minimizes performance differences based
    58 on the object model used to represent the exception.
    59 
    60 All tests are designed to be as minimal as possible, while still preventing
    61 excessive optimizations.
     57The exceptions used in these tests will always be a exception based off of
     58the base exception. This requirement minimizes performance differences based
     59on the object model used to repersent the exception.
     60
     61All tests were designed to be as minimal as possible while still preventing
     62exessive optimizations.
    6263For example, empty inline assembly blocks are used in \CFA and \Cpp to
    6364prevent excessive optimizations while adding no actual work.
    64 Each test was run eleven times. The top three and bottom three results were
    65 discarded and the remaining five values are averaged.
    66 
    67 The tests are compiled with gcc-10 for \CFA and g++-10 for \Cpp. Java is
    68 compiled with 11.0.11. Python with 3.8. The tests were run on:
    69 \begin{itemize}[nosep]
    70 \item
    71 ARM 2280 Kunpeng 920 48-core 2$\times$socket \lstinline{@} 2.6 GHz running Linux v5.11.0-25
    72 \item
    73 AMD 6380 Abu Dhabi 16-core 4$\times$socket \lstinline{@} 2.5 GHz running Linux v5.11.0-25
    74 \end{itemize}
    7565
    7666% We don't use catch-alls but if we did:
     
    8171The following tests were selected to test the performance of different
    8272components of the exception system.
    83 They should provide a guide as to where the EHM's costs are found.
     73The should provide a guide as to where the EHM's costs can be found.
    8474
    8575\paragraph{Raise and Handle}
    86 The first group measures the cost of a try statement when exceptions are raised
    87 and \emph{the stack is unwound}.  Each test has has a repeating function like
    88 the following
    89 \begin{cfa}
    90 void unwind_empty(unsigned int frames) {
    91         if (frames) {
    92                 unwind_empty(frames - 1);
    93         } else throw (empty_exception){&empty_vt};
    94 }
    95 \end{cfa}
    96 which is called M times, where each call recurses to a depth of N, an
    97 exception is raised, the stack is a unwound, and the exception caught.
     76The first group of tests involve setting up
     77So there is three layers to the test. The first is set up and a loop, which
     78configures the test and then runs it repeatedly to reduce the impact of
     79start-up and shutdown on the results.
     80Each iteration of the main loop
    9881\begin{itemize}[nosep]
    99 \item Empty:
    100 This test measures the cost of raising (stack walking) an exception through empty
    101 empty stack frames to an empty handler. (see above)
     82\item Empty Function:
     83The repeating function is empty except for the necessary control code.
    10284\item Destructor:
    103 
    104 This test measures the cost of raising an exception through non-empty frames
    105 where each frame has an object requiring destruction, to an empty
    106 handler. Hence, there are N destructor calls during unwinding.
    107 \begin{cfa}
    108 if (frames) {
    109         WithDestructor object;
    110         unwind_empty(frames - 1);
    111 \end{cfa}
     85The repeating function creates an object with a destructor before calling
     86itself.
    11287\item Finally:
    113 This test measures the cost of establishing a try block with an empty finally
    114 clause on the front side of the recursion and running the empty finally clause
    115 on the back side of the recursion during stack unwinding.
    116 \begin{cfa}
    117 if (frames) {
    118         try {
    119                 unwind_finally(frames - 1);
    120         } finally {}
    121 \end{cfa}
     88The repeating function calls itself inside a try block with a finally clause
     89attached.
    12290\item Other Handler:
    123 This test is like the finally test but the try block has a catch clause for an
    124 exception that is not raised, so catch matching is executed during stack
    125 unwinding but the match never successes until the catch at the bottom of the
    126 stack.
    127 \begin{cfa}
    128 if (frames) {
    129         try {
    130                 unwind_other(frames - 1);
    131         } catch (not_raised_exception *) {}
    132 \end{cfa}
     91The repeating function calls itself inside a try block with a handler that
     92will not match the raised exception. (But is of the same kind of handler.)
    13393\end{itemize}
    13494
    13595\paragraph{Cross Try Statement}
    136 The next group measures just the cost of executing a try statement so
    137 \emph{there is no stack unwinding}.  Hence, the program main loops N times
    138 around:
    139 \begin{cfa}
    140 try {
    141 } catch (not_raised_exception *) {}
    142 \end{cfa}
     96The next group measures the cost of a try statement when no exceptions are
     97raised. The test is set-up, then there is a loop to reduce the impact of
     98start-up and shutdown on the results.
     99In each iteration, a try statement is executed. Entering and leaving a loop
     100is all the test wants to do.
    143101\begin{itemize}[nosep]
    144102\item Handler:
    145 The try statement has a handler.
     103The try statement has a handler (of the matching kind).
    146104\item Finally:
    147 The try statement replaces the handler with a finally clause.
     105The try statement has a finally clause.
    148106\end{itemize}
    149107
    150108\paragraph{Conditional Matching}
    151 This final group measures the cost of conditional matching.
     109This group of tests checks the cost of conditional matching.
    152110Only \CFA implements the language level conditional match,
    153111the other languages must mimic with an ``unconditional" match (it still
    154112checks the exception's type) and conditional re-raise if it was not supposed
    155113to handle that exception.
    156 \begin{center}
    157 \begin{tabular}{ll}
    158 \multicolumn{1}{c}{\CFA} & \multicolumn{1}{c}{\Cpp, Java, Python} \\
    159 \begin{cfa}
    160 try {
    161         throw_exception();
    162 } catch (empty_exception * exc;
    163                  should_catch) {
    164 }
    165 \end{cfa}
    166 &
    167 \begin{cfa}
    168 try {
    169         throw_exception();
    170 } catch (EmptyException & exc) {
    171         if (!should_catch) throw;
    172 }
    173 \end{cfa}
    174 \end{tabular}
    175 \end{center}
    176114\begin{itemize}[nosep]
    177115\item Match All:
     
    192130
    193131\section{Results}
     132Each test was run eleven times. The top three and bottom three results were
     133discarded and the remaining five values are averaged.
     134
    194135In cases where a feature is not supported by a language the test is skipped
    195 for that language.
    196 \PAB{Report all values.
    197 
    198 Similarly, if a test does not change between resumption
     136for that language. Similarly, if a test is does not change between resumption
    199137and termination in \CFA, then only one test is written and the result
    200138was put into the termination column.
    201 }
    202139
    203140% Raw Data:
     
    300237\end{tabular}
    301238
    302 One result not directly related to \CFA but important to keep in
    303 mind is that, for exceptions, the standard intuition about which languages
    304 should go faster often does not hold. For example, there are cases where Python out-performs
    305 \Cpp and Java. The most likely explanation is that, since exceptions are
    306 rarely considered to be the common case, the more optimized languages
    307 make that case expense. In addition, languages with high-level
    308 representations have a much easier time scanning the stack as there is less
     239One result that is not directly related to \CFA but is important to keep in
     240mind is that in exceptions the standard intuitions about which languages
     241should go faster often do not hold. There are cases where Python out-preforms
     242\Cpp and Java. The most likely explination is that, since exceptions are
     243rarely considered to be the common case, the more optimized langages have
     244optimized at their expence. In addition languages with high level           
     245repersentations have a much easier time scanning the stack as there is less
    309246to decode.
    310247
    311 This observation means that while \CFA does not actually keep up with Python in every
    312 case, it is usually no worse than roughly half the speed of \Cpp. This performance is good
     248This means that while \CFA does not actually keep up with Python in every
     249case it is usually no worse than roughly half the speed of \Cpp. This is good
    313250enough for the prototyping purposes of the project.
    314251
    315252The test case where \CFA falls short is Raise Other, the case where the
    316253stack is unwound including a bunch of non-matching handlers.
    317 This slowdown seems to come from missing optimizations.
    318 
     254This slowdown seems to come from missing optimizations,
     255the results above came from gcc/g++ 10 (gcc as \CFA backend or g++ for \Cpp)
     256but the results change if they are run in gcc/g++ 9 instead.
    319257Importantly, there is a huge slowdown in \Cpp's results bringing that brings
    320 \CFA's performance back in that roughly half speed area. However many other
     258\CFA's performace back in that roughly half speed area. However many other
    321259\CFA benchmarks increase their run-time by a similar amount falling far
    322260behind their \Cpp counter-parts.
     
    331269Resumption exception handling is also incredibly fast. Often an order of
    332270magnitude or two better than the best termination speed.
    333 There is a simple explanation for this; traversing a linked list is much   
     271There is a simple explination for this; traversing a linked list is much   
    334272faster than examining and unwinding the stack. When resumption does not do as
    335 well its when more try statements are used per raise. Updating the internal
    336 linked list is not very expensive but it does add up.
     273well its when more try statements are used per raise. Updating the interal
     274linked list is not very expencive but it does add up.
    337275
    338276The relative speed of the Match All and Match None tests (within each
     
    342280\item
    343281Java and Python get similar values in both tests.
    344 Between the interpreted code, a higher level representation of the call
     282Between the interperated code, a higher level repersentation of the call
    345283stack and exception reuse it it is possible the cost for a second
    346284throw can be folded into the first.
    347285% Is this due to optimization?
    348286\item
    349 Both types of \CFA are slightly slower if there is not a match.
     287Both types of \CFA are slighly slower if there is not a match.
    350288For termination this likely comes from unwinding a bit more stack through
    351289libunwind instead of executing the code normally.
  • libcfa/src/concurrency/kernel/startup.cfa

    r3b8acfb rbe497c6  
    235235
    236236        register_tls( mainProcessor );
    237         mainThread->last_cpu = __kernel_getcpu();
    238237
    239238        //initialize the global state variables
     
    479478        state = Start;
    480479        self_cor{ info };
     480        last_cpu = __kernel_getcpu();
    481481        curr_cor = &self_cor;
    482482        curr_cluster = mainCluster;
  • libcfa/src/concurrency/thread.cfa

    r3b8acfb rbe497c6  
    3434        preempted = __NO_PREEMPTION;
    3535        corctx_flag = false;
    36         disable_interrupts();
    3736        last_cpu = __kernel_getcpu();
    38         enable_interrupts();
    3937        curr_cor = &self_cor;
    4038        self_mon.owner = &this;
  • libcfa/src/heap.cfa

    r3b8acfb rbe497c6  
    1010// Created On       : Tue Dec 19 21:58:35 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Aug  9 19:03:02 2021
    13 // Update Count     : 1040
     12// Last Modified On : Sat May 22 08:46:39 2021
     13// Update Count     : 1036
    1414//
    1515
     
    102102} // prtUnfreed
    103103
    104 extern int cfa_main_returned;                                                   // from bootloader.cf
    105104extern "C" {
    106105        void heapAppStart() {                                                           // called by __cfaabi_appready_startup
     
    110109        void heapAppStop() {                                                            // called by __cfaabi_appready_startdown
    111110                fclose( stdin ); fclose( stdout );
    112                 if ( cfa_main_returned ) prtUnfreed();                  // do not check unfreed storage if exit called
     111                prtUnfreed();
    113112        } // heapAppStop
    114113} // extern "C"
  • src/Parser/ExpressionNode.cc

    r3b8acfb rbe497c6  
    1010// Created On       : Sat May 16 13:17:07 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Aug  7 09:18:56 2021
    13 // Update Count     : 1077
     12// Last Modified On : Thu Aug 20 14:01:46 2020
     13// Update Count     : 1076
    1414//
    1515
     
    514514        return expr;
    515515} // build_varref
    516 
    517516// TODO: get rid of this and OperKinds and reuse code from OperatorTable
    518517static const char * OperName[] = {                                              // must harmonize with OperKinds
  • tests/.expect/declarationSpecifier.arm64.txt

    r3b8acfb rbe497c6  
    11321132char **_X13cfa_args_argvPPc_1;
    11331133char **_X13cfa_args_envpPPc_1;
    1134 signed int _X17cfa_main_returnedi_1 = ((signed int )0);
    11351134signed int main(signed int _X4argci_1, char **_X4argvPPc_1, char **_X4envpPPc_1){
    11361135    __attribute__ ((unused)) signed int _X12_retval_maini_1;
     
    11471146    }
    11481147
    1149     signed int _tmp_cp_ret6;
    1150     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
    1151     {
    1152         ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
    1153     }
    1154 
    1155     {
    1156         ((void)(_X12_retval_maini_1=_X3reti_2) /* ?{} */);
     1148    {
     1149        signed int _tmp_cp_ret6;
     1150        ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6)) /* ?{} */);
    11571151    }
    11581152
  • tests/.expect/declarationSpecifier.x64.txt

    r3b8acfb rbe497c6  
    11321132char **_X13cfa_args_argvPPc_1;
    11331133char **_X13cfa_args_envpPPc_1;
    1134 signed int _X17cfa_main_returnedi_1 = ((signed int )0);
    11351134signed int main(signed int _X4argci_1, char **_X4argvPPc_1, char **_X4envpPPc_1){
    11361135    __attribute__ ((unused)) signed int _X12_retval_maini_1;
     
    11471146    }
    11481147
    1149     signed int _tmp_cp_ret6;
    1150     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
    1151     {
    1152         ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
    1153     }
    1154 
    1155     {
    1156         ((void)(_X12_retval_maini_1=_X3reti_2) /* ?{} */);
     1148    {
     1149        signed int _tmp_cp_ret6;
     1150        ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6)) /* ?{} */);
    11571151    }
    11581152
  • tests/.expect/declarationSpecifier.x86.txt

    r3b8acfb rbe497c6  
    11321132char **_X13cfa_args_argvPPc_1;
    11331133char **_X13cfa_args_envpPPc_1;
    1134 signed int _X17cfa_main_returnedi_1 = ((signed int )0);
    11351134signed int main(signed int _X4argci_1, char **_X4argvPPc_1, char **_X4envpPPc_1){
    11361135    __attribute__ ((unused)) signed int _X12_retval_maini_1;
     
    11471146    }
    11481147
    1149     signed int _tmp_cp_ret6;
    1150     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
    1151     {
    1152         ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
    1153     }
    1154 
    1155     {
    1156         ((void)(_X12_retval_maini_1=_X3reti_2) /* ?{} */);
     1148    {
     1149        signed int _tmp_cp_ret6;
     1150        ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6)) /* ?{} */);
    11571151    }
    11581152
  • tests/.expect/gccExtensions.arm64.txt

    r3b8acfb rbe497c6  
    324324char **_X13cfa_args_argvPPc_1;
    325325char **_X13cfa_args_envpPPc_1;
    326 signed int _X17cfa_main_returnedi_1 = ((signed int )0);
    327326signed int main(signed int _X4argci_1, char **_X4argvPPc_1, char **_X4envpPPc_1){
    328327    __attribute__ ((unused)) signed int _X12_retval_maini_1;
     
    339338    }
    340339
    341     signed int _tmp_cp_ret6;
    342     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
    343     {
    344         ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
    345     }
    346 
    347     {
    348         ((void)(_X12_retval_maini_1=_X3reti_2) /* ?{} */);
     340    {
     341        signed int _tmp_cp_ret6;
     342        ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6)) /* ?{} */);
    349343    }
    350344
  • tests/.expect/gccExtensions.x64.txt

    r3b8acfb rbe497c6  
    324324char **_X13cfa_args_argvPPc_1;
    325325char **_X13cfa_args_envpPPc_1;
    326 signed int _X17cfa_main_returnedi_1 = ((signed int )0);
    327326signed int main(signed int _X4argci_1, char **_X4argvPPc_1, char **_X4envpPPc_1){
    328327    __attribute__ ((unused)) signed int _X12_retval_maini_1;
     
    339338    }
    340339
    341     signed int _tmp_cp_ret6;
    342     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
    343     {
    344         ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
    345     }
    346 
    347     {
    348         ((void)(_X12_retval_maini_1=_X3reti_2) /* ?{} */);
     340    {
     341        signed int _tmp_cp_ret6;
     342        ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6)) /* ?{} */);
    349343    }
    350344
  • tests/.expect/gccExtensions.x86.txt

    r3b8acfb rbe497c6  
    302302char **_X13cfa_args_argvPPc_1;
    303303char **_X13cfa_args_envpPPc_1;
    304 signed int _X17cfa_main_returnedi_1 = ((signed int )0);
    305304signed int main(signed int _X4argci_1, char **_X4argvPPc_1, char **_X4envpPPc_1){
    306305    __attribute__ ((unused)) signed int _X12_retval_maini_1;
     
    317316    }
    318317
    319     signed int _tmp_cp_ret6;
    320     signed int _X3reti_2 = (((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6);
    321     {
    322         ((void)(_X17cfa_main_returnedi_1=((signed int )1)));
    323     }
    324 
    325     {
    326         ((void)(_X12_retval_maini_1=_X3reti_2) /* ?{} */);
     318    {
     319        signed int _tmp_cp_ret6;
     320        ((void)(_X12_retval_maini_1=(((void)(_tmp_cp_ret6=invoke_main(_X4argci_1, _X4argvPPc_1, _X4envpPPc_1))) , _tmp_cp_ret6)) /* ?{} */);
    327321    }
    328322
  • tests/bitmanip3.cfa

    r3b8acfb rbe497c6  
    1010// Created On       : Tue Apr  7 21:22:59 2020
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug  8 23:12:19 2021
    13 // Update Count     : 76
     12// Last Modified On : Mon Aug 24 09:53:26 2020
     13// Update Count     : 66
    1414//
    1515
     
    133133        sout | nl | "floor2" | nl | nl;
    134134
    135         sout | "signed char";
     135        printf( "signed char\n" );
    136136        for ( sc = 1; sc != 0; sc <<= 1 ) {
    137137                scr1 = floor2( sc, sc ); scr2 = floor2( sc + 2hh, sc ); scr3 = floor2( -sc - 2hh, sc );
    138 //              printf( "floor2(%hhd, %hhd) = %hhd, floor2(%hhd, %hhd) = %hhd, floor2(%hhd, %hhd) = %hhd\n", sc, sc, scr1, sc + 2hh, sc, scr2, -sc - 2hh, sc, scr3 );
    139                 sout | "floor2(" | sc | "," | sc | ") = " | scr1 | ", floor2(" | sc + 2hh | "," | sc | ") = " | scr2 | ", floor2(" | -sc - 2hh | "," | sc | ") = " | scr3;
    140         } // for
    141         sout | nl;
    142 
    143         sout | "unsigned char";
     138                printf( "floor2(%hhd, %hhd) = %hhd, floor2(%hhd, %hhd) = %hhd, floor2(%hhd, %hhd) = %hhd\n", sc, sc, scr1, sc + 2hh, sc, scr2, -sc - 2hh, sc, scr3 );
     139        } // for
     140        printf( "\n" );
     141
     142        printf( "unsigned char\n" );
    144143        for ( uc = 1; uc != 0; uc <<= 1 ) {
    145144                ucr1 = floor2( uc, uc ); ucr2 = floor2( uc + 2hh, uc ); ucr3 = floor2( -uc - 2hh, uc );
    146 //              printf( "floor2(%hhu, %hhu) = %hhu, floor2(%hhu, %hhu) = %hhu, floor2(%hhu, %hhu) = %hhu\n", uc, uc, ucr1, uc + 2uhh, uc, ucr2, -uc - 2uhh, uc, ucr3 );
    147                 sout | "floor2(" | uc | "," | uc | ") = " | ucr1 | ", floor2(" | uc + 2uhh | "," | uc | ") = " | ucr2 | ", floor2(" | -uc - 2uhh | "," | uc | ") = " | ucr3;
    148         } // for
    149         sout | nl;
    150 
    151         sout | "short int";
     145                printf( "floor2(%hhu, %hhu) = %hhu, floor2(%hhu, %hhu) = %hhu, floor2(%hhu, %hhu) = %hhu\n", uc, uc, ucr1, uc + 2uhh, uc, ucr2, -uc - 2uhh, uc, ucr3 );
     146        } // for
     147        printf( "\n" );
     148
     149        printf( "short int\n" );
    152150        for ( si = 1; si != 0; si <<= 1 ) {
    153151                sir1 = floor2( si, si ); sir2 = floor2( si + 2hh, si ); sir3 = floor2( -si - 2hh, si );
    154 //              printf( "floor2(%hd, %hd) = %hd, floor2(%hd, %hd) = %hd, floor2(%hd, %hd) = %hd\n", si, si, sir1, si + 2h, si, sir2, -si - 2h, si, sir3 );
    155                 sout | "floor2(" | si | "," | si | ") = " | sir1 | ", floor2(" | si + 2h | "," | si | ") = " | sir2 | ", floor2(" | -si - 2h | "," | si | ") = " | sir3;
    156         } // for
    157         sout | nl;
    158 
    159         sout | "unsigned short int";
     152                printf( "floor2(%hd, %hd) = %hd, floor2(%hd, %hd) = %hd, floor2(%hd, %hd) = %hd\n", si, si, sir1, si + 2h, si, sir2, -si - 2h, si, sir3 );
     153        } // for
     154        printf( "\n" );
     155
     156        printf( "unsigned short int\n" );
    160157        for ( usi = 1; usi != 0; usi <<= 1 ) {
    161158                usir1 = floor2( usi, usi ); usir2 = floor2( usi + 2hh, usi ); usir3 = floor2( -usi - 2hh, usi );
    162 //              printf( "floor2(%hu, %hu) = %hu, floor2(%hu, %hu) = %hu, floor2(%hu, %hu) = %hu\n", usi, usi, usir1, usi + 2uh, usi, usir2, -usi - 2uh, usi, usir3 );
    163                 sout | "floor2(" | usi | "," | usi | ") = " | usir1 | ", floor2(" | usi + 2uh | "," | usi | ") = " | usir2 | ", floor2(" | -usi - 2uh | "," | usi | ") = " | usir3;
    164         } // for
    165         sout | nl;
    166 
    167         sout | "int";
     159                printf( "floor2(%hu, %hu) = %hu, floor2(%hu, %hu) = %hu, floor2(%hu, %hu) = %hu\n", usi, usi, usir1, usi + 2uh, usi, usir2, -usi - 2uh, usi, usir3 );
     160        } // for
     161        printf( "\n" );
     162
     163        printf( "int\n" );
    168164        for ( i = 1; i != 0; i <<= 1 ) {
    169165                ir1 = floor2( i, i ); ir2 = floor2( i + 2hh, i ); ir3 = floor2( -i - 2hh, i );
    170 //              printf( "floor2(%d, %d) = %d, floor2(%d, %d) = %d, floor2(%d, %d) = %d\n", i, i, ir1, i + 2, i, ir2, -i - 2, i, ir3 );
    171                 sout | "floor2(" | i | "," | i | ") = " | ir1 | ", floor2(" | i + 2 | "," | i | ") = " | ir2 | ", floor2(" | -i - 2 | "," | i | ") = " | ir3;
    172         } // for
    173         sout | nl;
    174 
    175         sout | "unsigned int";
     166                printf( "floor2(%d, %d) = %d, floor2(%d, %d) = %d, floor2(%d, %d) = %d\n", i, i, ir1, i + 2h, i, ir2, -i - 2h, i, ir3 );
     167        } // for
     168        printf( "\n" );
     169
     170        printf( "unsigned int\n" );
    176171        for ( ui = 1; ui != 0; ui <<= 1 ) {
    177172                uir1 = floor2( ui, ui ); uir2 = floor2( ui + 2hh, ui ); uir3 = floor2( -ui - 2hh, ui );
    178 //              printf( "floor2(%u, %u) = %u, floor2(%u, %u) = %u, floor2(%u, %u) = %u\n", ui, ui, uir1, ui + 2, ui, uir2, -ui - 2, ui, uir3 );
    179                 sout | "floor2(" | ui | "," | ui | ") = " | uir1 | ", floor2(" | ui + 2 | "," | ui | ") = " | uir2 | ", floor2(" | -ui - 2 | "," | ui | ") = " | uir3;
    180         } // for
    181         sout | nl;
    182 
    183         sout | "long int";
     173                printf( "floor2(%u, %u) = %u, floor2(%u, %u) = %u, floor2(%u, %u) = %u\n", ui, ui, uir1, ui + 2h, ui, uir2, -ui - 2h, ui, uir3 );
     174        } // for
     175        printf( "\n" );
     176
     177        printf( "long int\n" );
    184178        for ( li = 1; li != 0; li <<= 1 ) {
    185179                lir1 = floor2( li, li ); lir2 = floor2( li + 2hh, li ); lir3 = floor2( -li - 2hh, li );
    186 //              printf( "floor2(%ld, %ld) = %ld, floor2(%ld, %ld) = %ld, floor2(%ld, %ld) = %ld\n", li, li, lir1, li + 2l, li, lir2, -li - 2l, li, lir3 );
    187                 sout | "floor2(" | li | "," | li | ") = " | lir1 | ", floor2(" | li + 2l | "," | li | ") = " | lir2 | ", floor2(" | -li - 2l | "," | li | ") = " | lir3;
    188         } // for
    189         sout | nl;
    190 
    191         sout | "unsigned long int";
     180                printf( "floor2(%ld, %ld) = %ld, floor2(%ld, %ld) = %ld, floor2(%ld, %ld) = %ld\n", li, li, lir1, li + 2h, li, lir2, -li - 2h, li, lir3 );
     181        } // for
     182        printf( "\n" );
     183
     184        printf( "unsigned long int\n" );
    192185        for ( uli = 1; uli != 0; uli <<= 1 ) {
    193186                ulir1 = floor2( uli, uli ); ulir2 = floor2( uli + 2hh, uli ); ulir3 = floor2( -uli - 2hh, uli );
    194 //              printf( "floor2(%lu, %lu) = %lu, floor2(%lu, %lu) = %lu, floor2(%lu, %lu) = %lu\n", uli, uli, ulir1, uli + 2l, uli, ulir2, -uli - 2l, uli, ulir3 );
    195                 sout | "floor2(" | uli | "," | uli | ") = " | ulir1 | ", floor2(" | uli + 2l | "," | uli | ") = " | ulir2 | ", floor2(" | -uli - 2l | "," | uli | ") = " | ulir3;
    196         } // for
    197         sout | nl;
    198 
    199         sout | "long long int";
     187                printf( "floor2(%lu, %lu) = %lu, floor2(%lu, %lu) = %lu, floor2(%lu, %lu) = %lu\n", uli, uli, ulir1, uli + 2h, uli, ulir2, -uli - 2h, uli, ulir3 );
     188        } // for
     189        printf( "\n" );
     190
     191        printf( "long long int\n" );
    200192        for ( lli = 1; lli != 0; lli <<= 1 ) {
    201193                llir1 = floor2( lli, lli ); llir2 = floor2( lli + 2hh, lli ); llir3 = floor2( -lli - 2hh, lli );
    202 //              printf( "floor2(%lld, %lld) = %lld, floor2(%lld, %lld) = %lld, floor2(%lld, %lld) = %lld\n", lli, lli, llir1, lli + 2ll, lli, llir2, -lli - 2ll, lli, llir3 );
    203                 sout | "floor2(" | lli | "," | lli | ") = " | llir1 | ", floor2(" | lli + 2ll | "," | lli | ") = " | llir2 | ", floor2(" | -lli - 2ll | "," | lli | ") = " | llir3;
    204         } // for
    205         sout | nl;
    206 
    207         sout | "unsigned long long int";
     194                printf( "floor2(%lld, %lld) = %lld, floor2(%lld, %lld) = %lld, floor2(%lld, %lld) = %lld\n", lli, lli, llir1, lli + 2h, lli, llir2, -lli - 2h, lli, llir3 );
     195        } // for
     196        printf( "\n" );
     197
     198        printf( "unsigned long long int\n" );
    208199        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
    209200                ullir1 = floor2( ulli, ulli ); ullir2 = floor2( ulli + 2hh, ulli ); ullir3 = floor2( -ulli - 2hh, ulli );
    210 //              printf( "floor2(%llu, %llu) = %llu, floor2(%llu, %llu) = %llu, floor2(%llu, %llu) = %llu\n", ulli, ulli, ullir1, ulli + 2h, ulli, ullir2, -ulli - 2h, ulli, ullir3 );
    211                 sout | "floor2(" | ulli | "," | ulli | ") = " | ullir1 | ", floor2(" | ulli + 2ll | "," | ulli | ") = " | ullir2 | ", floor2(" | -ulli - 2ll | "," | ulli | ") = " | ullir3;
    212         } // for
    213         sout | nl;
     201                printf( "floor2(%llu, %llu) = %llu, floor2(%llu, %llu) = %llu, floor2(%llu, %llu) = %llu\n", ulli, ulli, ullir1, ulli + 2h, ulli, ullir2, -ulli - 2h, ulli, ullir3 );
     202        } // for
     203        printf( "\n" );
    214204#endif // 0
    215205        //============================================================
     
    217207        sout | nl | "ceiling2" | nl | nl;
    218208
    219         sout | "signed char";
     209        printf( "signed char\n" );
    220210        for ( sc = 1; sc != 0; sc <<= 1 ) {
    221211                scr1 = ceiling2( sc, sc ); scr2 = ceiling2( sc + 2hh, sc ); scr3 = ceiling2( -sc - 2hh, sc );
    222 //              printf( "ceiling2(%hhd, %hhd) = %hhd, ceiling2(%hhd, %hhd) = %hhd, ceiling2(%hhd, %hhd) = %hhd\n", sc, sc, scr1, sc + 2hh, sc, scr2, -sc - 2hh, sc, scr3 );
    223                 sout | "ceiling2(" | sc | "," | sc | ") = " | scr1 | ", ceiling2(" | sc + 2hh | "," | sc | ") = " | scr2 | ", ceiling2(" | -sc - 2hh | "," | sc | ") = " | scr3;
    224         } // for
    225         sout | nl;
    226 
    227         sout | "unsigned char";
     212                printf( "ceiling2(%hhd, %hhd) = %hhd, ceiling2(%hhd, %hhd) = %hhd, ceiling2(%hhd, %hhd) = %hhd\n", sc, sc, scr1, sc + 2hh, sc, scr2, -sc - 2hh, sc, scr3 );
     213        } // for
     214        printf( "\n" );
     215
     216        printf( "unsigned char\n" );
    228217        for ( uc = 1; uc != 0; uc <<= 1 ) {
    229218                ucr1 = ceiling2( uc, uc ); ucr2 = ceiling2( uc + 2hh, uc ); ucr3 = ceiling2( -uc - 2hh, uc );
    230 //              printf( "ceiling2(%hhu, %hhu) = %hhu, ceiling2(%hhu, %hhu) = %hhu, ceiling2(%hhu, %hhu) = %hhu\n", uc, uc, ucr1, uc + 2uhh, uc, ucr2, -uc - 2uhh, uc, ucr3 );
    231                 sout | "ceiling2(" | uc | "," | uc | ") = " | ucr1 | ", ceiling2(" | uc + 2hh | "," | uc | ") = " | ucr2 | ", ceiling2(" | -uc - 2hh | "," | uc | ") = " | ucr3;
    232         } // for
    233         sout | nl;
    234 
    235         sout | "short int";
     219                printf( "ceiling2(%hhu, %hhu) = %hhu, ceiling2(%hhu, %hhu) = %hhu, ceiling2(%hhu, %hhu) = %hhu\n", uc, uc, ucr1, uc + 2uhh, uc, ucr2, -uc - 2uhh, uc, ucr3 );
     220        } // for
     221        printf( "\n" );
     222
     223        printf( "short int\n" );
    236224        for ( si = 1; si != 0; si <<= 1 ) {
    237225                sir1 = ceiling2( si, si ); sir2 = ceiling2( si + 2hh, si ); sir3 = ceiling2( -si - 2hh, si );
    238 //              printf( "ceiling2(%hd, %hd) = %hd, ceiling2(%hd, %hd) = %hd, ceiling2(%hd, %hd) = %hd\n", si, si, sir1, si + 2h, si, sir2, -si - 2h, si, sir3 );
    239                 sout | "ceiling2(" | si | "," | si | ") = " | sir1 | ", ceiling2(" | si + 2h | "," | si | ") = " | sir2 | ", ceiling2(" | -si - 2h | "," | si | ") = " | sir3;
    240         } // for
    241         sout | nl;
    242 
    243         sout | "unsigned short int";
     226                printf( "ceiling2(%hd, %hd) = %hd, ceiling2(%hd, %hd) = %hd, ceiling2(%hd, %hd) = %hd\n", si, si, sir1, si + 2h, si, sir2, -si - 2h, si, sir3 );
     227        } // for
     228        printf( "\n" );
     229
     230        printf( "unsigned short int\n" );
    244231        for ( usi = 1; usi != 0; usi <<= 1 ) {
    245232                usir1 = ceiling2( usi, usi ); usir2 = ceiling2( usi + 2hh, usi ); usir3 = ceiling2( -usi - 2hh, usi );
    246 //              printf( "ceiling2(%hu, %hu) = %hu, ceiling2(%hu, %hu) = %hu, ceiling2(%hu, %hu) = %hu\n", usi, usi, usir1, usi + 2uh, usi, usir2, -usi - 2uh, usi, usir3 );
    247                 sout | "ceiling2(" | usi | "," | usi | ") = " | usir1 | ", ceiling2(" | usi + 2h | "," | usi | ") = " | usir2 | ", ceiling2(" | -usi - 2h | "," | usi | ") = " | usir3;
    248         } // for
    249         sout | nl;
    250 
    251         sout | "int";
     233                printf( "ceiling2(%hu, %hu) = %hu, ceiling2(%hu, %hu) = %hu, ceiling2(%hu, %hu) = %hu\n", usi, usi, usir1, usi + 2uh, usi, usir2, -usi - 2uh, usi, usir3 );
     234        } // for
     235        printf( "\n" );
     236
     237        printf( "int\n" );
    252238        for ( i = 1; i != 0; i <<= 1 ) {
    253239                ir1 = ceiling2( i, i ); ir2 = ceiling2( i + 2hh, i ); ir3 = ceiling2( -i - 2hh, i );
    254 //              printf( "ceiling2(%d, %d) = %d, ceiling2(%d, %d) = %d, ceiling2(%d, %d) = %d\n", i, i, ir1, i + 2, i, ir2, -i - 2, i, ir3 );
    255                 sout | "ceiling2(" | i | "," | i | ") = " | ir1 | ", ceiling2(" | i + 2 | "," | i | ") = " | ir2 | ", ceiling2(" | -i - 2 | "," | i | ") = " | ir3;
    256         } // for
    257         sout | nl;
    258 
    259         sout | "unsigned int";
     240                printf( "ceiling2(%d, %d) = %d, ceiling2(%d, %d) = %d, ceiling2(%d, %d) = %d\n", i, i, ir1, i + 2h, i, ir2, -i - 2h, i, ir3 );
     241        } // for
     242        printf( "\n" );
     243
     244        printf( "unsigned int\n" );
    260245        for ( ui = 1; ui != 0; ui <<= 1 ) {
    261246                uir1 = ceiling2( ui, ui ); uir2 = ceiling2( ui + 2hh, ui ); uir3 = ceiling2( -ui - 2hh, ui );
    262 //              printf( "ceiling2(%u, %u) = %u, ceiling2(%u, %u) = %u, ceiling2(%u, %u) = %u\n", ui, ui, uir1, ui + 2, ui, uir2, -ui - 2, ui, uir3 );
    263                 sout | "ceiling2(" | ui | "," | ui | ") = " | uir1 | ", ceiling2(" | ui + 2 | "," | ui | ") = " | uir2 | ", ceiling2(" | -ui - 2 | "," | ui | ") = " | uir3;
    264         } // for
    265         sout | nl;
    266 
    267         sout | "long int";
     247                printf( "ceiling2(%u, %u) = %u, ceiling2(%u, %u) = %u, ceiling2(%u, %u) = %u\n", ui, ui, uir1, ui + 2h, ui, uir2, -ui - 2h, ui, uir3 );
     248        } // for
     249        printf( "\n" );
     250
     251        printf( "long int\n" );
    268252        for ( li = 1; li != 0; li <<= 1 ) {
    269253                lir1 = ceiling2( li, li ); lir2 = ceiling2( li + 2hh, li ); lir3 = ceiling2( -li - 2hh, li );
    270 //              printf( "ceiling2(%ld, %ld) = %ld, ceiling2(%ld, %ld) = %ld, ceiling2(%ld, %ld) = %ld\n", li, li, lir1, li + 2l, li, lir2, -li - 2l, li, lir3 );
    271                 sout | "ceiling2(" | li | "," | li | ") = " | lir1 | ", ceiling2(" | li + 2l | "," | li | ") = " | lir2 | ", ceiling2(" | -li - 2l | "," | li | ") = " | lir3;
    272         } // for
    273         sout | nl;
    274 
    275         sout | "unsigned long int";
     254                printf( "ceiling2(%ld, %ld) = %ld, ceiling2(%ld, %ld) = %ld, ceiling2(%ld, %ld) = %ld\n", li, li, lir1, li + 2h, li, lir2, -li - 2h, li, lir3 );
     255        } // for
     256        printf( "\n" );
     257
     258        printf( "unsigned long int\n" );
    276259        for ( uli = 1; uli != 0; uli <<= 1 ) {
    277260                ulir1 = ceiling2( uli, uli ); ulir2 = ceiling2( uli + 2hh, uli ); ulir3 = ceiling2( -uli - 2hh, uli );
    278 //              printf( "ceiling2(%lu, %lu) = %lu, ceiling2(%lu, %lu) = %lu, ceiling2(%lu, %lu) = %lu\n", uli, uli, ulir1, uli + 2, uli, ulir2, -uli - 2, uli, ulir3 );
    279                 sout | "ceiling2(" | uli | "," | uli | ") = " | ulir1 | ", ceiling2(" | uli + 2l | "," | uli | ") = " | ulir2 | ", ceiling2(" | -uli - 2l | "," | uli | ") = " | ulir3;
    280         } // for
    281         sout | nl;
    282 
    283         sout | "long long int";
     261                printf( "ceiling2(%lu, %lu) = %lu, ceiling2(%lu, %lu) = %lu, ceiling2(%lu, %lu) = %lu\n", uli, uli, ulir1, uli + 2h, uli, ulir2, -uli - 2h, uli, ulir3 );
     262        } // for
     263        printf( "\n" );
     264
     265        printf( "long long int\n" );
    284266        for ( lli = 1; lli != 0; lli <<= 1 ) {
    285267                llir1 = ceiling2( lli, lli ); llir2 = ceiling2( lli + 2hh, lli ); llir3 = ceiling2( -lli - 2hh, lli );
    286 //              printf( "ceiling2(%lld, %lld) = %lld, ceiling2(%lld, %lld) = %lld, ceiling2(%lld, %lld) = %lld\n", lli, lli, llir1, lli + 2ll, lli, llir2, -lli - 2ll, lli, llir3 );
    287                 sout | "ceiling2(" | lli | "," | lli | ") = " | llir1 | ", ceiling2(" | lli + 2ll | "," | lli | ") = " | llir2 | ", ceiling2(" | -lli - 2ll | "," | lli | ") = " | llir3;
    288         } // for
    289         sout | nl;
    290 
    291         sout | "unsigned long long int";
     268                printf( "ceiling2(%lld, %lld) = %lld, ceiling2(%lld, %lld) = %lld, ceiling2(%lld, %lld) = %lld\n", lli, lli, llir1, lli + 2h, lli, llir2, -lli - 2h, lli, llir3 );
     269        } // for
     270        printf( "\n" );
     271
     272        printf( "unsigned long long int\n" );
    292273        for ( ulli = 1; ulli != 0; ulli <<= 1 ) {
    293274                ullir1 = ceiling2( ulli, ulli ); ullir2 = ceiling2( ulli + 2hh, ulli ); ullir3 = ceiling2( -ulli - 2hh, ulli );
    294 //              printf( "ceiling2(%llu, %llu) = %llu, ceiling2(%llu, %llu) = %llu, ceiling2(%llu, %llu) = %llu\n", ulli, ulli, ullir1, ulli + 2h, ulli, ullir2, -ulli - 2h, ulli, ullir3 );
    295                 sout | "ceiling2(" | ulli | "," | ulli | ") = " | ullir1 | ", ceiling2(" | ulli + 2ll | "," | ulli | ") = " | ullir2 | ", ceiling2(" | -ulli - 2ll | "," | ulli | ") = " | ullir3;
    296         } // for
    297         sout | nl;
     275                printf( "ceiling2(%llu, %llu) = %llu, ceiling2(%llu, %llu) = %llu, ceiling2(%llu, %llu) = %llu\n", ulli, ulli, ullir1, ulli + 2h, ulli, ullir2, -ulli - 2h, ulli, ullir3 );
     276        } // for
     277        printf( "\n" );
    298278#endif // 0
    299279} // main
  • tests/mathX.cfa

    r3b8acfb rbe497c6  
    1010// Created On       : Thu May 24 20:56:54 2018
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sun Aug  8 22:33:46 2021
    13 // Update Count     : 31
     12// Last Modified On : Sat Feb 20 18:26:38 2021
     13// Update Count     : 30
    1414//
    1515
     
    255255                sout | "ceiling(" | ulli | ", " | ulli | ") = " | ullir1 | ", ceiling(" | ulli + 2ull | ", " | ulli | ") = " | ullir2 | ", ceiling(" | -ulli - 2ull | ", " | ulli | ") = " | ullir3;
    256256        } // for
    257         sout | nl;
     257        printf( "\n" );
    258258#endif // 0
    259259} // main
Note: See TracChangeset for help on using the changeset viewer.