Changeset d923fca


Ignore:
Timestamp:
Feb 18, 2025, 12:54:23 PM (5 weeks ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
8705a11
Parents:
3e5fea2
Message:

Clean-up the warnings of the concurrency tests. A lot of little test level fixes, the most interesting repeated one is some formally redundent fallthough statements. pthread_attr_test had to be rewritten because of library restrictions. Changed some types so they would always be pointer sized. There was a library change, there was a function that could not be implemented; I trust that it is included for a reason so I just put it in a comment. There is a change to the compiler, wait-until now uses goto. The labelled breaks were code generated as unlabelled breaks and although it worked out slipped through some checks. Finally, there is one warning that I cannot solve at this time so tests that produce it have been put in their own lax group.

Files:
20 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified libcfa/src/concurrency/future.hfa

    r3e5fea2 rd923fca  
    176176        }
    177177
    178         bool on_selected( future(T) & this, select_node & node ) { return true; }
     178        bool on_selected( future(T) &, select_node & ) { return true; }
    179179        }
    180180}
     
    204204                // Mark the future as abandoned, meaning it will be deleted by the server
    205205                // This doesn't work beause of the potential need for a destructor
    206                 void abandon( single_future(T) & this );
     206                // void abandon( single_future(T) & this );
    207207
    208208                // Fulfil the future, returns whether or not someone was unblocked
  • TabularUnified src/Concurrency/Waituntil.cpp

    r3e5fea2 rd923fca  
    720720                                                )
    721721                                            ),
    722                                             new BranchStmt( cLoc, BranchStmt::Kind::Break, Label( cLoc, switchLabel ) )
     722                                            new BranchStmt( cLoc, BranchStmt::Goto, Label( cLoc, switchLabel ) )
    723723                                        }
    724724                                    )
     
    733733                        new NameExpr( loc, idxName ),
    734734                        std::move( switchCases ),
     735                        {}
     736                )
     737        );
     738
     739        ifBody->push_back(
     740                new NullStmt( loc,
    735741                        { Label( loc, switchLabel ) }
    736742                )
     
    790796                                                { new NameExpr( loc, clauseData.at(0)->statusName ) }
    791797                                            ),
    792                                             new BranchStmt( loc, BranchStmt::Kind::Break, Label( loc, forLabel ) )
     798                                            new BranchStmt( loc, BranchStmt::Goto, Label( loc, forLabel ) )
    793799                                        ),
    794800                                        ifSwitch
    795801                                    }
    796802                                ),   // body
     803                                {}
     804                        ),
     805                        new NullStmt( loc,
    797806                                { Label( loc, forLabel ) }
    798807                        )
  • TabularUnified tests/Makefile.am

    r3e5fea2 rd923fca  
    5252WFLAGS_OPT_LAX = \
    5353        ${WFLAGS_OPT_LAX_EXPECT_WARN} \
     54        ${WFLAGS_OPT_LAX_WAITING_ON_303} \
    5455        ${WFLAGS_OPT_LAX_TO_INVESTIGATE}
    5556
     
    6061        warnings/self-assignment
    6162
    62 # Tests that need investigation from the CFA team about why they require lax wflags.  Goal is to eliminate this list.
    63 WFLAGS_OPT_LAX_TO_INVESTIGATE = \
     63# These are failing because of trac #303; it is not likely to be fixed soon.
     64# It only shows up on some configurations and machines.
     65WFLAGS_OPT_LAX_WAITING_ON_303 = \
    6466        concurrency/actors/dynamic \
    6567        concurrency/actors/executor \
     
    7072        concurrency/actors/poison \
    7173        concurrency/actors/static \
    72         concurrency/actors/types \
    73         concurrency/channels/churn \
    74         concurrency/channels/contend \
    75         concurrency/channels/daisy_chain \
    76         concurrency/channels/hot_potato \
    77         concurrency/channels/pub_sub \
    78         concurrency/futures/multi \
    79         concurrency/futures/select_future \
    80         concurrency/futures/typed \
    81         concurrency/lockfree_stack \
    82         concurrency/pthread/bounded_buffer \
    83         concurrency/pthread/pthread_attr_test \
    84         concurrency/pthread/pthread_demo_create_join \
    85         concurrency/pthread/pthread_demo_lock \
    86         concurrency/pthread/pthread_key_test \
    87         concurrency/waituntil/all_types \
    88         concurrency/waituntil/basic_else \
    89         concurrency/waituntil/channel_close \
    90         concurrency/waituntil/channels \
    91         concurrency/waituntil/futures \
    92         concurrency/waituntil/locks \
    93         concurrency/waituntil/repeat_close \
    94         concurrency/waituntil/timeout \
     74        concurrency/actors/types
     75
     76# Tests that need investigation from the CFA team about why they require lax wflags.  Goal is to eliminate this list.
     77WFLAGS_OPT_LAX_TO_INVESTIGATE = \
    9578        exceptions/cardgame \
    9679        exceptions/defaults \
  • TabularUnified tests/concurrency/actors/executor.cfa

    r3e5fea2 rd923fca  
    2424struct d_msg { inline message; } shared_msg;
    2525
    26 allocation receive( d_actor & this, d_msg & msg ) with( this ) {
     26allocation receive( d_actor & this, d_msg & ) with( this ) {
    2727        if ( recs == rounds ) return Finished;
    2828        if ( recs % Batch == 0 ) {
     
    4343                        if ( BufSize < 0 ) fallthrough default;
    4444                } // if
     45                fallthrough;
    4546          case 6:
    4647                if ( strcmp( argv[5], "d" ) != 0 ) {                    // default ?
     
    4849                        if ( Batch < 1 ) fallthrough default;
    4950                } // if
     51                fallthrough;
    5052          case 5:
    5153                if ( strcmp( argv[4], "d" ) != 0 ) {                    // default ?
     
    5355                        if ( Processors < 1 ) fallthrough default;
    5456                } // if
     57                fallthrough;
    5558          case 4:
    5659                if ( strcmp( argv[3], "d" ) != 0 ) {                    // default ?
     
    5861                        if ( Rounds < 1 ) fallthrough default;
    5962                } // if
     63                fallthrough;
    6064          case 3:
    6165                if ( strcmp( argv[2], "d" ) != 0 ) {                    // default ?
     
    6367                        if ( Set < 1 ) fallthrough default;
    6468                } // if
     69                fallthrough;
    6570          case 2:
    6671                if ( strcmp( argv[1], "d" ) != 0 ) {                    // default ?
     
    6873                        if ( Actors < 1 || Actors <= Set || Actors % Set != 0 ) fallthrough default;
    6974                } // if
     75                fallthrough;
    7076          case 1:                                                                                       // use defaults
    7177                break;
  • TabularUnified tests/concurrency/actors/matrixMultiply.cfa

    r3e5fea2 rd923fca  
    2424}
    2525
    26 allocation receive( derived_actor & receiver, derived_msg & msg ) {
     26allocation receive( derived_actor &, derived_msg & msg ) {
    2727        for ( i; yc ) {                                                                         // multiply X_row by Y_col and sum products
    2828                msg.Z[i] = 0;
     
    4141                        if ( Processors < 1 ) fallthrough default;
    4242                } // if
     43        fallthrough;
    4344          case 4:
    4445                if ( strcmp( argv[3], "d" ) != 0 ) {                    // default ?
     
    4647                        if ( xr < 1 ) fallthrough default;
    4748                } // if
     49        fallthrough;
    4850          case 3:
    4951                if ( strcmp( argv[2], "d" ) != 0 ) {                    // default ?
     
    5153                        if ( xc < 1 ) fallthrough default;
    5254                } // if
     55        fallthrough;
    5356          case 2:
    5457                if ( strcmp( argv[1], "d" ) != 0 ) {                    // default ?
     
    5659                        if ( yc < 1 ) fallthrough default;
    5760                } // if
     61        fallthrough;
    5862          case 1:                                                                                       // use defaults
    5963                break;
  • TabularUnified tests/concurrency/channels/churn.cfa

    r3e5fea2 rd923fca  
    3030}
    3131
    32 void main(Consumer & this) {
     32void main(Consumer &) {
    3333    size_t i = 0;
    3434    size_t runs = 0;
     
    5353            }
    5454        } catchResume ( channel_closed * e ) {} // continue to remove until would block
    55         catch ( channel_closed * e ) {} 
     55        catch ( channel_closed * e ) {}
    5656    }
    5757
     
    6565thread Producer {};
    6666
    67 void main(Producer & this) {
     67void main(Producer &) {
    6868    size_t i = 0;
    6969    size_t runs = 0;
     
    7777            runs++;
    7878        }
    79     } catch ( channel_closed * e ) {} 
     79    } catch ( channel_closed * e ) {}
    8080    lock(o);
    8181    total_operations += runs;
     
    9393                        if ( ChannelSize < 1 ) fallthrough default;
    9494                } // if
     95                fallthrough;
    9596      case 3:
    9697                if ( strcmp( argv[2], "d" ) != 0 ) {                    // default ?
     
    9899                        if ( Channels < 1 ) fallthrough default;
    99100                } // if
     101                fallthrough;
    100102      case 2:
    101103                if ( strcmp( argv[1], "d" ) != 0 ) {                    // default ?
     
    103105                        if ( Processors < 1 ) fallthrough default;
    104106                } // if
     107                fallthrough;
    105108          case 1:                                                                                       // use defaults
    106109                break;
     
    121124
    122125    sout | "start";
    123     {   
     126    {
    124127        Consumer c[Consumers];
    125128        {
  • TabularUnified tests/concurrency/channels/contend.cfa

    r3e5fea2 rd923fca  
    130130                        if ( ChannelSize < 1 ) fallthrough default;
    131131                } // if
     132                fallthrough;
    132133          case 2:
    133134                if ( strcmp( argv[1], "d" ) != 0 ) {                    // default ?
     
    135136                        if ( Processors < 1 ) fallthrough default;
    136137                } // if
     138                fallthrough;
    137139          case 1:                                                                                       // use defaults
    138140                break;
  • TabularUnified tests/concurrency/channels/daisy_chain.cfa

    r3e5fea2 rd923fca  
    1717
    1818thread Task {};
    19 void main(Task & this) {
     19void main(Task &) {
    2020    size_t runs = 0;
    2121    int token = 0;
     
    4040            if ( Tasks < 1 ) fallthrough default;
    4141                } // if
     42                fallthrough;
    4243          case 2:
    4344                if ( strcmp( argv[1], "d" ) != 0 ) {                    // default ?
     
    4546                        if ( Processors < 1 ) fallthrough default;
    4647                } // if
     48                fallthrough;
    4749          case 1:                                                                                       // use defaults
    4850                break;
  • TabularUnified tests/concurrency/channels/hot_potato.cfa

    r3e5fea2 rd923fca  
    4545            if ( Tasks < 1 ) fallthrough default;
    4646                } // if
     47                fallthrough;
    4748          case 2:
    4849                if ( strcmp( argv[1], "d" ) != 0 ) {                    // default ?
     
    5051                        if ( Processors < 1 ) fallthrough default;
    5152                } // if
     53                fallthrough;
    5254          case 1:                                                                                       // use defaults
    5355                break;
  • TabularUnified tests/concurrency/channels/pub_sub.cfa

    r3e5fea2 rd923fca  
    9090            if ( Tasks < 1 ) fallthrough default;
    9191                } // if
     92                fallthrough;
    9293          case 2:
    9394                if ( strcmp( argv[1], "d" ) != 0 ) {                    // default ?
     
    9596                        if ( Processors < 1 ) fallthrough default;
    9697                } // if
     98                fallthrough;
    9799          case 1:                                                                                       // use defaults
    98100                break;
  • TabularUnified tests/concurrency/lockfree_stack.cfa

    r3e5fea2 rd923fca  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // lockfree_stack.cfa -- 
     7// lockfree_stack.cfa --
    88//
    99// Author           : Peter A. Buhr
     
    1212// Last Modified On : Fri Jun  9 14:01:07 2023
    1313// Update Count     : 68
    14 // 
     14//
    1515
    1616#include <thread.hfa>
     
    4242        n.next = stack;                                                                         // atomic assignment unnecessary
    4343        for () {                                                                                        // busy wait
    44                 Link temp{ &n, n.next.count + 1 };
     44                Link temp{ { &n, n.next.count + 1 } };
    4545                if ( CASV( s.stack.atom, n.next.atom, temp.atom ) ) break; // attempt to update top node
    4646        }
     
    5151        for () {                                                                                        // busy wait
    5252                if ( t.top == NULL ) return NULL;                               // empty stack ?
    53                 Link temp{ t.top->next.top, t.count };
     53                Link temp{ { t.top->next.top, t.count } };
    5454                if ( CASV( stack.atom, t.atom, temp.atom ) ) return t.top; // attempt to update top node
    5555        }
     
    6262
    6363thread Worker {};
    64 void main( Worker & w ) {
     64void main( Worker & ) {
    6565        for ( i; Times ) {
    6666                Node & n = *pop( stack );                                               // pop any node
  • TabularUnified tests/concurrency/pthread/pthread_attr_test.cfa

    r3e5fea2 rd923fca  
    44#include <thread.hfa>
    55
    6 void* foo(void* _attr){
     6void* foo(void*){
     7    pthread_t self = pthread_self();
     8    pthread_attr_t self_attr;
     9    pthread_getattr_np(self, &self_attr);
     10
    711    size_t size;
    8     pthread_attr_t* attr = (pthread_attr_t*)_attr;
    9     int status = pthread_attr_getstacksize(attr, &size);
     12    int status = pthread_attr_getstacksize(&self_attr, &size);
    1013    if (status != 0){
    1114        sout | "error return code";
     
    1619}
    1720
    18 int main(int argc, char const *argv[])
     21int main()
    1922{
    2023    pthread_attr_t attr;
     
    2326    pthread_t thr;
    2427    void* res;
    25     pthread_create(&thr, &attr, foo, (void*)&attr);
     28    pthread_create(&thr, &attr, foo, (void*)0);
    2629    pthread_join(thr, &res);
    2730    pthread_attr_destroy(&attr);
  • TabularUnified tests/concurrency/pthread/pthread_demo_create_join.cfa

    r3e5fea2 rd923fca  
    33/* test pthread create/join/exit */
    44
    5 int arr[20];
     5size_t arr[20];
    66
    77void* fetch(void* idx){
    8     int res = arr[(uint64_t)idx];
     8    size_t res = arr[(size_t)idx];
    99    pthread_exit((void*)res);
    1010    sout | "it should not be here";
     
    1919}
    2020
    21 int main(int argc, char const *argv[])
     21int main()
    2222{
    2323    pthread_t threads[20];
    2424    arr_init();
    2525    int status;
    26     for (int i = 0; i < 20; i++){
     26    for (size_t i = 0; i < 20; i++){
    2727        status = pthread_create(&threads[i], NULL, fetch, (void*)i);
    2828        if (status != 0) exit(1);
     
    3030    int res = 0;
    3131    for (int i = 0; i < 20; i++){
    32         void* _res = NULL;
    33         status = pthread_join(threads[i], &_res);
     32        void* res_i = NULL;
     33        status = pthread_join(threads[i], &res_i);
    3434        if (status != 0) exit(2);
    35         if (((uint64_t)_res) != i) exit(3);
    36         res += (uint64_t)_res;
     35        if (((size_t)res_i) != i) exit(3);
     36        res += (size_t)res_i;
    3737    }
    3838    sout | "final res is" | res;
  • TabularUnified tests/concurrency/pthread/pthread_key_test.cfa

    r3e5fea2 rd923fca  
    1616    #define BUFFSZ  48
    1717    pthread_key_t   key;
    18     volatile int total_value,total_value_getspec;
     18    volatile size_t total_value;
     19    volatile size_t total_value_getspec;
    1920    pthread_mutex_t value_mutex;
    2021
     
    2627        int       *tnum;
    2728        void      *getvalue;
    28         char       Buffer[BUFFSZ];
    2929
    3030        tnum = (int*)parm;
     
    3232
    3333        //printf("Thread %d executing\n", threadnum);
    34         value = (void *)(rand()%100);
     34        value = (void *)(size_t)(rand()%100);
    3535        status = pthread_setspecific(key, (void *) value);
    3636        if ( status !=  0) {
     
    4040        }
    4141        pthread_mutex_lock(&value_mutex);
    42         total_value_getspec += (int)value;
    43         total_value += (int)pthread_getspecific(key);
     42        total_value_getspec += (size_t)value;
     43        total_value += (size_t)pthread_getspecific(key);
    4444        pthread_mutex_unlock(&value_mutex);
    4545
    4646
    47         if (!(value = malloc(sizeof(Buffer))))
     47        if (!(value = malloc(BUFFSZ)))
    4848            printf("Thread %d could not allocate storage, errno = %d\n",
    4949                                                        threadnum, errno);
     
    6060
    6161        if (getvalue != value) {
    62         printf("getvalue not valid, getvalue=%d", (u_int64_t)getvalue);
     62            printf("getvalue not valid, getvalue=%p", getvalue);
    6363            return (void*)68;
    6464        }
     
    7676
    7777    int main() {
    78         int          getvalue;
    7978        int          status;
    8079        int          i;
     
    116115
    117116            if (thread_stat[i] != 0)   {
    118                 printf("bad thread status, thread %d, status=%d\n", i+1,
    119                                                         (u_int64_t)thread_stat[i]);
     117                printf("bad thread status, thread %d, status=%zd\n", i+1,
     118                                                        (size_t)thread_stat[i]);
    120119            }
    121120        }
    122         printf("total value is %d, total value by pthread_getspecific is %d\n", total_value, total_value_getspec);
     121        printf("total value is %zd, total value by pthread_getspecific is %zd\n", total_value, total_value_getspec);
    123122        exit(0);
    124123    }   // main
  • TabularUnified tests/concurrency/waituntil/all_types.cfa

    r3e5fea2 rd923fca  
    3333
    3434thread Server1 {};
    35 void main( Server1 & this ) {
    36     long long int a, b, c, i = 0, myTotal = 0;
     35void main( Server1 & ) {
     36    long long int a, c, i = 0, myTotal = 0;
    3737    for( ;;i++ ) {
    3838        when( i % 2 == 0 ) waituntil( a << A ) { myTotal += a; }
     
    4646
    4747thread Drainer {}; // ensures that the changing when states of Server1 don't result in a deadlock
    48 void main( Drainer & this ) {
    49     long long int a, b, c, myTotal = 0;
     48void main( Drainer & ) {
     49    long long int a, c, myTotal = 0;
    5050    for( ;; ) {
    5151        waituntil( F ) { myTotal += get(F); reset( F ); }
     
    5959
    6060thread Churner {}; // performs non-waituntil try insert/remove operations to add churn/interference
    61 void main( Churner & this ) {
     61void main( Churner & ) {
    6262    long long int out, myTotal = 0;
    6363    bool success;
  • TabularUnified tests/concurrency/waituntil/channel_close.cfa

    r3e5fea2 rd923fca  
    99
    1010thread Producer {};
    11 void main( Producer & this ) {
     11void main( Producer & ) {
    1212    try {
    1313        for( size_t i; 0~@ ) {
     
    1515            and waituntil( B << i ) { inserts++; }
    1616        }
    17     } catch ( channel_closed * e ) {} 
     17    } catch ( channel_closed * e ) {}
    1818}
    1919
    2020bool useAnd = false;
    2121thread Consumer {}; // ensures that the changing when states of Server1 don't result in a deadlock
    22 void main( Consumer & this ) {
     22void main( Consumer & ) {
    2323    ssize_t in, in2, A_removes = 0, B_removes = 0;
    2424
     
    3434        }
    3535    } catchResume ( channel_closed * e ) {                              // continue to remove until would block
    36         } catch ( channel_closed * e ) {} 
     36        } catch ( channel_closed * e ) {}
    3737
    3838    try {
     
    4040            waituntil( (in << A) ) { __atomic_thread_fence( __ATOMIC_SEQ_CST ); assert( A_removes == in ); A_removes++; removes++; }
    4141    } catchResume ( channel_closed * e ) {                              // continue to remove until would block
    42         } catch ( channel_closed * e ) {} 
     42        } catch ( channel_closed * e ) {}
    4343
    4444    try {
     
    4646            waituntil( (in << B) ) { __atomic_thread_fence( __ATOMIC_SEQ_CST ); assert( B_removes == in ); B_removes++; removes++; }
    4747    } catchResume ( channel_closed * e ) {                              // continue to remove until would block
    48         } catch ( channel_closed * e ) {} 
     48        } catch ( channel_closed * e ) {}
    4949}
    5050
  • TabularUnified tests/concurrency/waituntil/channels.cfa

    r3e5fea2 rd923fca  
    99
    1010thread Server1 {};
    11 void main( Server1 & this ) {
     11void main( Server1 & ) {
    1212    long long int a, b, c, i = 0, myTotal = 0;
    1313    for( ;;i++ ) {
     
    2121
    2222thread Drainer {}; // ensures that the changing when states of Server1 don't result in a deadlock
    23 void main( Drainer & this ) {
     23void main( Drainer & ) {
    2424    long long int a, b, c, myTotal = 0;
    2525    for( ;; ) {
     
    3333
    3434thread Churner {}; // performs non-waituntil try insert/remove operations to add churn/interference
    35 void main( Churner & this ) {
     35void main( Churner & ) {
    3636    long long int out, myTotal = 0;
    3737    bool success;
  • TabularUnified tests/concurrency/waituntil/futures.cfa

    r3e5fea2 rd923fca  
    88
    99thread Server1 {};
    10 void main( Server1 & this ) {
     10void main( Server1 & ) {
    1111    fulfil(B, 3);
    1212    P( s );
     
    1616
    1717thread Server2 {};
    18 void main( Server2 & this ) {
     18void main( Server2 & ) {
    1919    fulfil(B, 6);
    2020    fulfil(A, 5);
  • TabularUnified tests/concurrency/waituntil/locks.cfa

    r3e5fea2 rd923fca  
    1212
    1313thread Server1 {};
    14 void main( Server1 & this ) {
     14void main( Server1 & ) {
    1515    while( !done ) {
    1616        lock(A);
     
    4444                )
    4545                and when( i < 4 ) waituntil( C ) { c++; }
    46                
     46
    4747                when( i % 2 == 0 ) waituntil( A ) { a++; }
    4848                and when( i % 4 < 2 ) waituntil( B ) { b++; }
  • TabularUnified tests/concurrency/waituntil/repeat_close.cfa

    r3e5fea2 rd923fca  
    1010
    1111thread Producer {};
    12 void main( Producer & this ) {
    13     long long int my_inserts = 0;
     12void main( Producer & ) {
    1413    long long int A_i = 0, B_i = 0, C_i = 0, D_i = 0, E_i = 0, F_i = 0;
    1514    try {
     
    2221            and waituntil( F << i ) { F_i++; }
    2322        }
    24     } catch ( channel_closed * e ) {} 
     23    } catch ( channel_closed * e ) {}
    2524    __atomic_fetch_add( &inserts, A_i + B_i + C_i + D_i + E_i + F_i, __ATOMIC_SEQ_CST );
    2625}
    2726
    2827thread Consumer {};
    29 void main( Consumer & this ) {
     28void main( Consumer & ) {
    3029    long long int in, A_removes = 0, B_removes = 0, C_removes = 0, D_removes = 0, E_removes = 0, F_removes = 0;
    3130    try {
     
    8382    printf("Start\n");
    8483    for ( i; num_times ) {
    85         printf("%lu\n", i);
     84        printf("%zu\n", i);
    8685        A{chan_size};
    8786        B{chan_size};
Note: See TracChangeset for help on using the changeset viewer.