Changeset b244fa8 for tests/concurrency
- Timestamp:
- Sep 19, 2023, 10:28:06 AM (15 months ago)
- Branches:
- master
- Children:
- 5a1ae14
- Parents:
- 60f69f0
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrency/actors/matrixMultiply.cfa
r60f69f0 rb244fa8 5 5 #include <stdio.h> 6 6 7 int xr = 500, xc = 500, yc = 500, Processors = 1; // default values, must be signed7 ssize_t xr = 500, xc = 500, yc = 500, Processors = 1; // default values, must be signed 8 8 9 9 struct derived_actor { inline actor; }; … … 25 25 26 26 allocation receive( derived_actor & receiver, derived_msg & msg ) { 27 for ( unsigned int i = 0; i < yc; i += 1 ) {// multiply X_row by Y_col and sum products27 for ( i; yc ) { // multiply X_row by Y_col and sum products 28 28 msg.Z[i] = 0; 29 for ( unsigned int j = 0; j < xc; j += 1) {29 for ( j; xc ) { 30 30 msg.Z[i] += msg.X[j] * msg.Y[j][i]; 31 31 } // for … … 67 67 } // switch 68 68 69 unsigned int r, c;70 69 int * Z[xr], * X[xr], * Y[xc]; 71 70 72 for ( r = 0; r < xr; r += 1 ) {// create/initialize X matrix71 for ( r; xr ) { // create/initialize X matrix 73 72 X[r] = aalloc( xc ); 74 for ( c = 0; c < xc; c += 1) {73 for ( c; xc ) { 75 74 X[r][c] = r * c % 37; // for timing 76 75 } // for 77 76 } // for 78 for ( r = 0; r < xc; r += 1 ) {// create/initialize Y matrix77 for ( r; xc ) { // create/initialize Y matrix 79 78 Y[r] = aalloc( yc ); 80 for ( c = 0; c < yc; c += 1) {79 for ( c; yc ) { 81 80 Y[r][c] = r * c % 37; // for timing 82 81 } // for 83 82 } // for 84 for ( r = 0; r < xr; r += 1 ) {// create Z matrix83 for ( r; xr ) { // create Z matrix 85 84 Z[r] = aalloc( yc ); 86 85 } // for … … 98 97 derived_actor actors[xr]; 99 98 100 for ( unsigned int r = 0; r < xr; r += 1) {99 for ( r; xr ) { 101 100 messages[r]{ Z[r], X[r], Y }; 102 101 } // for 103 102 104 for ( unsigned int r = 0; r < xr; r += 1) {103 for ( r; xr ) { 105 104 actors[r] | messages[r]; 106 105 } // for … … 112 111 sout | "stopped"; 113 112 114 for ( r = 0; r < xr; r += 1 ) {// deallocate X and Z matrices113 for ( r; xr ) { // deallocate X and Z matrices 115 114 free( X[r] ); 116 115 free( Z[r] ); 117 116 } // for 118 for ( r = 0; r < xc; r += 1 ) {// deallocate Y matrix117 for ( r; xc ) { // deallocate Y matrix 119 118 free( Y[r] ); 120 119 } // for
Note: See TracChangeset
for help on using the changeset viewer.