/* 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 "simgrid/s4u/Host.hpp"
-#include <climits>
-
-#include "src/simix/smx_private.h"
+#include "smpi_comm.hpp"
#include "private.h"
#include "private.hpp"
-#include "smpi_comm.hpp"
+#include "simgrid/s4u/Host.hpp"
#include "smpi_coll.hpp"
#include "smpi_datatype.hpp"
#include "smpi_process.hpp"
#include "smpi_request.hpp"
#include "smpi_status.hpp"
#include "smpi_win.hpp"
+#include "src/simix/smx_private.h"
+#include <algorithm>
+#include <climits>
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_comm, smpi, "Logging specific to SMPI (comm)");
}
}
-static int compare_ints (const void *a, const void *b)
-{
- const int *da = static_cast<const int *>(a);
- const int *db = static_cast<const int *>(b);
-
- return static_cast<int>(*da > *db) - static_cast<int>(*da < *db);
-}
-
void Comm::init_smp(){
int leader = -1;
leader_group_size++;
}
}
- qsort(leader_list, leader_group_size, sizeof(int),compare_ints);
+ std::sort(leader_list, leader_list + leader_group_size);
MPI_Group leaders_group = new Group(leader_group_size);
XBT_LOG_NEW_DEFAULT_CATEGORY(flatifier, "Logging specific to this platform parsing tool");
-static int name_compare_hosts(const void *n1, const void *n2)
-{
- return std::strcmp(sg_host_get_name(*(sg_host_t *) n1), sg_host_get_name(*(sg_host_t *) n2));
-}
-
-static int name_compare_links(const void *n1, const void *n2)
-{
- return std::strcmp(sg_link_name(*(SD_link_t *) n1),sg_link_name(*(SD_link_t *) n2));
-}
-
static bool parse_cmdline(int* timings, char** platformFile, int argc, char** argv)
{
bool parse_ok = true;
// Hosts
unsigned int totalHosts = sg_host_count();
sg_host_t* hosts = sg_host_list();
- std::qsort((void*)hosts, totalHosts, sizeof(sg_host_t), name_compare_hosts);
+ std::sort(hosts, hosts + totalHosts,
+ [](sg_host_t a, sg_host_t b) { return strcmp(sg_host_get_name(a), sg_host_get_name(b)) < 0; });
for (unsigned int i = 0; i < totalHosts; i++) {
std::printf(" <host id=\"%s\" speed=\"%.0f\"", hosts[i]->getCname(), sg_host_speed(hosts[i]));
unsigned int totalLinks = sg_link_count();
simgrid::s4u::Link** links = sg_link_list();
- std::qsort((void*)links, totalLinks, sizeof(SD_link_t), name_compare_links);
+ std::sort(links, links + totalLinks,
+ [](simgrid::s4u::Link* a, simgrid::s4u::Link* b) { return strcmp(sg_link_name(a), sg_link_name(b)) < 0; });
for (unsigned int i = 0; i < totalLinks; i++) {
simgrid::s4u::Link* link = links[i];