mirror of
https://github.com/paboyle/Grid.git
synced 2024-11-10 07:55:35 +00:00
Update organisation
This commit is contained in:
parent
fdb886fe1a
commit
0021b72da9
@ -1,7 +1,83 @@
|
|||||||
|
#ifndef GRID_CARTESIAN_H
|
||||||
|
#define GRID_CARTESIAN_H
|
||||||
|
|
||||||
#include "Grid.h"
|
#include "Grid.h"
|
||||||
#include "Grid_vComplexD.h"
|
|
||||||
|
|
||||||
namespace dpo{
|
namespace dpo{
|
||||||
|
|
||||||
|
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Grid Support. Following will go into Grid.h.
|
||||||
|
/////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Cartesian grids
|
||||||
|
// dpo::Grid
|
||||||
|
// dpo::GridCartesian
|
||||||
|
// dpo::GridCartesianRedBlack
|
||||||
|
|
||||||
|
class Grid {
|
||||||
|
public:
|
||||||
|
// Give Lattice access
|
||||||
|
template<class object> friend class Lattice;
|
||||||
|
|
||||||
|
|
||||||
|
//protected:
|
||||||
|
|
||||||
|
// Lattice wide random support. not yet fully implemented. Need seed strategy
|
||||||
|
// and one generator per site.
|
||||||
|
//std::default_random_engine generator;
|
||||||
|
// static std::mt19937 generator( 9 );
|
||||||
|
|
||||||
|
|
||||||
|
// Grid information.
|
||||||
|
unsigned long _ndimension;
|
||||||
|
std::vector<int> _layout; // Which dimensions get relayed out over simd lanes.
|
||||||
|
std::vector<int> _dimensions; // Dimensions of array
|
||||||
|
std::vector<int> _rdimensions;// Reduced dimensions with simd lane images removed
|
||||||
|
std::vector<int> _ostride; // Outer stride for each dimension
|
||||||
|
std::vector<int> _istride; // Inner stride i.e. within simd lane
|
||||||
|
int _osites; // _isites*_osites = product(dimensions).
|
||||||
|
int _isites;
|
||||||
|
|
||||||
|
// subslice information
|
||||||
|
std::vector<int> _slice_block;
|
||||||
|
std::vector<int> _slice_stride;
|
||||||
|
std::vector<int> _slice_nblock;
|
||||||
|
public:
|
||||||
|
|
||||||
|
// These routines are key. Subdivide the linearised cartesian index into
|
||||||
|
// "inner" index identifying which simd lane of object<vFcomplex> is associated with coord
|
||||||
|
// "outer" index identifying which element of _odata in class "Lattice" is associated with coord.
|
||||||
|
// Compared to, say, Blitz++ we simply need to store BOTH an inner stride and an outer
|
||||||
|
// stride per dimension. The cost of evaluating the indexing information is doubled for an n-dimensional
|
||||||
|
// coordinate. Note, however, for data parallel operations the "inner" indexing cost is not paid and all
|
||||||
|
// lanes are operated upon simultaneously.
|
||||||
|
|
||||||
|
inline int oIndexReduced(std::vector<int> &rcoor)
|
||||||
|
{
|
||||||
|
int idx=0;
|
||||||
|
for(int d=0;d<_ndimension;d++) idx+=_ostride[d]*rcoor[d];
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
virtual int oIndex(std::vector<int> &coor)
|
||||||
|
{
|
||||||
|
int idx=0;
|
||||||
|
for(int d=0;d<_ndimension;d++) idx+=_ostride[d]*(coor[d]%_rdimensions[d]);
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
inline int iIndex(std::vector<int> &rcoor)
|
||||||
|
{
|
||||||
|
int idx=0;
|
||||||
|
for(int d=0;d<_ndimension;d++) idx+=_istride[d]*(rcoor[d]/_rdimensions[d]);
|
||||||
|
return idx;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline int oSites(void) { return _osites; };
|
||||||
|
inline int iSites(void) { return _isites; };
|
||||||
|
virtual int CheckerBoard(std::vector<int> site)=0;
|
||||||
|
virtual int CheckerBoardDestination(int source_cb,int shift)=0;
|
||||||
|
virtual int CheckerBoardShift(int source_cb,int dim,int shift)=0;
|
||||||
|
};
|
||||||
|
|
||||||
class GridCartesian: public Grid {
|
class GridCartesian: public Grid {
|
||||||
public:
|
public:
|
||||||
virtual int CheckerBoard(std::vector<int> site){
|
virtual int CheckerBoard(std::vector<int> site){
|
||||||
@ -176,3 +252,4 @@ protected:
|
|||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user