/[escript]/trunk/escript/src/DataAlgorithm.h
ViewVC logotype

Diff of /trunk/escript/src/DataAlgorithm.h

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 121 by jgs, Fri May 6 04:26:16 2005 UTC revision 122 by jgs, Thu Jun 9 05:38:05 2005 UTC
# Line 166  algorithm(DataExpanded& data, Line 166  algorithm(DataExpanded& data,
166    // calculate the reduction operation value for each data point    // calculate the reduction operation value for each data point
167    // storing the result for each data-point in successive entries    // storing the result for each data-point in successive entries
168    // in resultVector    // in resultVector
169    {    //
170  #pragma omp for private(i,j) schedule(static)    // this loop cannot be prallelised as "operation" is an instance of DataAlgorithmAdapter
171      for (i=0;i<numSamples;i++) {    // which maintains state between calls which would be corrupted by parallel execution
172        for (j=0;j<numDPPSample;j++) {    for (i=0;i<numSamples;i++) {
173  #pragma omp critical (reductionOp)      for (j=0;j<numDPPSample;j++) {
174      resultVector[j*numSamples+i]=dataView.reductionOp(data.getPointOffset(i,j),operation);        resultVector[j*numSamples+i]=dataView.reductionOp(data.getPointOffset(i,j),operation);
       }  
175      }      }
176    }    }
177    // now calculate the reduction operation value across the results    // now calculate the reduction operation value across the results
178    // for each data-point    // for each data-point
179      //
180      // this loop cannot be prallelised as "operation" is an instance of DataAlgorithmAdapter
181      // which maintains state between calls which would be corrupted by parallel execution
182    operation.resetResult();    operation.resetResult();
183    for (int l=0;l<resultVectorLength;l++) {    for (int l=0;l<resultVectorLength;l++) {
184      operation(resultVector[l]);      operation(resultVector[l]);
# Line 204  algorithm(DataTagged& data, Line 206  algorithm(DataTagged& data,
206    resultVector.push_back(data.getDefaultValue().reductionOp(operation));    resultVector.push_back(data.getDefaultValue().reductionOp(operation));
207    // now calculate the reduction operation value across the results    // now calculate the reduction operation value across the results
208    // for each tagged value    // for each tagged value
209      //
210      // this loop cannot be prallelised as "operation" is an instance of DataAlgorithmAdapter
211      // which maintains state between calls which would be corrupted by parallel execution
212    resultVectorLength=resultVector.size();    resultVectorLength=resultVector.size();
213    operation.resetResult();    operation.resetResult();
214    for (int l=0;l<resultVectorLength;l++) {    for (int l=0;l<resultVectorLength;l++) {
# Line 246  dp_algorithm(DataExpanded& data, Line 251  dp_algorithm(DataExpanded& data,
251    DataArrayView resultView=result.getPointDataView();    DataArrayView resultView=result.getPointDataView();
252    // perform the operation on each data-point and assign    // perform the operation on each data-point and assign
253    // this to the corresponding element in result    // this to the corresponding element in result
254    {    //
255  #pragma omp for private(i,j) schedule(static)    // this loop cannot be prallelised as "operation" is an instance of DataAlgorithmAdapter
256      for (i=0;i<numSamples;i++) {    // which maintains state between calls which would be corrupted by parallel execution
257        for (j=0;j<numDPPSample;j++) {    for (i=0;i<numSamples;i++) {
258  #pragma omp critical (reductionOp)      for (j=0;j<numDPPSample;j++) {
259          resultView.getData(result.getPointOffset(i,j)) =        resultView.getData(result.getPointOffset(i,j)) =
260            dataView.reductionOp(data.getPointOffset(i,j),operation);          dataView.reductionOp(data.getPointOffset(i,j),operation);
       }  
261      }      }
262    }    }
263  }  }
# Line 272  dp_algorithm(DataTagged& data, Line 276  dp_algorithm(DataTagged& data,
276    DataArrayView resultView=result.getPointDataView();    DataArrayView resultView=result.getPointDataView();
277    // perform the operation on each tagged data value    // perform the operation on each tagged data value
278    // and assign this to the corresponding element in result    // and assign this to the corresponding element in result
279      //
280      // this loop cannot be prallelised as "operation" is an instance of DataAlgorithmAdapter
281      // which maintains state between calls which would be corrupted by parallel execution
282    for (i=lookup.begin();i!=lookupEnd;i++) {    for (i=lookup.begin();i!=lookupEnd;i++) {
283      resultView.getData(i->second) =      resultView.getData(i->second) =
284        dataView.reductionOp(i->second,operation);        dataView.reductionOp(i->second,operation);
# Line 296  dp_algorithm(DataConstant& data, Line 303  dp_algorithm(DataConstant& data,
303  }  }
304    
305  } // end of namespace  } // end of namespace
306    
307  #endif  #endif

Legend:
Removed from v.121  
changed lines
  Added in v.122

  ViewVC Help
Powered by ViewVC 1.1.26