2016-01-02 14:51:32 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
|
|
|
Source file: ./lib/cartesian/Cartesian_full.h
|
|
|
|
|
|
|
|
Copyright (C) 2015
|
|
|
|
|
|
|
|
Author: Peter Boyle <paboyle@ph.ed.ac.uk>
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
|
|
it under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
|
|
(at your option) any later version.
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
GNU General Public License for more details.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License along
|
|
|
|
with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
|
|
|
|
See the full license in the file "LICENSE" in the top level distribution directory
|
|
|
|
*************************************************************************************/
|
|
|
|
/* END LEGAL */
|
2015-04-18 18:36:48 +01:00
|
|
|
#ifndef GRID_CARTESIAN_FULL_H
|
|
|
|
#define GRID_CARTESIAN_FULL_H
|
|
|
|
|
|
|
|
namespace Grid{
|
|
|
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Grid Support.
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
|
|
class GridCartesian: public GridBase {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2016-10-11 22:21:07 +01:00
|
|
|
virtual int CheckerBoardFromOindexTable (int Oindex) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
virtual int CheckerBoardFromOindex (int Oindex)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2015-04-18 18:36:48 +01:00
|
|
|
virtual int CheckerBoarded(int dim){
|
|
|
|
return 0;
|
|
|
|
}
|
2017-02-20 21:49:06 +00:00
|
|
|
virtual int CheckerBoard(const std::vector<int> &site){
|
2015-04-18 18:36:48 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2015-05-31 15:09:02 +01:00
|
|
|
virtual int CheckerBoardDestination(int cb,int shift,int dim){
|
2015-04-18 18:36:48 +01:00
|
|
|
return 0;
|
|
|
|
}
|
2015-05-31 15:09:02 +01:00
|
|
|
virtual int CheckerBoardShiftForCB(int source_cb,int dim,int shift, int ocb){
|
|
|
|
return shift;
|
|
|
|
}
|
2015-04-18 18:36:48 +01:00
|
|
|
virtual int CheckerBoardShift(int source_cb,int dim,int shift, int osite){
|
2015-05-31 15:09:02 +01:00
|
|
|
return shift;
|
2015-04-18 18:36:48 +01:00
|
|
|
}
|
2017-06-22 08:14:34 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
// Constructor takes a parent grid and possibly subdivides communicator.
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
2015-06-02 16:57:12 +01:00
|
|
|
GridCartesian(const std::vector<int> &dimensions,
|
|
|
|
const std::vector<int> &simd_layout,
|
2017-06-22 08:14:34 +01:00
|
|
|
const std::vector<int> &processor_grid,
|
|
|
|
GridCartesian &parent) : GridBase(processor_grid,parent)
|
|
|
|
{
|
|
|
|
Init(dimensions,simd_layout,processor_grid);
|
|
|
|
}
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
// Construct from comm world
|
|
|
|
/////////////////////////////////////////////////////////////////////////
|
|
|
|
GridCartesian(const std::vector<int> &dimensions,
|
|
|
|
const std::vector<int> &simd_layout,
|
|
|
|
const std::vector<int> &processor_grid) : GridBase(processor_grid)
|
|
|
|
{
|
|
|
|
Init(dimensions,simd_layout,processor_grid);
|
|
|
|
}
|
|
|
|
|
|
|
|
void Init(const std::vector<int> &dimensions,
|
|
|
|
const std::vector<int> &simd_layout,
|
|
|
|
const std::vector<int> &processor_grid)
|
2015-04-18 18:36:48 +01:00
|
|
|
{
|
|
|
|
///////////////////////
|
|
|
|
// Grid information
|
|
|
|
///////////////////////
|
|
|
|
_ndimension = dimensions.size();
|
|
|
|
|
|
|
|
_fdimensions.resize(_ndimension);
|
|
|
|
_gdimensions.resize(_ndimension);
|
|
|
|
_ldimensions.resize(_ndimension);
|
|
|
|
_rdimensions.resize(_ndimension);
|
|
|
|
_simd_layout.resize(_ndimension);
|
2017-06-11 23:14:10 +01:00
|
|
|
_lstart.resize(_ndimension);
|
|
|
|
_lend.resize(_ndimension);
|
2015-04-18 18:36:48 +01:00
|
|
|
|
|
|
|
_ostride.resize(_ndimension);
|
|
|
|
_istride.resize(_ndimension);
|
|
|
|
|
2015-04-19 14:55:58 +01:00
|
|
|
_fsites = _gsites = _osites = _isites = 1;
|
|
|
|
|
2015-04-18 18:36:48 +01:00
|
|
|
for(int d=0;d<_ndimension;d++){
|
|
|
|
_fdimensions[d] = dimensions[d]; // Global dimensions
|
|
|
|
_gdimensions[d] = _fdimensions[d]; // Global dimensions
|
|
|
|
_simd_layout[d] = simd_layout[d];
|
2015-04-19 14:55:58 +01:00
|
|
|
_fsites = _fsites * _fdimensions[d];
|
|
|
|
_gsites = _gsites * _gdimensions[d];
|
2015-04-18 18:36:48 +01:00
|
|
|
|
|
|
|
//FIXME check for exact division
|
|
|
|
|
|
|
|
// Use a reduced simd grid
|
|
|
|
_ldimensions[d]= _gdimensions[d]/_processors[d]; //local dimensions
|
|
|
|
_rdimensions[d]= _ldimensions[d]/_simd_layout[d]; //overdecomposition
|
2017-06-11 23:14:10 +01:00
|
|
|
_lstart[d] = _processor_coor[d]*_ldimensions[d];
|
|
|
|
_lend[d] = _processor_coor[d]*_ldimensions[d]+_ldimensions[d]-1;
|
|
|
|
_osites *= _rdimensions[d];
|
|
|
|
_isites *= _simd_layout[d];
|
2015-04-18 18:36:48 +01:00
|
|
|
|
|
|
|
// Addressing support
|
|
|
|
if ( d==0 ) {
|
|
|
|
_ostride[d] = 1;
|
|
|
|
_istride[d] = 1;
|
|
|
|
} else {
|
|
|
|
_ostride[d] = _ostride[d-1]*_rdimensions[d-1];
|
|
|
|
_istride[d] = _istride[d-1]*_simd_layout[d-1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
///////////////////////
|
|
|
|
// subplane information
|
|
|
|
///////////////////////
|
|
|
|
_slice_block.resize(_ndimension);
|
|
|
|
_slice_stride.resize(_ndimension);
|
|
|
|
_slice_nblock.resize(_ndimension);
|
|
|
|
|
|
|
|
int block =1;
|
|
|
|
int nblock=1;
|
|
|
|
for(int d=0;d<_ndimension;d++) nblock*=_rdimensions[d];
|
|
|
|
|
|
|
|
for(int d=0;d<_ndimension;d++){
|
|
|
|
nblock/=_rdimensions[d];
|
|
|
|
_slice_block[d] =block;
|
|
|
|
_slice_stride[d]=_ostride[d]*_rdimensions[d];
|
|
|
|
_slice_nblock[d]=nblock;
|
|
|
|
block = block*_rdimensions[d];
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|