Silence the logging in group-and-sort

This commit is contained in:
Alejandro Gallo 2022-02-22 12:09:41 +01:00
parent bbbfb30c6f
commit 10a7969710
13 changed files with 80 additions and 80 deletions

View File

@ -1813,7 +1813,7 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
, container3d(nNodes * nNodes * nNodes) , container3d(nNodes * nNodes * nNodes)
; ;
if (info.nodeId == 0) WITH_DBG if (info.nodeId == 0)
std::cout << "\tGoing through all " std::cout << "\tGoing through all "
<< allTuples.size() << allTuples.size()
<< " tuples in " << " tuples in "
@ -1845,7 +1845,7 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
} }
if (info.nodeId == 0) WITH_DBG if (info.nodeId == 0)
std::cout << "\tBuilding 1-d containers\n"; std::cout << "\tBuilding 1-d containers\n";
// DISTRIBUTE 1-d containers // DISTRIBUTE 1-d containers
// every tuple which is only located at one node belongs to this node // every tuple which is only located at one node belongs to this node
@ -1855,7 +1855,7 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
std::copy(_tuples.begin(), _tuples.end(), nodeTuples.begin()); std::copy(_tuples.begin(), _tuples.end(), nodeTuples.begin());
} }
if (info.nodeId == 0) WITH_DBG if (info.nodeId == 0)
std::cout << "\tBuilding 2-d containers\n"; std::cout << "\tBuilding 2-d containers\n";
// DISTRIBUTE 2-d containers // DISTRIBUTE 2-d containers
//the tuples which are located at two nodes are half/half given to these nodes //the tuples which are located at two nodes are half/half given to these nodes
@ -1890,7 +1890,7 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
} }
if (info.nodeId == 0) WITH_DBG if (info.nodeId == 0)
std::cout << "\tBuilding 3-d containers\n"; std::cout << "\tBuilding 3-d containers\n";
// DISTRIBUTE 3-d containers // DISTRIBUTE 3-d containers
for (size_t zyx = 0; zyx < container3d.size(); zyx++) { for (size_t zyx = 0; zyx < container3d.size(); zyx++) {
@ -1929,7 +1929,7 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
} }
if (info.nodeId == 0) std::cout << "\tswapping tuples...\n"; WITH_DBG if (info.nodeId == 0) std::cout << "\tswapping tuples...\n";
/* /*
* sort part of group-and-sort algorithm * sort part of group-and-sort algorithm
* every tuple on a given node is sorted in a way that * every tuple on a given node is sorted in a way that
@ -1959,16 +1959,16 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
} }
} }
if (info.nodeId == 0) std::cout << "\tsorting list of tuples...\n"; WITH_DBG if (info.nodeId == 0) std::cout << "\tsorting list of tuples...\n";
//now we sort the list of tuples //now we sort the list of tuples
std::sort(nodeTuples.begin(), nodeTuples.end()); std::sort(nodeTuples.begin(), nodeTuples.end());
if (info.nodeId == 0) std::cout << "\trestoring tuples...\n"; WITH_DBG if (info.nodeId == 0) std::cout << "\trestoring tuples...\n";
// we bring the tuples abc back in the order a<b<c // we bring the tuples abc back in the order a<b<c
for (auto &t: nodeTuples) std::sort(t.begin(), t.end()); for (auto &t: nodeTuples) std::sort(t.begin(), t.end());
#if ATRIP_DEBUG > 1 #if ATRIP_DEBUG > 1
if (info.nodeId == 0) WITH_DBG if (info.nodeId == 0)
std::cout << "checking for validity of " << nodeTuples.size() << std::endl; std::cout << "checking for validity of " << nodeTuples.size() << std::endl;
const bool anyInvalid const bool anyInvalid
= std::any_of(nodeTuples.begin(), = std::any_of(nodeTuples.begin(),
@ -1977,7 +1977,7 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
if (anyInvalid) throw "Some tuple is invalid in group-and-sort algorithm"; if (anyInvalid) throw "Some tuple is invalid in group-and-sort algorithm";
#endif #endif
if (info.nodeId == 0) std::cout << "\treturning tuples...\n"; WITH_DBG if (info.nodeId == 0) std::cout << "\treturning tuples...\n";
return nodeTuples; return nodeTuples;
} }

View File

@ -1,4 +1,4 @@
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Include%20header][Include header:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Include%20header][Include header:1]]
#pragma once #pragma once
#include <atrip/Atrip.hpp> #include <atrip/Atrip.hpp>

View File

@ -1,4 +1,4 @@
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Header][Header:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Header][Header:1]]
#pragma once #pragma once
#include <sstream> #include <sstream>
#include <string> #include <string>

View File

@ -1,4 +1,4 @@
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Blas][Blas:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Blas][Blas:1]]
#pragma once #pragma once
namespace atrip { namespace atrip {

View File

@ -1,4 +1,4 @@
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Macros][Macros:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Macros][Macros:1]]
#pragma once #pragma once
#include <functional> #include <functional>
#define ATRIP_BENCHMARK #define ATRIP_BENCHMARK
@ -61,20 +61,20 @@
#endif #endif
// Macros:1 ends here // Macros:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Macros][Macros:2]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Macros][Macros:2]]
#ifndef LOG #ifndef LOG
#define LOG(level, name) if (Atrip::rank == 0) std::cout << name << ": " #define LOG(level, name) if (Atrip::rank == 0) std::cout << name << ": "
#endif #endif
// Macros:2 ends here // Macros:2 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Macros][Macros:3]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Macros][Macros:3]]
#ifdef ATRIP_NO_OUTPUT #ifdef ATRIP_NO_OUTPUT
# undef LOG # undef LOG
# define LOG(level, name) if (false) std::cout << name << ": " # define LOG(level, name) if (false) std::cout << name << ": "
#endif #endif
// Macros:3 ends here // Macros:3 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::IterationDescriptor][IterationDescriptor]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::IterationDescriptor][IterationDescriptor]]
namespace atrip { namespace atrip {
struct IterationDescription; struct IterationDescription;

View File

@ -1,4 +1,4 @@
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Equations][Equations:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Equations][Equations:1]]
#pragma once #pragma once
#include<atrip/Slice.hpp> #include<atrip/Slice.hpp>

View File

@ -1,4 +1,4 @@
// [[file:~/cc4s/src/atrip/complex/atrip.org::*The%20rank%20mapping][The rank mapping:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*The%20rank%20mapping][The rank mapping:1]]
#pragma once #pragma once
#include <vector> #include <vector>

View File

@ -1,4 +1,4 @@
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Prolog][Prolog:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Prolog][Prolog:1]]
#pragma once #pragma once
#include <iostream> #include <iostream>
#include <algorithm> #include <algorithm>
@ -29,11 +29,11 @@ template <typename F=double>
struct Slice { struct Slice {
// Prolog:1 ends here // Prolog:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Location][Location:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Location][Location:1]]
struct Location { size_t rank; size_t source; }; struct Location { size_t rank; size_t source; };
// Location:1 ends here // Location:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Type][Type:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Type][Type:1]]
enum Type enum Type
{ A = 10 { A = 10
, B , B
@ -51,7 +51,7 @@ enum Type
}; };
// Type:1 ends here // Type:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*State][State:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*State][State:1]]
enum State { enum State {
Fetch = 0, Fetch = 0,
Dispatched = 2, Dispatched = 2,
@ -62,7 +62,7 @@ enum State {
}; };
// State:1 ends here // State:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*The%20Info%20structure][The Info structure:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*The%20Info%20structure][The Info structure:1]]
struct Info { struct Info {
// which part of a,b,c the slice holds // which part of a,b,c the slice holds
PartialTuple tuple; PartialTuple tuple;
@ -86,7 +86,7 @@ struct Info {
using Ty_x_Tu = std::pair< Type, PartialTuple >; using Ty_x_Tu = std::pair< Type, PartialTuple >;
// The Info structure:1 ends here // The Info structure:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Name][Name:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Name][Name:1]]
enum Name enum Name
{ TA = 100 { TA = 100
, VIJKA = 101 , VIJKA = 101
@ -96,19 +96,19 @@ enum Name
}; };
// Name:1 ends here // Name:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Database][Database:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Database][Database:1]]
struct LocalDatabaseElement { struct LocalDatabaseElement {
Slice<F>::Name name; Slice<F>::Name name;
Slice<F>::Info info; Slice<F>::Info info;
}; };
// Database:1 ends here // Database:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Database][Database:2]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Database][Database:2]]
using LocalDatabase = std::vector<LocalDatabaseElement>; using LocalDatabase = std::vector<LocalDatabaseElement>;
using Database = LocalDatabase; using Database = LocalDatabase;
// Database:2 ends here // Database:2 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*MPI%20Types][MPI Types:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*MPI%20Types][MPI Types:1]]
struct mpi { struct mpi {
static MPI_Datatype vector(size_t n, MPI_Datatype const& DT) { static MPI_Datatype vector(size_t n, MPI_Datatype const& DT) {
@ -214,7 +214,7 @@ struct mpi {
}; };
// MPI Types:1 ends here // MPI Types:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Static%20utilities][Static utilities:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Static%20utilities][Static utilities:1]]
static static
PartialTuple subtupleBySlice(ABCTuple abc, Type sliceType) { PartialTuple subtupleBySlice(ABCTuple abc, Type sliceType) {
switch (sliceType) { switch (sliceType) {
@ -232,7 +232,7 @@ PartialTuple subtupleBySlice(ABCTuple abc, Type sliceType) {
} }
// Static utilities:1 ends here // Static utilities:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Static%20utilities][Static utilities:2]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Static%20utilities][Static utilities:2]]
static std::vector<Slice<F>*> hasRecycledReferencingToIt static std::vector<Slice<F>*> hasRecycledReferencingToIt
( std::vector<Slice<F>> &slices ( std::vector<Slice<F>> &slices
, Info const& info , Info const& info
@ -249,7 +249,7 @@ static std::vector<Slice<F>*> hasRecycledReferencingToIt
} }
// Static utilities:2 ends here // Static utilities:2 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Static%20utilities][Static utilities:3]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Static%20utilities][Static utilities:3]]
static Slice<F>& findOneByType(std::vector<Slice<F>> &slices, Slice<F>::Type type) { static Slice<F>& findOneByType(std::vector<Slice<F>> &slices, Slice<F>::Type type) {
const auto sliceIt const auto sliceIt
= std::find_if(slices.begin(), slices.end(), = std::find_if(slices.begin(), slices.end(),
@ -265,7 +265,7 @@ static Slice<F>& findOneByType(std::vector<Slice<F>> &slices, Slice<F>::Type typ
} }
// Static utilities:3 ends here // Static utilities:3 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Static%20utilities][Static utilities:4]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Static%20utilities][Static utilities:4]]
static Slice<F>& static Slice<F>&
findRecycledSource (std::vector<Slice<F>> &slices, Slice<F>::Info info) { findRecycledSource (std::vector<Slice<F>> &slices, Slice<F>::Info info) {
const auto sliceIt const auto sliceIt
@ -291,7 +291,7 @@ findRecycledSource (std::vector<Slice<F>> &slices, Slice<F>::Info info) {
} }
// Static utilities:4 ends here // Static utilities:4 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Static%20utilities][Static utilities:5]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Static%20utilities][Static utilities:5]]
static Slice<F>& findByTypeAbc static Slice<F>& findByTypeAbc
( std::vector<Slice<F>> &slices ( std::vector<Slice<F>> &slices
, Slice<F>::Type type , Slice<F>::Type type
@ -321,7 +321,7 @@ static Slice<F>& findByTypeAbc
} }
// Static utilities:5 ends here // Static utilities:5 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Static%20utilities][Static utilities:6]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Static%20utilities][Static utilities:6]]
static Slice<F>& findByInfo(std::vector<Slice<F>> &slices, static Slice<F>& findByInfo(std::vector<Slice<F>> &slices,
Slice<F>::Info const& info) { Slice<F>::Info const& info) {
const auto sliceIt const auto sliceIt
@ -344,30 +344,30 @@ static Slice<F>& findByInfo(std::vector<Slice<F>> &slices,
} }
// Static utilities:6 ends here // Static utilities:6 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Attributes][Attributes:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Attributes][Attributes:1]]
Info info; Info info;
// Attributes:1 ends here // Attributes:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Attributes][Attributes:2]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Attributes][Attributes:2]]
F *data; F *data;
// Attributes:2 ends here // Attributes:2 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Attributes][Attributes:3]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Attributes][Attributes:3]]
MPI_Request request; MPI_Request request;
// Attributes:3 ends here // Attributes:3 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Attributes][Attributes:4]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Attributes][Attributes:4]]
const size_t size; const size_t size;
// Attributes:4 ends here // Attributes:4 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Member%20functions][Member functions:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Member%20functions][Member functions:1]]
void markReady() noexcept { void markReady() noexcept {
info.state = Ready; info.state = Ready;
info.recycling = Blank; info.recycling = Blank;
} }
// Member functions:1 ends here // Member functions:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Member%20functions][Member functions:2]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Member%20functions][Member functions:2]]
bool isUnwrapped() const noexcept { bool isUnwrapped() const noexcept {
return info.state == Ready return info.state == Ready
|| info.state == SelfSufficient || info.state == SelfSufficient
@ -375,7 +375,7 @@ bool isUnwrapped() const noexcept {
} }
// Member functions:2 ends here // Member functions:2 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Member%20functions][Member functions:3]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Member%20functions][Member functions:3]]
bool isUnwrappable() const noexcept { bool isUnwrappable() const noexcept {
return isUnwrapped() return isUnwrapped()
|| info.state == Recycled || info.state == Recycled
@ -408,7 +408,7 @@ inline bool isFree() const noexcept {
} }
// Member functions:3 ends here // Member functions:3 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Member%20functions][Member functions:4]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Member%20functions][Member functions:4]]
inline bool isRecyclable() const noexcept { inline bool isRecyclable() const noexcept {
return ( info.state == Dispatched return ( info.state == Dispatched
|| info.state == Ready || info.state == Ready
@ -419,7 +419,7 @@ inline bool isRecyclable() const noexcept {
} }
// Member functions:4 ends here // Member functions:4 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Member%20functions][Member functions:5]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Member%20functions][Member functions:5]]
inline bool hasValidDataPointer() const noexcept { inline bool hasValidDataPointer() const noexcept {
return data != nullptr return data != nullptr
&& info.state != Acceptor && info.state != Acceptor
@ -428,7 +428,7 @@ inline bool hasValidDataPointer() const noexcept {
} }
// Member functions:5 ends here // Member functions:5 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Member%20functions][Member functions:6]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Member%20functions][Member functions:6]]
void unwrapAndMarkReady() { void unwrapAndMarkReady() {
if (info.state == Ready) return; if (info.state == Ready) return;
if (info.state != Dispatched) if (info.state != Dispatched)
@ -460,7 +460,7 @@ void unwrapAndMarkReady() {
} }
// Member functions:6 ends here // Member functions:6 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Epilog][Epilog:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Epilog][Epilog:1]]
Slice(size_t size_) Slice(size_t size_)
: info({}) : info({})
, data(nullptr) , data(nullptr)
@ -471,7 +471,7 @@ Slice(size_t size_)
}; // struct Slice }; // struct Slice
// Epilog:1 ends here // Epilog:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Debug][Debug:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Debug][Debug:1]]
template <typename F=double> template <typename F=double>
std::ostream& operator<<(std::ostream& out, typename Slice<F>::Location const& v) { std::ostream& operator<<(std::ostream& out, typename Slice<F>::Location const& v) {
// TODO: remove me // TODO: remove me

View File

@ -1,4 +1,4 @@
// [[file:~/cc4s/src/atrip/complex/atrip.org::*The%20slice%20union][The slice union:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*The%20slice%20union][The slice union:1]]
#pragma once #pragma once
#include <atrip/Debug.hpp> #include <atrip/Debug.hpp>
#include <atrip/Slice.hpp> #include <atrip/Slice.hpp>

View File

@ -1,4 +1,4 @@
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Prolog][Prolog:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Prolog][Prolog:1]]
#pragma once #pragma once
#include <vector> #include <vector>
@ -21,7 +21,7 @@
namespace atrip { namespace atrip {
// Prolog:1 ends here // Prolog:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Tuples%20types][Tuples types:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Tuples%20types][Tuples types:1]]
using ABCTuple = std::array<size_t, 3>; using ABCTuple = std::array<size_t, 3>;
using PartialTuple = std::array<size_t, 2>; using PartialTuple = std::array<size_t, 2>;
using ABCTuples = std::vector<ABCTuple>; using ABCTuples = std::vector<ABCTuple>;
@ -30,14 +30,14 @@ constexpr ABCTuple FAKE_TUPLE = {0, 0, 0};
constexpr ABCTuple INVALID_TUPLE = {1, 1, 1}; constexpr ABCTuple INVALID_TUPLE = {1, 1, 1};
// Tuples types:1 ends here // Tuples types:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Distributing%20the%20tuples][Distributing the tuples:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Distributing%20the%20tuples][Distributing the tuples:1]]
struct TuplesDistribution { struct TuplesDistribution {
virtual ABCTuples getTuples(size_t Nv, MPI_Comm universe) = 0; virtual ABCTuples getTuples(size_t Nv, MPI_Comm universe) = 0;
virtual bool tupleIsFake(ABCTuple const& t) { return t == FAKE_TUPLE; } virtual bool tupleIsFake(ABCTuple const& t) { return t == FAKE_TUPLE; }
}; };
// Distributing the tuples:1 ends here // Distributing the tuples:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Node%20information][Node information:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Node%20information][Node information:1]]
std::vector<std::string> getNodeNames(MPI_Comm comm){ std::vector<std::string> getNodeNames(MPI_Comm comm){
int rank, np; int rank, np;
MPI_Comm_rank(comm, &rank); MPI_Comm_rank(comm, &rank);
@ -77,7 +77,7 @@ std::vector<std::string> getNodeNames(MPI_Comm comm){
} }
// Node information:1 ends here // Node information:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Node%20information][Node information:2]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Node%20information][Node information:2]]
struct RankInfo { struct RankInfo {
const std::string name; const std::string name;
const size_t nodeId; const size_t nodeId;
@ -139,7 +139,7 @@ getClusterInfo(MPI_Comm comm) {
} }
// Node information:2 ends here // Node information:2 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Naive%20list][Naive list:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Naive%20list][Naive list:1]]
ABCTuples getTuplesList(size_t Nv, size_t rank, size_t np) { ABCTuples getTuplesList(size_t Nv, size_t rank, size_t np) {
const size_t const size_t
@ -173,7 +173,7 @@ ABCTuples getTuplesList(size_t Nv, size_t rank, size_t np) {
} }
// Naive list:1 ends here // Naive list:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Naive%20list][Naive list:2]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Naive%20list][Naive list:2]]
ABCTuples getAllTuplesList(const size_t Nv) { ABCTuples getAllTuplesList(const size_t Nv) {
const size_t n = Nv * (Nv + 1) * (Nv + 2) / 6 - Nv; const size_t n = Nv * (Nv + 1) * (Nv + 2) / 6 - Nv;
ABCTuples result(n); ABCTuples result(n);
@ -189,7 +189,7 @@ ABCTuples getAllTuplesList(const size_t Nv) {
} }
// Naive list:2 ends here // Naive list:2 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Naive%20list][Naive list:3]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Naive%20list][Naive list:3]]
struct NaiveDistribution : public TuplesDistribution { struct NaiveDistribution : public TuplesDistribution {
ABCTuples getTuples(size_t Nv, MPI_Comm universe) override { ABCTuples getTuples(size_t Nv, MPI_Comm universe) override {
int rank, np; int rank, np;
@ -200,11 +200,11 @@ struct NaiveDistribution : public TuplesDistribution {
}; };
// Naive list:3 ends here // Naive list:3 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Prolog][Prolog:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Prolog][Prolog:1]]
namespace group_and_sort { namespace group_and_sort {
// Prolog:1 ends here // Prolog:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Utils][Utils:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Utils][Utils:1]]
// Provides the node on which the slice-element is found // Provides the node on which the slice-element is found
// Right now we distribute the slices in a round robin fashion // Right now we distribute the slices in a round robin fashion
// over the different nodes (NOTE: not mpi ranks but nodes) // over the different nodes (NOTE: not mpi ranks but nodes)
@ -229,7 +229,7 @@ struct Info {
}; };
// Utils:1 ends here // Utils:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Distribution][Distribution:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Distribution][Distribution:1]]
ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) { ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
ABCTuples nodeTuples; ABCTuples nodeTuples;
@ -241,7 +241,7 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
, container3d(nNodes * nNodes * nNodes) , container3d(nNodes * nNodes * nNodes)
; ;
if (info.nodeId == 0) WITH_DBG if (info.nodeId == 0)
std::cout << "\tGoing through all " std::cout << "\tGoing through all "
<< allTuples.size() << allTuples.size()
<< " tuples in " << " tuples in "
@ -273,7 +273,7 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
} }
if (info.nodeId == 0) WITH_DBG if (info.nodeId == 0)
std::cout << "\tBuilding 1-d containers\n"; std::cout << "\tBuilding 1-d containers\n";
// DISTRIBUTE 1-d containers // DISTRIBUTE 1-d containers
// every tuple which is only located at one node belongs to this node // every tuple which is only located at one node belongs to this node
@ -283,7 +283,7 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
std::copy(_tuples.begin(), _tuples.end(), nodeTuples.begin()); std::copy(_tuples.begin(), _tuples.end(), nodeTuples.begin());
} }
if (info.nodeId == 0) WITH_DBG if (info.nodeId == 0)
std::cout << "\tBuilding 2-d containers\n"; std::cout << "\tBuilding 2-d containers\n";
// DISTRIBUTE 2-d containers // DISTRIBUTE 2-d containers
//the tuples which are located at two nodes are half/half given to these nodes //the tuples which are located at two nodes are half/half given to these nodes
@ -318,7 +318,7 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
} }
if (info.nodeId == 0) WITH_DBG if (info.nodeId == 0)
std::cout << "\tBuilding 3-d containers\n"; std::cout << "\tBuilding 3-d containers\n";
// DISTRIBUTE 3-d containers // DISTRIBUTE 3-d containers
for (size_t zyx = 0; zyx < container3d.size(); zyx++) { for (size_t zyx = 0; zyx < container3d.size(); zyx++) {
@ -357,7 +357,7 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
} }
if (info.nodeId == 0) std::cout << "\tswapping tuples...\n"; WITH_DBG if (info.nodeId == 0) std::cout << "\tswapping tuples...\n";
/* /*
* sort part of group-and-sort algorithm * sort part of group-and-sort algorithm
* every tuple on a given node is sorted in a way that * every tuple on a given node is sorted in a way that
@ -387,16 +387,16 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
} }
} }
if (info.nodeId == 0) std::cout << "\tsorting list of tuples...\n"; WITH_DBG if (info.nodeId == 0) std::cout << "\tsorting list of tuples...\n";
//now we sort the list of tuples //now we sort the list of tuples
std::sort(nodeTuples.begin(), nodeTuples.end()); std::sort(nodeTuples.begin(), nodeTuples.end());
if (info.nodeId == 0) std::cout << "\trestoring tuples...\n"; WITH_DBG if (info.nodeId == 0) std::cout << "\trestoring tuples...\n";
// we bring the tuples abc back in the order a<b<c // we bring the tuples abc back in the order a<b<c
for (auto &t: nodeTuples) std::sort(t.begin(), t.end()); for (auto &t: nodeTuples) std::sort(t.begin(), t.end());
#if ATRIP_DEBUG > 1 #if ATRIP_DEBUG > 1
if (info.nodeId == 0) WITH_DBG if (info.nodeId == 0)
std::cout << "checking for validity of " << nodeTuples.size() << std::endl; std::cout << "checking for validity of " << nodeTuples.size() << std::endl;
const bool anyInvalid const bool anyInvalid
= std::any_of(nodeTuples.begin(), = std::any_of(nodeTuples.begin(),
@ -405,13 +405,13 @@ ABCTuples specialDistribution(Info const& info, ABCTuples const& allTuples) {
if (anyInvalid) throw "Some tuple is invalid in group-and-sort algorithm"; if (anyInvalid) throw "Some tuple is invalid in group-and-sort algorithm";
#endif #endif
if (info.nodeId == 0) std::cout << "\treturning tuples...\n"; WITH_DBG if (info.nodeId == 0) std::cout << "\treturning tuples...\n";
return nodeTuples; return nodeTuples;
} }
// Distribution:1 ends here // Distribution:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Main][Main:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Main][Main:1]]
std::vector<ABCTuple> main(MPI_Comm universe, size_t Nv) { std::vector<ABCTuple> main(MPI_Comm universe, size_t Nv) {
int rank, np; int rank, np;
@ -451,7 +451,7 @@ std::vector<ABCTuple> main(MPI_Comm universe, size_t Nv) {
MPI_Comm_split(universe, color, key, &INTRA_COMM); MPI_Comm_split(universe, color, key, &INTRA_COMM);
// Main:1 ends here // Main:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Main][Main:2]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Main][Main:2]]
size_t const size_t const
tuplesPerRankLocal tuplesPerRankLocal
= nodeTuples.size() / nodeInfos[rank].ranksPerNode = nodeTuples.size() / nodeInfos[rank].ranksPerNode
@ -479,7 +479,7 @@ LOG(1,"Atrip") << "ranks per node " << nodeInfos[rank].ranksPerNode << "\n";
LOG(1,"Atrip") << "#nodes " << nNodes << "\n"; LOG(1,"Atrip") << "#nodes " << nNodes << "\n";
// Main:2 ends here // Main:2 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Main][Main:3]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Main][Main:3]]
size_t const totalTuples size_t const totalTuples
= tuplesPerRankGlobal * nodeInfos[rank].ranksPerNode; = tuplesPerRankGlobal * nodeInfos[rank].ranksPerNode;
@ -491,7 +491,7 @@ if (computeDistribution) {
} }
// Main:3 ends here // Main:3 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Main][Main:4]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Main][Main:4]]
{ {
// construct mpi type for abctuple // construct mpi type for abctuple
MPI_Datatype MPI_ABCTUPLE; MPI_Datatype MPI_ABCTUPLE;
@ -515,13 +515,13 @@ if (computeDistribution) {
} }
// Main:4 ends here // Main:4 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Main][Main:5]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Main][Main:5]]
return result; return result;
} }
// Main:5 ends here // Main:5 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Interface][Interface:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Interface][Interface:1]]
struct Distribution : public TuplesDistribution { struct Distribution : public TuplesDistribution {
ABCTuples getTuples(size_t Nv, MPI_Comm universe) override { ABCTuples getTuples(size_t Nv, MPI_Comm universe) override {
return main(universe, Nv); return main(universe, Nv);
@ -529,10 +529,10 @@ struct Distribution : public TuplesDistribution {
}; };
// Interface:1 ends here // Interface:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Epilog][Epilog:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Epilog][Epilog:1]]
} // namespace group_and_sort } // namespace group_and_sort
// Epilog:1 ends here // Epilog:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Epilog][Epilog:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Epilog][Epilog:1]]
} }
// Epilog:1 ends here // Epilog:1 ends here

View File

@ -1,4 +1,4 @@
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Unions][Unions:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Unions][Unions:1]]
#pragma once #pragma once
#include <atrip/SliceUnion.hpp> #include <atrip/SliceUnion.hpp>

View File

@ -1,4 +1,4 @@
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Prolog][Prolog:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Prolog][Prolog:1]]
#pragma once #pragma once
#include <sstream> #include <sstream>
#include <string> #include <string>
@ -11,7 +11,7 @@
namespace atrip { namespace atrip {
// Prolog:1 ends here // Prolog:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Pretty%20printing][Pretty printing:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Pretty%20printing][Pretty printing:1]]
template <typename T> template <typename T>
std::string pretty_print(T&& value) { std::string pretty_print(T&& value) {
std::stringstream stream; std::stringstream stream;
@ -22,7 +22,7 @@ template <typename T>
} }
// Pretty printing:1 ends here // Pretty printing:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Chrono][Chrono:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Chrono][Chrono:1]]
#define WITH_CHRONO(__chrono_name, ...) \ #define WITH_CHRONO(__chrono_name, ...) \
Atrip::chrono[__chrono_name].start(); \ Atrip::chrono[__chrono_name].start(); \
__VA_ARGS__ \ __VA_ARGS__ \
@ -41,6 +41,6 @@ struct Timer {
using Timings = std::map<std::string, Timer>; using Timings = std::map<std::string, Timer>;
// Chrono:1 ends here // Chrono:1 ends here
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Epilog][Epilog:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Epilog][Epilog:1]]
} }
// Epilog:1 ends here // Epilog:1 ends here

View File

@ -1,4 +1,4 @@
// [[file:~/cc4s/src/atrip/complex/atrip.org::*Main][Main:1]] // [[file:~/cc4s/src/atrip/bbbfb30/atrip.org::*Main][Main:1]]
#include <iomanip> #include <iomanip>
#include <atrip/Atrip.hpp> #include <atrip/Atrip.hpp>