1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-14 01:35:36 +00:00

Checking for integer divisions in cartesian full

This commit is contained in:
Guido Cossu 2017-08-08 10:31:12 +01:00
parent 06e6f8de00
commit 44051aecd1

View File

@ -63,8 +63,7 @@ public:
} }
GridCartesian(const std::vector<int> &dimensions, GridCartesian(const std::vector<int> &dimensions,
const std::vector<int> &simd_layout, const std::vector<int> &simd_layout,
const std::vector<int> &processor_grid const std::vector<int> &processor_grid) : GridBase(processor_grid)
) : GridBase(processor_grid)
{ {
/////////////////////// ///////////////////////
// Grid information // Grid information
@ -84,28 +83,34 @@ public:
_fsites = _gsites = _osites = _isites = 1; _fsites = _gsites = _osites = _isites = 1;
for(int d=0;d<_ndimension;d++){ for (int d = 0; d < _ndimension; d++)
{
_fdimensions[d] = dimensions[d]; // Global dimensions _fdimensions[d] = dimensions[d]; // Global dimensions
_gdimensions[d] = _fdimensions[d]; // Global dimensions _gdimensions[d] = _fdimensions[d]; // Global dimensions
_simd_layout[d] = simd_layout[d]; _simd_layout[d] = simd_layout[d];
_fsites = _fsites * _fdimensions[d]; _fsites = _fsites * _fdimensions[d];
_gsites = _gsites * _gdimensions[d]; _gsites = _gsites * _gdimensions[d];
//FIXME check for exact division
// Use a reduced simd grid // Use a reduced simd grid
_ldimensions[d] = _gdimensions[d] / _processors[d]; //local dimensions _ldimensions[d] = _gdimensions[d] / _processors[d]; //local dimensions
assert(_ldimensions[d] * _processors[d] == _gdimensions[d]);
_rdimensions[d] = _ldimensions[d] / _simd_layout[d]; //overdecomposition _rdimensions[d] = _ldimensions[d] / _simd_layout[d]; //overdecomposition
assert(_rdimensions[d] * _simd_layout[d] == _ldimensions[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;
_osites *= _rdimensions[d]; _osites *= _rdimensions[d];
_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];
} }
@ -120,19 +125,18 @@ 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];
_slice_nblock[d] = nblock; _slice_nblock[d] = nblock;
block = block * _rdimensions[d]; block = block * _rdimensions[d];
} }
}; };
}; };
} }
#endif #endif