Changeset 5e44ac2 for tests/concurrent/examples/matrixSum.c
- Timestamp:
- Aug 15, 2018, 1:58:02 PM (7 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 90cac45
- Parents:
- d7d63e5 (diff), 7bd4cc9 (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 moved
Legend:
- Unmodified
- Added
- Removed
-
tests/concurrent/examples/matrixSum.c
rd7d63e5 r5e44ac2 1 // -*- Mode: C -*- 2 // 1 // -*- Mode: C -*- 2 // 3 3 // Cforall Version 1.0.0 Copyright (C) 2017 University of Waterloo 4 4 // 5 5 // The contents of this file are covered under the licence agreement in the 6 6 // file "LICENCE" distributed with Cforall. 7 // 8 // matrixSum.c -- 9 // 7 // 8 // matrixSum.c -- 9 // 10 10 // Author : Peter A. Buhr 11 11 // Created On : Mon Oct 9 08:29:28 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Fri May 25 09:34:27201814 // Update Count : 1 015 // 13 // Last Modified On : Thu Aug 9 09:17:30 2018 14 // Update Count : 13 15 // 16 16 17 #include <fstream >18 #include <kernel >19 #include <thread >17 #include <fstream.hfa> 18 #include <kernel.hfa> 19 #include <thread.hfa> 20 20 21 21 thread Adder { … … 30 30 void main( Adder & adder ) with( adder ) { // thread starts here 31 31 subtotal = 0; 32 for ( int c = 0; c < cols; c += 1) {32 for ( c; cols ) { 33 33 subtotal += row[c]; 34 34 } // for … … 36 36 37 37 int main() { 38 constint rows = 10, cols = 1000;38 /* const */ int rows = 10, cols = 1000; 39 39 int matrix[rows][cols], subtotals[rows], total = 0; 40 40 processor p; // add kernel thread 41 41 42 for ( int r = 0; r < rows; r += 1) {43 for ( int c = 0; c < cols; c += 1) {42 for ( r; rows ) { 43 for ( c; cols ) { 44 44 matrix[r][c] = 1; 45 45 } // for 46 46 } // for 47 47 Adder * adders[rows]; 48 for ( int r = 0; r < rows; r += 1 ) {// start threads to sum rows48 for ( r; rows ) { // start threads to sum rows 49 49 adders[r] = &(*malloc()){ matrix[r], cols, subtotals[r] }; 50 50 // adders[r] = new( matrix[r], cols, &subtotals[r] ); 51 51 } // for 52 for ( int r = 0; r < rows; r += 1 ) {// wait for threads to finish52 for ( r; rows ) { // wait for threads to finish 53 53 delete( adders[r] ); 54 54 total += subtotals[r]; // total subtotals
Note:
See TracChangeset
for help on using the changeset viewer.