14 using std::setprecision;
17 dash::util::TimeMeasure::Clock
33 void print_measurement_header();
34 void print_measurement_record(
55 static void minmax_fn(
const void *invec,
void *inoutvec,
size_t,
void *)
60 if (minmax_in->min < minmax_out->min) {
61 minmax_out->min = minmax_in->min;
64 if (minmax_in->max > minmax_out->max) {
65 minmax_out->max = minmax_in->max;
70 static void minmax_lambda(
const void *invec,
void *inoutvec,
size_t,
void *userdata)
74 T& fn = *
static_cast<T*
>(userdata);
75 *minmax_out = fn(*minmax_in, *minmax_out);
78 int main(
int argc,
char** argv)
87 bench_params.print_header();
88 bench_params.print_pinning();
91 auto bench_cfg = bench_params.config();
93 print_params(bench_params, params);
94 print_measurement_header();
98 std::array<std::string, 5> testcases {{
99 "dart_allreduce.minmax",
100 "dart_allreduce.min",
101 "dart_allreduce.shared",
102 "dart_allreduce.custom",
103 "dart_allreduce.lambda" 106 while(round < params.rounds) {
107 for(
auto testcase : testcases){
108 res = evaluate(params.reps, testcase, params);
109 print_measurement_record(bench_cfg, res, params);
115 cout <<
"Benchmark finished" << endl;
130 float lmax = 1000000 - r;
132 auto ts_tot_start = Timer::Now();
134 for (
int i = 0; i < reps; i++) {
135 if (testcase ==
"dart_allreduce.minmax") {
136 std::array<float, 2> min_max_in{lmin, lmax};
137 std::array<float, 2> min_max_out{};
147 else if (testcase ==
"dart_allreduce.min") {
148 std::array<float, 2> min_max_in{lmin, lmax};
149 std::array<float, 2> min_max_out{};
167 else if (testcase ==
"dart_allreduce.shared") {
168 using value_t = float;
175 auto const start_min =
static_cast<value_t
>(g_min.get());
176 auto const start_max =
static_cast<value_t
>(g_max.get());
180 g_min.get().fetch_op(dash::min<value_t>(), 0);
184 }
else if (testcase ==
"dart_allreduce.custom") {
188 dart_operation_t new_op;
191 &minmax_fn, NULL,
true, new_type,
true, &new_op);
202 }
else if (testcase ==
"dart_allreduce.lambda") {
206 dart_operation_t new_op;
210 if (a.min < res.min) {
213 if (a.max > res.max) {
219 &minmax_lambda<decltype(fn)>, &fn,
true, new_type,
true, &new_op);
233 mes.time_total_s = Timer::ElapsedSince(ts_tot_start) / (double)reps / 1E6;
234 mes.testcase = testcase;
238 void print_measurement_header()
242 << std::setw( 5) <<
"units" <<
"," 243 << std::setw( 9) <<
"mpi.impl" <<
"," 244 << std::setw(30) <<
"impl" <<
"," 245 << std::setw( 8) <<
"total.s" 250 void print_measurement_record(
256 std::string mpi_impl = dash__toxstr(DASH_MPI_IMPL_ID);
257 auto mes = measurement;
260 << std::setw(9) << mpi_impl <<
"," 261 << std::fixed << setprecision(2) << setw(30) << mes.testcase <<
"," 262 << std::fixed << setprecision(8) << setw(12) << mes.time_total_s
273 for (
auto i = 1; i < argc; i += 2) {
274 std::string flag = argv[i];
276 params.reps = atoi(argv[i+1]);
279 params.rounds = atoi(argv[i+1]);
293 bench_cfg.print_section_start(
"Runtime arguments");
294 bench_cfg.print_param(
"-r",
"repetitions per round", params.reps);
295 bench_cfg.print_param(
"-n",
"rounds", params.rounds);
296 bench_cfg.print_section_end();
global_unit_t myid()
Shortcut to query the global unit ID of the calling unit.
size_t size()
Return the number of units in the global team.
dart_ret_t dart_op_destroy(dart_operation_t *op)
Destroy a operation object created through dart_op_create and set op to DART_OP_UNDEFINED.
intptr_t dart_datatype_t
Raw data types supported by the DART interface.
void finalize()
Finalize the DASH library and the underlying runtime system.
dart_ret_t dart_type_destroy(dart_datatype_t *dart_type)
Destroy a data type that was previously created using dart_type_create_strided or dart_type_create_in...
Reduce operands to their maximum value.
dart_ret_t dart_allreduce(const void *sendbuf, void *recvbuf, size_t nelem, dart_datatype_t dtype, dart_operation_t op, dart_team_t team)
DART Equivalent to MPI allreduce.
dart_ret_t dart_type_create_custom(size_t num_bytes, dart_datatype_t *newtype)
Create a custom data type of size num_bytes bytes.
Type trait for mapping to DART data types.
struct dash::unit_id< dash::local_unit, dart_team_unit_t > team_unit_t
Unit ID to use for team-local IDs.
Shared access to a value in global memory across a team.
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.
dart_ret_t dart_op_create(dart_operator_t op, void *userdata, bool commute, dart_datatype_t dtype, bool dtype_is_tmp, dart_operation_t *new_op)
Create a new operation new_op that can be used in collective reduction operations, i.e., dart_reduce, dart_allreduce.