mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-25 13:15:55 +01:00
Added more asserts at grid creation time
This commit is contained in:
parent
44051aecd1
commit
8a3fe60a27
@ -161,16 +161,20 @@ public:
|
|||||||
|
|
||||||
_checker_dim_mask = checker_dim_mask;
|
_checker_dim_mask = checker_dim_mask;
|
||||||
|
|
||||||
for(int d=0;d<_ndimension;d++){
|
for (int d = 0; d < _ndimension; d++)
|
||||||
|
{
|
||||||
_fdimensions[d] = dimensions[d];
|
_fdimensions[d] = dimensions[d];
|
||||||
_gdimensions[d] = _fdimensions[d];
|
_gdimensions[d] = _fdimensions[d];
|
||||||
_fsites = _fsites * _fdimensions[d];
|
_fsites = _fsites * _fdimensions[d];
|
||||||
_gsites = _gsites * _gdimensions[d];
|
_gsites = _gsites * _gdimensions[d];
|
||||||
|
|
||||||
if (d==_checker_dim) {
|
if (d == _checker_dim)
|
||||||
|
{
|
||||||
|
assert((_gdimensions[d] & 0x1) == 0);
|
||||||
_gdimensions[d] = _gdimensions[d] / 2; // Remove a checkerboard
|
_gdimensions[d] = _gdimensions[d] / 2; // Remove a checkerboard
|
||||||
}
|
}
|
||||||
_ldimensions[d] = _gdimensions[d] / _processors[d];
|
_ldimensions[d] = _gdimensions[d] / _processors[d];
|
||||||
|
assert(_ldimensions[d] * _processors[d] == _gdimensions[d]);
|
||||||
_lstart[d] = _processor_coor[d] * _ldimensions[d];
|
_lstart[d] = _processor_coor[d] * _ldimensions[d];
|
||||||
_lend[d] = _processor_coor[d] * _ldimensions[d] + _ldimensions[d] - 1;
|
_lend[d] = _processor_coor[d] * _ldimensions[d] + _ldimensions[d] - 1;
|
||||||
|
|
||||||
@ -182,8 +186,10 @@ public:
|
|||||||
|
|
||||||
// all elements of a simd vector must have same checkerboard.
|
// all elements of a simd vector must have same checkerboard.
|
||||||
// If Ls vectorised, this must still be the case; e.g. dwf rb5d
|
// If Ls vectorised, this must still be the case; e.g. dwf rb5d
|
||||||
if ( _simd_layout[d]>1 ) {
|
if (_simd_layout[d] > 1)
|
||||||
if ( checker_dim_mask[d] ) {
|
{
|
||||||
|
if (checker_dim_mask[d])
|
||||||
|
{
|
||||||
assert((_rdimensions[d] & 0x1) == 0);
|
assert((_rdimensions[d] & 0x1) == 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -192,15 +198,16 @@ public:
|
|||||||
_isites *= _simd_layout[d];
|
_isites *= _simd_layout[d];
|
||||||
|
|
||||||
// Addressing support
|
// Addressing support
|
||||||
if ( d==0 ) {
|
if (d == 0)
|
||||||
|
{
|
||||||
_ostride[d] = 1;
|
_ostride[d] = 1;
|
||||||
_istride[d] = 1;
|
_istride[d] = 1;
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
_ostride[d] = _ostride[d - 1] * _rdimensions[d - 1];
|
_ostride[d] = _ostride[d - 1] * _rdimensions[d - 1];
|
||||||
_istride[d] = _istride[d - 1] * _simd_layout[d - 1];
|
_istride[d] = _istride[d - 1] * _simd_layout[d - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -212,9 +219,11 @@ public:
|
|||||||
|
|
||||||
int block = 1;
|
int block = 1;
|
||||||
int nblock = 1;
|
int nblock = 1;
|
||||||
for(int d=0;d<_ndimension;d++) nblock*=_rdimensions[d];
|
for (int d = 0; d < _ndimension; d++)
|
||||||
|
nblock *= _rdimensions[d];
|
||||||
|
|
||||||
for(int d=0;d<_ndimension;d++){
|
for (int d = 0; d < _ndimension; d++)
|
||||||
|
{
|
||||||
nblock /= _rdimensions[d];
|
nblock /= _rdimensions[d];
|
||||||
_slice_block[d] = block;
|
_slice_block[d] = block;
|
||||||
_slice_stride[d] = _ostride[d] * _rdimensions[d];
|
_slice_stride[d] = _ostride[d] * _rdimensions[d];
|
||||||
@ -226,23 +235,29 @@ public:
|
|||||||
// Create a checkerboard lookup table
|
// Create a checkerboard lookup table
|
||||||
////////////////////////////////////////////////
|
////////////////////////////////////////////////
|
||||||
int rvol = 1;
|
int rvol = 1;
|
||||||
for(int d=0;d<_ndimension;d++){
|
for (int d = 0; d < _ndimension; d++)
|
||||||
|
{
|
||||||
rvol = rvol * _rdimensions[d];
|
rvol = rvol * _rdimensions[d];
|
||||||
}
|
}
|
||||||
_checker_board.resize(rvol);
|
_checker_board.resize(rvol);
|
||||||
for(int osite=0;osite<_osites;osite++){
|
for (int osite = 0; osite < _osites; osite++)
|
||||||
|
{
|
||||||
_checker_board[osite] = CheckerBoardFromOindex(osite);
|
_checker_board[osite] = CheckerBoardFromOindex(osite);
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual int oIndex(std::vector<int> &coor)
|
virtual int oIndex(std::vector<int> &coor)
|
||||||
{
|
{
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for(int d=0;d<_ndimension;d++) {
|
for (int d = 0; d < _ndimension; d++)
|
||||||
if( d==_checker_dim ) {
|
{
|
||||||
|
if (d == _checker_dim)
|
||||||
|
{
|
||||||
idx += _ostride[d] * ((coor[d] / 2) % _rdimensions[d]);
|
idx += _ostride[d] * ((coor[d] / 2) % _rdimensions[d]);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
idx += _ostride[d] * (coor[d] % _rdimensions[d]);
|
idx += _ostride[d] * (coor[d] % _rdimensions[d]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -252,16 +267,19 @@ protected:
|
|||||||
virtual int iIndex(std::vector<int> &lcoor)
|
virtual int iIndex(std::vector<int> &lcoor)
|
||||||
{
|
{
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
for(int d=0;d<_ndimension;d++) {
|
for (int d = 0; d < _ndimension; d++)
|
||||||
if( d==_checker_dim ) {
|
{
|
||||||
|
if (d == _checker_dim)
|
||||||
|
{
|
||||||
idx += _istride[d] * (lcoor[d] / (2 * _rdimensions[d]));
|
idx += _istride[d] * (lcoor[d] / (2 * _rdimensions[d]));
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
idx += _istride[d] * (lcoor[d] / _rdimensions[d]);
|
idx += _istride[d] * (lcoor[d] / _rdimensions[d]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return idx;
|
return idx;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
x
Reference in New Issue
Block a user