1
0
mirror of https://github.com/paboyle/Grid.git synced 2024-11-10 07:55:35 +00:00

Coordinate handling gpu friendly

This commit is contained in:
paboyle 2018-02-24 22:22:02 +00:00
parent bf5fb89aff
commit 078901278c
11 changed files with 37 additions and 38 deletions

View File

@ -79,7 +79,7 @@ void CayleyFermion5D<Impl>::DminusDag(const FermionField &psi, FermionField &chi
template<class Impl> void CayleyFermion5D<Impl>::CayleyReport(void) template<class Impl> void CayleyFermion5D<Impl>::CayleyReport(void)
{ {
this->Report(); this->Report();
std::vector<int> latt = GridDefaultLatt(); Coordinate latt = GridDefaultLatt();
RealD volume = this->Ls; for(int mu=0;mu<Nd;mu++) volume=volume*latt[mu]; RealD volume = this->Ls; for(int mu=0;mu<Nd;mu++) volume=volume*latt[mu];
RealD NP = this->_FourDimGrid->_Nprocessors; RealD NP = this->_FourDimGrid->_Nprocessors;
if ( M5Dcalls > 0 ) { if ( M5Dcalls > 0 ) {

View File

@ -374,7 +374,7 @@ public:
} }
for (int lidx = 0; lidx < GaugeGrid->lSites(); lidx++) { for (int lidx = 0; lidx < GaugeGrid->lSites(); lidx++) {
std::vector<int> lcoor; Coordinate lcoor;
GaugeGrid->LocalIndexToLocalCoor(lidx, lcoor); GaugeGrid->LocalIndexToLocalCoor(lidx, lcoor);
peekLocalSite(ScalarUmu, Umu, lcoor); peekLocalSite(ScalarUmu, Umu, lcoor);
@ -514,13 +514,12 @@ public:
assert((distance == 1) || (distance == -1)); // nearest neighbour stencil hard code assert((distance == 1) || (distance == -1)); // nearest neighbour stencil hard code
assert((sl == 1) || (sl == 2)); assert((sl == 1) || (sl == 2));
std::vector<int> icoor; Coordinate icoor;
if ( SE->_around_the_world && Params.twists[mmu] ) { if ( SE->_around_the_world && Params.twists[mmu] ) {
if ( sl == 2 ) { if ( sl == 2 ) {
std::vector<sobj> vals(Nsimd); ExtractBuffer<sobj> vals(Nsimd);
extract(chi,vals); extract(chi,vals);
for(int s=0;s<Nsimd;s++){ for(int s=0;s<Nsimd;s++){
@ -905,7 +904,7 @@ public:
SiteScalarGaugeLink ScalarU; SiteScalarGaugeLink ScalarU;
SiteDoubledGaugeField ScalarUds; SiteDoubledGaugeField ScalarUds;
std::vector<int> lcoor; Coordinate lcoor;
GaugeGrid->LocalIndexToLocalCoor(lidx, lcoor); GaugeGrid->LocalIndexToLocalCoor(lidx, lcoor);
peekLocalSite(ScalarUds, Uds, lcoor); peekLocalSite(ScalarUds, Uds, lcoor);
@ -933,7 +932,7 @@ public:
SiteScalarGaugeLink ScalarU; SiteScalarGaugeLink ScalarU;
SiteDoubledGaugeField ScalarUds; SiteDoubledGaugeField ScalarUds;
std::vector<int> lcoor; Coordinate lcoor;
GaugeGrid->LocalIndexToLocalCoor(lidx, lcoor); GaugeGrid->LocalIndexToLocalCoor(lidx, lcoor);
peekLocalSite(ScalarUds, UUUds, lcoor); peekLocalSite(ScalarUds, UUUds, lcoor);

View File

@ -294,7 +294,7 @@ void ImprovedStaggeredFermion5D<Impl>::Dhop(const FermionField &in, FermionField
template<class Impl> template<class Impl>
void ImprovedStaggeredFermion5D<Impl>::Report(void) void ImprovedStaggeredFermion5D<Impl>::Report(void)
{ {
std::vector<int> latt = GridDefaultLatt(); Coordinate latt = GridDefaultLatt();
RealD volume = Ls; for(int mu=0;mu<Nd;mu++) volume=volume*latt[mu]; RealD volume = Ls; for(int mu=0;mu<Nd;mu++) volume=volume*latt[mu];
RealD NP = _FourDimGrid->_Nprocessors; RealD NP = _FourDimGrid->_Nprocessors;
RealD NN = _FourDimGrid->NodeCount(); RealD NN = _FourDimGrid->NodeCount();

View File

@ -150,7 +150,7 @@ void WilsonFermion<Impl>::MomentumSpacePropagator(FermionField &out, const Fermi
Gamma::Algebra::GammaT Gamma::Algebra::GammaT
}; };
std::vector<int> latt_size = _grid->_fdimensions; Coordinate latt_size = _grid->_fdimensions;
FermionField num (_grid); num = Zero(); FermionField num (_grid); num = Zero();
LatComplex wilson(_grid); wilson= Zero(); LatComplex wilson(_grid); wilson= Zero();

View File

@ -139,7 +139,7 @@ void WilsonFermion5D<Impl>::Report(void)
RealD NP = _FourDimGrid->_Nprocessors; RealD NP = _FourDimGrid->_Nprocessors;
RealD NN = _FourDimGrid->NodeCount(); RealD NN = _FourDimGrid->NodeCount();
RealD volume = Ls; RealD volume = Ls;
std::vector<int> latt = _FourDimGrid->GlobalDimensions(); Coordinate latt = _FourDimGrid->GlobalDimensions();
for(int mu=0;mu<Nd;mu++) volume=volume*latt[mu]; for(int mu=0;mu<Nd;mu++) volume=volume*latt[mu];
if ( DhopCalls > 0 ) { if ( DhopCalls > 0 ) {
@ -584,8 +584,7 @@ void WilsonFermion5D<Impl>::MomentumSpacePropagatorHt(FermionField &out,const Fe
Gamma::Algebra::GammaT Gamma::Algebra::GammaT
}; };
std::vector<int> latt_size = _grid->_fdimensions; Coordinate latt_size = _grid->FullDimensions();
FermionField num (_grid); num = Zero(); FermionField num (_grid); num = Zero();
@ -626,7 +625,7 @@ void WilsonFermion5D<Impl>::MomentumSpacePropagatorHt(FermionField &out,const Fe
// FIXME Need a Lattice acosh // FIXME Need a Lattice acosh
for(int idx=0;idx<_grid->lSites();idx++){ for(int idx=0;idx<_grid->lSites();idx++){
std::vector<int> lcoor(Nd); Coordinate lcoor(Nd);
Tcomplex cc; Tcomplex cc;
_grid->LocalIndexToLocalCoor(idx,lcoor); _grid->LocalIndexToLocalCoor(idx,lcoor);
peekLocalSite(cc,cosha,lcoor); peekLocalSite(cc,cosha,lcoor);
@ -663,7 +662,7 @@ void WilsonFermion5D<Impl>::MomentumSpacePropagatorHw(FermionField &out,const Fe
typedef Lattice<iSinglet<vector_type> > LatComplex; typedef Lattice<iSinglet<vector_type> > LatComplex;
std::vector<int> latt_size = _grid->_fdimensions; Coordinate latt_size = _grid->FullDimensions();
LatComplex sk(_grid); sk = Zero(); LatComplex sk(_grid); sk = Zero();
LatComplex sk2(_grid); sk2= Zero(); LatComplex sk2(_grid); sk2= Zero();
@ -714,7 +713,7 @@ void WilsonFermion5D<Impl>::MomentumSpacePropagatorHw(FermionField &out,const Fe
// Helper macro to reverse Simd vector. Fixme: slow, generic implementation. // Helper macro to reverse Simd vector. Fixme: slow, generic implementation.
#define REVERSE_LS(qSite, qSiteRev, Nsimd) \ #define REVERSE_LS(qSite, qSiteRev, Nsimd) \
{ \ { \
std::vector<typename SitePropagator::scalar_object> qSiteVec(Nsimd); \ ExtractBuffer<typename SitePropagator::scalar_object> qSiteVec(Nsimd); \
extract(qSite, qSiteVec); \ extract(qSite, qSiteVec); \
for (int i = 0; i < Nsimd / 2; ++i) \ for (int i = 0; i < Nsimd / 2; ++i) \
{ \ { \

View File

@ -102,8 +102,8 @@ void Photon<Gimpl>::invKHatSquared(GaugeLinkField &out)
GridBase *grid = out.Grid(); GridBase *grid = out.Grid();
GaugeLinkField kmu(grid), one(grid); GaugeLinkField kmu(grid), one(grid);
const unsigned int nd = grid->_ndimension; const unsigned int nd = grid->_ndimension;
std::vector<int> &l = grid->_fdimensions; Coordinate &l = grid->_fdimensions;
std::vector<int> zm(nd,0); Coordinate zm(nd,0);
TComplex Tone = Complex(1.0,0.0); TComplex Tone = Complex(1.0,0.0);
TComplex Tzero= Complex(0.0,0.0); TComplex Tzero= Complex(0.0,0.0);
@ -132,7 +132,7 @@ void Photon<Gimpl>::zmSub(GaugeLinkField &out)
{ {
case ZmScheme::qedTL: case ZmScheme::qedTL:
{ {
std::vector<int> zm(nd,0); Coordinate zm(nd,0);
TComplex Tzero = Complex(0.0,0.0); TComplex Tzero = Complex(0.0,0.0);
pokeSite(Tzero, out, zm); pokeSite(Tzero, out, zm);
@ -177,7 +177,7 @@ void Photon<Gimpl>::StochasticWeight(GaugeLinkField &weight)
{ {
auto *grid = dynamic_cast<GridCartesian *>(weight.Grid()); auto *grid = dynamic_cast<GridCartesian *>(weight.Grid());
const unsigned int nd = grid->_ndimension; const unsigned int nd = grid->_ndimension;
std::vector<int> latt_size = grid->_fdimensions; Coordinate latt_size = grid->_fdimensions;
Integer vol = 1; Integer vol = 1;
for(int d = 0; d < nd; d++) for(int d = 0; d < nd; d++)
@ -250,7 +250,7 @@ void Photon<Gimpl>::StochasticField(GaugeField &out, GridParallelRNG &rng,
// typedef typename GaugeField::scalar_type ScalComplex; // typedef typename GaugeField::scalar_type ScalComplex;
// typedef Lattice<iSinglet<vector_type> > LatComplex; // typedef Lattice<iSinglet<vector_type> > LatComplex;
// //
// std::vector<int> latt_size = grid->_fdimensions; // Coordinate latt_size = grid->_fdimensions;
// //
// LatComplex denom(grid); denom= Zero(); // LatComplex denom(grid); denom= Zero();
// LatComplex one(grid); one = ScalComplex(1.0,0.0); // LatComplex one(grid); one = ScalComplex(1.0,0.0);
@ -268,7 +268,7 @@ void Photon<Gimpl>::StochasticField(GaugeField &out, GridParallelRNG &rng,
// //
// denom = denom + 4.0*sin(kmu*0.5)*sin(kmu*0.5); // Wilson term // denom = denom + 4.0*sin(kmu*0.5)*sin(kmu*0.5); // Wilson term
// } // }
// std::vector<int> zero_mode(nd,0); // Coordinate zero_mode(nd,0);
// TComplexD Tone = ComplexD(1.0,0.0); // TComplexD Tone = ComplexD(1.0,0.0);
// TComplexD Tzero= ComplexD(0.0,0.0); // TComplexD Tzero= ComplexD(0.0,0.0);
// //

View File

@ -51,7 +51,7 @@ public:
GridBase *grid = out.Grid(); GridBase *grid = out.Grid();
Field kmu(grid), one(grid); Field kmu(grid), one(grid);
const unsigned int nd = grid->_ndimension; const unsigned int nd = grid->_ndimension;
std::vector<int> &l = grid->_fdimensions; Coordinate &l = grid->_fdimensions;
one = Complex(1.0,0.0); one = Complex(1.0,0.0);
out = m*m; out = m*m;

View File

@ -113,6 +113,7 @@ public:
GridFourDimModule(const std::vector<int> tweak_simd) GridFourDimModule(const std::vector<int> tweak_simd)
{ {
Coordinate _tweak_simd(tweak_simd);
if (tweak_simd.size() != 4) if (tweak_simd.size() != 4)
{ {
std::cout << GridLogError std::cout << GridLogError
@ -131,7 +132,7 @@ public:
{ {
set_full(SpaceTimeGrid::makeFourDimGrid( set_full(SpaceTimeGrid::makeFourDimGrid(
GridDefaultLatt(), GridDefaultLatt(),
tweak_simd, _tweak_simd,
GridDefaultMpi())); GridDefaultMpi()));
set_rb(SpaceTimeGrid::makeFourDimRedBlackGrid(grid_.get())); set_rb(SpaceTimeGrid::makeFourDimRedBlackGrid(grid_.get()));
} }

View File

@ -140,8 +140,8 @@ public:
////////////////////////////////// //////////////////////////////////
// Work out Fp = psq_max/ psq... // Work out Fp = psq_max/ psq...
////////////////////////////////// //////////////////////////////////
std::vector<int> latt_size = grid->GlobalDimensions(); Coordinate latt_size = grid->GlobalDimensions();
std::vector<int> coor(grid->_ndimension,0); Coordinate coor(grid->_ndimension,0);
for(int mu=0;mu<Nd;mu++) { for(int mu=0;mu<Nd;mu++) {
Real TwoPiL = M_PI * 2.0/ latt_size[mu]; Real TwoPiL = M_PI * 2.0/ latt_size[mu];

View File

@ -33,7 +33,7 @@ NAMESPACE_BEGIN(Grid);
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
// Public interface // Public interface
///////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////
GridCartesian *SpaceTimeGrid::makeFourDimGrid(const std::vector<int> & latt,const std::vector<int> &simd,const std::vector<int> &mpi) GridCartesian *SpaceTimeGrid::makeFourDimGrid(const Coordinate & latt,const Coordinate &simd,const Coordinate &mpi)
{ {
return new GridCartesian(latt,simd,mpi); return new GridCartesian(latt,simd,mpi);
} }
@ -41,18 +41,18 @@ GridRedBlackCartesian *SpaceTimeGrid::makeFourDimRedBlackGrid(const GridCartesia
{ {
return new GridRedBlackCartesian(FourDimGrid); return new GridRedBlackCartesian(FourDimGrid);
} }
GridCartesian *SpaceTimeGrid::makeFourDimDWFGrid(const std::vector<int> & latt,const std::vector<int> &mpi) GridCartesian *SpaceTimeGrid::makeFourDimDWFGrid(const Coordinate & latt,const Coordinate &mpi)
{ {
std::vector<int> simd(4,1); Coordinate simd(4,1);
return makeFourDimGrid(latt,simd,mpi); return makeFourDimGrid(latt,simd,mpi);
} }
GridCartesian *SpaceTimeGrid::makeFiveDimGrid(int Ls,const GridCartesian *FourDimGrid) GridCartesian *SpaceTimeGrid::makeFiveDimGrid(int Ls,const GridCartesian *FourDimGrid)
{ {
int N4=FourDimGrid->_ndimension; int N4=FourDimGrid->_ndimension;
std::vector<int> latt5(1,Ls); Coordinate latt5(1,Ls);
std::vector<int> simd5(1,1); Coordinate simd5(1,1);
std::vector<int> mpi5(1,1); Coordinate mpi5(1,1);
for(int d=0;d<N4;d++){ for(int d=0;d<N4;d++){
latt5.push_back(FourDimGrid->_fdimensions[d]); latt5.push_back(FourDimGrid->_fdimensions[d]);
@ -67,7 +67,7 @@ GridRedBlackCartesian *SpaceTimeGrid::makeFiveDimRedBlackGrid(int Ls,const GridC
{ {
int N4=FourDimGrid->_ndimension; int N4=FourDimGrid->_ndimension;
int cbd=1; int cbd=1;
std::vector<int> cb5(1,0); Coordinate cb5(1,0);
for(int d=0;d<N4;d++){ for(int d=0;d<N4;d++){
cb5.push_back( 1); cb5.push_back( 1);
} }
@ -83,9 +83,9 @@ GridCartesian *SpaceTimeGrid::makeFiveDimDWFGrid(int Ls,const GridCartes
int N4 = FourDimGrid->_ndimension; int N4 = FourDimGrid->_ndimension;
int nsimd = FourDimGrid->Nsimd(); int nsimd = FourDimGrid->Nsimd();
std::vector<int> latt5(1,Ls); Coordinate latt5(1,Ls);
std::vector<int> simd5(1,nsimd); Coordinate simd5(1,nsimd);
std::vector<int> mpi5(1,1); Coordinate mpi5(1,1);
for(int d=0;d<N4;d++){ for(int d=0;d<N4;d++){
latt5.push_back(FourDimGrid->_fdimensions[d]); latt5.push_back(FourDimGrid->_fdimensions[d]);
@ -102,7 +102,7 @@ GridRedBlackCartesian *SpaceTimeGrid::makeFiveDimDWFRedBlackGrid(int Ls,const Gr
{ {
int N4=FourDimGrid->_ndimension; int N4=FourDimGrid->_ndimension;
int cbd=1; int cbd=1;
std::vector<int> cb5(1,0); Coordinate cb5(1,0);
for(int d=0;d<N4;d++){ for(int d=0;d<N4;d++){
cb5.push_back(1); cb5.push_back(1);
} }

View File

@ -33,7 +33,7 @@ NAMESPACE_BEGIN(Grid);
class SpaceTimeGrid { class SpaceTimeGrid {
public: public:
static GridCartesian *makeFourDimGrid(const std::vector<int> & latt,const std::vector<int> &simd,const std::vector<int> &mpi); static GridCartesian *makeFourDimGrid(const Coordinate & latt,const Coordinate &simd,const Coordinate &mpi);
static GridRedBlackCartesian *makeFourDimRedBlackGrid (const GridCartesian *FourDimGrid); static GridRedBlackCartesian *makeFourDimRedBlackGrid (const GridCartesian *FourDimGrid);
static GridCartesian *makeFiveDimGrid (int Ls,const GridCartesian *FourDimGrid); static GridCartesian *makeFiveDimGrid (int Ls,const GridCartesian *FourDimGrid);
@ -41,7 +41,7 @@ public:
static GridCartesian *makeFiveDimDWFGrid (int Ls,const GridCartesian *FourDimGrid); static GridCartesian *makeFiveDimDWFGrid (int Ls,const GridCartesian *FourDimGrid);
static GridRedBlackCartesian *makeFiveDimDWFRedBlackGrid(int Ls,const GridCartesian *FourDimGrid); static GridRedBlackCartesian *makeFiveDimDWFRedBlackGrid(int Ls,const GridCartesian *FourDimGrid);
static GridCartesian *makeFourDimDWFGrid (const std::vector<int> & latt,const std::vector<int> &mpi); static GridCartesian *makeFourDimDWFGrid (const Coordinate & latt,const Coordinate &mpi);
}; };