~vcs-imports/escript-finley/trunk

« back to all changes in this revision

Viewing changes to escript/src/Data.cpp

  • Committer: jfenwick
  • Date: 2010-10-11 01:48:14 UTC
  • Revision ID: svn-v4:77569008-7704-0410-b7a0-a92fef0b09fd:trunk:3259
Merging dudley and scons updates from branches

Show diffs side-by-side

added added

removed removed

Lines of Context:
1294
1294
        memcpy(tmpData,&(getDataAtOffsetRO(offset)),length*sizeof(double));
1295
1295
     }
1296
1296
  }
1297
 
#ifdef PASO_MPI
 
1297
#ifdef ESYS_MPI
1298
1298
  // broadcast the data to all other processes
1299
1299
  MPI_Bcast( tmpData, length, MPI_DOUBLE, procNo, get_MPIComm() );
1300
1300
#endif
1344
1344
  {                             
1345
1345
    throw DataException("Can not integrate over non-continuous domains.");
1346
1346
  }
1347
 
#ifdef PASO_MPI
 
1347
#ifdef ESYS_MPI
1348
1348
  dom->setToIntegrals(integrals_local,*this);
1349
1349
  // Global sum: use an array instead of a vector because elements of array are guaranteed to be contiguous in memory
1350
1350
  double *tmp = new double[dataPointSize];
1557
1557
        }
1558
1558
        else
1559
1559
        {
1560
 
#ifdef PASO_MPI
 
1560
#ifdef ESYS_MPI
1561
1561
            return lazyAlgWorker<AbsMax>(0,MPI_MAX);
1562
1562
#else
1563
1563
            return lazyAlgWorker<AbsMax>(0);
1588
1588
        }
1589
1589
        else
1590
1590
        {
1591
 
#ifdef PASO_MPI
 
1591
#ifdef ESYS_MPI
1592
1592
            return lazyAlgWorker<FMax>(numeric_limits<double>::max()*-1, MPI_MAX);
1593
1593
#else
1594
1594
            return lazyAlgWorker<FMax>(numeric_limits<double>::max()*-1);
1619
1619
        }
1620
1620
        else
1621
1621
        {
1622
 
#ifdef PASO_MPI
 
1622
#ifdef ESYS_MPI
1623
1623
            return lazyAlgWorker<FMin>(numeric_limits<double>::max(), MPI_MIN);
1624
1624
#else
1625
1625
            return lazyAlgWorker<FMin>(numeric_limits<double>::max());
1631
1631
 
1632
1632
template <class BinaryOp>
1633
1633
double
1634
 
#ifdef PASO_MPI
 
1634
#ifdef ESYS_MPI
1635
1635
Data::lazyAlgWorker(double init, MPI_Op mpiop_type)
1636
1636
#else
1637
1637
Data::lazyAlgWorker(double init)
1675
1675
        #pragma omp critical
1676
1676
        val=operation(val,localtot);
1677
1677
   }
1678
 
#ifdef PASO_MPI
 
1678
#ifdef ESYS_MPI
1679
1679
   double globalValue;
1680
1680
   MPI_Allreduce( &localval, &globalValue, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD );
1681
1681
   if (globalValue!=0)
1687
1687
   {
1688
1688
        return makeNaN();
1689
1689
   }
1690
 
#ifdef PASO_MPI
 
1690
#ifdef ESYS_MPI
1691
1691
   MPI_Allreduce( &val, &globalValue, 1, MPI_DOUBLE, mpiop_type, MPI_COMM_WORLD );
1692
1692
   return globalValue;
1693
1693
#else
1702
1702
  bool haveNaN=getReady()->hasNaN();
1703
1703
  double localValue=0;
1704
1704
  
1705
 
#ifdef PASO_MPI
 
1705
#ifdef ESYS_MPI
1706
1706
  if (haveNaN)
1707
1707
  {
1708
1708
        localValue=1.0;
1726
1726
  AbsMax abs_max_func;
1727
1727
  localValue = algorithm(abs_max_func,0);
1728
1728
 
1729
 
#ifdef PASO_MPI
 
1729
#ifdef ESYS_MPI
1730
1730
  
1731
1731
  MPI_Allreduce( &localValue, &globalValue, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD );
1732
1732
  return globalValue;
1741
1741
  bool haveNaN=getReady()->hasNaN();
1742
1742
  double localValue=0;
1743
1743
 
1744
 
#ifdef PASO_MPI
 
1744
#ifdef ESYS_MPI
1745
1745
  if (haveNaN)
1746
1746
  {
1747
1747
        localValue=1.0;
1763
1763
  // set the initial maximum value to min possible double
1764
1764
  FMax fmax_func;
1765
1765
  localValue = algorithm(fmax_func,numeric_limits<double>::infinity()*-1);
1766
 
#ifdef PASO_MPI
 
1766
#ifdef ESYS_MPI
1767
1767
  MPI_Allreduce( &localValue, &globalValue, 1, MPI_DOUBLE, MPI_MAX, MPI_COMM_WORLD );
1768
1768
  return globalValue;
1769
1769
#else
1777
1777
  bool haveNaN=getReady()->hasNaN();
1778
1778
  double localValue=0;
1779
1779
 
1780
 
#ifdef PASO_MPI
 
1780
#ifdef ESYS_MPI
1781
1781
  if (haveNaN)
1782
1782
  {
1783
1783
        localValue=1.0;
1798
1798
  // set the initial minimum value to max possible double
1799
1799
  FMin fmin_func;
1800
1800
  localValue = algorithm(fmin_func,numeric_limits<double>::infinity());
1801
 
#ifdef PASO_MPI
 
1801
#ifdef ESYS_MPI
1802
1802
  MPI_Allreduce( &localValue, &globalValue, 1, MPI_DOUBLE, MPI_MIN, MPI_COMM_WORLD );
1803
1803
  return globalValue;
1804
1804
#else
2122
2122
  int numDPPSample=temp.getNumDataPointsPerSample();
2123
2123
 
2124
2124
  double local_val, local_min;
2125
 
  #ifdef PASO_MPI
 
2125
  #ifdef ESYS_MPI
2126
2126
  double next[2];
2127
2127
  #endif
2128
2128
  int local_lowi=0,local_lowj=0;        
2149
2149
    }
2150
2150
  }
2151
2151
 
2152
 
#ifdef PASO_MPI
 
2152
#ifdef ESYS_MPI
2153
2153
  // determine the processor on which the minimum occurs
2154
2154
  next[0] = min;
2155
2155
  next[1] = numSamples;
2210
2210
  int numDPPSample=temp.getNumDataPointsPerSample();
2211
2211
 
2212
2212
  double local_val, local_max;
2213
 
  #ifdef PASO_MPI
 
2213
  #ifdef ESYS_MPI
2214
2214
  double next[2];
2215
2215
  #endif
2216
2216
  int local_highi=0,local_highj=0;      
2236
2236
      highj=local_highj;
2237
2237
    }
2238
2238
  }
2239
 
#ifdef PASO_MPI
 
2239
#ifdef ESYS_MPI
2240
2240
  // determine the processor on which the maximum occurs
2241
2241
  next[0] = max;
2242
2242
  next[1] = numSamples;
2430
2430
  Data out(0.,getDataPointShape(),getFunctionSpace());
2431
2431
  out.typeMatchRight(*this);
2432
2432
  int errcode=m_data->matrixInverse(out.getReadyPtr().get());
2433
 
#ifdef PASO_MPI
 
2433
#ifdef ESYS_MPI
2434
2434
  int globalval=0;
2435
2435
  MPI_Allreduce( &errcode, &globalval, 1, MPI_INT, MPI_MAX, get_MPIComm() );
2436
2436
  errcode=globalval;
3153
3153
{
3154
3154
 
3155
3155
    int localNeedSummary=0;
3156
 
#ifdef PASO_MPI
 
3156
#ifdef ESYS_MPI
3157
3157
    int globalNeedSummary=0;
3158
3158
#endif
3159
3159
    if (!m_data->isEmpty() &&
3163
3163
        localNeedSummary=1;
3164
3164
    }
3165
3165
 
3166
 
#ifdef PASO_MPI
 
3166
#ifdef ESYS_MPI
3167
3167
    MPI_Allreduce( &localNeedSummary, &globalNeedSummary, 1, MPI_INT, MPI_MAX, get_MPIComm() );
3168
3168
    localNeedSummary=globalNeedSummary;
3169
3169
#endif
3357
3357
                  } // if (!error)
3358
3358
            }   // parallelised for
3359
3359
        } // if !haserror
3360
 
#ifdef PASO_MPI
 
3360
#ifdef ESYS_MPI
3361
3361
        int rerror=0;
3362
3362
        MPI_Allreduce( &error, &rerror, 1, MPI_INT, MPI_MAX, get_MPIComm() );
3363
3363
        error=rerror;
3546
3546
            }  // if (!haserror)
3547
3547
        }       // parallel for
3548
3548
     } // !error
3549
 
#ifdef PASO_MPI
 
3549
#ifdef ESYS_MPI
3550
3550
     int rerror=0;
3551
3551
     MPI_Allreduce( &error, &rerror, 1, MPI_INT, MPI_MAX, get_MPIComm() );
3552
3552
     error=rerror;
3608
3608
Data::get_MPISize() const
3609
3609
{
3610
3610
        int size;
3611
 
#ifdef PASO_MPI
 
3611
#ifdef ESYS_MPI
3612
3612
        int error;
3613
3613
        error = MPI_Comm_size( get_MPIComm(), &size );
3614
3614
#else
3621
3621
Data::get_MPIRank() const
3622
3622
{
3623
3623
        int rank;
3624
 
#ifdef PASO_MPI
 
3624
#ifdef ESYS_MPI
3625
3625
        int error;
3626
3626
        error = MPI_Comm_rank( get_MPIComm(), &rank );
3627
3627
#else
3633
3633
MPI_Comm
3634
3634
Data::get_MPIComm() const
3635
3635
{
3636
 
#ifdef PASO_MPI
 
3636
#ifdef ESYS_MPI
3637
3637
        return MPI_COMM_WORLD;
3638
3638
#else
3639
3639
        return -1;
3799
3799
    {
3800
3800
        throw DataException("applyBinaryCFunction: Unsupported combination of inputs.");
3801
3801
    }
3802
 
#ifdef PASO_MPI
 
3802
#ifdef ESYS_MPI
3803
3803
    int global;
3804
3804
    MPI_Allreduce(&err, &global, 1, MPI_INT, MPI_MAX, MPI_COMM_WORLD);
3805
3805
    err=global;