mirror of
https://github.com/paboyle/Grid.git
synced 2025-04-11 22:50:45 +01:00
Precision change going in; useful for mixed precision algorithms for example.
This commit is contained in:
parent
28cd99882c
commit
ab89418658
@ -325,6 +325,41 @@ inline void blockPromote(const Lattice<iVector<CComplex,nbasis > > &coarseData,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Useful for precision conversion, or indeed anything where an operator= does a conversion on scalars.
|
||||||
|
// Simd layouts need not match since we use peek/poke Local
|
||||||
|
template<class vobj,class vvobj>
|
||||||
|
void localConvert(const Lattice<vobj> &in,Lattice<vvobj> &out)
|
||||||
|
{
|
||||||
|
typedef typename vobj::scalar_object sobj;
|
||||||
|
typedef typename vvobj::scalar_object ssobj;
|
||||||
|
|
||||||
|
sobj s;
|
||||||
|
ssobj ss;
|
||||||
|
|
||||||
|
GridBase *ig = in._grid;
|
||||||
|
GridBase *og = out._grid;
|
||||||
|
|
||||||
|
int ni = ig->_ndimension;
|
||||||
|
int no = og->_ndimension;
|
||||||
|
|
||||||
|
assert(ni == no);
|
||||||
|
|
||||||
|
for(int d=0;d<no;d++){
|
||||||
|
assert(ig->_processors[d] == og->_processors[d]);
|
||||||
|
assert(ig->_ldimensions[d] == og->_ldimensions[d]);
|
||||||
|
}
|
||||||
|
|
||||||
|
PARALLEL_FOR_LOOP
|
||||||
|
for(int idx=0;idx<ig->lSites();idx++){
|
||||||
|
std::vector<int> lcoor(ni);
|
||||||
|
ig->LocalIndexToLocalCoor(idx,lcoor);
|
||||||
|
peekLocalSite(s,in,lcoor);
|
||||||
|
ss=s;
|
||||||
|
pokeLocalSite(ss,out,lcoor);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
template<class vobj>
|
template<class vobj>
|
||||||
void InsertSlice(const Lattice<vobj> &lowDim,Lattice<vobj> & higherDim,int slice, int orthog)
|
void InsertSlice(const Lattice<vobj> &lowDim,Lattice<vobj> & higherDim,int slice, int orthog)
|
||||||
{
|
{
|
||||||
@ -351,12 +386,13 @@ void InsertSlice(const Lattice<vobj> &lowDim,Lattice<vobj> & higherDim,int slice
|
|||||||
}
|
}
|
||||||
|
|
||||||
// the above should guarantee that the operations are local
|
// the above should guarantee that the operations are local
|
||||||
std::vector<int> lcoor(nl);
|
PARALLEL_FOR_LOOP
|
||||||
std::vector<int> hcoor(nh);
|
|
||||||
hcoor[orthog] = slice;
|
|
||||||
for(int idx=0;idx<lg->lSites();idx++){
|
for(int idx=0;idx<lg->lSites();idx++){
|
||||||
|
std::vector<int> lcoor(nl);
|
||||||
|
std::vector<int> hcoor(nh);
|
||||||
lg->LocalIndexToLocalCoor(idx,lcoor);
|
lg->LocalIndexToLocalCoor(idx,lcoor);
|
||||||
dl=0;
|
dl=0;
|
||||||
|
hcoor[orthog] = slice;
|
||||||
for(int d=0;d<nh;d++){
|
for(int d=0;d<nh;d++){
|
||||||
if ( d!=orthog ) {
|
if ( d!=orthog ) {
|
||||||
hcoor[d]=lcoor[dl++];
|
hcoor[d]=lcoor[dl++];
|
||||||
@ -392,12 +428,13 @@ void ExtractSlice(Lattice<vobj> &lowDim,const Lattice<vobj> & higherDim,int slic
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// the above should guarantee that the operations are local
|
// the above should guarantee that the operations are local
|
||||||
std::vector<int> lcoor(nl);
|
PARALLEL_FOR_LOOP
|
||||||
std::vector<int> hcoor(nh);
|
|
||||||
hcoor[orthog] = slice;
|
|
||||||
for(int idx=0;idx<lg->lSites();idx++){
|
for(int idx=0;idx<lg->lSites();idx++){
|
||||||
|
std::vector<int> lcoor(nl);
|
||||||
|
std::vector<int> hcoor(nh);
|
||||||
lg->LocalIndexToLocalCoor(idx,lcoor);
|
lg->LocalIndexToLocalCoor(idx,lcoor);
|
||||||
dl=0;
|
dl=0;
|
||||||
|
hcoor[orthog] = slice;
|
||||||
for(int d=0;d<nh;d++){
|
for(int d=0;d<nh;d++){
|
||||||
if ( d!=orthog ) {
|
if ( d!=orthog ) {
|
||||||
hcoor[d]=lcoor[dl++];
|
hcoor[d]=lcoor[dl++];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user