Tangle: Update files

This commit is contained in:
2021-10-19 13:52:00 +02:00
parent 18d0264f11
commit 03b66dac8d
6 changed files with 113 additions and 64 deletions

View File

@@ -7,6 +7,13 @@
#include <ctf.hpp>
#define ADD_ATTRIBUTE(_type, _name, _default) \
_type _name = _default; \
Input& with_ ## _name(_type i) { \
_name = i; \
return *this; \
}
namespace atrip {
struct Atrip {
@@ -24,9 +31,6 @@ namespace atrip {
, *Vhhhp = nullptr
, *Vppph = nullptr
;
int maxIterations = 0, iterationMod = -1;
bool barrier = false;
bool chrono = false;
Input& with_epsilon_i(CTF::Tensor<double> * t) { ei = t; return *this; }
Input& with_epsilon_a(CTF::Tensor<double> * t) { ea = t; return *this; }
Input& with_Tai(CTF::Tensor<double> * t) { Tph = t; return *this; }
@@ -34,10 +38,19 @@ namespace atrip {
Input& with_Vabij(CTF::Tensor<double> * t) { Vpphh = t; return *this; }
Input& with_Vijka(CTF::Tensor<double> * t) { Vhhhp = t; return *this; }
Input& with_Vabci(CTF::Tensor<double> * t) { Vppph = t; return *this; }
Input& with_maxIterations(int i) { maxIterations = i; return *this; }
Input& with_iterationMod(int i) { iterationMod = i; return *this; }
Input& with_barrier(bool i) { barrier = i; return *this; }
Input& with_chrono(bool i) { chrono = i; return *this; }
enum TuplesDistribution {
NAIVE,
GROUP_AND_SORT,
};
ADD_ATTRIBUTE(bool, chrono, false)
ADD_ATTRIBUTE(bool, barrier, false)
ADD_ATTRIBUTE(int, maxIterations, 0)
ADD_ATTRIBUTE(int, iterationMod, -1)
ADD_ATTRIBUTE(TuplesDistribution, tuplesDistribution, NAIVE)
};
struct Output {
@@ -47,4 +60,6 @@ namespace atrip {
};
}
#undef ADD_ATTRIBUTE
// Atrip:1 ends here

View File

@@ -2,12 +2,17 @@
#pragma once
#define ATRIP_BENCHMARK
//#define ATRIP_DONT_SLICE
#define ATRIP_DEBUG 1
//#define ATRIP_WORKLOAD_DUMP
#define ATRIP_USE_DGEMM
//#define ATRIP_PRINT_TUPLES
#ifndef ATRIP_DEBUG
#define ATRIP_DEBUG 1
#endif
#ifndef LOG
#define LOG(level, name) if (Atrip::rank == 0) std::cout << name << ": "
#endif
#if ATRIP_DEBUG == 4
# pragma message("WARNING: You have OCD debugging ABC triples "\
@@ -45,7 +50,7 @@
# define WITH_CRAZY_DEBUG if (false)
# define WITH_DBG
# define DBG(...) dbg(__VA_ARGS__)
#elif ATRIP_DEBUG == 1
#else
# define OCD_Barrier(com)
# define WITH_OCD if (false)
# define WITH_ROOT if (false)
@@ -54,7 +59,5 @@
# define WITH_DBG if (false)
# define WITH_CRAZY_DEBUG if (false)
# define DBG(...)
#else
# error("ATRIP_DEBUG is not defined!")
#endif
// Debug:1 ends here

View File

@@ -77,10 +77,16 @@ getABCRange(size_t np, size_t rank, ABCTuples const& tuplesList) {
auto const& it = n_tuples_per_rank.begin();
return
{ std::accumulate(it, it + rank , 0)
, std::accumulate(it, it + rank + 1, 0)
};
std::pair<size_t, size_t> const
range = { std::accumulate(it, it + rank , 0)
, std::accumulate(it, it + rank + 1, 0) - 1
};
WITH_RANK << "range = "
<< range.first << " -> " << range.second
<< std::endl;
return range;
}
// Naive list:2 ends here
@@ -92,12 +98,23 @@ struct NaiveDistribution : public TuplesDistribution {
MPI_Comm_rank(universe, &rank);
MPI_Comm_size(universe, &np);
auto const all = getTuplesList(Nv);
auto const range = getABCRange((size_t)np, (size_t)rank, all);
const size_t
tuplesPerRank
= all.size() / np
+ size_t(all.size() % np != 0)
;
//auto const range = getABCRange((size_t)np, (size_t)rank, all);
std::pair<size_t, size_t> const
range = { tuplesPerRank * rank
, tuplesPerRank * (rank + 1) - 1
};
std::vector<ABCTuple> result(range.second - range.first, FAKE_TUPLE);
std::copy(all.begin() + range.first,
range.second >= all.size()
? all.end()
: all.begin() + range.first + range.second,
? all.end()
: all.begin() + range.first + range.second,
result.begin());
return result;
}
@@ -226,7 +243,6 @@ specialDistribution(Info info, std::vector<ABCTuple> const& allTuples) {
size_t nNodes(info.nNodes);
size_t np(info.np);
size_t N(allTuples.size());
size_t tuplePerNode( ceil( ((double)N) / nNodes) );
// nodeid tuple list
std::map<size_t, std::vector<ABCTuple> > container1d;

View File

@@ -6,6 +6,7 @@
#include <chrono>
#include <ctf.hpp>
#include <atrip/Debug.hpp>
namespace atrip {
// Prolog:1 ends here