Changeset d923fca
- Timestamp:
- Feb 18, 2025, 12:54:23 PM (5 weeks ago)
- Branches:
- master
- Children:
- 8705a11
- Parents:
- 3e5fea2
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified libcfa/src/concurrency/future.hfa ¶
r3e5fea2 rd923fca 176 176 } 177 177 178 bool on_selected( future(T) & this, select_node & node) { return true; }178 bool on_selected( future(T) &, select_node & ) { return true; } 179 179 } 180 180 } … … 204 204 // Mark the future as abandoned, meaning it will be deleted by the server 205 205 // 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 ); 207 207 208 208 // Fulfil the future, returns whether or not someone was unblocked -
TabularUnified src/Concurrency/Waituntil.cpp ¶
r3e5fea2 rd923fca 720 720 ) 721 721 ), 722 new BranchStmt( cLoc, BranchStmt:: Kind::Break, Label( cLoc, switchLabel ) )722 new BranchStmt( cLoc, BranchStmt::Goto, Label( cLoc, switchLabel ) ) 723 723 } 724 724 ) … … 733 733 new NameExpr( loc, idxName ), 734 734 std::move( switchCases ), 735 {} 736 ) 737 ); 738 739 ifBody->push_back( 740 new NullStmt( loc, 735 741 { Label( loc, switchLabel ) } 736 742 ) … … 790 796 { new NameExpr( loc, clauseData.at(0)->statusName ) } 791 797 ), 792 new BranchStmt( loc, BranchStmt:: Kind::Break, Label( loc, forLabel ) )798 new BranchStmt( loc, BranchStmt::Goto, Label( loc, forLabel ) ) 793 799 ), 794 800 ifSwitch 795 801 } 796 802 ), // body 803 {} 804 ), 805 new NullStmt( loc, 797 806 { Label( loc, forLabel ) } 798 807 ) -
TabularUnified tests/Makefile.am ¶
r3e5fea2 rd923fca 52 52 WFLAGS_OPT_LAX = \ 53 53 ${WFLAGS_OPT_LAX_EXPECT_WARN} \ 54 ${WFLAGS_OPT_LAX_WAITING_ON_303} \ 54 55 ${WFLAGS_OPT_LAX_TO_INVESTIGATE} 55 56 … … 60 61 warnings/self-assignment 61 62 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. 65 WFLAGS_OPT_LAX_WAITING_ON_303 = \ 64 66 concurrency/actors/dynamic \ 65 67 concurrency/actors/executor \ … … 70 72 concurrency/actors/poison \ 71 73 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. 77 WFLAGS_OPT_LAX_TO_INVESTIGATE = \ 95 78 exceptions/cardgame \ 96 79 exceptions/defaults \ -
TabularUnified tests/concurrency/actors/executor.cfa ¶
r3e5fea2 rd923fca 24 24 struct d_msg { inline message; } shared_msg; 25 25 26 allocation receive( d_actor & this, d_msg & msg) with( this ) {26 allocation receive( d_actor & this, d_msg & ) with( this ) { 27 27 if ( recs == rounds ) return Finished; 28 28 if ( recs % Batch == 0 ) { … … 43 43 if ( BufSize < 0 ) fallthrough default; 44 44 } // if 45 fallthrough; 45 46 case 6: 46 47 if ( strcmp( argv[5], "d" ) != 0 ) { // default ? … … 48 49 if ( Batch < 1 ) fallthrough default; 49 50 } // if 51 fallthrough; 50 52 case 5: 51 53 if ( strcmp( argv[4], "d" ) != 0 ) { // default ? … … 53 55 if ( Processors < 1 ) fallthrough default; 54 56 } // if 57 fallthrough; 55 58 case 4: 56 59 if ( strcmp( argv[3], "d" ) != 0 ) { // default ? … … 58 61 if ( Rounds < 1 ) fallthrough default; 59 62 } // if 63 fallthrough; 60 64 case 3: 61 65 if ( strcmp( argv[2], "d" ) != 0 ) { // default ? … … 63 67 if ( Set < 1 ) fallthrough default; 64 68 } // if 69 fallthrough; 65 70 case 2: 66 71 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? … … 68 73 if ( Actors < 1 || Actors <= Set || Actors % Set != 0 ) fallthrough default; 69 74 } // if 75 fallthrough; 70 76 case 1: // use defaults 71 77 break; -
TabularUnified tests/concurrency/actors/matrixMultiply.cfa ¶
r3e5fea2 rd923fca 24 24 } 25 25 26 allocation receive( derived_actor & receiver, derived_msg & msg ) {26 allocation receive( derived_actor &, derived_msg & msg ) { 27 27 for ( i; yc ) { // multiply X_row by Y_col and sum products 28 28 msg.Z[i] = 0; … … 41 41 if ( Processors < 1 ) fallthrough default; 42 42 } // if 43 fallthrough; 43 44 case 4: 44 45 if ( strcmp( argv[3], "d" ) != 0 ) { // default ? … … 46 47 if ( xr < 1 ) fallthrough default; 47 48 } // if 49 fallthrough; 48 50 case 3: 49 51 if ( strcmp( argv[2], "d" ) != 0 ) { // default ? … … 51 53 if ( xc < 1 ) fallthrough default; 52 54 } // if 55 fallthrough; 53 56 case 2: 54 57 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? … … 56 59 if ( yc < 1 ) fallthrough default; 57 60 } // if 61 fallthrough; 58 62 case 1: // use defaults 59 63 break; -
TabularUnified tests/concurrency/channels/churn.cfa ¶
r3e5fea2 rd923fca 30 30 } 31 31 32 void main(Consumer & this) {32 void main(Consumer &) { 33 33 size_t i = 0; 34 34 size_t runs = 0; … … 53 53 } 54 54 } catchResume ( channel_closed * e ) {} // continue to remove until would block 55 catch ( channel_closed * e ) {} 55 catch ( channel_closed * e ) {} 56 56 } 57 57 … … 65 65 thread Producer {}; 66 66 67 void main(Producer & this) {67 void main(Producer &) { 68 68 size_t i = 0; 69 69 size_t runs = 0; … … 77 77 runs++; 78 78 } 79 } catch ( channel_closed * e ) {} 79 } catch ( channel_closed * e ) {} 80 80 lock(o); 81 81 total_operations += runs; … … 93 93 if ( ChannelSize < 1 ) fallthrough default; 94 94 } // if 95 fallthrough; 95 96 case 3: 96 97 if ( strcmp( argv[2], "d" ) != 0 ) { // default ? … … 98 99 if ( Channels < 1 ) fallthrough default; 99 100 } // if 101 fallthrough; 100 102 case 2: 101 103 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? … … 103 105 if ( Processors < 1 ) fallthrough default; 104 106 } // if 107 fallthrough; 105 108 case 1: // use defaults 106 109 break; … … 121 124 122 125 sout | "start"; 123 { 126 { 124 127 Consumer c[Consumers]; 125 128 { -
TabularUnified tests/concurrency/channels/contend.cfa ¶
r3e5fea2 rd923fca 130 130 if ( ChannelSize < 1 ) fallthrough default; 131 131 } // if 132 fallthrough; 132 133 case 2: 133 134 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? … … 135 136 if ( Processors < 1 ) fallthrough default; 136 137 } // if 138 fallthrough; 137 139 case 1: // use defaults 138 140 break; -
TabularUnified tests/concurrency/channels/daisy_chain.cfa ¶
r3e5fea2 rd923fca 17 17 18 18 thread Task {}; 19 void main(Task & this) {19 void main(Task &) { 20 20 size_t runs = 0; 21 21 int token = 0; … … 40 40 if ( Tasks < 1 ) fallthrough default; 41 41 } // if 42 fallthrough; 42 43 case 2: 43 44 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? … … 45 46 if ( Processors < 1 ) fallthrough default; 46 47 } // if 48 fallthrough; 47 49 case 1: // use defaults 48 50 break; -
TabularUnified tests/concurrency/channels/hot_potato.cfa ¶
r3e5fea2 rd923fca 45 45 if ( Tasks < 1 ) fallthrough default; 46 46 } // if 47 fallthrough; 47 48 case 2: 48 49 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? … … 50 51 if ( Processors < 1 ) fallthrough default; 51 52 } // if 53 fallthrough; 52 54 case 1: // use defaults 53 55 break; -
TabularUnified tests/concurrency/channels/pub_sub.cfa ¶
r3e5fea2 rd923fca 90 90 if ( Tasks < 1 ) fallthrough default; 91 91 } // if 92 fallthrough; 92 93 case 2: 93 94 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? … … 95 96 if ( Processors < 1 ) fallthrough default; 96 97 } // if 98 fallthrough; 97 99 case 1: // use defaults 98 100 break; -
TabularUnified tests/concurrency/lockfree_stack.cfa ¶
r3e5fea2 rd923fca 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // lockfree_stack.cfa -- 7 // lockfree_stack.cfa -- 8 8 // 9 9 // Author : Peter A. Buhr … … 12 12 // Last Modified On : Fri Jun 9 14:01:07 2023 13 13 // Update Count : 68 14 // 14 // 15 15 16 16 #include <thread.hfa> … … 42 42 n.next = stack; // atomic assignment unnecessary 43 43 for () { // busy wait 44 Link temp{ &n, n.next.count + 1};44 Link temp{ { &n, n.next.count + 1 } }; 45 45 if ( CASV( s.stack.atom, n.next.atom, temp.atom ) ) break; // attempt to update top node 46 46 } … … 51 51 for () { // busy wait 52 52 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 } }; 54 54 if ( CASV( stack.atom, t.atom, temp.atom ) ) return t.top; // attempt to update top node 55 55 } … … 62 62 63 63 thread Worker {}; 64 void main( Worker & w) {64 void main( Worker & ) { 65 65 for ( i; Times ) { 66 66 Node & n = *pop( stack ); // pop any node -
TabularUnified tests/concurrency/pthread/pthread_attr_test.cfa ¶
r3e5fea2 rd923fca 4 4 #include <thread.hfa> 5 5 6 void* foo(void* _attr){ 6 void* foo(void*){ 7 pthread_t self = pthread_self(); 8 pthread_attr_t self_attr; 9 pthread_getattr_np(self, &self_attr); 10 7 11 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); 10 13 if (status != 0){ 11 14 sout | "error return code"; … … 16 19 } 17 20 18 int main( int argc, char const *argv[])21 int main() 19 22 { 20 23 pthread_attr_t attr; … … 23 26 pthread_t thr; 24 27 void* res; 25 pthread_create(&thr, &attr, foo, (void*) &attr);28 pthread_create(&thr, &attr, foo, (void*)0); 26 29 pthread_join(thr, &res); 27 30 pthread_attr_destroy(&attr); -
TabularUnified tests/concurrency/pthread/pthread_demo_create_join.cfa ¶
r3e5fea2 rd923fca 3 3 /* test pthread create/join/exit */ 4 4 5 int arr[20];5 size_t arr[20]; 6 6 7 7 void* fetch(void* idx){ 8 int res = arr[(uint64_t)idx];8 size_t res = arr[(size_t)idx]; 9 9 pthread_exit((void*)res); 10 10 sout | "it should not be here"; … … 19 19 } 20 20 21 int main( int argc, char const *argv[])21 int main() 22 22 { 23 23 pthread_t threads[20]; 24 24 arr_init(); 25 25 int status; 26 for ( int i = 0; i < 20; i++){26 for (size_t i = 0; i < 20; i++){ 27 27 status = pthread_create(&threads[i], NULL, fetch, (void*)i); 28 28 if (status != 0) exit(1); … … 30 30 int res = 0; 31 31 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); 34 34 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; 37 37 } 38 38 sout | "final res is" | res; -
TabularUnified tests/concurrency/pthread/pthread_key_test.cfa ¶
r3e5fea2 rd923fca 16 16 #define BUFFSZ 48 17 17 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; 19 20 pthread_mutex_t value_mutex; 20 21 … … 26 27 int *tnum; 27 28 void *getvalue; 28 char Buffer[BUFFSZ];29 29 30 30 tnum = (int*)parm; … … 32 32 33 33 //printf("Thread %d executing\n", threadnum); 34 value = (void *)( rand()%100);34 value = (void *)(size_t)(rand()%100); 35 35 status = pthread_setspecific(key, (void *) value); 36 36 if ( status != 0) { … … 40 40 } 41 41 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); 44 44 pthread_mutex_unlock(&value_mutex); 45 45 46 46 47 if (!(value = malloc( sizeof(Buffer))))47 if (!(value = malloc(BUFFSZ))) 48 48 printf("Thread %d could not allocate storage, errno = %d\n", 49 49 threadnum, errno); … … 60 60 61 61 if (getvalue != value) { 62 printf("getvalue not valid, getvalue=%d", (u_int64_t)getvalue);62 printf("getvalue not valid, getvalue=%p", getvalue); 63 63 return (void*)68; 64 64 } … … 76 76 77 77 int main() { 78 int getvalue;79 78 int status; 80 79 int i; … … 116 115 117 116 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]); 120 119 } 121 120 } 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); 123 122 exit(0); 124 123 } // main -
TabularUnified tests/concurrency/waituntil/all_types.cfa ¶
r3e5fea2 rd923fca 33 33 34 34 thread Server1 {}; 35 void main( Server1 & this) {36 long long int a, b,c, i = 0, myTotal = 0;35 void main( Server1 & ) { 36 long long int a, c, i = 0, myTotal = 0; 37 37 for( ;;i++ ) { 38 38 when( i % 2 == 0 ) waituntil( a << A ) { myTotal += a; } … … 46 46 47 47 thread 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;48 void main( Drainer & ) { 49 long long int a, c, myTotal = 0; 50 50 for( ;; ) { 51 51 waituntil( F ) { myTotal += get(F); reset( F ); } … … 59 59 60 60 thread Churner {}; // performs non-waituntil try insert/remove operations to add churn/interference 61 void main( Churner & this) {61 void main( Churner & ) { 62 62 long long int out, myTotal = 0; 63 63 bool success; -
TabularUnified tests/concurrency/waituntil/channel_close.cfa ¶
r3e5fea2 rd923fca 9 9 10 10 thread Producer {}; 11 void main( Producer & this) {11 void main( Producer & ) { 12 12 try { 13 13 for( size_t i; 0~@ ) { … … 15 15 and waituntil( B << i ) { inserts++; } 16 16 } 17 } catch ( channel_closed * e ) {} 17 } catch ( channel_closed * e ) {} 18 18 } 19 19 20 20 bool useAnd = false; 21 21 thread Consumer {}; // ensures that the changing when states of Server1 don't result in a deadlock 22 void main( Consumer & this) {22 void main( Consumer & ) { 23 23 ssize_t in, in2, A_removes = 0, B_removes = 0; 24 24 … … 34 34 } 35 35 } catchResume ( channel_closed * e ) { // continue to remove until would block 36 } catch ( channel_closed * e ) {} 36 } catch ( channel_closed * e ) {} 37 37 38 38 try { … … 40 40 waituntil( (in << A) ) { __atomic_thread_fence( __ATOMIC_SEQ_CST ); assert( A_removes == in ); A_removes++; removes++; } 41 41 } catchResume ( channel_closed * e ) { // continue to remove until would block 42 } catch ( channel_closed * e ) {} 42 } catch ( channel_closed * e ) {} 43 43 44 44 try { … … 46 46 waituntil( (in << B) ) { __atomic_thread_fence( __ATOMIC_SEQ_CST ); assert( B_removes == in ); B_removes++; removes++; } 47 47 } catchResume ( channel_closed * e ) { // continue to remove until would block 48 } catch ( channel_closed * e ) {} 48 } catch ( channel_closed * e ) {} 49 49 } 50 50 -
TabularUnified tests/concurrency/waituntil/channels.cfa ¶
r3e5fea2 rd923fca 9 9 10 10 thread Server1 {}; 11 void main( Server1 & this) {11 void main( Server1 & ) { 12 12 long long int a, b, c, i = 0, myTotal = 0; 13 13 for( ;;i++ ) { … … 21 21 22 22 thread Drainer {}; // ensures that the changing when states of Server1 don't result in a deadlock 23 void main( Drainer & this) {23 void main( Drainer & ) { 24 24 long long int a, b, c, myTotal = 0; 25 25 for( ;; ) { … … 33 33 34 34 thread Churner {}; // performs non-waituntil try insert/remove operations to add churn/interference 35 void main( Churner & this) {35 void main( Churner & ) { 36 36 long long int out, myTotal = 0; 37 37 bool success; -
TabularUnified tests/concurrency/waituntil/futures.cfa ¶
r3e5fea2 rd923fca 8 8 9 9 thread Server1 {}; 10 void main( Server1 & this) {10 void main( Server1 & ) { 11 11 fulfil(B, 3); 12 12 P( s ); … … 16 16 17 17 thread Server2 {}; 18 void main( Server2 & this) {18 void main( Server2 & ) { 19 19 fulfil(B, 6); 20 20 fulfil(A, 5); -
TabularUnified tests/concurrency/waituntil/locks.cfa ¶
r3e5fea2 rd923fca 12 12 13 13 thread Server1 {}; 14 void main( Server1 & this) {14 void main( Server1 & ) { 15 15 while( !done ) { 16 16 lock(A); … … 44 44 ) 45 45 and when( i < 4 ) waituntil( C ) { c++; } 46 46 47 47 when( i % 2 == 0 ) waituntil( A ) { a++; } 48 48 and when( i % 4 < 2 ) waituntil( B ) { b++; } -
TabularUnified tests/concurrency/waituntil/repeat_close.cfa ¶
r3e5fea2 rd923fca 10 10 11 11 thread Producer {}; 12 void main( Producer & this ) { 13 long long int my_inserts = 0; 12 void main( Producer & ) { 14 13 long long int A_i = 0, B_i = 0, C_i = 0, D_i = 0, E_i = 0, F_i = 0; 15 14 try { … … 22 21 and waituntil( F << i ) { F_i++; } 23 22 } 24 } catch ( channel_closed * e ) {} 23 } catch ( channel_closed * e ) {} 25 24 __atomic_fetch_add( &inserts, A_i + B_i + C_i + D_i + E_i + F_i, __ATOMIC_SEQ_CST ); 26 25 } 27 26 28 27 thread Consumer {}; 29 void main( Consumer & this) {28 void main( Consumer & ) { 30 29 long long int in, A_removes = 0, B_removes = 0, C_removes = 0, D_removes = 0, E_removes = 0, F_removes = 0; 31 30 try { … … 83 82 printf("Start\n"); 84 83 for ( i; num_times ) { 85 printf("% lu\n", i);84 printf("%zu\n", i); 86 85 A{chan_size}; 87 86 B{chan_size};
Note: See TracChangeset
for help on using the changeset viewer.