17 using std::setprecision;
20 dash::util::TimeMeasure::Clock
47 #define ASSERT_EQ(_e, _a) do { \ 48 assert((_e) == (_a)); \ 51 #define ASSERT_EQ(_e, _a) do { \ 57 std::array<const char*, 6> testcase_str {{
67 void print_measurement_header();
68 void print_measurement_record(
82 experiment_t testcase,
85 template<
typename ValueType,
typename BinaryOperation>
98 auto myid = team.myid();
102 if (l_first != l_last) {
103 auto l_result = std::accumulate(std::next(l_first), l_last, *l_first, binary_op);
104 l_results.local[0].l_result = l_result;
105 l_results.local[0].l_valid =
true;
107 l_results.local[0].l_valid =
false;
113 for (
size_t i = 0; i < team.size(); i++) {
114 local_result lr = l_results[i];
116 result = binary_op(result, lr.l_result);
125 struct minmax operator+(const minmax &other)
const {
127 res.min += other.min;
128 res.max += other.max;
132 struct minmax& operator+=(
const minmax &other) {
134 res.min += other.min;
135 res.max += other.max;
140 static void minmax_fn(
const void *invec,
void *inoutvec,
size_t,
void *)
145 if (minmax_in->min < minmax_out->min) {
146 minmax_out->min = minmax_in->min;
149 if (minmax_in->max > minmax_out->max) {
150 minmax_out->max = minmax_in->max;
155 static void minmax_lambda(
const void *invec,
void *inoutvec,
size_t,
void *userdata)
159 T& fn = *
static_cast<T*
>(userdata);
160 *minmax_out = fn(*minmax_in, *minmax_out);
163 int main(
int argc,
char** argv)
172 bench_params.print_header();
173 bench_params.print_pinning();
176 auto bench_cfg = bench_params.config();
178 print_params(bench_params, params);
179 print_measurement_header();
183 std::array<experiment_t, 6> testcases{{
192 std::array<experiment_t, 5> testcases{{
201 while(round < params.rounds) {
202 for(
auto testcase : testcases){
203 res = evaluate(params.reps, testcase, params);
204 print_measurement_record(bench_cfg, res, params);
210 cout <<
"Benchmark finished" << endl;
225 float lmax = 1000 - r;
227 auto ts_tot_start = Timer::Now();
229 for (
int i = 0; i < reps; i++) {
230 if (testcase == ARRAYSTRUCT) {
233 minmax_t out = reduce_array(&in, std::next(&in), init,
241 else if (testcase == ARRAYDOUBLE) {
242 double in = lmin + lmax;
243 double out = reduce_array(&in, std::next(&in), 0.0,
249 else if (testcase == DARTSTRUCT) {
255 }
else if (testcase == DARTDOUBLE) {
256 double in = lmin + lmax;
257 double out =
dash::reduce(&in, std::next(&in), 0.0,
true);
259 }
else if (testcase == DARTLAMBDA) {
260 double in = lmin + lmax;
262 [](
double a,
double b){
return a + b; });
266 else if (testcase == MPIDOUBLE) {
267 double in = lmin + lmax;
269 MPI_Allreduce(&in, &out, 1, MPI_DOUBLE, MPI_SUM, MPI_COMM_WORLD);
275 mes.time_total_s = Timer::ElapsedSince(ts_tot_start) / (double)reps / 1E6;
276 mes.testcase = testcase_str[testcase];
280 void print_measurement_header()
284 << std::setw( 5) <<
"units" <<
"," 285 << std::setw( 9) <<
"mpi.impl" <<
"," 286 << std::setw(30) <<
"impl" <<
"," 287 << std::setw( 8) <<
"total.s" 292 void print_measurement_record(
298 std::string mpi_impl = dash__toxstr(MPI_IMPL_ID);
299 auto mes = measurement;
302 << std::setw(9) << mpi_impl <<
"," 303 << std::fixed << setprecision(2) << setw(30) << mes.testcase <<
"," 304 << std::fixed << setprecision(8) << setw(12) << mes.time_total_s
315 for (
auto i = 1; i < argc; i += 2) {
316 std::string flag = argv[i];
318 params.reps = atoi(argv[i+1]);
321 params.rounds = atoi(argv[i+1]);
335 bench_cfg.print_section_start(
"Runtime arguments");
336 bench_cfg.print_param(
"-r",
"repetitions per round", params.reps);
337 bench_cfg.print_param(
"-n",
"rounds", params.rounds);
338 bench_cfg.print_section_end();
global_unit_t myid()
Shortcut to query the global unit ID of the calling unit.
Reduce operands to their sum.
std::iterator_traits< LocalInputIter >::value_type reduce(LocalInputIter in_first, LocalInputIter in_last, InitType init, BinaryOperation binary_op=BinaryOperation(), bool non_empty=true, dash::Team &team=dash::Team::All())
Accumulate values in each process' range [in_first, in_last) using the provided binary reduce functio...
size_t size()
Return the number of units in the global team.
void finalize()
Finalize the DASH library and the underlying runtime system.
struct dash::dart_operation ValueType
Reduce operands to their minimum value.
static Team & All()
The invariant Team instance containing all available units.
void init(int *argc, char ***argv)
Initialize the DASH library and the underlying runtime system.