diff --git a/atrip.org b/atrip.org index 52398c1..e2e6e69 100644 --- a/atrip.org +++ b/atrip.org @@ -1241,12 +1241,13 @@ and define subclasses of slice unions. namespace atrip { + template void sliceIntoVector - ( std::vector &v - , CTF::Tensor &toSlice + ( std::vector &v + , CTF::Tensor &toSlice , std::vector const low , std::vector const up - , CTF::Tensor const& origin + , CTF::Tensor const& origin , std::vector const originLow , std::vector const originUp ) { @@ -1273,155 +1274,159 @@ namespace atrip { , origin_.low.data() , origin_.up.data() , 1.0); - memcpy(v.data(), toSlice.data, sizeof(double) * v.size()); + memcpy(v.data(), toSlice.data, sizeof(F) * v.size()); #endif } - struct TAPHH : public SliceUnion { - TAPHH( Tensor const& sourceTensor + template + struct TAPHH : public SliceUnion { + TAPHH( CTF::Tensor const& sourceTensor , size_t No , size_t Nv , size_t np , MPI_Comm child_world , MPI_Comm global_world - ) : SliceUnion( sourceTensor - , {Slice::A, Slice::B, Slice::C} - , {Nv, No, No} // size of the slices - , {Nv} - , np - , child_world - , global_world - , Slice::TA - , 4) { + ) : SliceUnion( sourceTensor + , {Slice::A, Slice::B, Slice::C} + , {Nv, No, No} // size of the slices + , {Nv} + , np + , child_world + , global_world + , Slice::TA + , 4) { init(sourceTensor); } - void sliceIntoBuffer(size_t it, Tensor &to, Tensor const& from) override + void sliceIntoBuffer(size_t it, CTF::Tensor &to, CTF::Tensor const& from) override { - const int Nv = sliceLength[0] - , No = sliceLength[1] - , a = rankMap.find({static_cast(Atrip::rank), it}); + const int Nv = this->sliceLength[0] + , No = this->sliceLength[1] + , a = this->rankMap.find({static_cast(Atrip::rank), it}); ; - sliceIntoVector( sources[it] - , to, {0, 0, 0}, {Nv, No, No} - , from, {a, 0, 0, 0}, {a+1, Nv, No, No} - ); + sliceIntoVector( this->sources[it] + , to, {0, 0, 0}, {Nv, No, No} + , from, {a, 0, 0, 0}, {a+1, Nv, No, No} + ); } }; - struct HHHA : public SliceUnion { - HHHA( Tensor const& sourceTensor + template + struct HHHA : public SliceUnion { + HHHA( CTF::Tensor const& sourceTensor , size_t No , size_t Nv , size_t np , MPI_Comm child_world , MPI_Comm global_world - ) : SliceUnion( sourceTensor - , {Slice::A, Slice::B, Slice::C} - , {No, No, No} // size of the slices - , {Nv} // size of the parametrization - , np - , child_world - , global_world - , Slice::VIJKA - , 4) { + ) : SliceUnion( sourceTensor + , {Slice::A, Slice::B, Slice::C} + , {No, No, No} // size of the slices + , {Nv} // size of the parametrization + , np + , child_world + , global_world + , Slice::VIJKA + , 4) { init(sourceTensor); } - void sliceIntoBuffer(size_t it, Tensor &to, Tensor const& from) override + void sliceIntoBuffer(size_t it, CTF::Tensor &to, CTF::Tensor const& from) override { - const int No = sliceLength[0] - , a = rankMap.find({static_cast(Atrip::rank), it}) + const int No = this->sliceLength[0] + , a = this->rankMap.find({static_cast(Atrip::rank), it}) ; - sliceIntoVector( sources[it] - , to, {0, 0, 0}, {No, No, No} - , from, {0, 0, 0, a}, {No, No, No, a+1} - ); + sliceIntoVector( this->sources[it] + , to, {0, 0, 0}, {No, No, No} + , from, {0, 0, 0, a}, {No, No, No, a+1} + ); } }; - struct ABPH : public SliceUnion { - ABPH( Tensor const& sourceTensor + template + struct ABPH : public SliceUnion { + ABPH( CTF::Tensor const& sourceTensor , size_t No , size_t Nv , size_t np , MPI_Comm child_world , MPI_Comm global_world - ) : SliceUnion( sourceTensor - , { Slice::AB, Slice::BC, Slice::AC - , Slice::BA, Slice::CB, Slice::CA - } - , {Nv, No} // size of the slices - , {Nv, Nv} // size of the parametrization - , np - , child_world - , global_world - , Slice::VABCI - , 2*6) { + ) : SliceUnion( sourceTensor + , { Slice::AB, Slice::BC, Slice::AC + , Slice::BA, Slice::CB, Slice::CA + } + , {Nv, No} // size of the slices + , {Nv, Nv} // size of the parametrization + , np + , child_world + , global_world + , Slice::VABCI + , 2*6) { init(sourceTensor); } - void sliceIntoBuffer(size_t it, Tensor &to, Tensor const& from) override { + void sliceIntoBuffer(size_t it, CTF::Tensor &to, CTF::Tensor const& from) override { - const int Nv = sliceLength[0] - , No = sliceLength[1] - , el = rankMap.find({static_cast(Atrip::rank), it}) + const int Nv = this->sliceLength[0] + , No = this->sliceLength[1] + , el = this->rankMap.find({static_cast(Atrip::rank), it}) , a = el % Nv , b = el / Nv ; - sliceIntoVector( sources[it] - , to, {0, 0}, {Nv, No} - , from, {a, b, 0, 0}, {a+1, b+1, Nv, No} - ); + sliceIntoVector( this->sources[it] + , to, {0, 0}, {Nv, No} + , from, {a, b, 0, 0}, {a+1, b+1, Nv, No} + ); } }; - struct ABHH : public SliceUnion { - ABHH( Tensor const& sourceTensor + template + struct ABHH : public SliceUnion { + ABHH( CTF::Tensor const& sourceTensor , size_t No , size_t Nv , size_t np , MPI_Comm child_world , MPI_Comm global_world - ) : SliceUnion( sourceTensor - , {Slice::AB, Slice::BC, Slice::AC} - , {No, No} // size of the slices - , {Nv, Nv} // size of the parametrization - , np - , child_world - , global_world - , Slice::VABIJ - , 6) { + ) : SliceUnion( sourceTensor + , {Slice::AB, Slice::BC, Slice::AC} + , {No, No} // size of the slices + , {Nv, Nv} // size of the parametrization + , np + , child_world + , global_world + , Slice::VABIJ + , 6) { init(sourceTensor); } - void sliceIntoBuffer(size_t it, Tensor &to, Tensor const& from) override { + void sliceIntoBuffer(size_t it, CTF::Tensor &to, CTF::Tensor const& from) override { const int Nv = from.lens[0] - , No = sliceLength[1] - , el = rankMap.find({static_cast(Atrip::rank), it}) + , No = this->sliceLength[1] + , el = this->rankMap.find({static_cast(Atrip::rank), it}) , a = el % Nv , b = el / Nv ; - sliceIntoVector( sources[it] - , to, {0, 0}, {No, No} - , from, {a, b, 0, 0}, {a+1, b+1, No, No} - ); + sliceIntoVector( this->sources[it] + , to, {0, 0}, {No, No} + , from, {a, b, 0, 0}, {a+1, b+1, No, No} + ); } @@ -1429,39 +1434,40 @@ namespace atrip { }; - struct TABHH : public SliceUnion { - TABHH( Tensor const& sourceTensor + template + struct TABHH : public SliceUnion { + TABHH( CTF::Tensor const& sourceTensor , size_t No , size_t Nv , size_t np , MPI_Comm child_world , MPI_Comm global_world - ) : SliceUnion( sourceTensor - , {Slice::AB, Slice::BC, Slice::AC} - , {No, No} // size of the slices - , {Nv, Nv} // size of the parametrization - , np - , child_world - , global_world - , Slice::TABIJ - , 6) { + ) : SliceUnion( sourceTensor + , {Slice::AB, Slice::BC, Slice::AC} + , {No, No} // size of the slices + , {Nv, Nv} // size of the parametrization + , np + , child_world + , global_world + , Slice::TABIJ + , 6) { init(sourceTensor); } - void sliceIntoBuffer(size_t it, Tensor &to, Tensor const& from) override { + void sliceIntoBuffer(size_t it, CTF::Tensor &to, CTF::Tensor const& from) override { // TODO: maybe generalize this with ABHH const int Nv = from.lens[0] - , No = sliceLength[1] - , el = rankMap.find({static_cast(Atrip::rank), it}) + , No = this->sliceLength[1] + , el = this->rankMap.find({static_cast(Atrip::rank), it}) , a = el % Nv , b = el / Nv ; - sliceIntoVector( sources[it] - , to, {0, 0}, {No, No} - , from, {a, b, 0, 0}, {a+1, b+1, No, No} - ); + sliceIntoVector( this->sources[it] + , to, {0, 0}, {No, No} + , from, {a, b, 0, 0}, {a+1, b+1, No, No} + ); }