Changeset eef8dfb for tests/concurrent


Ignore:
Timestamp:
Jan 7, 2021, 2:55:57 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
58fe85a
Parents:
bdfc032 (diff), 44e37ef (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' into dkobets-vector

Location:
tests/concurrent
Files:
23 added
11 edited
1 moved

Legend:

Unmodified
Added
Removed
  • tests/concurrent/.expect/monitor.txt

    rbdfc032 reef8dfb  
    1 4000000
     13000000
  • tests/concurrent/coroutineYield.cfa

    rbdfc032 reef8dfb  
    3333                        sout | "Coroutine 2";
    3434                #endif
    35                 suspend();
     35                suspend;
    3636        }
    3737}
  • tests/concurrent/examples/.expect/datingService.txt

    rbdfc032 reef8dfb  
    1 Girl:17 is dating Boy at 2 with ccode 17
    2  Boy:2 is dating Girl 17 with ccode 17
    3  Boy:14 is dating Girl 5 with ccode 5
    4 Girl:5 is dating Boy at 14 with ccode 5
    5  Boy:9 is dating Girl 10 with ccode 10
    6 Girl:10 is dating Boy at 9 with ccode 10
    7  Boy:1 is dating Girl 18 with ccode 18
    8 Girl:18 is dating Boy at 1 with ccode 18
    9  Boy:16 is dating Girl 3 with ccode 3
    10 Girl:3 is dating Boy at 16 with ccode 3
    11  Boy:5 is dating Girl 14 with ccode 14
    12 Girl:14 is dating Boy at 5 with ccode 14
    13  Boy:15 is dating Girl 4 with ccode 4
    14 Girl:4 is dating Boy at 15 with ccode 4
    15 Girl:0 is dating Boy at 19 with ccode 0
    16  Boy:19 is dating Girl 0 with ccode 0
    17 Girl:9 is dating Boy at 10 with ccode 9
    18  Boy:10 is dating Girl 9 with ccode 9
    19 Girl:11 is dating Boy at 8 with ccode 11
    20  Boy:8 is dating Girl 11 with ccode 11
    21  Boy:12 is dating Girl 7 with ccode 7
    22 Girl:7 is dating Boy at 12 with ccode 7
    23  Boy:11 is dating Girl 8 with ccode 8
    24 Girl:8 is dating Boy at 11 with ccode 8
    25 Girl:16 is dating Boy at 3 with ccode 16
    26  Boy:3 is dating Girl 16 with ccode 16
    27 Girl:15 is dating Boy at 4 with ccode 15
    28  Boy:4 is dating Girl 15 with ccode 15
    29 Girl:19 is dating Boy at 0 with ccode 19
    30  Boy:0 is dating Girl 19 with ccode 19
    31 Girl:2 is dating Boy at 17 with ccode 2
    32  Boy:17 is dating Girl 2 with ccode 2
    33  Boy:13 is dating Girl 6 with ccode 6
    34 Girl:6 is dating Boy at 13 with ccode 6
    35  Boy:7 is dating Girl 12 with ccode 12
    36 Girl:12 is dating Boy at 7 with ccode 12
    37 Girl:13 is dating Boy at 6 with ccode 13
    38  Boy:6 is dating Girl 13 with ccode 13
    39 Girl:1 is dating Boy at 18 with ccode 1
    40  Boy:18 is dating Girl 1 with ccode 1
     1done
  • tests/concurrent/examples/boundedBufferEXT.cfa

    rbdfc032 reef8dfb  
    11//
    22// Cforall Version 1.0.0 Copyright (C) 2018 University of Waterloo
    3 // 
     3//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
     
    8787}
    8888
     89enum { Prods = 4, Cons = 5 };
     90Producer * prods[Prods];
     91Consumer * cons[Cons];
     92
    8993int main() {
    9094        Buffer(int) buffer;
    91         enum { Prods = 4, Cons = 5 };
    92         Producer * prods[Prods];
    93         Consumer * cons[Cons];
    9495        int sums[Cons];
    9596        int i;
  • tests/concurrent/examples/datingService.cfa

    rbdfc032 reef8dfb  
    11//
    22// Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo
    3 // 
     3//
    44// The contents of this file are covered under the licence agreement in the
    55// file "LICENCE" distributed with Cforall.
     
    1010// Created On       : Mon Oct 30 12:56:20 2017
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Jun 21 11:32:34 2019
    13 // Update Count     : 38
     12// Last Modified On : Sun Sep 27 15:42:25 2020
     13// Update Count     : 40
    1414//
    1515
     
    3535                signal_block( Boys[ccode] );                                    // restart boy to set phone number
    3636        } // if
    37         sout | "Girl:" | PhoneNo | "is dating Boy at" | BoyPhoneNo | "with ccode" | ccode;
     37        // sout | "Girl:" | PhoneNo | "is dating Boy at" | BoyPhoneNo | "with ccode" | ccode;
    3838        return BoyPhoneNo;
    3939} // DatingService girl
     
    4747                signal_block( Girls[ccode] );                                   // restart girl to set phone number
    4848        } // if
    49         sout | " Boy:" | PhoneNo | "is dating Girl" | GirlPhoneNo | "with ccode" | ccode;
     49        // sout | " Boy:" | PhoneNo | "is dating Girl" | GirlPhoneNo | "with ccode" | ccode;
    5050        return GirlPhoneNo;
    5151} // DatingService boy
     
    108108                if ( girlck[ boyck[i] ] != boyck[ girlck[i] ] ) abort();
    109109        } // for
     110
     111        printf( "done\n" );                                                                     // non-empty .expect file
    110112} // main
    111113
  • tests/concurrent/examples/quickSort.cfa

    rbdfc032 reef8dfb  
    1111// Created On       : Wed Dec  6 12:15:52 2017
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Thu Oct 10 13:58:18 2019
    14 // Update Count     : 176
     13// Last Modified On : Wed Feb 12 18:24:47 2020
     14// Update Count     : 177
    1515//
    1616
     
    2727
    2828void ?{}( Quicksort & qs, int values[], int size, int depth ) {
    29         qs.values = values;  qs.low = 0;  qs.high = size;  qs.depth = depth;
     29        qs.[values, low, high, depth] = [values, 0, size, depth];
    3030} // Quicksort
    3131
     
    167167                        values[counter] = size - counter;                       // descending values
    168168                } // for
    169                 for ( int i = 0; i < 200; i +=1 ) {                             // random shuffle a few values
     169                for ( i; 200 ) {                                                                // random shuffle a few values
    170170                        swap( values[rand() % size], values[rand() % size] );
    171171                } // for
  • tests/concurrent/monitor.cfa

    rbdfc032 reef8dfb  
    2929
    3030void main( MyThread & this ) {
    31         for(int i = 0; i < 1_000_000; i++) {
     31        for(int i = 0; i < 750_000; i++) {
    3232                increment( global );
    3333        }
  • tests/concurrent/multi-monitor.cfa

    rbdfc032 reef8dfb  
    1111
    1212void increment( monitor_t & mutex p1, monitor_t & mutex p2, int & value ) {
     13        assert(active_thread() == get_monitor(p1)->owner);
     14        assert(active_thread() == get_monitor(p2)->owner);
    1315        value += 1;
     16        assert(active_thread() == get_monitor(p1)->owner);
     17        assert(active_thread() == get_monitor(p2)->owner);
    1418}
    1519
  • tests/concurrent/signal/block.cfa

    rbdfc032 reef8dfb  
    3333
    3434monitor global_data_t {
    35         thread_desc * last_thread;
    36         thread_desc * last_signaller;
     35        $thread * last_thread;
     36        $thread * last_signaller;
    3737};
    3838
     
    8282        if( !is_empty( cond ) ) {
    8383
    84                 thread_desc * next = front( cond );
     84                $thread * next = ( $thread * ) front( cond );
    8585
    8686                if( ! signal_block( cond ) ) {
  • tests/concurrent/signal/disjoint.cfa

    rbdfc032 reef8dfb  
    2121#endif
    2222
     23// This tests checks what happens when someone barges in the midle of the release
     24// of a bulk of monitors.
     25
    2326enum state_t { WAIT, SIGNAL, BARGE };
    2427
    2528monitor global_t {};
    26 global_t mut;
    2729
    2830monitor global_data_t;
     
    3335        int counter;
    3436        state_t state;
    35 } data;
     37};
     38
     39// Use a global struct because the order needs to match with Signaller thread
     40struct {
     41        global_t mut;
     42        global_data_t data;
     43} globals;
    3644
    3745condition cond;
     
    4048
    4149void ?{}( global_data_t & this ) {
    42         this.counter == 0;
     50        this.counter = 0;
    4351        this.state = BARGE;
    4452}
     
    5361
    5462thread Barger {};
     63void ?{}( Barger & this ) {
     64        ((thread&)this){ "Barger Thread" };
     65}
    5566
    5667void main( Barger & this ) {
    5768        while( !all_done ) {
    58                 barge( data );
     69                barge( globals.data );
    5970                yield();
    6071        }
     
    7889
    7990thread Waiter {};
     91void ?{}( Waiter & this ) {
     92        ((thread&)this){ "Waiter Thread" };
     93}
    8094
    8195void main( Waiter & this ) {
    82         while( wait( mut, data ) ) { KICK_WATCHDOG; yield(); }
     96        while( wait( globals.mut, globals.data ) ) { KICK_WATCHDOG; yield(); }
    8397}
    8498
     
    92106
    93107void logic( global_t & mutex a ) {
    94         signal( cond, a, data );
     108        signal( cond, a, globals.data );
    95109
    96110        yield( random( 10 ) );
    97111
    98112        //This is technically a mutual exclusion violation but the mutex monitor protects us
    99         bool running = TEST(data.counter < N) && data.counter > 0;
    100         if( data.state != SIGNAL && running ) {
    101                 sout | "ERROR Eager signal" | data.state;
     113        bool running = TEST(globals.data.counter < N) && globals.data.counter > 0;
     114        if( globals.data.state != SIGNAL && running ) {
     115                sout | "ERROR Eager signal" | globals.data.state;
    102116        }
    103117}
    104118
    105119thread Signaller {};
     120void ?{}( Signaller & this ) {
     121        ((thread&)this){ "Signaller Thread" };
     122}
    106123
    107124void main( Signaller & this ) {
    108125        while( !all_done ) {
    109                 logic( mut );
     126                logic( globals.mut );
    110127                yield();
    111128        }
  • tests/concurrent/suspend_then.cfa

    rbdfc032 reef8dfb  
    11#include <fstream.hfa>
    22#include <kernel.hfa>
    3 #include <monitor.hfa>
    43#include <thread.hfa>
    54#include <time.hfa>
     
    109#include "long_tests.hfa"
    1110
    12 #ifndef PREEMPTION_RATE
    13 #define PREEMPTION_RATE 10`ms
    14 #endif
    15 
    1611Duration default_preemption() {
    17         return PREEMPTION_RATE;
     12        return 0;
    1813}
    1914
     
    2621#if !defined(TEST_FOREVER)
    2722        static inline void print(const char * const text ) {
    28                 write( STDERR_FILENO, text, strlen(text) );
     23                write( STDOUT_FILENO, text, strlen(text) );
    2924        }
    3025#else
     
    3227#endif
    3328
    34 coroutine Coroutine {};
     29generator Coroutine { int i; };
    3530
    3631volatile bool done = false;
     
    4944
    5045void main(Coroutine& this) {
    51         suspend();
    52         for(int i = 0; TEST(i < N); i++) {
     46        this.i = 0;
     47        suspend;
     48        for(;TEST(this.i < N); this.i++) {
    5349
    54                 print("C - Suspending");
    55                 void publish() {
    56                         print("C - Publishing");
     50                print("C - Suspending\n");
     51                suspend{
     52                        print("C - Publishing\n");
    5753                        assert(!the_cor);
    5854                        store( this );
    5955                }
    60                 suspend_then(publish);
    6156                assert(!the_cor);
    62                 print("Coroutine 2");
     57                print("C - Back\n");
    6358                KICK_WATCHDOG;
    6459                yield();
    6560        }
    6661        done = true;
    67         suspend();
     62        suspend;
    6863}
    6964
     
    7772                if(!mine) continue;
    7873
    79                 print("T - took");
     74                print("T - took\n");
    8075                resume(*mine);
    81                 print("T - back");
    8276        }
    8377}
  • tests/concurrent/waitfor/when.cfa

    rbdfc032 reef8dfb  
    5757
    5858void arbiter( global_t & mutex this ) {
     59        // There is a race at start where callers can get in before the arbiter.
     60        // It doesn't really matter here so just restart the loop correctly and move on
     61        this.last_call = 6;
     62
    5963        for( int i = 0; i < N; i++ ) {
    6064                   when( this.last_call == 6 ) waitfor( call1 : this ) { if( this.last_call != 1) { serr | "Expected last_call to be 1 got" | this.last_call; } }
Note: See TracChangeset for help on using the changeset viewer.