diff --git a/atrip.org b/atrip.org index 43a7f04..8d06e58 100644 --- a/atrip.org +++ b/atrip.org @@ -32,9 +32,9 @@ namespace mpi { } +template struct Slice { - using F = double; #+end_src A slice is the concept of a subset of values of a given tensor. @@ -124,8 +124,8 @@ As an example, for the doubles amplitudes \( T^{ab}_{ij} \), one need two kinds // DATABASE ==========================================================={{{1 struct LocalDatabaseElement { - Slice::Name name; - Slice::Info info; + Slice::Name name; + Slice::Info info; }; using LocalDatabase = std::vector; using Database = LocalDatabase; @@ -148,7 +148,7 @@ As an example, for the doubles amplitudes \( T^{ab}_{ij} \), one need two kinds constexpr int n = 2; // create a sliceLocation to measure in the current architecture // the packing of the struct - Slice::Location measure; + Slice::Location measure; MPI_Datatype dt; const std::vector lengths(n, 1); const MPI_Datatype types[n] = {usizeDt(), usizeDt()}; @@ -172,7 +172,7 @@ As an example, for the doubles amplitudes \( T^{ab}_{ij} \), one need two kinds static MPI_Datatype sliceInfo () { constexpr int n = 5; MPI_Datatype dt; - Slice::Info measure; + Slice::Info measure; const std::vector lengths(n, 1); const MPI_Datatype types[n] = { vector(2, usizeDt()) @@ -244,10 +244,10 @@ As an example, for the doubles amplitudes \( T^{ab}_{ij} \), one need two kinds ,* It is important here to return a reference to a Slice ,* not to accidentally copy the associated buffer of the slice. ,*/ - static Slice& findOneByType(std::vector &slices, Slice::Type type) { + static Slice& findOneByType(std::vector> &slices, Slice::Type type) { const auto sliceIt = std::find_if(slices.begin(), slices.end(), - [&type](Slice const& s) { + [&type](Slice const& s) { return type == s.info.type; }); WITH_CRAZY_DEBUG @@ -262,11 +262,11 @@ As an example, for the doubles amplitudes \( T^{ab}_{ij} \), one need two kinds ,* Check if an info has ,* ,*/ - static std::vector hasRecycledReferencingToIt - ( std::vector &slices + static std::vector*> hasRecycledReferencingToIt + ( std::vector> &slices , Info const& info ) { - std::vector result; + std::vector*> result; for (auto& s: slices) if ( s.info.recycling == info.type @@ -277,11 +277,11 @@ As an example, for the doubles amplitudes \( T^{ab}_{ij} \), one need two kinds return result; } - static Slice& - findRecycledSource (std::vector &slices, Slice::Info info) { + static Slice& + findRecycledSource (std::vector> &slices, Slice::Info info) { const auto sliceIt = std::find_if(slices.begin(), slices.end(), - [&info](Slice const& s) { + [&info](Slice const& s) { return info.recycling == s.info.type && info.tuple == s.info.tuple && State::Recycled != s.info.state @@ -301,15 +301,15 @@ As an example, for the doubles amplitudes \( T^{ab}_{ij} \), one need two kinds return *sliceIt; } - static Slice& findByTypeAbc - ( std::vector &slices - , Slice::Type type + static Slice& findByTypeAbc + ( std::vector> &slices + , Slice::Type type , ABCTuple const& abc ) { - const auto tuple = Slice::subtupleBySlice(abc, type); + const auto tuple = Slice::subtupleBySlice(abc, type); const auto sliceIt = std::find_if(slices.begin(), slices.end(), - [&type, &tuple](Slice const& s) { + [&type, &tuple](Slice const& s) { return type == s.info.type && tuple == s.info.tuple ; @@ -329,11 +329,11 @@ As an example, for the doubles amplitudes \( T^{ab}_{ij} \), one need two kinds return *sliceIt; } - static Slice& findByInfo(std::vector &slices, - Slice::Info const& info) { + static Slice& findByInfo(std::vector> &slices, + Slice::Info const& info) { const auto sliceIt = std::find_if(slices.begin(), slices.end(), - [&info](Slice const& s) { + [&info](Slice const& s) { // TODO: maybe implement comparison in Info struct return info.type == s.info.type && info.state == s.info.state @@ -479,13 +479,15 @@ As an example, for the doubles amplitudes \( T^{ab}_{ij} \), one need two kinds }; // struct Slice -std::ostream& operator<<(std::ostream& out, Slice::Location const& v) { +template +std::ostream& operator<<(std::ostream& out, typename Slice::Location const& v) { // TODO: remove me out << "{.r(" << v.rank << "), .s(" << v.source << ")};"; return out; } -std::ostream& operator<<(std::ostream& out, Slice::Info const& i) { +template +std::ostream& operator<<(std::ostream& out, typename Slice::Info const& i) { out << "«t" << i.type << ", s" << i.state << "»" << " ⊙ {" << i.from.rank << ", " << i.from.source << "}" << " ∴ {" << i.tuple[0] << ", " << i.tuple[1] << "}"