Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/tests/matrixSum.c

    rd6655bd r9f865d1  
    1111// Created On       : Mon Oct  9 08:29:28 2017
    1212// Last Modified By : Peter A. Buhr
    13 // Last Modified On : Mon Oct  9 08:30:08 2017
    14 // Update Count     : 1
     13// Last Modified On : Sun Oct 29 21:08:48 2017
     14// Update Count     : 2
    1515//
    1616
     
    2020
    2121thread Adder {
    22     int * row, cols, * subtotal;                        // communication
     22    int * row, cols, * subtotal;                                                // communication
    2323};
    2424
     
    3232    *adder.subtotal = 0;
    3333    for ( int c = 0; c < adder.cols; c += 1 ) {
    34         *adder.subtotal += adder.row[c];
     34                *adder.subtotal += adder.row[c];
    3535    } // for
    3636}
     
    3939    const int rows = 10, cols = 1000;
    4040    int matrix[rows][cols], subtotals[rows], total = 0;
    41     processor p;                                        // extra kernel thread
     41    processor p;                                                                                // extra kernel thread
    4242
    4343    for ( int r = 0; r < rows; r += 1 ) {
    44         for ( int c = 0; c < cols; c += 1 ) {
    45             matrix[r][c] = 1;
    46         } // for
     44                for ( int c = 0; c < cols; c += 1 ) {
     45                        matrix[r][c] = 1;
     46                } // for
    4747    } // for
    4848    Adder * adders[rows];
    49     for ( int r = 0; r < rows; r += 1 ) {               // start threads to sum rows
    50         adders[r] = &(*malloc()){ matrix[r], cols, subtotals[r] };
    51 //      adders[r] = new( matrix[r], cols, &subtotals[r] );
     49    for ( int r = 0; r < rows; r += 1 ) {                               // start threads to sum rows
     50                adders[r] = &(*malloc()){ matrix[r], cols, subtotals[r] };
     51//              adders[r] = new( matrix[r], cols, &subtotals[r] );
    5252    } // for
    53     for ( int r = 0; r < rows; r += 1 ) {               // wait for threads to finish
    54         delete( adders[r] );
    55         total += subtotals[r];                          // total subtotals
     53    for ( int r = 0; r < rows; r += 1 ) {                               // wait for threads to finish
     54                delete( adders[r] );
     55                total += subtotals[r];                                                  // total subtotals
    5656    } // for
    5757    sout | total | endl;
Note: See TracChangeset for help on using the changeset viewer.