From ac7d1f26ad48e944dda68ec50aee0ca6ae0a5f61 Mon Sep 17 00:00:00 2001 From: paboyle Date: Wed, 4 Nov 2015 03:19:16 -0800 Subject: [PATCH] Either blocking or lebesgue curve --- lib/stencil/Lebesgue.cc | 99 +++++++++++++++++++++++++++++++++++------ 1 file changed, 85 insertions(+), 14 deletions(-) diff --git a/lib/stencil/Lebesgue.cc b/lib/stencil/Lebesgue.cc index 977e3562..abc6ccb8 100644 --- a/lib/stencil/Lebesgue.cc +++ b/lib/stencil/Lebesgue.cc @@ -1,8 +1,10 @@ #include +#include namespace Grid { int LebesgueOrder::UseLebesgueOrder; +std::vector LebesgueOrder::Block({2,2,2,2}); LebesgueOrder::IndexInteger LebesgueOrder::alignup(IndexInteger n){ n--; // 1000 0011 --> 1000 0010 @@ -15,12 +17,79 @@ LebesgueOrder::IndexInteger LebesgueOrder::alignup(IndexInteger n){ return n; }; -LebesgueOrder::LebesgueOrder(GridBase *grid) +LebesgueOrder::LebesgueOrder(GridBase *_grid) +{ + grid = _grid; + if ( Block[0]==0) ZGraph(); + else CartesianBlocking(); +} + +void LebesgueOrder::CartesianBlocking(void) +{ + _LebesgueReorder.resize(0); + + std::cout << GridLogMessage << " CartesianBlocking "; + for(int d=0;d_ndimension; + + assert(ND==4); + assert(ND==Block.size()); + + std::vector dims(ND); + std::vector xo(ND,0); + std::vector xi(ND,0); + + for(IndexInteger mu=0;mu_rdimensions[mu]; + } + + IterateO(ND,ND-1,xo,xi,dims); +}; + +void LebesgueOrder::IterateO(int ND,int dim, + std::vector & xo, + std::vector & xi, + std::vector &dims) +{ + for(xo[dim]=0;xo[dim] 0 ) { + IterateO(ND,dim-1,xo,xi,dims); + } else { + IterateI(ND,ND-1,xo,xi,dims); + } + } +}; + +void LebesgueOrder::IterateI(int ND, + int dim, + std::vector & xo, + std::vector & xi, + std::vector &dims) +{ + std::vector x(ND); + for(xi[dim]=0;xi[dim] 0 ) { + IterateI(ND,dim-1,xo,xi,dims); + } else { + for(int d=0;dIndexFromCoor(x,index,grid->_rdimensions); + _LebesgueReorder.push_back(index); + } + } +} + +void LebesgueOrder::ZGraph(void) { _LebesgueReorder.resize(0); // Align up dimensions to power of two. const IndexInteger one=1; + IndexInteger ND = grid->_ndimension; std::vector dims(ND); std::vector adims(ND); @@ -36,17 +105,7 @@ LebesgueOrder::LebesgueOrder(GridBase *grid) // i) avoids recursion // ii) has loop lengths at most the width of a 32 bit word. int sitebit=0; - int split=2; - for(int mu=0;mu coor(4); + for(IndexInteger asite=0;asiteoCoorFromOindex (coor,_LebesgueReorder[asite]); + std::cout << " site "<" << _LebesgueReorder[asite]<< " = [" + << coor[0]<<"," + << coor[1]<<"," + << coor[2]<<"," + << coor[3]<<"]" + <