Changeset a2c2363 for tests/concurrency/actors/matrix.cfa
- Timestamp:
- Sep 18, 2023, 10:21:29 AM (10 months ago)
- Branches:
- master
- Children:
- e4c3819
- Parents:
- e3784a50 (diff), 7edf912 (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrency/actors/matrix.cfa
re3784a50 ra2c2363 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; }; 10 10 11 11 struct derived_msg { 12 13 12 inline message; 13 int * Z; 14 14 int * X; 15 15 int ** Y; 16 16 }; 17 17 18 18 void ?{}( derived_msg & this ) {} 19 19 void ?{}( derived_msg & this, int * Z, int * X, int ** Y ) { 20 ((message &) this){ Nodelete };21 22 23 20 set_allocation( this, Nodelete ); 21 this.Z = Z; 22 this.X = X; 23 this.Y = Y; 24 24 } 25 25 26 26 allocation receive( derived_actor & receiver, derived_msg & msg ) { 27 28 29 30 31 32 33 27 for ( unsigned int i = 0; i < yc; i += 1 ) { // multiply X_row by Y_col and sum products 28 msg.Z[i] = 0; 29 for ( unsigned int j = 0; j < xc; j += 1 ) { 30 msg.Z[i] += msg.X[j] * msg.Y[j][i]; 31 } // for 32 } // for 33 return Finished; 34 34 } 35 35 36 36 int main( int argc, char * argv[] ) { 37 37 switch ( argc ) { 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 71 69 unsigned int r, c; 72 70 int * Z[xr], * X[xr], * Y[xc]; 73 71 … … 88 86 } // for 89 87 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]; 99 97 100 98 derived_actor actors[xr]; 101 99 102 100 for ( unsigned int r = 0; r < xr; r += 1 ) { … … 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 117 115 free( X[r] ); 118 116 free( Z[r] ); 119 117 } // for 120 118 for ( r = 0; r < xc; r += 1 ) { // deallocate Y matrix 121 119 free( Y[r] ); 122 120 } // for 123 124 return 0;125 121 }
Note: See TracChangeset
for help on using the changeset viewer.