/* parmap_test -- test parmap */
-/* Copyright (c) 2007-2018. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2007-2020. The SimGrid Team. All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/internal_config.h" // HAVE_FUTEX_H
-#include <simgrid/msg.h>
+#include <simgrid/s4u/Engine.hpp>
#include <xbt.h>
#include <xbt/parmap.hpp>
#include <algorithm>
#include <cstdlib>
#include <numeric> // std::iota
+#include <sstream>
+#include <thread>
#include <vector>
XBT_LOG_NEW_DEFAULT_CATEGORY(parmap_test, "Test for parmap");
return ret;
}
-static void fun_get_id(uintptr_t* arg)
+static void fun_get_id(std::string* arg)
{
- *arg = (uintptr_t)xbt_os_thread_self();
+ std::stringstream ss;
+ ss << std::this_thread::get_id();
+ *arg = ss.str();
xbt_os_sleep(0.05);
}
for (unsigned num_workers = 1; num_workers <= 16; num_workers *= 2) {
const unsigned len = 2 * num_workers;
- simgrid::xbt::Parmap<uintptr_t*> parmap(num_workers, mode);
- std::vector<uintptr_t> a(len);
- std::vector<uintptr_t*> data(len);
+ simgrid::xbt::Parmap<std::string*> parmap(num_workers, mode);
+ std::vector<std::string> a(len);
+ std::vector<std::string*> data(len);
std::iota(begin(data), end(data), &a[0]);
parmap.apply(fun_get_id, data);
std::sort(begin(a), end(a));
- unsigned count = std::distance(begin(a), std::unique(begin(a), end(a)));
+ unsigned count = static_cast<unsigned>(std::distance(begin(a), std::unique(begin(a), end(a))));
if (count != num_workers) {
XBT_CRITICAL("only %u/%u threads did some work", count, num_workers);
ret = 1;
{
int status = 0;
xbt_log_control_set("parmap_test.fmt:[%c/%p]%e%m%n");
- MSG_init(&argc, argv);
+ simgrid::s4u::Engine e(&argc, argv);
SIMIX_context_set_nthreads(16); // dummy value > 1
XBT_INFO("Basic testing posix");