Mercurial > cgi-bin > hgwebdir.cgi > PR > Applications > Vthread > Vthread__Matrix_Mult__Bench
changeset 1:103a5f3b74cf
Works on small matrices -- too many threads, dies on large matrices
| author | Me |
|---|---|
| date | Tue, 26 Oct 2010 19:37:08 -0700 |
| parents | 3b0e43240104 |
| children | b2bced9907ea |
| files | .hgignore src/Application/Matrix_Mult.c src/Application/VPThread__Matrix_Mult/Result_Pr.c src/Application/main.c |
| diffstat | 4 files changed, 19 insertions(+), 8 deletions(-) [+] |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/.hgignore Tue Oct 26 19:37:08 2010 -0700 1.3 @@ -0,0 +1,6 @@ 1.4 +Makefile 1.5 +.dep.inc 1.6 +nbproject 1.7 +dist 1.8 +build 1.9 +
2.1 --- a/src/Application/Matrix_Mult.c Fri Sep 17 11:28:28 2010 -0700 2.2 +++ b/src/Application/Matrix_Mult.c Tue Oct 26 19:37:08 2010 -0700 2.3 @@ -51,7 +51,7 @@ 2.4 read_Matrix_From_File( Matrix *matrixStruc, char *matrixFileName ) 2.5 { int row, maxRead, numRows, numCols; 2.6 float32 *matrixStart; 2.7 - size_t lineSz = 0; 2.8 + int32 lineSz = 0; 2.9 FILE *file; 2.10 char *line = NULL; 2.11 2.12 @@ -148,16 +148,18 @@ 2.13 2.14 void 2.15 printMatrix( Matrix *matrix ) 2.16 - { int r, c, numRows, numCols; 2.17 + { int r, c, numRows, numCols, rowsToPrint, colsToPrint, rowIncr, colIncr; 2.18 float32 *matrixArray; 2.19 2.20 - numRows = matrix->numRows; 2.21 - numCols = matrix->numCols; 2.22 + numRows = rowsToPrint = matrix->numRows; 2.23 + numCols = colsToPrint = matrix->numCols; 2.24 matrixArray = matrix->matrix; 2.25 2.26 - for( r = 0; r < numRows; r++ ) 2.27 - { for( c = 0; c < numCols; c++ ) 2.28 - { printf( "%f | ", *(matrixArray + r*numCols + c) ); 2.29 + rowIncr = numRows/20; if(rowIncr == 0) rowIncr = 1;//20 to 39 rows printed 2.30 + colIncr = numCols/20; if(colIncr == 0) colIncr = 1;//20 to 39 cols printed 2.31 + for( r = 0; r < numRows; r += rowIncr ) 2.32 + { for( c = 0; c < numCols; c += colIncr ) 2.33 + { printf( "%3.1f | ", matrixArray[ r * numCols + c ] ); 2.34 } 2.35 printf("\n"); 2.36 }
3.1 --- a/src/Application/VPThread__Matrix_Mult/Result_Pr.c Fri Sep 17 11:28:28 2010 -0700 3.2 +++ b/src/Application/VPThread__Matrix_Mult/Result_Pr.c Tue Oct 26 19:37:08 2010 -0700 3.3 @@ -32,6 +32,9 @@ 3.4 3.5 //Tell divider that have the vector lock -- so it's sure won't miss any 3.6 // signals from the vector-threads it's about to create 3.7 + //Don't need a signal variable -- this thd can't be created until 3.8 + // divider thd already has the start lock 3.9 + VPThread__mutex_lock( globals->start_mutex, animatingPr );//finish wait 3.10 VPThread__cond_signal( globals->start_cond, animatingPr ); 3.11 VPThread__mutex_unlock( globals->start_mutex, animatingPr );//finish wait 3.12
4.1 --- a/src/Application/main.c Fri Sep 17 11:28:28 2010 -0700 4.2 +++ b/src/Application/main.c Tue Oct 26 19:37:08 2010 -0700 4.3 @@ -27,7 +27,7 @@ 4.4 4.5 printf("\nresult matrix: \n"); 4.6 4.7 -// printMatrix( resultMatrix ); 4.8 + printMatrix( resultMatrix ); 4.9 4.10 // VPThread__print_stats(); 4.11
