xbt_dynar_t build_hostlist_from_hostcount(int hostcount)
{
xbt_dynar_t host_list = xbt_dynar_new(sizeof(char*), xbt_free_ref);
- int i;
-
- for (i = 1; i <= hostcount; i++) {
+ for (int i = 1; i <= hostcount; i++) {
char *hostname = bprintf("host%d", i);
XBT_DEBUG("%s", hostname);
xbt_dynar_push(host_list, &hostname);
int broadcaster_build_chain(broadcaster_t bc)
{
msg_task_t task = NULL;
- char **cur = (char**)xbt_dynar_iterator_next(bc->it);
- const char *me = "host0"; /* FIXME: hardcoded*/ /*MSG_host_get_name(MSG_host_self());*/
- const char *current_host = NULL;
- const char *prev = NULL;
- const char *next = NULL;
- const char *last = NULL;
+ char** cur = (char**)xbt_dynar_iterator_next(bc->it);
+ const char* me = MSG_host_get_name(MSG_host_self());
+ const char* current_host = NULL;
+ const char* prev = NULL;
+ const char* next = NULL;
+ const char* last = NULL;
/* Build the chain if there's at least one peer */
if (cur != NULL) {
int broadcaster_send_file(broadcaster_t bc)
{
- const char *me = "host0"; /* FIXME: hardcoded*/ /*MSG_host_get_name(MSG_host_self());*/
- //msg_comm_t comm = NULL;
+ const char* me = MSG_host_get_name(MSG_host_self());
msg_task_t task = NULL;
bc->current_piece = 0;
/* Destroy iterator and hostlist */
xbt_dynar_iterator_delete(bc->it);
xbt_dynar_free(&bc->pending_sends);
- xbt_dynar_free(&bc->host_list); /* FIXME: host names are not free'd */
+ xbt_dynar_free(&bc->host_list);
xbt_free(bc);
}
it->list = list;
it->length = xbt_dynar_length(list);
- it->indices_list = criteria_fn(it->length); //xbt_dynar_new(sizeof(int), NULL);
+ it->indices_list = criteria_fn(it->length); // Creates and fills a dynar of int
it->criteria_fn = criteria_fn;
it->current = 0;
xbt_dynar_t forward_indices_list(int size)
{
xbt_dynar_t indices_list = xbt_dynar_new(sizeof(int), NULL);
- int i;
- for (i = 0; i < size; i++)
+ for (int i = 0; i < size; i++)
xbt_dynar_push_as(indices_list, int, i);
return indices_list;
}
{}
void operator()() const
{
+ char noarg[] = {'\0'};
const int argc = args_->size();
std::vector<std::string> args = *args_;
std::unique_ptr<char*[]> argv(new char*[argc + 1]);
for (int i = 0; i != argc; ++i)
- argv[i] = args[i].empty() ? const_cast<char*>(""): &args[i].front();
+ argv[i] = args[i].empty() ? noarg : &args[i].front();
argv[argc] = nullptr;
code_(argc, argv.get());
}
class BypassRoute {
public:
explicit BypassRoute(NetPoint* gwSrc, NetPoint* gwDst) : gw_src(gwSrc), gw_dst(gwDst) {}
- const NetPoint* gw_src;
- const NetPoint* gw_dst;
+ NetPoint* gw_src;
+ NetPoint* gw_dst;
std::vector<surf::LinkImpl*> links;
};
"calls to getRoute",
src->cname(), dst->cname(), bypassedRoute->links.size());
if (src != key.first)
- getGlobalRoute(src, const_cast<NetPoint*>(bypassedRoute->gw_src), links, latency);
+ getGlobalRoute(src, bypassedRoute->gw_src, links, latency);
for (surf::LinkImpl* link : bypassedRoute->links) {
links->push_back(link);
if (latency)
*latency += link->latency();
}
if (dst != key.second)
- getGlobalRoute(const_cast<NetPoint*>(bypassedRoute->gw_dst), dst, links, latency);
+ getGlobalRoute(bypassedRoute->gw_dst, dst, links, latency);
return true;
}
XBT_DEBUG("No bypass route from '%s' to '%s'.", src->cname(), dst->cname());
xbt_getpid = &MSG_process_self_PID;
if (!msg_global) {
- msg_global = xbt_new0(s_MSG_Global_t, 1);
+ msg_global = new s_MSG_Global_t();
xbt_cfg_register_boolean("msg/debug-multiple-use", "no", _sg_cfg_cb_msg_debug_multiple_use,
"Print backtraces of both processes when there is a conflict of multiple use of a task");
TRACE_surf_resource_utilization_release();
TRACE_end();
- free(msg_global);
+ delete msg_global;
msg_global = nullptr;
}
if (strcmp(storage_priv_src->hostname, MSG_host_self()->cname())) {
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_priv_src->hostname, read_size);
- msg_host_t *m_host_list = nullptr;
- m_host_list = xbt_new0(msg_host_t, 2);
-
- m_host_list[0] = MSG_host_self();
- m_host_list[1] = attached_host;
- double flops_amount[] = { 0, 0};
- double bytes_amount[] = { 0, 0, static_cast<double>(read_size), 0 };
+ msg_host_t m_host_list[] = {MSG_host_self(), attached_host};
+ double flops_amount[] = {0, 0};
+ double bytes_amount[] = {0, 0, static_cast<double>(read_size), 0};
msg_task_t task = MSG_parallel_task_create("file transfer for read", 2, m_host_list, flops_amount, bytes_amount,
nullptr);
msg_error_t transfer = MSG_parallel_task_execute(task);
MSG_task_destroy(task);
- xbt_free(m_host_list);
+
if(transfer != MSG_OK){
if (transfer == MSG_HOST_FAILURE)
XBT_WARN("Transfer error, %s remote host just turned off!", attached_host->cname());
if (strcmp(storage_priv_src->hostname, MSG_host_self()->cname())) {
/* the file is hosted on a remote host, initiate a communication between src and dest hosts for data transfer */
XBT_DEBUG("File is on %s remote host, initiate data transfer of %llu bytes.", storage_priv_src->hostname, size);
- msg_host_t *m_host_list = nullptr;
- m_host_list = xbt_new0(msg_host_t, 2);
-
- m_host_list[0] = MSG_host_self();
- m_host_list[1] = attached_host;
- double flops_amount[] = { 0, 0 };
- double bytes_amount[] = { 0, static_cast<double>(size), 0, 0 };
+ msg_host_t m_host_list[] = {MSG_host_self(), attached_host};
+ double flops_amount[] = {0, 0};
+ double bytes_amount[] = {0, static_cast<double>(size), 0, 0};
msg_task_t task = MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount,
nullptr);
msg_error_t transfer = MSG_parallel_task_execute(task);
MSG_task_destroy(task);
- free(m_host_list);
+
if(transfer != MSG_OK){
if (transfer == MSG_HOST_FAILURE)
XBT_WARN("Transfer error, %s remote host just turned off!", attached_host->cname());
char *mount_name;
char *storage_name;
xbt_dict_foreach(storage_list,cursor,mount_name,storage_name){
- char* file_mount_name = static_cast<char *>(xbt_malloc ((strlen(mount_name)+1)));
- strncpy(file_mount_name,fullpath,strlen(mount_name)+1);
+ char* file_mount_name = static_cast<char*>(xbt_malloc(strlen(mount_name) + 1));
+ strncpy(file_mount_name, fullpath, strlen(mount_name) + 1);
file_mount_name[strlen(mount_name)] = '\0';
- if(!strcmp(file_mount_name,mount_name) && strlen(mount_name)>longest_prefix_length){
+ if (!strcmp(file_mount_name, mount_name) && strlen(mount_name) > longest_prefix_length) {
/* The current mount name is found in the full path and is bigger than the previous*/
longest_prefix_length = strlen(mount_name);
- storage_dest = (msg_storage_t) xbt_lib_get_elm_or_null(storage_lib, storage_name);
+ storage_dest = (msg_storage_t)xbt_lib_get_elm_or_null(storage_lib, storage_name);
}
xbt_free(file_mount_name);
}
XBT_DEBUG("Initiate data transfer of %llu bytes between %s and %s.", read_size, storage_priv_src->hostname,
host_name_dest);
- msg_host_t *m_host_list = nullptr;
- m_host_list = xbt_new0(msg_host_t, 2);
-
- m_host_list[0] = attached_host;
- m_host_list[1] = host_dest;
- double flops_amount[] = { 0, 0 };
- double bytes_amount[] = { 0, static_cast<double>(read_size), 0, 0 };
+ msg_host_t m_host_list[] = {attached_host, host_dest};
+ double flops_amount[] = {0, 0};
+ double bytes_amount[] = {0, static_cast<double>(read_size), 0, 0};
msg_task_t task =
MSG_parallel_task_create("file transfer for write", 2, m_host_list, flops_amount, bytes_amount, nullptr);
msg_error_t transfer = MSG_parallel_task_execute(task);
MSG_task_destroy(task);
- xbt_free(m_host_list);
+
if(transfer != MSG_OK){
if (transfer == MSG_HOST_FAILURE)
XBT_WARN("Transfer error, %s remote host just turned off!", host_name_dest);
static int smpi_run_entry_point(smpi_entry_point_type entry_point, std::vector<std::string> args)
{
+ char noarg[] = {'\0'};
const int argc = args.size();
std::unique_ptr<char*[]> argv(new char*[argc + 1]);
for (int i = 0; i != argc; ++i)
- argv[i] = args[i].empty() ? const_cast<char*>(""): &args[i].front();
+ argv[i] = args[i].empty() ? noarg : &args[i].front();
argv[argc] = nullptr;
int res = entry_point(argc, argv.get());
NetworkAction *action;
double init_rate;
ActiveComm() : destination(nullptr),action(nullptr),init_rate(-1){};
- ~ActiveComm(){};
+ virtual ~ActiveComm() = default;
};
class IBNode{
//number of comms the node is receiving
int nbActiveCommsDown;
explicit IBNode(int id) : id(id),nbActiveCommsDown(0){};
- ~IBNode(){};
+ virtual ~IBNode() = default;
};
class XBT_PRIVATE NetworkIBModel : public NetworkSmpiModel {
#include "storage_interface.hpp"
#include "surf_private.h"
-#include "xbt/file.h" /* xbt_getline */
#include <boost/algorithm/string.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/split.hpp>
XBT_CDEBUG(xbt_dict_cursor, "next element: %p", current);
}
- while (current == NULL && ++line <= cursor->dict->table_size) {
+ while (current == NULL && (line + 1) <= cursor->dict->table_size) {
+ line++;
XBT_CDEBUG(xbt_dict_cursor, "current is NULL, take the next line");
current = cursor->dict->table[line];
XBT_CDEBUG(xbt_dict_cursor, "element in the next line: %p", current);
*/
ssize_t xbt_getline(char **buf, size_t *n, FILE *stream)
{
- ssize_t i;
- int ch;
-
- ch = getc(stream);
+ int ch = getc(stream);
if (ferror(stream) || feof(stream))
return -1;
*buf = xbt_malloc(*n);
}
- i = 0;
+ ssize_t i = 0;
do {
- if (i == *n)
- *buf = xbt_realloc(*buf, *n += 512);
- (*buf)[i++] = ch;
+ if (i == *n) {
+ *n += 512;
+ *buf = xbt_realloc(*buf, *n);
+ }
+ (*buf)[i] = ch;
+ i++;
} while (ch != '\n' && (ch = getc(stream)) != EOF);
- if (i == *n)
- *buf = xbt_realloc(*buf, *n += 1);
+ if (i == *n) {
+ *n += 1;
+ *buf = xbt_realloc(*buf, *n);
+ }
(*buf)[i] = '\0';
return i;
/* I want the standard error to go below 0.1 second.
* Two tests at least will be run (count is not > 0) */
SMPI_SAMPLE_LOCAL(0, 0.1) {
- if (verbose || n++ < 2) {
+ if (verbose || n < 2) {
+ n++;
if (verbose)
fprintf(stderr, "(%12.6f)", MPI_Wtime());
else
static void test(int nb_cnst, int nb_var, int nb_elem, unsigned int pw_base_limit, unsigned int pw_max_limit,
float rate_no_limit, int max_share, int mode)
{
- lmm_constraint_t *cnst = xbt_new0(lmm_constraint_t, nb_cnst);
- lmm_variable_t *var = xbt_new0(lmm_variable_t, nb_var);
- int *used = xbt_new0(int, nb_cnst);
+ lmm_constraint_t cnst[nb_cnst];
+ lmm_variable_t var[nb_var];
+ int used[nb_cnst];
int concurrency_share;
lmm_system_t Sys = lmm_system_new(1);
for (int i = 0; i < nb_var; i++)
lmm_variable_free(Sys, var[i]);
lmm_system_free(Sys);
- free(cnst);
- free(var);
- free(used);
}
unsigned int TestClasses [][4]=
fun:smpi_simulated_main_
}
+#SMPI leaks the dlopen handle used for loading the program
+{
+ dlopen handle leaks (1/2)
+ Memcheck:Leak
+ match-leak-kinds:reachable
+ fun:malloc
+ ...
+ fun:dlopen@@GLIBC_*
+ ...
+ fun:main
+}
+
+{
+ dlopen handle leaks (2/2)
+ Memcheck:Leak
+ match-leak-kinds:reachable
+ fun:calloc
+ ...
+ fun:dlopen@@GLIBC_*
+ ...
+ fun:main
+}
+
# Memory leaks appearing to be in libcgraph. They can be seen with the
# following simple program:
# ,----