Changeset 8d61d620
- Timestamp:
- Jun 21, 2019, 3:42:05 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 18e683b, f2f22e3
- Parents:
- c1ed2ee (diff), 49dee5e (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. - Location:
- tests/concurrent/examples
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/examples/boundedBufferEXT.cfa
rc1ed2ee r8d61d620 10 10 // Created On : Wed Apr 18 22:52:12 2018 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 22 13:41:33201913 // Update Count : 1 212 // Last Modified On : Fri Jun 21 08:19:20 2019 13 // Update Count : 14 14 14 // 15 15 … … 52 52 } 53 53 54 const int Sentinel = -1;54 enum { Sentinel = -1 }; 55 55 56 56 thread Producer { … … 59 59 }; 60 60 void main( Producer & prod ) with( prod ) { 61 for ( i nt i = 1; i <= N; i += 1) {61 for ( i; 1 ~= N ) { 62 62 yield( random( 5 ) ); 63 63 insert( buffer, 1 ); … … 99 99 srandom( 1003 ); 100 100 101 for ( i = 0; i < Cons; i += 1 ) {// create consumers101 for ( i; Cons ) { // create consumers 102 102 cons[i] = new( &buffer, sums[i] ); 103 103 } // for 104 for ( i = 0; i < Prods; i += 1 ) {// create producers104 for ( i; Prods ) { // create producers 105 105 prods[i] = new( &buffer, 100000 ); 106 106 } // for 107 107 108 for ( i = 0; i < Prods; i += 1 ) {// wait for producers to finish108 for ( i; Prods ) { // wait for producers to finish 109 109 delete( prods[i] ); 110 110 } // for 111 for ( i = 0; i < Cons; i += 1 ) {// generate sentinal values to stop consumers111 for ( i; Cons ) { // generate sentinal values to stop consumers 112 112 insert( buffer, Sentinel ); 113 113 } // for 114 114 int sum = 0; 115 for ( i = 0; i < Cons; i += 1 ) {// wait for consumers to finish115 for ( i; Cons ) { // wait for consumers to finish 116 116 delete( cons[i] ); 117 117 sum += sums[i]; -
tests/concurrent/examples/boundedBufferINT.cfa
rc1ed2ee r8d61d620 10 10 // Created On : Mon Oct 30 12:45:13 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 22 13:41:52201913 // Update Count : 8812 // Last Modified On : Fri Jun 21 08:20:46 2019 13 // Update Count : 90 14 14 // 15 15 … … 53 53 } 54 54 55 const int Sentinel = -1;55 enum { Sentinel = -1 }; 56 56 57 57 thread Producer { … … 60 60 }; 61 61 void main( Producer & prod ) with( prod ) { 62 for ( i nt i = 1; i <= N; i += 1) {62 for ( i; 1 ~= N ) { 63 63 yield( random( 5 ) ); 64 64 insert( buffer, 1 ); … … 100 100 srandom( 1003 ); 101 101 102 for ( i = 0; i < Cons; i += 1 ) {// create consumers102 for ( i; Cons ) { // create consumers 103 103 cons[i] = new( &buffer, sums[i] ); 104 104 } // for 105 for ( i = 0; i < Prods; i += 1 ) {// create producers105 for ( i; Prods ) { // create producers 106 106 prods[i] = new( &buffer, 100000 ); 107 107 } // for 108 108 109 for ( i = 0; i < Prods; i += 1 ) {// wait for producers to finish109 for ( i; Prods ) { // wait for producers to finish 110 110 delete( prods[i] ); 111 111 } // for 112 for ( i = 0; i < Cons; i += 1 ) {// generate sentinal values to stop consumers112 for ( i; Cons ) { // generate sentinal values to stop consumers 113 113 insert( buffer, Sentinel ); 114 114 } // for 115 115 int sum = 0; 116 for ( i = 0; i < Cons; i += 1 ) {// wait for consumers to finish116 for ( i; Cons ) { // wait for consumers to finish 117 117 delete( cons[i] ); 118 118 sum += sums[i]; -
tests/concurrent/examples/datingService.cfa
rc1ed2ee r8d61d620 10 10 // Created On : Mon Oct 30 12:56:20 2017 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 22 13:41:39201913 // Update Count : 3 112 // Last Modified On : Fri Jun 21 11:32:34 2019 13 // Update Count : 38 14 14 // 15 15 … … 95 95 srandom( /*getpid()*/ 103 ); 96 96 97 for ( unsigned int i = 0; i < CompCodes; i += 1) {98 girls[i] = new( &TheExchange, i, i ); 97 for ( i; (unsigned int)CompCodes ) { 98 girls[i] = new( &TheExchange, i, i ); // TheExchange constructor needs unsigned int 99 99 boys[i] = new( &TheExchange, i, CompCodes - ( i + 1 ) ); 100 100 } // for 101 101 102 for ( unsigned int i = 0; i < CompCodes; i += 1) {102 for ( i; CompCodes ) { 103 103 delete( boys[i] ); 104 104 delete( girls[i] ); 105 105 } // for 106 106 107 for ( unsigned int i = 0; i < CompCodes; i += 1) {107 for ( i; CompCodes ) { 108 108 if ( girlck[ boyck[i] ] != boyck[ girlck[i] ] ) abort(); 109 109 } // for -
tests/concurrent/examples/gortn.cfa
rc1ed2ee r8d61d620 10 10 // Created On : Wed Feb 20 08:02:37 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Feb 20 08:35:55201913 // Update Count : 312 // Last Modified On : Fri Jun 21 08:25:03 2019 13 // Update Count : 4 14 14 // 15 15 … … 18 18 19 19 struct Msg { int i, j; }; 20 thread Go rtn { int i; float f; Msg m; };21 void ^?{}( Go rtn & mutex ) {}22 void mem1( Go rtn & mutex gortn, int i ) { gortn.i = i; }23 void mem2( Go rtn & mutex gortn, float f ) { gortn.f = f; }24 void mem3( Go rtn & mutex gortn, Msg m ) { gortn.m = m; }20 thread GoRtn { int i; float f; Msg m; }; 21 void ^?{}( GoRtn & mutex ) {} 22 void mem1( GoRtn & mutex gortn, int i ) { gortn.i = i; } 23 void mem2( GoRtn & mutex gortn, float f ) { gortn.f = f; } 24 void mem3( GoRtn & mutex gortn, Msg m ) { gortn.m = m; } 25 25 26 void main( Go rtn & gortn ) with( gortn ) {27 for ( ;;) {26 void main( GoRtn & gortn ) with( gortn ) { 27 for () { 28 28 waitfor( mem1, gortn ) sout | i; 29 29 or waitfor( mem2, gortn ) sout | f; … … 33 33 } 34 34 int main() { 35 Go rtn gortn; // start thread35 GoRtn gortn; // start thread 36 36 mem1( gortn, 0 ); 37 37 mem2( gortn, 2.5 ); -
tests/concurrent/examples/quickSort.cfa
rc1ed2ee r8d61d620 11 11 // Created On : Wed Dec 6 12:15:52 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Fri Mar 22 13:42:01201914 // Update Count : 17 013 // Last Modified On : Fri Jun 21 08:27:45 2019 14 // Update Count : 172 15 15 // 16 16 … … 138 138 if ( eof( unsortedfile ) ) break; 139 139 int * values = alloc( size ); // values to be sorted, too large to put on stack 140 for ( int counter = 0; counter < size; counter += 1 ) {// read unsorted numbers140 for ( counter; size ) { // read unsorted numbers 141 141 unsortedfile | values[counter]; 142 142 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; … … 148 148 Quicksort QS = { values, size - 1, 0 }; // sort values 149 149 } // wait until sort tasks terminate 150 for ( int counter = 0; counter < size; counter += 1 ) {// print sorted list150 for ( counter; size ) { // print sorted list 151 151 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; 152 152 sortedfile | values[counter]; … … 163 163 164 164 int * values = alloc( size ); // values to be sorted, too large to put on stack 165 for ( int counter = 0; counter < size; counter += 1 ) {// generate unsorted numbers165 for ( counter; size ) { // generate unsorted numbers 166 166 values[counter] = size - counter; // descending values 167 167 } // for … … 170 170 } // wait until sort tasks terminate 171 171 172 // for ( int counter = 0; counter < size - 1; counter += 1 ) {// check sorting172 // for ( counter; size - 1 ) { // check sorting 173 173 // if ( values[counter] > values[counter + 1] ) abort(); 174 174 // } // for -
tests/concurrent/examples/quickSort.generic.cfa
rc1ed2ee r8d61d620 11 11 // Created On : Wed Dec 6 12:15:52 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Fri Mar 15 14:52:41201914 // Update Count : 14 713 // Last Modified On : Fri Jun 21 08:28:20 2019 14 // Update Count : 149 15 15 // 16 16 … … 141 141 if ( eof( unsortedfile ) ) break; 142 142 ELEMTYPE * values = alloc( size ); // values to be sorted, too large to put on stack 143 for ( int counter = 0; counter < size; counter += 1 ) {// read unsorted numbers143 for ( counter; size ) { // read unsorted numbers 144 144 unsortedfile | values[counter]; 145 145 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; … … 151 151 Quicksort(ELEMTYPE) QS = { values, size - 1, 0 }; // sort values 152 152 } // wait until sort tasks terminate 153 for ( int counter = 0; counter < size; counter += 1 ) {// print sorted list153 for ( counter; size ) { // print sorted list 154 154 if ( counter != 0 && counter % ValuesPerLine == 0 ) sortedfile | nl | " "; 155 155 sortedfile | values[counter]; … … 166 166 167 167 ELEMTYPE * values = alloc( size ); // values to be sorted, too large to put on stack 168 for ( int counter = 0; counter < size; counter += 1 ) {// generate unsorted numbers168 for ( counter; size ) { // generate unsorted numbers 169 169 values[counter] = size - counter; // descending values 170 170 } // for … … 173 173 } // wait until sort tasks terminate 174 174 175 // for ( int counter = 0; counter < size - 1; counter += 1 ) {// check sorting175 // for ( counter; size - 1 ) { // check sorting 176 176 // if ( values[counter] > values[counter + 1] ) abort(); 177 177 // } // for
Note: See TracChangeset
for help on using the changeset viewer.