Commit a96193ba authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Fixed bug in parallel reduction on host

parent 1ad0339b
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -189,7 +189,10 @@ reduce( Operation& operation,
#pragma omp parallel
      {
         // initialize array for thread-local results
         ResultType r[ 4 ] = { operation.initialValue() };
         ResultType r[ 4 ] = { operation.initialValue(),
                               operation.initialValue(),
                               operation.initialValue(),
                               operation.initialValue() };

         #pragma omp for nowait
         for( int b = 0; b < blocks; b++ ) {
@@ -226,7 +229,10 @@ reduce( Operation& operation,
#endif
      if( blocks > 1 ) {
         // initialize array for unrolled results
         ResultType r[ 4 ] = { operation.initialValue() };
         ResultType r[ 4 ] = { operation.initialValue(),
                               operation.initialValue(),
                               operation.initialValue(),
                               operation.initialValue() };

         // main reduction (explicitly unrolled loop)
         for( int b = 0; b < blocks; b++ ) {