Changeset 50be8af5 for tests/concurrency
- Timestamp:
- Sep 17, 2023, 11:19:08 AM (15 months ago)
- Branches:
- master
- Children:
- 7edf912
- Parents:
- 697c957
- Location:
- tests/concurrency
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrency/actors/dynamic.cfa
r697c957 r50be8af5 36 36 case 2: 37 37 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? 38 Times = ato i( argv[1] );39 if ( Times < 1 ) goto Usage;38 Times = ato( argv[1] ); 39 if ( Times < 1 ) fallthru default; 40 40 } // if 41 41 case 1: // use defaults 42 42 break; 43 43 default: 44 Usage: 45 sout | "Usage: " | argv[0] | " [ times (> 0) ]"; 46 exit( EXIT_FAILURE ); 44 exit | "Usage: " | argv[0] | " [ times (> 0) ]"; 47 45 } // switch 48 46 49 printf("starting\n");47 sout | "starting"; 50 48 51 49 executor e{ 0, 1, 1, false }; 52 50 start_actor_system( e ); 53 51 54 printf("started\n");52 sout | "started"; 55 53 56 54 derived_msg * d_msg = alloc(); … … 60 58 *d_actor | *d_msg; 61 59 62 printf("stopping\n");60 sout | "stopping"; 63 61 64 62 stop_actor_system(); 65 63 66 printf("stopped\n");64 sout | "stopped"; 67 65 68 66 return 0; -
tests/concurrency/actors/executor.cfa
r697c957 r50be8af5 40 40 case 7: 41 41 if ( strcmp( argv[6], "d" ) != 0 ) { // default ? 42 BufSize = ato i( argv[6] );43 if ( BufSize < 0 ) goto Usage;42 BufSize = ato( argv[6] ); 43 if ( BufSize < 0 ) fallthru default; 44 44 } // if 45 45 case 6: 46 46 if ( strcmp( argv[5], "d" ) != 0 ) { // default ? 47 Batch = ato i( argv[5] );48 if ( Batch < 1 ) goto Usage;47 Batch = ato( argv[5] ); 48 if ( Batch < 1 ) fallthru default; 49 49 } // if 50 50 case 5: 51 51 if ( strcmp( argv[4], "d" ) != 0 ) { // default ? 52 Processors = ato i( argv[4] );53 if ( Processors < 1 ) goto Usage;52 Processors = ato( argv[4] ); 53 if ( Processors < 1 ) fallthru default; 54 54 } // if 55 55 case 4: 56 56 if ( strcmp( argv[3], "d" ) != 0 ) { // default ? 57 Rounds = ato i( argv[3] );58 if ( Rounds < 1 ) goto Usage;57 Rounds = ato( argv[3] ); 58 if ( Rounds < 1 ) fallthru default; 59 59 } // if 60 60 case 3: 61 61 if ( strcmp( argv[2], "d" ) != 0 ) { // default ? 62 Set = ato i( argv[2] );63 if ( Set < 1 ) goto Usage;62 Set = ato( argv[2] ); 63 if ( Set < 1 ) fallthru default; 64 64 } // if 65 65 case 2: 66 66 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? 67 Actors = ato i( argv[1] );68 if ( Actors < 1 || Actors <= Set || Actors % Set != 0 ) goto Usage;67 Actors = ato( argv[1] ); 68 if ( Actors < 1 || Actors <= Set || Actors % Set != 0 ) fallthru default; 69 69 } // if 70 70 case 1: // use defaults 71 71 break; 72 72 default: 73 Usage: 74 sout | "Usage: " | argv[0] 73 exit | "Usage: " | argv[0] 75 74 | " [ actors (> 0 && > set && actors % set == 0 ) | 'd' (default " | Actors 76 75 | ") ] [ set (> 0) | 'd' (default " | Set … … 80 79 | ") ] [ buffer size (>= 0) | 'd' (default " | BufSize 81 80 | ") ]" ; 82 exit( EXIT_FAILURE );83 81 } // switch 84 82 85 83 executor e{ Processors, Processors, Processors == 1 ? 1 : Processors * 512, true }; 86 84 87 printf("starting\n");85 sout | "starting"; 88 86 89 87 start_actor_system( e ); 90 88 91 printf("started\n");89 sout | "started"; 92 90 93 91 d_actor actors[ Actors ]; … … 97 95 } // for 98 96 99 printf("stopping\n");97 sout | "stopping"; 100 98 101 99 stop_actor_system(); 102 100 103 printf("stopped\n");101 sout | "stopped"; 104 102 105 103 return 0; -
tests/concurrency/actors/matrix.cfa
r697c957 r50be8af5 5 5 #include <stdio.h> 6 6 7 unsigned int xr = 500, xc = 500, yc = 500, Processors = 1; // default values 7 int xr = 500, xc = 500, yc = 500, Processors = 1; // default values, must be signed 8 8 9 9 struct derived_actor { inline actor; }; … … 38 38 case 5: 39 39 if ( strcmp( argv[4], "d" ) != 0 ) { // default ? 40 Processors = ato i( argv[4] );41 if ( Processors < 1 ) goto Usage;40 Processors = ato( argv[4] ); 41 if ( Processors < 1 ) fallthru default; 42 42 } // if 43 43 case 4: 44 44 if ( strcmp( argv[3], "d" ) != 0 ) { // default ? 45 xr = ato i( argv[3] );46 if ( xr < 1 ) goto Usage;45 xr = ato( argv[3] ); 46 if ( xr < 1 ) fallthru default; 47 47 } // if 48 48 case 3: 49 49 if ( strcmp( argv[2], "d" ) != 0 ) { // default ? 50 xc = ato i( argv[2] );51 if ( xc < 1 ) goto Usage;50 xc = ato( argv[2] ); 51 if ( xc < 1 ) fallthru default; 52 52 } // if 53 53 case 2: 54 54 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? 55 yc = ato i( argv[1] );56 if ( yc < 1 ) goto Usage;55 yc = ato( argv[1] ); 56 if ( yc < 1 ) fallthru default; 57 57 } // if 58 58 case 1: // use defaults 59 59 break; 60 60 default: 61 Usage: 62 sout | "Usage: " | argv[0] 61 exit | "Usage: " | argv[0] 63 62 | " [ yc (> 0) | 'd' (default " | yc 64 63 | ") ] [ xc (> 0) | 'd' (default " | xc … … 66 65 | ") ] [ processors (> 0) | 'd' (default " | Processors 67 66 | ") ]" ; 68 exit( EXIT_FAILURE );69 67 } // switch 70 68 … … 90 88 executor e{ Processors, Processors, Processors == 1 ? 1 : Processors * 16, true }; 91 89 92 printf("starting\n");90 sout | "starting"; 93 91 94 92 start_actor_system( e ); 95 93 96 printf("started\n");94 sout | "started"; 97 95 98 96 derived_msg messages[xr]; … … 108 106 } // for 109 107 110 printf("stopping\n");108 sout | "stopping"; 111 109 112 110 stop_actor_system(); 113 111 114 printf("stopped\n");112 sout | "stopped"; 115 113 116 114 for ( r = 0; r < xr; r += 1 ) { // deallocate X and Z matrices … … 121 119 free( Y[r] ); 122 120 } // for 123 124 return 0;125 121 } -
tests/concurrency/actors/pingpong.cfa
r697c957 r50be8af5 42 42 43 43 int main( int argc, char * argv[] ) { 44 printf("start\n");44 sout | "start"; 45 45 46 46 processor p[Processors - 1]; … … 56 56 stop_actor_system(); 57 57 58 printf("end\n"); 59 return 0; 58 sout | "end"; 60 59 } -
tests/concurrency/actors/static.cfa
r697c957 r50be8af5 33 33 case 2: 34 34 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? 35 Times = ato i( argv[1] );36 if ( Times < 1 ) goto Usage;35 Times = ato( argv[1] ); 36 if ( Times < 1 ) fallthru default; 37 37 } // if 38 38 case 1: // use defaults 39 39 break; 40 40 default: 41 Usage: 42 sout | "Usage: " | argv[0] | " [ times (> 0) ]"; 43 exit( EXIT_FAILURE ); 41 exit | "Usage: " | argv[0] | " [ times (> 0) ]"; 44 42 } // switch 45 43 46 printf("starting\n");44 sout | "starting"; 47 45 48 46 executor e{ 0, 1, 1, false }; 49 47 start_actor_system( e ); 50 48 51 printf("started\n");49 sout | "started"; 52 50 53 51 derived_msg msg; … … 57 55 actor | msg; 58 56 59 printf("stopping\n");57 sout | "stopping"; 60 58 61 59 stop_actor_system(); 62 60 63 printf("stopped\n");61 sout | "stopped"; 64 62 65 63 return 0; -
tests/concurrency/actors/types.cfa
r697c957 r50be8af5 62 62 63 63 int main( int argc, char * argv[] ) { 64 printf("start\n");64 sout | "start"; 65 65 66 66 processor p[Processors - 1]; 67 67 68 printf("basic test\n");68 sout | "basic test"; 69 69 start_actor_system( Processors ); // test passing number of processors 70 70 derived_actor a; … … 75 75 stop_actor_system(); 76 76 77 printf("same message and different actors test\n");77 sout | "same message and different actors test"; 78 78 start_actor_system(); // let system detect # of processors 79 79 derived_actor2 d_ac2_0, d_ac2_1; … … 86 86 87 87 { 88 printf("same message and different actor types test\n");88 sout | "same message and different actor types test"; 89 89 executor e{ 0, Processors, Processors == 1 ? 1 : Processors * 4, false }; 90 90 start_actor_system( e ); // pass an explicit executor … … 99 99 100 100 { 101 printf("different message types, one actor test\n");101 sout | "different message types, one actor test"; 102 102 executor e{ 1, Processors, Processors == 1 ? 1 : Processors * 4, true }; 103 103 start_actor_system( Processors ); … … 112 112 113 113 { 114 printf("nested inheritance actor test\n");114 sout | "nested inheritance actor test"; 115 115 executor e{ 1, Processors, Processors == 1 ? 1 : Processors * 4, true }; 116 116 start_actor_system( Processors ); … … 124 124 } // RAII to clean up executor 125 125 126 printf("end\n"); 127 return 0; 126 sout | "end"; 128 127 } -
tests/concurrency/channels/barrier.cfa
r697c957 r50be8af5 8 8 9 9 size_t total_operations = 0; 10 int Processors = 1, Tasks = 5, BarrierSize = 2; 10 ssize_t Processors = 1, Tasks = 5, BarrierSize = 2; // must be signed 11 11 12 12 typedef channel( int ) Channel; … … 65 65 case 3: 66 66 if ( strcmp( argv[2], "d" ) != 0 ) { // default ? 67 BarrierSize = ato i( argv[2] );68 if ( Processors < 1 ) goto Usage;67 BarrierSize = ato( argv[2] ); 68 if ( Processors < 1 ) fallthru default; 69 69 } // if 70 70 case 2: 71 71 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? 72 Processors = ato i( argv[1] );73 if ( Processors < 1 ) goto Usage;72 Processors = ato( argv[1] ); 73 if ( Processors < 1 ) fallthru default; 74 74 } // if 75 75 case 1: // use defaults 76 76 break; 77 77 default: 78 Usage: 79 sout | "Usage: " | argv[0] 78 exit | "Usage: " | argv[0] 80 79 | " [ processors (> 0) | 'd' (default " | Processors 81 80 | ") ] [ BarrierSize (> 0) | 'd' (default " | BarrierSize 82 81 | ") ]" ; 83 exit( EXIT_FAILURE );84 82 } // switch 85 83 if ( Tasks < BarrierSize ) -
tests/concurrency/channels/big_elems.cfa
r697c957 r50be8af5 2 2 #include "parallel_harness.hfa" 3 3 4 s ize_t Processors = 10, Channels = 10, Producers = 40, Consumers = 40, ChannelSize = 128;4 ssize_t Processors = 10, Channels = 10, Producers = 40, Consumers = 40, ChannelSize = 128; 5 5 6 6 int main() { -
tests/concurrency/channels/churn.cfa
r697c957 r50be8af5 7 7 #include <time.hfa> 8 8 9 s ize_t Processors = 1, Channels = 4, Producers = 2, Consumers = 2, ChannelSize = 128;9 ssize_t Processors = 1, Channels = 4, Producers = 2, Consumers = 2, ChannelSize = 128; 10 10 11 11 owner_lock o; … … 90 90 case 4: 91 91 if ( strcmp( argv[3], "d" ) != 0 ) { // default ? 92 if ( atoi( argv[3] ) < 1 ) goto Usage;93 ChannelSize = atoi( argv[3] );92 ChannelSize = ato( argv[3] ); 93 if ( ChannelSize < 1 ) fallthru default; 94 94 } // if 95 95 case 3: 96 96 if ( strcmp( argv[2], "d" ) != 0 ) { // default ? 97 if ( atoi( argv[2] ) < 1 ) goto Usage;98 Channels = atoi( argv[2] );97 Channels = ato( argv[2] ); 98 if ( Channels < 1 ) fallthru default; 99 99 } // if 100 100 case 2: 101 101 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? 102 if ( atoi( argv[1] ) < 1 ) goto Usage;103 Processors = atoi( argv[1] );102 Processors = ato( argv[1] ); 103 if ( Processors < 1 ) fallthru default; 104 104 } // if 105 105 case 1: // use defaults 106 106 break; 107 107 default: 108 Usage: 109 sout | "Usage: " | argv[0] 108 exit | "Usage: " | argv[0] 110 109 | " [ processors > 0 | d ]" 111 110 | " [ producers > 0 | d ]" 112 111 | " [ consumers > 0 | d ]" 113 112 | " [ channels > 0 | d ]"; 114 exit( EXIT_FAILURE );115 113 } 116 114 processor p[Processors - 1]; -
tests/concurrency/channels/contend.cfa
r697c957 r50be8af5 127 127 case 3: 128 128 if ( strcmp( argv[2], "d" ) != 0 ) { // default ? 129 ChannelSize = atoi( argv[2] ); 129 ChannelSize = ato( argv[2] ); 130 if ( ChannelSize < 1 ) fallthru default; 130 131 } // if 131 132 case 2: 132 133 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? 133 Processors = ato i( argv[1] );134 if ( Processors < 1 ) goto Usage;134 Processors = ato( argv[1] ); 135 if ( Processors < 1 ) fallthru default; 135 136 } // if 136 137 case 1: // use defaults 137 138 break; 138 139 default: 139 Usage: 140 sout | "Usage: " | argv[0] 140 exit | "Usage: " | argv[0] 141 141 | " [ processors (> 0) | 'd' (default " | Processors 142 142 | ") ] [ channel size (>= 0) | 'd' (default " | ChannelSize 143 143 | ") ]" ; 144 exit( EXIT_FAILURE );145 144 } // switch 145 146 146 test(Processors, Channels, Producers, Consumers, ChannelSize); 147 147 } -
tests/concurrency/channels/daisy_chain.cfa
r697c957 r50be8af5 8 8 9 9 size_t total_operations = 0; 10 s ize_t Processors = 1, Tasks = 4;10 ssize_t Processors = 1, Tasks = 4; // must be signed 11 11 12 12 owner_lock o; … … 37 37 case 3: 38 38 if ( strcmp( argv[2], "d" ) != 0 ) { // default ? 39 Tasks = ato i( argv[2] );40 if ( Tasks < 1 ) goto Usage;39 Tasks = ato( argv[2] ); 40 if ( Tasks < 1 ) fallthru default; 41 41 } // if 42 42 case 2: 43 43 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? 44 Processors = ato i( argv[1] );45 if ( Processors < 1 ) goto Usage;44 Processors = ato( argv[1] ); 45 if ( Processors < 1 ) fallthru default; 46 46 } // if 47 47 case 1: // use defaults 48 48 break; 49 49 default: 50 Usage: 51 sout | "Usage: " | argv[0] 50 exit | "Usage: " | argv[0] 52 51 | " [ processors (> 0) | 'd' (default " | Processors 53 52 | ") ] [ channel size (>= 0) | 'd' (default " | Tasks 54 53 | ") ]" ; 55 exit( EXIT_FAILURE );56 54 } // switch 57 55 processor proc[Processors - 1]; … … 71 69 // sout | total_operations; 72 70 sout | "done"; 73 74 return 0;75 71 } -
tests/concurrency/channels/hot_potato.cfa
r697c957 r50be8af5 8 8 9 9 size_t total_operations = 0; 10 s ize_t Processors = 1, Tasks = 4;10 ssize_t Processors = 1, Tasks = 4; // must be signed 11 11 12 12 owner_lock o; … … 38 38 } 39 39 40 41 40 int main( int argc, char * argv[] ) { 42 41 switch ( argc ) { 43 42 case 3: 44 43 if ( strcmp( argv[2], "d" ) != 0 ) { // default ? 45 Tasks = ato i( argv[2] );46 if ( Tasks < 1 ) goto Usage;44 Tasks = ato( argv[2] ); 45 if ( Tasks < 1 ) fallthru default; 47 46 } // if 48 47 case 2: 49 48 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? 50 Processors = ato i( argv[1] );51 if ( Processors < 1 ) goto Usage;49 Processors = ato( argv[1] ); 50 if ( Processors < 1 ) fallthru default; 52 51 } // if 53 52 case 1: // use defaults 54 53 break; 55 54 default: 56 Usage: 57 sout | "Usage: " | argv[0] 55 exit | "Usage: " | argv[0] 58 56 | " [ processors (> 0) | 'd' (default " | Processors 59 57 | ") ] [ channel size (>= 0) | 'd' (default " | Tasks 60 58 | ") ]" ; 61 exit( EXIT_FAILURE );62 59 } // switch 60 63 61 processor proc[Processors - 1]; 64 62 -
tests/concurrency/channels/pub_sub.cfa
r697c957 r50be8af5 87 87 case 3: 88 88 if ( strcmp( argv[2], "d" ) != 0 ) { // default ? 89 Tasks = ato i( argv[2] );90 if ( Tasks < 1 ) goto Usage;89 Tasks = ato( argv[2] ); 90 if ( Tasks < 1 ) fallthru default; 91 91 } // if 92 92 case 2: 93 93 if ( strcmp( argv[1], "d" ) != 0 ) { // default ? 94 Processors = ato i( argv[1] );95 if ( Processors < 1 ) goto Usage;94 Processors = ato( argv[1] ); 95 if ( Processors < 1 ) fallthru default; 96 96 } // if 97 97 case 1: // use defaults 98 98 break; 99 99 default: 100 Usage: 101 sout | "Usage: " | argv[0] 100 exit | "Usage: " | argv[0] 102 101 | " [ processors (> 0) | 'd' (default " | Processors 103 102 | ") ] [ Tasks (> 0) | 'd' (default " | Tasks 104 103 | ") ]" ; 105 exit( EXIT_FAILURE );106 104 } // switch 107 105 BarrierSize = Tasks; -
tests/concurrency/examples/matrixSum.cfa
r697c957 r50be8af5 10 10 // Created On : Mon Oct 9 08:29:28 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 20 08:37:53 201913 // Update Count : 1 612 // Last Modified On : Fri Sep 8 19:05:34 2023 13 // Update Count : 19 14 14 // 15 15 16 16 #include <fstream.hfa> 17 #include <kernel.hfa>18 17 #include <thread.hfa> 19 18 … … 35 34 36 35 int main() { 37 /* const */int rows = 10, cols = 1000;36 const int rows = 10, cols = 1000; 38 37 int matrix[rows][cols], subtotals[rows], total = 0; 39 38 processor p; // add kernel thread 40 39 41 for ( r; rows ) { 40 for ( r; rows ) { // initialize 42 41 for ( c; cols ) { 43 42 matrix[r][c] = 1; 44 43 } // for 45 44 } // for 45 46 46 Adder * adders[rows]; 47 47 for ( r; rows ) { // start threads to sum rows 48 48 adders[r] = &(*malloc()){ matrix[r], cols, subtotals[r] }; 49 // adders[r] = new( matrix[r], cols, &subtotals[r] );49 // adders[r] = new( matrix[r], cols, subtotals[r] ); 50 50 } // for 51 51 52 for ( r; rows ) { // wait for threads to finish 52 53 delete( adders[r] ); … … 57 58 58 59 // Local Variables: // 59 // tab-width: 4 //60 60 // compile-command: "cfa matrixSum.cfa" // 61 61 // End: // -
tests/concurrency/unified_locking/locks.cfa
r697c957 r50be8af5 1 1 #include <stdio.h> 2 #include "locks.hfa"2 #include <locks.hfa> 3 3 #include <stdlib.hfa> 4 4 #include <thread.hfa> -
tests/concurrency/unified_locking/pthread_locks.cfa
r697c957 r50be8af5 1 1 #include <stdio.h> 2 #include "locks.hfa"2 #include <locks.hfa> 3 3 #include <stdlib.hfa> 4 4 #include <thread.hfa> -
tests/concurrency/unified_locking/test_debug.cfa
r697c957 r50be8af5 1 #include "locks.hfa"1 #include <locks.hfa> 2 2 3 3 fast_block_lock f; -
tests/concurrency/unified_locking/thread_test.cfa
r697c957 r50be8af5 1 1 #include <stdio.h> 2 #include "locks.hfa"2 #include <locks.hfa> 3 3 #include <stdlib.hfa> 4 4 #include <thread.hfa>
Note: See TracChangeset
for help on using the changeset viewer.