2016-01-02 14:51:32 +00:00
|
|
|
/*************************************************************************************
|
|
|
|
|
|
|
|
Grid physics library, www.github.com/paboyle/Grid
|
|
|
|
|
|
|
|
Source file: ./lib/cshift/Cshift_common.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-03 04:52:53 +01:00
|
|
|
#ifndef _GRID_CSHIFT_COMMON_H_
|
|
|
|
#define _GRID_CSHIFT_COMMON_H_
|
|
|
|
|
2015-04-18 20:44:19 +01:00
|
|
|
namespace Grid {
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2015-04-28 08:11:59 +01:00
|
|
|
template<class vobj>
|
|
|
|
class SimpleCompressor {
|
|
|
|
public:
|
|
|
|
void Point(int) {};
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2016-02-18 00:16:45 +00:00
|
|
|
vobj operator() (const vobj &arg) {
|
2015-04-28 08:11:59 +01:00
|
|
|
return arg;
|
|
|
|
}
|
|
|
|
};
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2015-04-28 08:11:59 +01:00
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// Gather for when there is no need to SIMD split with compression
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
template<class vobj,class cobj,class compressor> void
|
2016-01-10 19:20:16 +00:00
|
|
|
Gather_plane_simple (const Lattice<vobj> &rhs,std::vector<cobj,alignedAllocator<cobj> > &buffer,int dimension,int plane,int cbmask,compressor &compress, int off=0)
|
2015-04-28 08:11:59 +01:00
|
|
|
{
|
|
|
|
int rd = rhs._grid->_rdimensions[dimension];
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2015-04-28 08:11:59 +01:00
|
|
|
if ( !rhs._grid->CheckerBoarded(dimension) ) {
|
|
|
|
cbmask = 0x3;
|
|
|
|
}
|
2015-08-11 06:22:20 +01:00
|
|
|
|
2015-04-28 08:11:59 +01:00
|
|
|
int so = plane*rhs._grid->_ostride[dimension]; // base offset for start of plane
|
|
|
|
|
2015-05-28 13:47:01 +01:00
|
|
|
int e1=rhs._grid->_slice_nblock[dimension];
|
|
|
|
int e2=rhs._grid->_slice_block[dimension];
|
2016-02-18 22:33:58 +00:00
|
|
|
int stride=rhs._grid->_slice_stride[dimension];
|
2015-11-06 11:23:23 +00:00
|
|
|
if ( cbmask == 0x3 ) {
|
|
|
|
PARALLEL_NESTED_LOOP2
|
|
|
|
for(int n=0;n<e1;n++){
|
|
|
|
for(int b=0;b<e2;b++){
|
2016-02-18 22:33:58 +00:00
|
|
|
int o = n*stride;
|
|
|
|
int bo = n*e2;
|
2016-02-18 00:16:45 +00:00
|
|
|
buffer[off+bo+b]=compress(rhs._odata[so+o+b]);
|
2015-04-03 04:52:53 +01:00
|
|
|
}
|
|
|
|
}
|
2015-11-06 11:23:23 +00:00
|
|
|
} else {
|
|
|
|
int bo=0;
|
|
|
|
for(int n=0;n<e1;n++){
|
|
|
|
for(int b=0;b<e2;b++){
|
2016-02-18 22:33:58 +00:00
|
|
|
int o = n*stride;
|
2015-11-06 11:23:23 +00:00
|
|
|
int ocb=1<<rhs._grid->CheckerBoardFromOindex(o+b);// Could easily be a table lookup
|
|
|
|
if ( ocb &cbmask ) {
|
2016-02-18 00:16:45 +00:00
|
|
|
buffer[off+bo++]=compress(rhs._odata[so+o+b]);
|
2015-11-06 11:23:23 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-03 04:52:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-28 08:11:59 +01:00
|
|
|
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
// Gather for when there *is* need to SIMD split with compression
|
|
|
|
///////////////////////////////////////////////////////////////////
|
|
|
|
template<class cobj,class vobj,class compressor> void
|
|
|
|
Gather_plane_extract(const Lattice<vobj> &rhs,std::vector<typename cobj::scalar_object *> pointers,int dimension,int plane,int cbmask,compressor &compress)
|
2015-04-03 04:52:53 +01:00
|
|
|
{
|
|
|
|
int rd = rhs._grid->_rdimensions[dimension];
|
|
|
|
|
|
|
|
if ( !rhs._grid->CheckerBoarded(dimension) ) {
|
2015-04-28 08:11:59 +01:00
|
|
|
cbmask = 0x3;
|
|
|
|
}
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2015-04-28 08:11:59 +01:00
|
|
|
int so = plane*rhs._grid->_ostride[dimension]; // base offset for start of plane
|
2015-05-28 13:47:01 +01:00
|
|
|
|
|
|
|
int e1=rhs._grid->_slice_nblock[dimension];
|
|
|
|
int e2=rhs._grid->_slice_block[dimension];
|
2016-02-18 00:16:45 +00:00
|
|
|
int n1=rhs._grid->_slice_stride[dimension];
|
|
|
|
int n2=rhs._grid->_slice_block[dimension];
|
2015-11-06 11:23:23 +00:00
|
|
|
if ( cbmask ==0x3){
|
|
|
|
PARALLEL_NESTED_LOOP2
|
|
|
|
for(int n=0;n<e1;n++){
|
|
|
|
for(int b=0;b<e2;b++){
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2016-02-18 00:16:45 +00:00
|
|
|
int o = n*n1;
|
|
|
|
int offset = b+n*n2;
|
|
|
|
cobj temp =compress(rhs._odata[so+o+b]);
|
2015-04-28 08:11:59 +01:00
|
|
|
extract<cobj>(temp,pointers,offset);
|
2015-11-06 11:23:23 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
assert(0); //Fixme think this is buggy
|
|
|
|
for(int n=0;n<e1;n++){
|
|
|
|
for(int b=0;b<e2;b++){
|
|
|
|
int o=n*rhs._grid->_slice_stride[dimension];
|
|
|
|
int ocb=1<<rhs._grid->CheckerBoardFromOindex(o+b);
|
|
|
|
int offset = b+n*rhs._grid->_slice_block[dimension];
|
|
|
|
|
|
|
|
if ( ocb & cbmask ) {
|
2016-02-18 00:16:45 +00:00
|
|
|
cobj temp =compress(rhs._odata[so+o+b]);
|
2015-11-06 11:23:23 +00:00
|
|
|
extract<cobj>(temp,pointers,offset);
|
|
|
|
}
|
2015-04-03 04:52:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-04-28 08:11:59 +01:00
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// Gather for when there is no need to SIMD split
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
template<class vobj> void Gather_plane_simple (const Lattice<vobj> &rhs,std::vector<vobj,alignedAllocator<vobj> > &buffer, int dimension,int plane,int cbmask)
|
|
|
|
{
|
|
|
|
SimpleCompressor<vobj> dontcompress;
|
|
|
|
Gather_plane_simple (rhs,buffer,dimension,plane,cbmask,dontcompress);
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// Gather for when there *is* need to SIMD split
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
template<class vobj> void Gather_plane_extract(const Lattice<vobj> &rhs,std::vector<typename vobj::scalar_object *> pointers,int dimension,int plane,int cbmask)
|
|
|
|
{
|
|
|
|
SimpleCompressor<vobj> dontcompress;
|
|
|
|
Gather_plane_extract<vobj,vobj,decltype(dontcompress)>(rhs,pointers,dimension,plane,cbmask,dontcompress);
|
|
|
|
}
|
|
|
|
|
2015-04-03 04:52:53 +01:00
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// Scatter for when there is no need to SIMD split
|
|
|
|
//////////////////////////////////////////////////////
|
2015-04-28 08:11:59 +01:00
|
|
|
template<class vobj> void Scatter_plane_simple (Lattice<vobj> &rhs,std::vector<vobj,alignedAllocator<vobj> > &buffer, int dimension,int plane,int cbmask)
|
2015-04-03 04:52:53 +01:00
|
|
|
{
|
|
|
|
int rd = rhs._grid->_rdimensions[dimension];
|
|
|
|
|
|
|
|
if ( !rhs._grid->CheckerBoarded(dimension) ) {
|
2015-04-28 08:11:59 +01:00
|
|
|
cbmask=0x3;
|
|
|
|
}
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2015-04-28 08:11:59 +01:00
|
|
|
int so = plane*rhs._grid->_ostride[dimension]; // base offset for start of plane
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2015-05-28 13:47:01 +01:00
|
|
|
int e1=rhs._grid->_slice_nblock[dimension];
|
|
|
|
int e2=rhs._grid->_slice_block[dimension];
|
2015-11-06 11:23:23 +00:00
|
|
|
|
|
|
|
if ( cbmask ==0x3 ) {
|
|
|
|
PARALLEL_NESTED_LOOP2
|
|
|
|
for(int n=0;n<e1;n++){
|
|
|
|
for(int b=0;b<e2;b++){
|
|
|
|
int o =n*rhs._grid->_slice_stride[dimension];
|
|
|
|
int bo =n*rhs._grid->_slice_block[dimension];
|
|
|
|
rhs._odata[so+o+b]=buffer[bo+b];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
int bo=0;
|
|
|
|
for(int n=0;n<e1;n++){
|
|
|
|
for(int b=0;b<e2;b++){
|
|
|
|
int o =n*rhs._grid->_slice_stride[dimension];
|
|
|
|
int bo =n*rhs._grid->_slice_block[dimension];
|
|
|
|
int ocb=1<<rhs._grid->CheckerBoardFromOindex(o+b);// Could easily be a table lookup
|
|
|
|
if ( ocb & cbmask ) {
|
|
|
|
rhs._odata[so+o+b]=buffer[bo++];
|
|
|
|
}
|
2015-04-03 04:52:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// Scatter for when there *is* need to SIMD split
|
|
|
|
//////////////////////////////////////////////////////
|
2015-04-28 08:11:59 +01:00
|
|
|
template<class vobj,class cobj> void Scatter_plane_merge(Lattice<vobj> &rhs,std::vector<cobj *> pointers,int dimension,int plane,int cbmask)
|
2015-04-03 04:52:53 +01:00
|
|
|
{
|
|
|
|
int rd = rhs._grid->_rdimensions[dimension];
|
|
|
|
|
|
|
|
if ( !rhs._grid->CheckerBoarded(dimension) ) {
|
2015-04-28 08:11:59 +01:00
|
|
|
cbmask=0x3;
|
|
|
|
}
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2015-04-28 08:11:59 +01:00
|
|
|
int so = plane*rhs._grid->_ostride[dimension]; // base offset for start of plane
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2015-05-28 13:47:01 +01:00
|
|
|
int e1=rhs._grid->_slice_nblock[dimension];
|
|
|
|
int e2=rhs._grid->_slice_block[dimension];
|
2015-11-06 11:23:23 +00:00
|
|
|
|
|
|
|
if(cbmask ==0x3 ) {
|
2015-05-13 00:31:00 +01:00
|
|
|
PARALLEL_NESTED_LOOP2
|
2015-11-06 11:23:23 +00:00
|
|
|
for(int n=0;n<e1;n++){
|
|
|
|
for(int b=0;b<e2;b++){
|
|
|
|
int o = n*rhs._grid->_slice_stride[dimension];
|
|
|
|
int offset = b+n*rhs._grid->_slice_block[dimension];
|
2015-04-28 08:11:59 +01:00
|
|
|
merge(rhs._odata[so+o+b],pointers,offset);
|
2015-04-03 04:52:53 +01:00
|
|
|
}
|
|
|
|
}
|
2015-11-06 11:23:23 +00:00
|
|
|
} else {
|
|
|
|
assert(0); // think this is buggy FIXME
|
|
|
|
for(int n=0;n<e1;n++){
|
|
|
|
for(int b=0;b<e2;b++){
|
|
|
|
int o = n*rhs._grid->_slice_stride[dimension];
|
|
|
|
int offset = b+n*rhs._grid->_slice_block[dimension];
|
|
|
|
int ocb=1<<rhs._grid->CheckerBoardFromOindex(o+b);
|
|
|
|
if ( ocb&cbmask ) {
|
|
|
|
merge(rhs._odata[so+o+b],pointers,offset);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-04-03 04:52:53 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// local to node block strided copies
|
|
|
|
//////////////////////////////////////////////////////
|
2015-06-01 12:25:59 +01:00
|
|
|
template<class vobj> void Copy_plane(Lattice<vobj>& lhs,const Lattice<vobj> &rhs, int dimension,int lplane,int rplane,int cbmask)
|
2015-04-03 04:52:53 +01:00
|
|
|
{
|
|
|
|
int rd = rhs._grid->_rdimensions[dimension];
|
|
|
|
|
|
|
|
if ( !rhs._grid->CheckerBoarded(dimension) ) {
|
2015-04-28 08:11:59 +01:00
|
|
|
cbmask=0x3;
|
|
|
|
}
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2015-04-28 08:11:59 +01:00
|
|
|
int ro = rplane*rhs._grid->_ostride[dimension]; // base offset for start of plane
|
|
|
|
int lo = lplane*lhs._grid->_ostride[dimension]; // base offset for start of plane
|
2015-05-28 13:47:01 +01:00
|
|
|
|
|
|
|
int e1=rhs._grid->_slice_nblock[dimension]; // clearly loop invariant for icpc
|
|
|
|
int e2=rhs._grid->_slice_block[dimension];
|
2016-02-18 22:33:58 +00:00
|
|
|
int stride = rhs._grid->_slice_stride[dimension];
|
2015-11-06 11:23:23 +00:00
|
|
|
if(cbmask == 0x3 ){
|
2015-05-13 00:31:00 +01:00
|
|
|
PARALLEL_NESTED_LOOP2
|
2015-11-06 11:23:23 +00:00
|
|
|
for(int n=0;n<e1;n++){
|
|
|
|
for(int b=0;b<e2;b++){
|
2015-05-27 02:34:56 +01:00
|
|
|
|
2016-02-18 22:33:58 +00:00
|
|
|
int o =n*stride+b;
|
2015-11-06 11:23:23 +00:00
|
|
|
//lhs._odata[lo+o]=rhs._odata[ro+o];
|
2015-05-26 04:02:54 +01:00
|
|
|
vstream(lhs._odata[lo+o],rhs._odata[ro+o]);
|
|
|
|
}
|
2015-11-06 11:23:23 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
PARALLEL_NESTED_LOOP2
|
|
|
|
for(int n=0;n<e1;n++){
|
|
|
|
for(int b=0;b<e2;b++){
|
|
|
|
|
2016-02-18 22:33:58 +00:00
|
|
|
int o =n*stride+b;
|
2015-11-06 11:23:23 +00:00
|
|
|
int ocb=1<<lhs._grid->CheckerBoardFromOindex(o);
|
|
|
|
if ( ocb&cbmask ) {
|
|
|
|
//lhs._odata[lo+o]=rhs._odata[ro+o];
|
|
|
|
vstream(lhs._odata[lo+o],rhs._odata[ro+o]);
|
|
|
|
}
|
|
|
|
}
|
2015-04-03 04:52:53 +01:00
|
|
|
}
|
|
|
|
}
|
2015-05-22 09:33:15 +01:00
|
|
|
|
2015-04-03 04:52:53 +01:00
|
|
|
}
|
|
|
|
|
2015-06-01 12:25:59 +01:00
|
|
|
template<class vobj> void Copy_plane_permute(Lattice<vobj>& lhs,const Lattice<vobj> &rhs, int dimension,int lplane,int rplane,int cbmask,int permute_type)
|
2015-04-03 04:52:53 +01:00
|
|
|
{
|
2015-05-22 09:33:15 +01:00
|
|
|
|
2015-04-03 04:52:53 +01:00
|
|
|
int rd = rhs._grid->_rdimensions[dimension];
|
|
|
|
|
|
|
|
if ( !rhs._grid->CheckerBoarded(dimension) ) {
|
2015-04-28 08:11:59 +01:00
|
|
|
cbmask=0x3;
|
|
|
|
}
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2015-04-28 08:11:59 +01:00
|
|
|
int ro = rplane*rhs._grid->_ostride[dimension]; // base offset for start of plane
|
|
|
|
int lo = lplane*lhs._grid->_ostride[dimension]; // base offset for start of plane
|
2015-05-28 13:47:01 +01:00
|
|
|
|
|
|
|
int e1=rhs._grid->_slice_nblock[dimension];
|
|
|
|
int e2=rhs._grid->_slice_block [dimension];
|
2016-02-18 22:33:58 +00:00
|
|
|
int stride = rhs._grid->_slice_stride[dimension];
|
2015-05-13 00:31:00 +01:00
|
|
|
PARALLEL_NESTED_LOOP2
|
2015-05-28 13:47:01 +01:00
|
|
|
for(int n=0;n<e1;n++){
|
|
|
|
for(int b=0;b<e2;b++){
|
2015-05-15 11:36:22 +01:00
|
|
|
|
2016-02-18 22:33:58 +00:00
|
|
|
int o =n*stride;
|
2015-04-28 08:11:59 +01:00
|
|
|
int ocb=1<<lhs._grid->CheckerBoardFromOindex(o+b);
|
|
|
|
if ( ocb&cbmask ) {
|
2015-04-03 04:52:53 +01:00
|
|
|
permute(lhs._odata[lo+o+b],rhs._odata[ro+o+b],permute_type);
|
|
|
|
}
|
2015-05-15 11:36:22 +01:00
|
|
|
|
|
|
|
}}
|
2015-04-03 04:52:53 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//////////////////////////////////////////////////////
|
|
|
|
// Local to node Cshift
|
|
|
|
//////////////////////////////////////////////////////
|
2015-06-01 12:25:59 +01:00
|
|
|
template<class vobj> void Cshift_local(Lattice<vobj>& ret,const Lattice<vobj> &rhs,int dimension,int shift)
|
2015-04-03 04:52:53 +01:00
|
|
|
{
|
|
|
|
int sshift[2];
|
|
|
|
|
2015-05-31 15:09:02 +01:00
|
|
|
sshift[0] = rhs._grid->CheckerBoardShiftForCB(rhs.checkerboard,dimension,shift,Even);
|
|
|
|
sshift[1] = rhs._grid->CheckerBoardShiftForCB(rhs.checkerboard,dimension,shift,Odd);
|
2015-04-03 04:52:53 +01:00
|
|
|
|
|
|
|
if ( sshift[0] == sshift[1] ) {
|
|
|
|
Cshift_local(ret,rhs,dimension,shift,0x3);
|
|
|
|
} else {
|
|
|
|
Cshift_local(ret,rhs,dimension,shift,0x1);// if checkerboard is unfavourable take two passes
|
|
|
|
Cshift_local(ret,rhs,dimension,shift,0x2);// both with block stride loop iteration
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-06-01 12:25:59 +01:00
|
|
|
template<class vobj> Lattice<vobj> Cshift_local(Lattice<vobj> &ret,const Lattice<vobj> &rhs,int dimension,int shift,int cbmask)
|
2015-04-03 04:52:53 +01:00
|
|
|
{
|
2015-04-06 11:26:24 +01:00
|
|
|
GridBase *grid = rhs._grid;
|
|
|
|
int fd = grid->_fdimensions[dimension];
|
|
|
|
int rd = grid->_rdimensions[dimension];
|
|
|
|
int ld = grid->_ldimensions[dimension];
|
|
|
|
int gd = grid->_gdimensions[dimension];
|
2016-04-19 23:35:15 +01:00
|
|
|
int ly = grid->_simd_layout[dimension];
|
2015-04-03 04:52:53 +01:00
|
|
|
|
|
|
|
// Map to always positive shift modulo global full dimension.
|
|
|
|
shift = (shift+fd)%fd;
|
|
|
|
|
2015-05-31 15:09:02 +01:00
|
|
|
ret.checkerboard = grid->CheckerBoardDestination(rhs.checkerboard,shift,dimension);
|
2015-04-03 04:52:53 +01:00
|
|
|
// the permute type
|
2015-04-06 11:26:24 +01:00
|
|
|
int permute_dim =grid->PermuteDim(dimension);
|
|
|
|
int permute_type=grid->PermuteType(dimension);
|
2016-04-19 23:35:15 +01:00
|
|
|
int permute_type_dist;
|
2015-04-03 04:52:53 +01:00
|
|
|
|
|
|
|
for(int x=0;x<rd;x++){
|
|
|
|
|
|
|
|
int o = 0;
|
2015-04-06 11:26:24 +01:00
|
|
|
int bo = x * grid->_ostride[dimension];
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2015-05-31 15:09:02 +01:00
|
|
|
int cb= (cbmask==0x2)? Odd : Even;
|
2015-04-03 04:52:53 +01:00
|
|
|
|
2015-05-31 15:09:02 +01:00
|
|
|
int sshift = grid->CheckerBoardShiftForCB(rhs.checkerboard,dimension,shift,cb);
|
2015-04-03 04:52:53 +01:00
|
|
|
int sx = (x+sshift)%rd;
|
2015-05-31 15:09:02 +01:00
|
|
|
|
2016-04-19 23:35:15 +01:00
|
|
|
// FIXME : This must change where we have a
|
|
|
|
// Rotate slice.
|
|
|
|
|
|
|
|
// Document how this works ; why didn't I do this when I first wrote it...
|
|
|
|
// wrap is whether sshift > rd.
|
|
|
|
// num is sshift mod rd.
|
|
|
|
//
|
2015-04-03 04:52:53 +01:00
|
|
|
int permute_slice=0;
|
|
|
|
if(permute_dim){
|
|
|
|
int wrap = sshift/rd;
|
|
|
|
int num = sshift%rd;
|
2016-04-19 23:35:15 +01:00
|
|
|
|
2015-04-03 04:52:53 +01:00
|
|
|
if ( x< rd-num ) permute_slice=wrap;
|
2016-04-19 23:35:15 +01:00
|
|
|
else permute_slice = (wrap+1)%ly;
|
|
|
|
|
|
|
|
if ( (ly>2) && (permute_slice) ) {
|
|
|
|
assert(permute_type & RotateBit);
|
|
|
|
permute_type_dist = permute_type|permute_slice;
|
|
|
|
} else {
|
|
|
|
permute_type_dist = permute_type;
|
|
|
|
}
|
|
|
|
|
2015-04-03 04:52:53 +01:00
|
|
|
}
|
|
|
|
|
2016-04-19 23:35:15 +01:00
|
|
|
if ( permute_slice ) Copy_plane_permute(ret,rhs,dimension,x,sx,cbmask,permute_type_dist);
|
2015-04-03 04:52:53 +01:00
|
|
|
else Copy_plane(ret,rhs,dimension,x,sx,cbmask);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
2015-04-18 20:44:19 +01:00
|
|
|
}
|
2015-04-03 04:52:53 +01:00
|
|
|
#endif
|