# Diff of /branches/diaplayground/ripley/src/Brick.cpp

revision 4703 by jfenwick, Fri Feb 21 00:55:31 2014 UTC revision 4705 by jfenwick, Fri Feb 21 02:36:15 2014 UTC
# Line 2876  namespace Line 2876  namespace
2876          for (int x=-r;x<=r;++x)          for (int x=-r;x<=r;++x)
2877          {                  {
2878              arr[(x+r)+(y+r)*(r*2+1)+(z+r)*(r*2+1)*(r*2+1)]=common*exp(-(x*x+y*y+z*z)/(2*sigma*sigma));              arr[(x+r)+(y+r)*(r*2+1)+(z+r)*(r*2+1)*(r*2+1)]=common*exp(-(x*x+y*y+z*z)/(2*sigma*sigma));
2879              total+=arr[(x+r)+(y+r)*(r*2+1)+(z+r)*(r*2+1)*(r*2+1)];              total+=arr[(x+r)+(y+r)*(r*2+1)+(z+r)*(r*2+1)*(r*2+1)];
cerr <<     arr[(x+r)+(y+r)*(r*2+1)+(z+r)*(r*2+1)*(r*2+1)] << " ";
2880          }          }
cerr << endl;
2881          }          }
2882      }      }
2883      double invtotal=1/total;      double invtotal=1/total;
# Line 3057  escript::Data Brick::randomFillWorker(co Line 3055  escript::Data Brick::randomFillWorker(co
3055      dim_t Z=m_mpiInfo->rank/(m_NX[0]*m_NX[1]);      dim_t Z=m_mpiInfo->rank/(m_NX[0]*m_NX[1]);
3056  #endif      #endif
3057
3058        /*
3059      // if we wanted to test a repeating pattern      // if we wanted to test a repeating pattern
3060      size_t basex=0;      size_t basex=0;
3061      size_t basey=0;      size_t basey=0;
# Line 3070  escript::Data Brick::randomFillWorker(co Line 3068  escript::Data Brick::randomFillWorker(co
3068  cout << "basex=" << basex << " basey=" << basey << " basez=" << basez << endl;      cout << "basex=" << basex << " basey=" << basey << " basez=" << basez << endl;
3069
3070  #endif      #endif
if (seed==0)
{
seed=2; // since we are using the seed parameter as the spacing and 0 spacing causes an exception
}
3071      esysUtils::patternFillArray(1, ext[0],ext[1],ext[2], src, 4, basex, basey, basez, numvals);      esysUtils::patternFillArray(1, ext[0],ext[1],ext[2], src, 4, basex, basey, basez, numvals);
3072    */
3073

for (int z=0;z<ext[2];++z)
{
for (int y=0;y<ext[1];++y)
{
for (int x=0;x<ext[0];++x)
{
cout << "(";
for (int p=0;p<numvals;++p)
{
cout << src[(x+y*ext[0]+z*ext[0]*ext[1])*numvals+p] << ", ";
}
cout << ") ";

}
cout << endl;
}
cout << endl;
}

/*
cout << "Pattern:\n";
for (int i=0;i<ext[0]*ext[1]*ext[2];)
{
cout << src[i++] << " ";
if (i%ext[0]==0)
cout << "\n";
if (i%(ext[0]*ext[1])==0)
cout << "\n";
}*/

3074  #ifdef ESYS_MPI  #ifdef ESYS_MPI
3075
3076
# Line 3136  for (int i=0;i<ext[0]*ext[1]*ext[2];) Line 3097  for (int i=0;i<ext[0]*ext[1]*ext[2];)
3097
3098
3099      block.copyAllToBuffer(src);      block.copyAllToBuffer(src);

for (size_t j=0;j<incoms.size();++j)
{
message& m=incoms[j];
for (int i=0;i<block.getBuffSize(m.srcbuffid);++i)
{
block.getInBuffer(m.srcbuffid)[i]=-42;
}
}

3100
3101      int comserr=0;          int comserr=0;
3102      for (size_t i=0;i<incoms.size();++i)      for (size_t i=0;i<incoms.size();++i)
# Line 3160  for (int i=0;i<block.getBuffSize(m.srcbu Line 3110  for (int i=0;i<block.getBuffSize(m.srcbu
3110      {      {
3111      message& m=outcoms[i];      message& m=outcoms[i];
3112      comserr|=MPI_Isend(block.getOutBuffer(m.srcbuffid), block.getBuffSize(m.srcbuffid) , MPI_DOUBLE, m.destID, m.tag, m_mpiInfo->comm, reqs+(rused++));      comserr|=MPI_Isend(block.getOutBuffer(m.srcbuffid), block.getBuffSize(m.srcbuffid) , MPI_DOUBLE, m.destID, m.tag, m_mpiInfo->comm, reqs+(rused++));
if (m.destID==1)
{
cout << "Sending to 1\n";
for (int i=0;i<block.getBuffSize(m.srcbuffid);++i)
{
cout << block.getOutBuffer(m.srcbuffid)[i] << " ";
}
cout << endl;
}
3113      }          }
3114
3115      if (!comserr)      if (!comserr)
# Line 3185  cout << endl; Line 3126  cout << endl;
3126      }      }
3127
3128      block.copyUsedFromBuffer(src);      block.copyUsedFromBuffer(src);
3129
for (size_t i=0;i<incoms.size();++i)
{
message& m=incoms[i];
cout << "From" <<  m.sourceID << "Recv " << (int)m.destbuffid << endl;
for (int j=0;j<block.getBuffSize(m.destbuffid);++j)
{
cout << block.getInBuffer(m.destbuffid)[j] << " ";
}
cout << endl;
}

3130  #endif      #endif
3131
/*
cout << "Pattern (post transfer):\n";
for (int i=0;i<ext[0]*ext[1]*ext[2];)
{
cout << src[i++] << " ";
if (i%ext[0]==0)
cout << "\n";
if (i%(ext[0]*ext[1])==0)
cout << "\n";
}   */

3132      if (radius==0 || numvals>1) // the truth of either should imply the truth of the other but let's be safe      if (radius==0 || numvals>1) // the truth of either should imply the truth of the other but let's be safe
3133      {      {
3134
# Line 3249  for (int i=0;i<ext[0]*ext[1]*ext[2];) Line 3164  for (int i=0;i<ext[0]*ext[1]*ext[2];)
3164      escript::DataVector& dv=resdat.getExpandedVectorReference();      escript::DataVector& dv=resdat.getExpandedVectorReference();
3166
// cout << "Convolution matrix\n";
// double ctot=0;
// for (int i=0;i<di*di*di;++i)
// {
//     cout << convolution[i] << " ";
//     ctot+=convolution[i];
//     if ((i+1)%di==0)
//     {
//  cout << "\n";
//     }
//     if ((i+1)%(di*di)==0)
//     {
//  cout << "\n";
//     }
// }
//
// cout << "Sum of matrix is = " << ctot << endl;

3167      for (size_t z=0;z<(internal[2]);++z)      for (size_t z=0;z<(internal[2]);++z)
3168      {      {
3169          for (size_t y=0;y<(internal[1]);++y)              for (size_t y=0;y<(internal[1]);++y)
# Line 3280  for (int i=0;i<ext[0]*ext[1]*ext[2];) Line 3176  for (int i=0;i<ext[0]*ext[1]*ext[2];)
3176          }          }
3177      }      }
3178
// cout << "\nResulting matrix:\n";
//     for (size_t z=0;z<(internal[2]);++z)
//     {
//  for (size_t y=0;y<(internal[1]);++y)
//  {
//      for (size_t x=0;x<(internal[0]);++x)
//      {
//      cout << dv[x+y*(internal[0])+z*internal[0]*internal[1]] << " ";
//      }
//      cout << endl;
//  }
//  cout << endl;
//     }

3179      delete[] convolution;      delete[] convolution;
3180      delete[] src;      delete[] src;
3181      return resdat;      return resdat;

Legend:
 Removed from v.4703 changed lines Added in v.4705