diff --git a/Grid/algorithms/multigrid/GeneralCoarsenedMatrixMultiRHS.h b/Grid/algorithms/multigrid/GeneralCoarsenedMatrixMultiRHS.h index 202a1452..e6c12bdc 100644 --- a/Grid/algorithms/multigrid/GeneralCoarsenedMatrixMultiRHS.h +++ b/Grid/algorithms/multigrid/GeneralCoarsenedMatrixMultiRHS.h @@ -175,25 +175,117 @@ public: assert(j==unpadded_sites); CopyMatrix(); } - template void GridtoBLAS(const Lattice &grid,deviceVector &out) + template void GridtoBLAS(const Lattice &from,deviceVector &to) { +#if 0 std::vector tmp; - unvectorizeToLexOrdArray(tmp,grid); - // std::cout << "GridtoBLAS volume " <lSites()<<" "<lSites()); - assert(tmp.size()==out.size()); - out.resize(tmp.size()); - acceleratorCopyToDevice(&tmp[0],&out[0],sizeof(typename vobj::scalar_object)*tmp.size()); + unvectorizeToLexOrdArray(tmp,from); + assert(tmp.size()==from.Grid()->lSites()); + assert(tmp.size()==to.size()); + to.resize(tmp.size()); + acceleratorCopyToDevice(&tmp[0],&to[0],sizeof(typename vobj::scalar_object)*tmp.size()); +#else + typedef typename vobj::scalar_object sobj; + typedef typename vobj::scalar_type scalar_type; + typedef typename vobj::vector_type vector_type; + + GridBase *Fg = from.Grid(); + assert(!Fg->_isCheckerBoarded); + int nd = Fg->_ndimension; + + to.resize(Fg->lSites()); + + Coordinate LocalLatt = Fg->LocalDimensions(); + size_t nsite = 1; + for(int i=0;i_ostride; + Coordinate f_istride = Fg->_istride; + Coordinate f_rdimensions = Fg->_rdimensions; + + autoView(from_v,from,AcceleratorRead); + auto to_v = &to[0]; + + const int words=sizeof(vobj)/sizeof(vector_type); + accelerator_for(idx,nsite,1,{ + + Coordinate from_coor, base; + Lexicographic::CoorFromIndex(base,idx,LocalLatt); + for(int i=0;i void BLAStoGrid(Lattice &grid,deviceVector &in) { +#if 0 std::vector tmp; tmp.resize(in.size()); // std::cout << "BLAStoGrid volume " <lSites()<lSites()); acceleratorCopyFromDevice(&in[0],&tmp[0],sizeof(typename vobj::scalar_object)*in.size()); vectorizeFromLexOrdArray(tmp,grid); +#else + typedef typename vobj::scalar_object sobj; + typedef typename vobj::scalar_type scalar_type; + typedef typename vobj::vector_type vector_type; + + GridBase *Tg = grid.Grid(); + assert(!Tg->_isCheckerBoarded); + int nd = Tg->_ndimension; + + assert(in.size()==Tg->lSites()); + + Coordinate LocalLatt = Tg->LocalDimensions(); + size_t nsite = 1; + for(int i=0;i_ostride; + Coordinate t_istride = Tg->_istride; + Coordinate t_rdimensions = Tg->_rdimensions; + + autoView(to_v,grid,AcceleratorWrite); + auto from_v = &in[0]; + + const int words=sizeof(vobj)/sizeof(vector_type); + accelerator_for(idx,nsite,1,{ + + Coordinate to_coor, base; + Lexicographic::CoorFromIndex(base,idx,LocalLatt); + for(int i=0;i