- gfortran
- libboost-dev
- libboost-all-dev
+ - libdw-dev
+ - libevent-dev
+ - libunwind8-dev
coverity_scan:
project:
name: "simgrid/simgrid"
# - ls -lR $TRAVIS_BUILD_DIR/LuaInstall
script:
- - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew update ; fi
- - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew install python3; fi
- - cmake -Denable_documentation=OFF -Denable_coverage=ON -Denable_java=ON -Denable_model-checking=OFF -Denable_lua=OFF -Denable_compile_optimizations=ON -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_compile_warnings=ON .
+ - test "$TRAVIS_OS_NAME" == "osx" && brew update
+ - test "$TRAVIS_OS_NAME" == "osx" && brew install python3
+ - test "$TRAVIS_OS_NAME" == "osx" && cmake -Denable_model-checking=OFF -Denable_documentation=OFF -Denable_coverage=ON -Denable_java=ON -Denable_lua=OFF -Denable_compile_optimizations=ON -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_compile_warnings=ON .
+ - test "$TRAVIS_OS_NAME" == "linux" && cmake -Denable_model-checking=ON -Denable_documentation=OFF -Denable_coverage=ON -Denable_java=ON -Denable_lua=OFF -Denable_compile_optimizations=ON -Denable_smpi=ON -Denable_smpi_MPICH3_testsuite=OFF -Denable_compile_warnings=ON .
# run make in the sonar wrapper && run the tests before sonar to get coverage info
- ./tools/internal/travis-sonarqube.sh make VERBOSE=1
# if sonar was not run (and if the build succeeded), run the tests manually
- New algorithm to privatize globals: dlopen, with dynamic loading tricks
- New option: smpi/keep-temps to not cleanup temp files
- XBT/Replay:
- - New function xbt_replay_action_get():
+ XBT
+ - Replay: New function xbt_replay_action_get():
Retrieve the function previously associated to an event type.
+ - DROPPED FUNCTION: xbt_str_varsubst()
+ - DROPPED MODULE: strbuff. We don't need it anymore.
-- Release target: June 21 2017 -- Da SimGrid team <simgrid-devel@lists.gforge.inria.fr>
--- a/tools/cmake/UnitTesting.cmake
+++ b/tools/cmake/UnitTesting.cmake
@@ -11,6 +11,7 @@ set(FILES_CONTAINING_UNITTESTS
- src/xbt/xbt_strbuff.c
src/xbt/xbt_sha.c
src/xbt/config.c
+ src/xbt/plouf.c
- \ref XBT_dict
- \ref XBT_swag
- \ref XBT_heap
- - @ref xbt_strbuff
- \ref XBT_misc
- \ref XBT_graph
- %%L: line number where the log event was raised (LOG4J compatible)
- %%M: function name (LOG4J compatible -- called method name here of course).
- - %%b: full backtrace (Called %%throwable in LOG4J).
- Defined only under windows or when using the GNU libc because backtrace() is not defined
- elsewhere, and we only have a fallback for windows boxes, not mac ones for example.
- - %%B: short backtrace (only the first line of the %%b).
- Called %%throwable{short} in LOG4J; defined where %%b is.
-
- %%d: date (UNIX-like epoch)
- %%r: application age (time elapsed since the beginning of the application)
poorVictim.kill();
Msg.info("Ok, goodbye now.");
- exit(); // This would be more useful if not placed on the last line
+ // The actor can also commit a suicide with the following command
+ exit(); // This will forcefully stop the current actor
+ // Of course, it's not useful here at the end of the main function, but that's for the example (and to check that this still works in the automated tests)
}
}
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;
}
{
Comm() : Activity() {}
public:
- ~Comm() override;
+ virtual ~Comm() = default;
/*! take a range of s4u::Comm* (last excluded) and return when one of them is finished. The return value is an
* iterator on the finished Comms. */
XBT_PUBLIC(void) smpi_execute_flops(double flops);
XBT_PUBLIC(void) smpi_execute(double duration);
+XBT_PUBLIC(void) smpi_execute_benched(double duration);
XBT_PUBLIC(double) smpi_get_host_power_peak_at(int pstate_index);
XBT_PUBLIC(double) smpi_get_host_current_power_peak();
#include <xbt/log.h>
#include <xbt/module.h>
-#include <xbt/strbuff.h>
#include <xbt/dynar.h>
#include <xbt/dict.h>
simgrid::xbt::WithContextException(throwpoint, simgrid::xbt::backtrace())
{}
- ~xbt_ex() override;
+ ~xbt_ex() = default;
/** Category (what went wrong) */
xbt_errcat_t category = unknown_error;
{}
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());
}
SG_BEGIN_DECL()
typedef struct {
- unsigned int lines, rows;
+ unsigned int lines;
+ unsigned int rows;
unsigned long elmsize;
char *data;
+++ /dev/null
-/* Copyright (c) 2016. 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. */
-
-#ifndef SIMGRIX_XBT_MEMORY_HPP
-#define SIMGRIX_XBT_MEMORY_HPP
-
-#include <memory>
-
-namespace simgrid {
-namespace xbt {
-
-}
-}
-
-#endif
XBT_PUBLIC(char *) xbt_str_join_array(const char *const *strs, const char *sep);
XBT_PUBLIC(void) xbt_str_subst(char *str, char from, char to, int amount);
-XBT_PUBLIC(char *) xbt_str_varsubst(const char *str, xbt_dict_t patterns);
XBT_PUBLIC(long int) xbt_str_parse_int(const char* str, const char* error_msg);
XBT_PUBLIC(double) xbt_str_parse_double(const char* str, const char* error_msg);
+++ /dev/null
-/* strbuff -- string buffers */
-
-/* Copyright (c) 2007-2011, 2013-2014. 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. */
-
-#ifndef XBT_STRBUFF_H
-#define XBT_STRBUFF_H
-
-#include "xbt/sysdep.h"
-#include "xbt/function_types.h"
-#include "xbt/log.h"
-#include "xbt/str.h"
-#include "xbt/dict.h"
-
-SG_BEGIN_DECL()
-
-/** @defgroup xbt_strbuff String buffers
- * @ingroup XBT_adt
- *
- * This data container is very similar to the Java StringBuffer:
- * that's a string to which you can add content with a lesser performance
- * penalty than if you recreate a new string from scratch. Once done building
- * your string, you must retrieve the content and free its container.
- *
- * @{
- */
-
-/** @brief Buffer data container **/
-typedef struct xbt_strbuff {
- char *data;
- int used;
- int size;
-} s_xbt_strbuff_t;
-typedef s_xbt_strbuff_t* xbt_strbuff_t;
-
-XBT_PUBLIC(void) xbt_strbuff_clear(xbt_strbuff_t b);
-XBT_PUBLIC(xbt_strbuff_t) xbt_strbuff_new(void);
-XBT_PUBLIC(xbt_strbuff_t) xbt_strbuff_new_from(const char *s);
-XBT_PUBLIC(void) xbt_strbuff_free(xbt_strbuff_t b);
-XBT_PUBLIC(void) xbt_strbuff_free_container(xbt_strbuff_t b);
-XBT_PUBLIC(void) xbt_strbuff_append(xbt_strbuff_t b, const char *toadd);
-XBT_PUBLIC(void) xbt_strbuff_printf(xbt_strbuff_t b, const char *fmt, ...);
-XBT_PUBLIC(void) xbt_strbuff_chomp(xbt_strbuff_t b);
-XBT_PUBLIC(void) xbt_strbuff_trim(xbt_strbuff_t b);
-XBT_PUBLIC(void) xbt_strbuff_varsubst(xbt_strbuff_t b, xbt_dict_t patterns);
-
-/** @} */
-SG_END_DECL()
-#endif
# Disable some rules on some files
-sonar.issue.ignore.multicriteria=j1,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b
+sonar.issue.ignore.multicriteria=j1,jni1,jni2,c1,c2a,c2b,c3,c4a,c4b,f1
# The Object.finalize() method should not be overriden
# But we need to clean the native memory with JNI
sonar.issue.ignore.multicriteria.jni2.ruleKey=cpp:S1172
sonar.issue.ignore.multicriteria.jni2.resourceKey=src/bindings/java/*.cpp
+
# Pointers should not be cast to integral types
# But we need that for jMSG, smpi and other places
sonar.issue.ignore.multicriteria.c1.ruleKey=cpp:S1767
sonar.issue.ignore.multicriteria.c4b.resourceKey=examples/**/*.hpp
+# "reinterpret_cast" should not be used
+# But we need this to interface C and Fortran
+sonar.issue.ignore.multicriteria.f1.ruleKey=cpp:S3630
+sonar.issue.ignore.multicriteria.f1.resourceKey=src/smpi/smpi_f77.cpp
+
+
# Exclude some files from the analysis:
# - our unit tests
# - the tests that we borrowed elsewhere (MPICH and ISP)
+++ /dev/null
-/* Copyright (c) 2010-2015. 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/instr/instr_private.h"
-#include "xbt/virtu.h" /* sg_cmdline */
-#include "xbt/xbt_os_time.h"
-#include "simgrid/sg_config.h"
-
-#include <errno.h>
-#include <string.h>
-#include <sys/stat.h>
-
-#ifdef WIN32
-#include <direct.h> // _mkdir
-#endif
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_TI_trace, instr_trace, "tracing event system");
-
-extern FILE *tracing_file;
-double prefix=0.0;
-
-xbt_dict_t tracing_files = nullptr;
-
-extern s_instr_trace_writer_t active_writer;
-
-void TRACE_TI_init()
-{
- active_writer.print_PushState = &print_TIPushState;
- active_writer.print_CreateContainer = &print_TICreateContainer;
- active_writer.print_DestroyContainer = &print_TIDestroyContainer;
-}
-
-void TRACE_TI_start()
-{
- char *filename = TRACE_get_filename();
- tracing_file = fopen(filename, "w");
- if (tracing_file == nullptr) {
- THROWF(system_error, 1, "Tracefile %s could not be opened for writing.", filename);
- }
-
- XBT_DEBUG("Filename %s is open for writing", filename);
-
- /* output one line comment */
- dump_comment(TRACE_get_comment());
-
- /* output comment file */
- dump_comment_file(TRACE_get_comment_file());
-}
-
-void TRACE_TI_end()
-{
- xbt_dict_free(&tracing_files);
- fclose(tracing_file);
- char *filename = TRACE_get_filename();
- XBT_DEBUG("Filename %s is closed", filename);
-}
-
-void print_TICreateContainer(paje_event_t event)
-{
- //if we are in the mode with only one file
- static FILE *temp = nullptr;
-
- if (tracing_files == nullptr) {
- tracing_files = xbt_dict_new_homogeneous(nullptr);
- //generate unique run id with time
- prefix = xbt_os_time();
- }
-
- if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || temp == nullptr) {
- char *folder_name = bprintf("%s_files", TRACE_get_filename());
- char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, ((createContainer_t) event->data)->container->name);
-#ifdef WIN32
- _mkdir(folder_name);
-#else
- mkdir(folder_name, S_IRWXU | S_IRWXG | S_IRWXO);
-#endif
- temp = fopen(filename, "w");
- xbt_assert(temp, "Tracefile %s could not be opened for writing: %s", filename, strerror(errno));
- fprintf(tracing_file, "%s\n", filename);
-
- xbt_free(folder_name);
- xbt_free(filename);
- }
-
- xbt_dict_set(tracing_files, ((createContainer_t) event->data)->container->name, (void *) temp, nullptr);
-}
-
-void print_TIDestroyContainer(paje_event_t event)
-{
- if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file")|| xbt_dict_length(tracing_files) == 1) {
- FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, ((destroyContainer_t) event->data)->container->name);
- fclose(f);
- }
- xbt_dict_remove(tracing_files, ((destroyContainer_t) event->data)->container->name);
-}
-
-void print_TIPushState(paje_event_t event)
-{
- int i;
-
- //char* function=nullptr;
- if (((pushState_t) event->data)->extra == nullptr)
- return;
- instr_extra_data extra = (instr_extra_data) (((pushState_t) event->data)->extra);
-
- char *process_id = nullptr;
- //FIXME: dirty extract "rank-" from the name, as we want the bare process id here
- if (strstr(((pushState_t) event->data)->container->name, "rank-") == nullptr)
- process_id = xbt_strdup(((pushState_t) event->data)->container->name);
- else
- process_id = xbt_strdup(((pushState_t) event->data)->container->name + 5);
-
- FILE* trace_file = (FILE* )xbt_dict_get(tracing_files, ((pushState_t) event->data)->container->name);
-
- switch (extra->type) {
- case TRACING_INIT:
- fprintf(trace_file, "%s init\n", process_id);
- break;
- case TRACING_FINALIZE:
- fprintf(trace_file, "%s finalize\n", process_id);
- break;
- case TRACING_SEND:
- fprintf(trace_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
- break;
- case TRACING_ISEND:
- fprintf(trace_file, "%s Isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
- break;
- case TRACING_RECV:
- fprintf(trace_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
- break;
- case TRACING_IRECV:
- fprintf(trace_file, "%s Irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
- break;
- case TRACING_TEST:
- fprintf(trace_file, "%s test\n", process_id);
- break;
- case TRACING_WAIT:
- fprintf(trace_file, "%s wait\n", process_id);
- break;
- case TRACING_WAITALL:
- fprintf(trace_file, "%s waitAll\n", process_id);
- break;
- case TRACING_BARRIER:
- fprintf(trace_file, "%s barrier\n", process_id);
- break;
- case TRACING_BCAST: // rank bcast size (root) (datatype)
- fprintf(trace_file, "%s bcast %d ", process_id, extra->send_size);
- if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
- fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
- fprintf(trace_file, "\n");
- break;
- case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype)
- fprintf(trace_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size);
- if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
- fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
- fprintf(trace_file, "\n");
- break;
- case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype)
- fprintf(trace_file, "%s allReduce %d %f %s\n", process_id, extra->send_size, extra->comp_size, extra->datatype1);
- break;
- case TRACING_ALLTOALL: // rank alltoall send_size recv_size (sendtype) (recvtype)
- fprintf(trace_file, "%s allToAll %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->datatype1,
- extra->datatype2);
- break;
- case TRACING_ALLTOALLV: // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype)
- fprintf(trace_file, "%s allToAllV %d ", process_id, extra->send_size);
- for (i = 0; i < extra->num_processes; i++)
- fprintf(trace_file, "%d ", extra->sendcounts[i]);
- fprintf(trace_file, "%d ", extra->recv_size);
- for (i = 0; i < extra->num_processes; i++)
- fprintf(trace_file, "%d ", extra->recvcounts[i]);
- fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
- break;
- case TRACING_GATHER: // rank gather send_size recv_size root (sendtype) (recvtype)
- fprintf(trace_file, "%s gather %d %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->root,
- extra->datatype1, extra->datatype2);
- break;
- case TRACING_ALLGATHERV: // rank allgatherv send_size [recvcounts] (sendtype) (recvtype)
- fprintf(trace_file, "%s allGatherV %d ", process_id, extra->send_size);
- for (i = 0; i < extra->num_processes; i++)
- fprintf(trace_file, "%d ", extra->recvcounts[i]);
- fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
- break;
- case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype)
- fprintf(trace_file, "%s reduceScatter ", process_id);
- for (i = 0; i < extra->num_processes; i++)
- fprintf(trace_file, "%d ", extra->recvcounts[i]);
- fprintf(trace_file, "%f %s\n", extra->comp_size, extra->datatype1);
- break;
- case TRACING_COMPUTING:
- fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size);
- break;
- case TRACING_SLEEPING:
- fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration);
- break;
- case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype)
- fprintf(trace_file, "%s gatherV %d ", process_id, extra->send_size);
- for (i = 0; i < extra->num_processes; i++)
- fprintf(trace_file, "%d ", extra->recvcounts[i]);
- fprintf(trace_file, "%d %s %s\n", extra->root, extra->datatype1, extra->datatype2);
- break;
- case TRACING_WAITANY:
- case TRACING_SENDRECV:
- case TRACING_SCATTER:
- case TRACING_SCATTERV:
- case TRACING_ALLGATHER:
- case TRACING_SCAN:
- case TRACING_EXSCAN:
- case TRACING_COMM_SIZE:
- case TRACING_COMM_SPLIT:
- case TRACING_COMM_DUP:
- case TRACING_SSEND:
- case TRACING_ISSEND:
- default:
- XBT_WARN ("Call from %s impossible to translate into replay command : Not implemented (yet)",
- ((pushState_t) event->data)->value->name);
- break;
- }
-
- if (extra->recvcounts != nullptr)
- xbt_free(extra->recvcounts);
- if (extra->sendcounts != nullptr)
- xbt_free(extra->sendcounts);
- xbt_free(process_id);
- xbt_free(extra);
-}
static bool trace_configured = false;
static bool trace_active = false;
+instr_fmt_type_t instr_fmt_type = instr_fmt_paje;
+
static void TRACE_getopts()
{
trace_enabled = xbt_cfg_get_boolean(OPT_TRACING);
const char* format = xbt_cfg_get_string(OPT_TRACING_FORMAT);
XBT_DEBUG("Tracing format %s\n", format);
if(!strcmp(format, "Paje")){
- TRACE_paje_init();
TRACE_paje_start();
}else if (!strcmp(format, "TI")){
- TRACE_TI_init();
+ instr_fmt_type = instr_fmt_TI;
TRACE_TI_start();
}else{
xbt_die("Unknown trace format :%s ", format);
val_t value = PJ_value_get (mark_value, type);
XBT_DEBUG("MARK %s %s", mark_type, mark_value);
- new_pajeNewEvent (MSG_get_clock(), PJ_container_get_root(), type, value);
+ new NewEvent (MSG_get_clock(), PJ_container_get_root(), type, value);
}
/** \ingroup TRACE_mark
type_t type = PJ_type_get (variable, container->type);
switch (what){
case INSTR_US_SET:
- new_pajeSetVariable(time, container, type, value);
+ new SetVariableEvent(time, container, type, value);
break;
case INSTR_US_ADD:
- new_pajeAddVariable(time, container, type, value);
+ new AddVariableEvent(time, container, type, value);
break;
case INSTR_US_SUB:
- new_pajeSubVariable(time, container, type, value);
+ new SubVariableEvent(time, container, type, value);
break;
default:
THROW_IMPOSSIBLE;
container_t container = PJ_container_get(host);
type_t type = PJ_type_get (state, container->type);
val_t val = PJ_value_get_or_new (value, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */
- new_pajeSetState(MSG_get_clock(), container, type, val);
+ new SetStateEvent(MSG_get_clock(), container, type, val);
}
/** \ingroup TRACE_user_variables
container_t container = PJ_container_get(host);
type_t type = PJ_type_get (state, container->type);
val_t val = PJ_value_get_or_new (value, nullptr, type); /* if user didn't declare a value with a color, use nullptr color */
- new_pajePushState(MSG_get_clock(), container, type, val);
+ new PushStateEvent(MSG_get_clock(), container, type, val);
}
/** \ingroup TRACE_user_variables
{
container_t container = PJ_container_get(host);
type_t type = PJ_type_get (state, container->type);
- new_pajePopState(MSG_get_clock(), container, type);
+ new PopStateEvent(MSG_get_clock(), container, type);
}
/** \ingroup TRACE_user_variables
{
container_t container = PJ_container_get(host);
type_t type = PJ_type_get (state, container->type);
- new_pajeResetState(MSG_get_clock(), container, type);
+ new ResetStateEvent(MSG_get_clock(), container, type);
}
/** \ingroup TRACE_API
newContainer->children = xbt_dict_new_homogeneous(nullptr);
if (newContainer->father){
xbt_dict_set(newContainer->father->children, newContainer->name, newContainer, nullptr);
- new_pajeCreateContainer (newContainer);
+ new CreateContainerEvent(newContainer);
}
//register all kinds by name
if (!TRACE_disable_destroy() && container != PJ_container_get_root()){
//do not trace the container destruction if user requests
//or if the container is root
- new_pajeDestroyContainer(container);
+ new DestroyContainerEvent(container);
}
//remove it from allContainers data structure
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/instr/instr_private.h"
+#include "src/instr/instr_smpi.h"
+#include "src/smpi/private.hpp"
+#include "typeinfo"
#include "xbt/virtu.h" /* sg_cmdline */
+#include "simgrid/sg_config.h"
+
#include <sstream>
+#include <vector>
#include <iomanip> /** std::setprecision **/
-#include "simgrid/sg_config.h"
+#include <sys/stat.h>
+#ifdef WIN32
+#include <direct.h> // _mkdir
+#endif
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_trace, instr_trace, "tracing event system");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_trace, instr, "tracing event system");
-extern FILE * tracing_file;
extern s_instr_trace_writer_t active_writer;
static std::stringstream stream;
+FILE *tracing_file = nullptr;
+
+static xbt_dict_t tracing_files = nullptr; // TI specific
+static double prefix=0.0; // TI specific
+
+
+void print_NULL(PajeEvent* event){}
+
+/* The active set of functions for the selected trace format
+ * By default, they all do nothing, hence the print_NULL to avoid segfaults */
-static void print_paje_debug(std::string functionName, paje_event_t event) {
- XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event->event_type, TRACE_precision(),
- event->timestamp);
+s_instr_trace_writer_t active_writer = {&print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL,
+ &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL,
+ &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL};
+
+std::vector<PajeEvent*> buffer;
+void buffer_debug(std::vector<PajeEvent*> *buf);
+
+void dump_comment (const char *comment)
+{
+ if (!strlen(comment)) return;
+ fprintf (tracing_file, "# %s\n", comment);
}
-template<typename T> static void init_stream(paje_event_t event) {
- stream << std::fixed << std::setprecision(TRACE_precision());
- stream << (int) event->event_type;
+void dump_comment_file (const char *filename)
+{
+ if (!strlen(filename)) return;
+ FILE *file = fopen (filename, "r");
+ if (!file){
+ THROWF (system_error, 1, "Comment file %s could not be opened for reading.", filename);
+ }
+ while (!feof(file)){
+ char c;
+ c = fgetc(file);
+ if (feof(file)) break;
+ fprintf (tracing_file, "# ");
+ while (c != '\n'){
+ fprintf (tracing_file, "%c", c);
+ c = fgetc(file);
+ if (feof(file)) break;
+ }
+ fprintf (tracing_file, "\n");
+ }
+ fclose(file);
+}
+
+double TRACE_last_timestamp_to_dump = 0;
+//dumps the trace file until the timestamp TRACE_last_timestamp_to_dump
+void TRACE_paje_dump_buffer (int force)
+{
+ if (!TRACE_is_enabled()) return;
+ XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump);
+ if (force){
+ for (auto event : buffer){
+ event->print();
+ delete event;
+ }
+ buffer.clear();
+ }else{
+ std::vector<PajeEvent*>::iterator i = buffer.begin();
+ for (auto event :buffer){
+ double head_timestamp = event->timestamp;
+ if (head_timestamp > TRACE_last_timestamp_to_dump)
+ break;
+ event->print();
+ delete event;
+ ++i;
+ }
+ buffer.erase(buffer.begin(), i);
+ }
+ XBT_DEBUG("%s: ends", __FUNCTION__);
+}
+
+void buffer_debug(std::vector<PajeEvent*> *buf);
+void buffer_debug(std::vector<PajeEvent*> *buf) {
+ return;
+ XBT_DEBUG(">>>>>> Dump the state of the buffer. %zu events", buf->size());
+ for (auto event :*buf){
+ event->print();
+ XBT_DEBUG("%p %s", event, stream.str().c_str());
+ stream.str("");
+ stream.clear();
+ }
+ XBT_DEBUG("<<<<<<");
}
static void print_row() {
stream << std::endl;
fprintf(tracing_file, "%s", stream.str().c_str());
+ XBT_DEBUG("Dump %s", stream.str().c_str());
stream.str("");
stream.clear();
}
-static void print_timestamp(paje_event_t event) {
+static void print_timestamp(PajeEvent* event) {
stream << " ";
/* prevent 0.0000 in the trace - this was the behavior before the transition to c++ */
if (event->timestamp < 1e-12)
stream << 0;
else
stream << event->timestamp;
+}
+
+/* internal do the instrumentation module */
+static void insert_into_buffer (PajeEvent* tbi)
+{
+ if (TRACE_buffer() == 0){
+ tbi->print ();
+ delete tbi;
+ return;
+ }
+ buffer_debug(&buffer);
+
+ XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%zu)",
+ __FUNCTION__, (int)tbi->event_type, tbi->timestamp, buffer.size());
+ std::vector<PajeEvent*>::reverse_iterator i;
+ for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
+ PajeEvent* e1 = *i;
+ XBT_DEBUG("compare to %p is of type %d; timestamp:%f", e1,
+ (int)e1->event_type, e1->timestamp);
+ if (e1->timestamp <= tbi->timestamp)
+ break;
+ }
+ buffer.insert(i.base(), tbi);
+ if (i == buffer.rend())
+ XBT_DEBUG("%s: inserted at beginning", __FUNCTION__);
+ else if (i == buffer.rbegin())
+ XBT_DEBUG("%s: inserted at end", __FUNCTION__);
+ else
+ XBT_DEBUG("%s: inserted at pos= %zd from its end", __FUNCTION__,
+ std::distance(buffer.rbegin(),i));
+
+ buffer_debug(&buffer);
}
-template<typename T> static void print_default_pajeLink_row(paje_event_t& event) {
- init_stream<T>(event);
- print_timestamp(event);
- stream << " " << static_cast<T>(event->data)->type->id
- << " " << static_cast<T>(event->data)->container->id
- << " " << static_cast<T>(event->data)->value;
-}
-
-template<typename T> static void print_default_pajeState_row(paje_event_t& event) {
- init_stream<T>(event);
- print_timestamp(event);
- stream << " " << static_cast<T>(event->data)->type->id
- << " " << static_cast<T>(event->data)->container->id;
-}
-
-template<typename T> static void print_default_pajeType_row(paje_event_t& event) {
- init_stream<T>(event);
- stream << " " << static_cast<T>(event->data)->type->id
- << " " << static_cast<T>(event->data)->type->father->id
- << " " << static_cast<T>(event->data)->type->name;
-}
-
-template<typename T> static void print_default_pajeVariable_row(paje_event_t& event) {
- init_stream<T>(event);
- print_timestamp(event);
- stream << " " << static_cast<T>(event->data)->type->id
- << " " << static_cast<T>(event->data)->container->id
- << " " << static_cast<T>(event->data)->value;
-
- print_row();
-}
-
-void TRACE_paje_init() {
- active_writer.print_DefineContainerType = &print_pajeDefineContainerType;
- active_writer.print_DefineVariableType = &print_pajeDefineVariableType;
- active_writer.print_DefineStateType = &print_pajeDefineStateType;
- active_writer.print_DefineEventType = &print_pajeDefineEventType;
- active_writer.print_DefineLinkType = &print_pajeDefineLinkType;
- active_writer.print_DefineEntityValue = &print_pajeDefineEntityValue;
- active_writer.print_CreateContainer = &print_pajeCreateContainer;
- active_writer.print_DestroyContainer = &print_pajeDestroyContainer;
- active_writer.print_SetVariable = &print_pajeSetVariable;
- active_writer.print_AddVariable = &print_pajeAddVariable;
- active_writer.print_SubVariable = &print_pajeSubVariable;
- active_writer.print_SetState = &print_pajeSetState;
- active_writer.print_PushState = &print_pajePushState;
- active_writer.print_PopState = &print_pajePopState;
- active_writer.print_ResetState = &print_pajeResetState;
- active_writer.print_StartLink = &print_pajeStartLink;
- active_writer.print_EndLink = &print_pajeEndLink;
- active_writer.print_NewEvent = &print_pajeNewEvent;
+PajeEvent:: ~PajeEvent()
+{
+ XBT_DEBUG("%s not implemented for %p: event_type=%d, timestamp=%f", __FUNCTION__,
+ this, (int)event_type, timestamp);
+// xbt_backtrace_display_current();
+
+ /* switch (event->event_type){
+ case PAJE_StartLink:
+ xbt_free (((startLink_t)(event->data))->value);
+ xbt_free (((startLink_t)(event->data))->key);
+ break;
+ case PAJE_EndLink:
+ xbt_free (((endLink_t)(event->data))->value);
+ xbt_free (((endLink_t)(event->data))->key);
+ break;
+ default:
+ break;
+ }*/
}
void TRACE_paje_start() {
XBT_DEBUG("Filename %s is closed", filename);
}
-void print_pajeDefineContainerType(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- print_default_pajeType_row<defineContainerType_t>(event);
- print_row();
+DefineContainerEvent::DefineContainerEvent(type_t type)
+{
+
+ event_type = PAJE_DefineContainerType;
+ timestamp = 0;
+ this->type = type;
+ XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
+ //print it
+ print ();
+}
+
+void DefineContainerEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ stream << " " << type->id
+ << " " << type->father->id
+ << " " << type->name;
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
+
+}
+
+
+
+DefineVariableTypeEvent::DefineVariableTypeEvent(type_t type)
+{
+ this->event_type = PAJE_DefineVariableType;
+ this->timestamp = 0;
+ this->type = type;
+
+ XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
+
+ //print it
+ print ();
+}
+
+void DefineVariableTypeEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ stream << " " << type->id
+ << " " << type->father->id
+ << " " << type->name;
+ if (type->color)
+ stream << " \"" << type->color << "\"";
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
+}
+
+DefineStateTypeEvent::DefineStateTypeEvent(type_t type)
+{
+ this->event_type = PAJE_DefineStateType;
+ this->timestamp = 0;
+ this->type = type;
+
+ XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
+
+ //print it
+ print();
+}
+
+
+DefineEventTypeEvent::DefineEventTypeEvent(type_t type)
+{
+ this->event_type = PAJE_DefineEventType;
+ this->timestamp = 0;
+ this->type = type;
+
+ XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
+
+ //print it
+ print();
+}
+
+
+void DefineStateTypeEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ stream << " " << type->id
+ << " " << type->father->id
+ << " " << type->name;
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
}
-void print_pajeDefineVariableType(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- print_default_pajeType_row<defineVariableType_t>(event);
- if(static_cast<defineVariableType_t>(event->data)->type->color)
- stream << " \"" << static_cast<defineVariableType_t>(event->data)->type->color << "\"";
- print_row();
+void DefineEventTypeEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ stream << " " << type->id
+ << " " << type->father->id
+ << " " << type->name;
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
}
-void print_pajeDefineStateType(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- print_default_pajeType_row<defineStateType_t>(event);
- print_row();
+DefineLinkTypeEvent::DefineLinkTypeEvent(type_t type, type_t source, type_t dest)
+{
+ this->event_type = PAJE_DefineLinkType;
+ this->timestamp = 0;
+ this->type = type;
+ this->source = source;
+ this->dest = dest;
+
+ XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
+
+ //print it
+ print();
+}
+
+void DefineLinkTypeEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ stream << " " << type->id
+ << " " << type->father->id
+ << " " << source->id
+ << " " << dest->id
+ << " " << type->name;
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
+}
+
+DefineEntityValueEvent::DefineEntityValueEvent (val_t value)
+{
+ this->event_type = PAJE_DefineEntityValue;
+ this->timestamp = 0;
+ this->value = value;
+
+ XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event_type);
+
+ //print it
+ print();
+}
+
+
+void DefineEntityValueEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ stream << " " << value->id
+ << " " << value->father->id
+ << " " << value->name;
+ if(value->color)
+ stream << " \"" << value->color << "\"";
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
+}
+
+CreateContainerEvent::CreateContainerEvent (container_t container)
+{
+ this->event_type = PAJE_CreateContainer;
+ this->timestamp = SIMIX_get_clock();
+ this->container = container;
+
+ XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+ print();
}
-void print_pajeDefineEventType(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- print_default_pajeType_row<defineEventType_t>(event);
- print_row();
+void CreateContainerEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ print_timestamp(this);
+ stream << " " << container->id
+ << " " << container->type->id
+ << " " << container->father->id
+ << " \"" << container->name << "\"";
+
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ //if we are in the mode with only one file
+ static FILE *ti_unique_file = nullptr;
+
+ if (tracing_files == nullptr) {
+ tracing_files = xbt_dict_new_homogeneous(nullptr);
+ //generate unique run id with time
+ prefix = xbt_os_time();
+ }
+
+ if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file") || ti_unique_file == nullptr) {
+ char *folder_name = bprintf("%s_files", TRACE_get_filename());
+ char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, container->name);
+#ifdef WIN32
+ _mkdir(folder_name);
+#else
+ mkdir(folder_name, S_IRWXU | S_IRWXG | S_IRWXO);
+#endif
+ ti_unique_file = fopen(filename, "w");
+ xbt_assert(ti_unique_file, "Tracefile %s could not be opened for writing: %s", filename, strerror(errno));
+ fprintf(tracing_file, "%s\n", filename);
+
+ xbt_free(folder_name);
+ xbt_free(filename);
+ }
+
+ xbt_dict_set(tracing_files, container->name, (void *) ti_unique_file, nullptr);
+ } else {
+ THROW_IMPOSSIBLE;
+ }
}
-void print_pajeDefineLinkType(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- init_stream<defineLinkType_t>(event);
- stream << " " << static_cast<defineLinkType_t>(event->data)->type->id
- << " " << static_cast<defineLinkType_t>(event->data)->type->father->id
- << " " << static_cast<defineLinkType_t>(event->data)->source->id
- << " " << static_cast<defineLinkType_t>(event->data)->dest->id
- << " " << static_cast<defineLinkType_t>(event->data)->type->name;
- print_row();
+DestroyContainerEvent::DestroyContainerEvent (container_t container)
+{
+ this->event_type = PAJE_DestroyContainer;
+ this->timestamp = SIMIX_get_clock();
+ this->container = container;
+
+ XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+ print();
}
-void print_pajeDefineEntityValue (paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- init_stream<defineEntityValue_t>(event);
- stream << " " << static_cast<defineEntityValue_t>(event->data)->value->id
- << " " << static_cast<defineEntityValue_t>(event->data)->value->father->id
- << " " << static_cast<defineEntityValue_t>(event->data)->value->name;
- if(static_cast<defineEntityValue_t>(event->data)->value->color)
- stream << " \"" << static_cast<defineEntityValue_t>(event->data)->value->color << "\"";
- print_row();
+void DestroyContainerEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ print_timestamp(this);
+ stream << " " << container->type->id
+ << " " << container->id;
+
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ if (!xbt_cfg_get_boolean("tracing/smpi/format/ti-one-file")|| xbt_dict_length(tracing_files) == 1) {
+ FILE* f = (FILE*)xbt_dict_get_or_null(tracing_files, container->name);
+ fclose(f);
+ }
+ xbt_dict_remove(tracing_files, container->name);
+ } else {
+ THROW_IMPOSSIBLE;
+ }
}
-void print_pajeCreateContainer(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- init_stream<createContainer_t>(event);
- print_timestamp(event);
- stream << " " << static_cast<createContainer_t>(event->data)->container->id
- << " " << static_cast<createContainer_t>(event->data)->container->type->id
- << " " << static_cast<createContainer_t>(event->data)->container->father->id
- << " \"" << static_cast<createContainer_t>(event->data)->container->name << "\"";
+SetVariableEvent::SetVariableEvent (double timestamp, container_t container, type_t type, double value)
+{
+ this->event_type = PAJE_SetVariable;
+ this->timestamp = timestamp;
+ this->type = type;
+ this->container = container;
+ this->value = value;
+
+ XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
- print_row();
+ insert_into_buffer (this);
}
-void print_pajeDestroyContainer(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- init_stream<createContainer_t>(event);
- print_timestamp(event);
- stream << " " << static_cast<createContainer_t>(event->data)->container->type->id
- << " " << static_cast<createContainer_t>(event->data)->container->id;
+void SetVariableEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ print_timestamp(this);
+ stream << " " << type->id
+ << " " << container->id
+ << " " << value;
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
+}
+
+AddVariableEvent::AddVariableEvent (double timestamp, container_t container, type_t type, double value)
+{
+ this->event_type = PAJE_AddVariable;
+ this->timestamp = timestamp;
+ this->type = type;
+ this->container = container;
+ this->value = value;
- print_row();
+ XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+ insert_into_buffer (this);
}
-void print_pajeSetVariable(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- print_default_pajeVariable_row<setVariable_t>(event);
+void AddVariableEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ print_timestamp(this);
+ stream << " " << type->id
+ << " " << container->id
+ << " " << value;
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
}
-void print_pajeAddVariable(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- print_default_pajeVariable_row<addVariable_t>(event);
+SubVariableEvent::SubVariableEvent (double timestamp, container_t container, type_t type, double value)
+{
+ this->event_type = PAJE_SubVariable;
+ this->timestamp = timestamp;
+ this->type = type;
+ this->container = container;
+ this->value = value;
+
+ XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+ insert_into_buffer (this);
}
-void print_pajeSubVariable(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- print_default_pajeVariable_row<subVariable_t>(event);
+void SubVariableEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ print_timestamp(this);
+ stream << " " << type->id
+ << " " << container->id
+ << " " << value;
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
}
-void print_pajeSetState(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
+SetStateEvent::SetStateEvent (double timestamp, container_t container, type_t type, val_t value)
+{
+ this->event_type = PAJE_SetState;
+ this->timestamp = timestamp;
+ this->type = type;
+ this->container = container;
+ this->value = value;
- print_default_pajeState_row<setState_t>(event);
- stream << " " << static_cast<setState_t>(event->data)->value->id;
#if HAVE_SMPI
if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
- stream << " \"" << static_cast<setState_t>(event->data)->filename
- << "\" " << static_cast<setState_t>(event->data)->linenumber;
+ smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
+ filename = loc->filename;
+ linenumber = loc->linenumber;
}
#endif
- print_row();
+
+ XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+ insert_into_buffer (this);
}
-void print_pajePushState(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- print_default_pajeState_row<pushState_t>(event);
- stream << " " << static_cast<pushState_t>(event->data)->value->id;
+void SetStateEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ print_timestamp(this);
+ stream << " " << type->id
+ << " " << container->id;
+ stream << " " <<value->id;
+#if HAVE_SMPI
+ if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
+ stream << " \"" << filename
+ << "\" " << linenumber;
+ }
+#endif
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
+}
+
+PushStateEvent::PushStateEvent (double timestamp, container_t container, type_t type, val_t value, void* extra)
+{
+ this->event_type = PAJE_PushState;
+ this->timestamp = timestamp;
+ this->type = type;
+ this->container = container;
+ this->value = value;
+ this->extra_ = extra;
- if (TRACE_display_sizes()) {
- stream << " ";
- if (static_cast<pushState_t>(event->data)->extra != nullptr) {
- stream << static_cast<instr_extra_data>(static_cast<pushState_t>(event->data)->extra)->send_size;
- }
- else {
- stream << 0;
- }
- }
#if HAVE_SMPI
if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
- stream << " \"" << static_cast<pushState_t>(event->data)->filename
- << "\" " << static_cast<pushState_t>(event->data)->linenumber;
+ smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
+ filename = loc->filename;
+ linenumber = loc->linenumber;
}
#endif
- print_row();
-
- if (static_cast<pushState_t>(event->data)->extra != nullptr) {
- if (static_cast<instr_extra_data>(static_cast<pushState_t>(event->data)->extra)->sendcounts != nullptr)
- xbt_free(static_cast<instr_extra_data>(static_cast<pushState_t>(event->data)->extra)->sendcounts);
- if (static_cast<instr_extra_data>(static_cast<pushState_t>(event->data)->extra)->recvcounts != nullptr)
- xbt_free(static_cast<instr_extra_data>(static_cast<pushState_t>(event->data)->extra)->recvcounts);
- xbt_free(static_cast<pushState_t>(event->data)->extra);
- }
+
+ XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+ insert_into_buffer (this);
}
-void print_pajePopState(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- print_default_pajeState_row<popState_t>(event);
- print_row();
+PushStateEvent::PushStateEvent (double timestamp, container_t container, type_t type, val_t value)
+ : PushStateEvent(timestamp, container, type, value, nullptr)
+{}
+void PushStateEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ print_timestamp(this);
+ stream << " " << type->id
+ << " " << container->id;
+ stream << " " <<value->id;
+
+ if (TRACE_display_sizes()) {
+ stream << " ";
+ if (extra_ != nullptr) {
+ stream << static_cast<instr_extra_data>(extra_)->send_size;
+ }
+ else {
+ stream << 0;
+ }
+ }
+#if HAVE_SMPI
+ if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
+ stream << " \"" << filename
+ << "\" " << linenumber;
+ }
+#endif
+ print_row();
+
+ if (extra_ != nullptr) {
+ if (static_cast<instr_extra_data>(extra_)->sendcounts != nullptr)
+ xbt_free(static_cast<instr_extra_data>(extra_)->sendcounts);
+ if (static_cast<instr_extra_data>(extra_)->recvcounts != nullptr)
+ xbt_free(static_cast<instr_extra_data>(extra_)->recvcounts);
+ xbt_free(extra_);
+ }
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ if (extra_ == nullptr)
+ return;
+ instr_extra_data extra = (instr_extra_data)extra_;
+
+ char *process_id = nullptr;
+ //FIXME: dirty extract "rank-" from the name, as we want the bare process id here
+ if (strstr(container->name, "rank-") == nullptr)
+ process_id = xbt_strdup(container->name);
+ else
+ process_id = xbt_strdup(container->name + 5);
+
+ FILE* trace_file = (FILE* )xbt_dict_get(tracing_files, container->name);
+
+ switch (extra->type) {
+ case TRACING_INIT:
+ fprintf(trace_file, "%s init\n", process_id);
+ break;
+ case TRACING_FINALIZE:
+ fprintf(trace_file, "%s finalize\n", process_id);
+ break;
+ case TRACING_SEND:
+ fprintf(trace_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
+ break;
+ case TRACING_ISEND:
+ fprintf(trace_file, "%s Isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
+ break;
+ case TRACING_RECV:
+ fprintf(trace_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
+ break;
+ case TRACING_IRECV:
+ fprintf(trace_file, "%s Irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
+ break;
+ case TRACING_TEST:
+ fprintf(trace_file, "%s test\n", process_id);
+ break;
+ case TRACING_WAIT:
+ fprintf(trace_file, "%s wait\n", process_id);
+ break;
+ case TRACING_WAITALL:
+ fprintf(trace_file, "%s waitAll\n", process_id);
+ break;
+ case TRACING_BARRIER:
+ fprintf(trace_file, "%s barrier\n", process_id);
+ break;
+ case TRACING_BCAST: // rank bcast size (root) (datatype)
+ fprintf(trace_file, "%s bcast %d ", process_id, extra->send_size);
+ if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
+ fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
+ fprintf(trace_file, "\n");
+ break;
+ case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype)
+ fprintf(trace_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size);
+ if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
+ fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
+ fprintf(trace_file, "\n");
+ break;
+ case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype)
+ fprintf(trace_file, "%s allReduce %d %f %s\n", process_id, extra->send_size, extra->comp_size, extra->datatype1);
+ break;
+ case TRACING_ALLTOALL: // rank alltoall send_size recv_size (sendtype) (recvtype)
+ fprintf(trace_file, "%s allToAll %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->datatype1,
+ extra->datatype2);
+ break;
+ case TRACING_ALLTOALLV: // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype)
+ fprintf(trace_file, "%s allToAllV %d ", process_id, extra->send_size);
+ for (int i = 0; i < extra->num_processes; i++)
+ fprintf(trace_file, "%d ", extra->sendcounts[i]);
+ fprintf(trace_file, "%d ", extra->recv_size);
+ for (int i = 0; i < extra->num_processes; i++)
+ fprintf(trace_file, "%d ", extra->recvcounts[i]);
+ fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
+ break;
+ case TRACING_GATHER: // rank gather send_size recv_size root (sendtype) (recvtype)
+ fprintf(trace_file, "%s gather %d %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->root,
+ extra->datatype1, extra->datatype2);
+ break;
+ case TRACING_ALLGATHERV: // rank allgatherv send_size [recvcounts] (sendtype) (recvtype)
+ fprintf(trace_file, "%s allGatherV %d ", process_id, extra->send_size);
+ for (int i = 0; i < extra->num_processes; i++)
+ fprintf(trace_file, "%d ", extra->recvcounts[i]);
+ fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
+ break;
+ case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype)
+ fprintf(trace_file, "%s reduceScatter ", process_id);
+ for (int i = 0; i < extra->num_processes; i++)
+ fprintf(trace_file, "%d ", extra->recvcounts[i]);
+ fprintf(trace_file, "%f %s\n", extra->comp_size, extra->datatype1);
+ break;
+ case TRACING_COMPUTING:
+ fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size);
+ break;
+ case TRACING_SLEEPING:
+ fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration);
+ break;
+ case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype)
+ fprintf(trace_file, "%s gatherV %d ", process_id, extra->send_size);
+ for (int i = 0; i < extra->num_processes; i++)
+ fprintf(trace_file, "%d ", extra->recvcounts[i]);
+ fprintf(trace_file, "%d %s %s\n", extra->root, extra->datatype1, extra->datatype2);
+ break;
+ case TRACING_WAITANY:
+ case TRACING_SENDRECV:
+ case TRACING_SCATTER:
+ case TRACING_SCATTERV:
+ case TRACING_ALLGATHER:
+ case TRACING_SCAN:
+ case TRACING_EXSCAN:
+ case TRACING_COMM_SIZE:
+ case TRACING_COMM_SPLIT:
+ case TRACING_COMM_DUP:
+ case TRACING_SSEND:
+ case TRACING_ISSEND:
+ default:
+ XBT_WARN ("Call from %s impossible to translate into replay command : Not implemented (yet)",
+ value->name);
+ break;
+ }
+
+ if (extra->recvcounts != nullptr)
+ xbt_free(extra->recvcounts);
+ if (extra->sendcounts != nullptr)
+ xbt_free(extra->sendcounts);
+ xbt_free(process_id);
+ xbt_free(extra);
+
+ } else {
+ THROW_IMPOSSIBLE;
+ }
}
-void print_pajeResetState(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- print_default_pajeState_row<resetState_t>(event);
- print_row();
+
+PopStateEvent::PopStateEvent (double timestamp, container_t container, type_t type)
+{
+ this->event_type = PAJE_PopState;
+ this->timestamp = timestamp;
+ this->type = type;
+ this->container = container;
+
+ XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+ insert_into_buffer (this);
}
-void print_pajeStartLink(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- print_default_pajeLink_row<startLink_t>(event);
- stream << " " << static_cast<startLink_t>(event->data)->sourceContainer->id
- << " " << static_cast<startLink_t>(event->data)->key;
+void PopStateEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ print_timestamp(this);
+ stream << " " << type->id
+ << " " << container->id;
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
+}
- if (TRACE_display_sizes()) {
- stream << " " << static_cast<startLink_t>(event->data)->size;
- }
- print_row();
+ResetStateEvent::ResetStateEvent (double timestamp, container_t container, type_t type)
+{
+ this->event_type = PAJE_ResetState;
+ this->timestamp = timestamp;
+ this->type = type;
+ this->container = container;
+
+ XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+ insert_into_buffer (this);
+}
+
+void ResetStateEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ print_timestamp(this);
+ stream << " " << type->id
+ << " " << container->id;
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
+}
+
+StartLinkEvent::StartLinkEvent (double timestamp, container_t container,
+ type_t type, container_t sourceContainer, const char *value, const char *key)
+ : StartLinkEvent(timestamp, container, type, sourceContainer, value, key, -1)
+{}
+
+StartLinkEvent::StartLinkEvent (double timestamp, container_t container, type_t type, container_t sourceContainer,
+ const char *value, const char *key, int size)
+{
+ event_type = PAJE_StartLink;
+ this->timestamp = timestamp;
+ this->type = type;
+ this->container = container;
+ this->sourceContainer = sourceContainer;
+ this->value = xbt_strdup(value);
+ this->key = xbt_strdup(key);
+ this->size = size;
+
+ XBT_DEBUG("%s: event_type=%d, timestamp=%f, value:%s", __FUNCTION__,
+ (int)event_type, this->timestamp, this->value);
+
+ insert_into_buffer (this);
+}
+
+void StartLinkEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ print_timestamp(this);
+ stream << " " <<type->id
+ << " " <<container->id
+ << " " <<value;
+ stream << " " << sourceContainer->id
+ << " " << key;
+
+ if (TRACE_display_sizes()) {
+ stream << " " << size;
+ }
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
+}
+
+EndLinkEvent::EndLinkEvent (double timestamp, container_t container, type_t type, container_t destContainer,
+ const char *value, const char *key)
+{
+ this->event_type = PAJE_EndLink;
+ this->timestamp = timestamp;
+ this->type = type;
+ this->container = container;
+ this->destContainer = destContainer;
+ this->value = xbt_strdup(value);
+ this->key = xbt_strdup(key);
+
+ XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+ insert_into_buffer (this);
+}
+
+
+void EndLinkEvent::print() {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ print_timestamp(this);
+ stream << " " <<type->id
+ << " " <<container->id
+ << " " <<value;
+ stream << " " << destContainer->id
+ << " " << key;
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
}
-void print_pajeEndLink(paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- print_default_pajeLink_row<startLink_t>(event);
- stream << " " << static_cast<endLink_t>(event->data)->destContainer->id
- << " " << static_cast<endLink_t>(event->data)->key;
- print_row();
+NewEvent::NewEvent (double timestamp, container_t container, type_t type, val_t value)
+{
+ this->event_type = PAJE_NewEvent;
+ this->timestamp = timestamp;
+ this->type = type;
+ this->container = container;
+ this->value = value;
+
+ XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event_type, this->timestamp);
+
+ insert_into_buffer (this);
}
-void print_pajeNewEvent (paje_event_t event) {
- print_paje_debug(__FUNCTION__, event);
- init_stream<newEvent_t>(event);
- print_timestamp(event);
- stream << " " << static_cast<newEvent_t>(event->data)->type->id
- << " " << static_cast<newEvent_t>(event->data)->container->id
- << " " << static_cast<newEvent_t>(event->data)->value->id;
- print_row();
+void NewEvent::print () {
+ if (instr_fmt_type == instr_fmt_paje) {
+ XBT_DEBUG("%s: event_type=%d, timestamp=%.*f", __FUNCTION__, (int)event_type, TRACE_precision(), timestamp);
+ stream << std::fixed << std::setprecision(TRACE_precision());
+ stream << (int)this->event_type;
+ print_timestamp(this);
+ stream << " " << type->id
+ << " " << container->id
+ << " " << value->id;
+ print_row();
+ } else if (instr_fmt_type == instr_fmt_TI) {
+ /* Nothing to do */
+ } else {
+ THROW_IMPOSSIBLE;
+ }
}
+
+
+void TRACE_TI_start()
+{
+ char *filename = TRACE_get_filename();
+ tracing_file = fopen(filename, "w");
+ if (tracing_file == nullptr)
+ THROWF(system_error, 1, "Tracefile %s could not be opened for writing.", filename);
+
+ XBT_DEBUG("Filename %s is open for writing", filename);
+
+ /* output one line comment */
+ dump_comment(TRACE_get_comment());
+
+ /* output comment file */
+ dump_comment_file(TRACE_get_comment_file());
+}
+
+void TRACE_TI_end()
+{
+ xbt_dict_free(&tracing_files);
+ fclose(tracing_file);
+ char *filename = TRACE_get_filename();
+ XBT_DEBUG("Filename %s is closed", filename);
+}
+
if(father){
XBT_DEBUG("ContainerType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
- new_pajeDefineContainerType (ret);
+ new DefineContainerEvent(ret);
}
return ret;
}
type_t PJ_type_event_new (const char *name, type_t father)
-{
+{
if (name == nullptr){
THROWF (tracing_error, 0, "can't create an event type with a nullptr name");
}
type_t ret = newType (name, name, nullptr, TYPE_EVENT, father);
XBT_DEBUG("EventType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
- new_pajeDefineEventType(ret);
+ new DefineEventTypeEvent(ret);
return ret;
}
ret = newType (name, name, color, TYPE_VARIABLE, father);
}
XBT_DEBUG("VariableType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
- new_pajeDefineVariableType (ret);
+ new DefineVariableTypeEvent (ret);
return ret;
}
ret = newType (name, key, nullptr, TYPE_LINK, father);
XBT_DEBUG("LinkType %s(%s), child of %s(%s) %s(%s)->%s(%s)", ret->name, ret->id, father->name, father->id,
source->name, source->id, dest->name, dest->id);
- new_pajeDefineLinkType(ret, source, dest);
+ new DefineLinkTypeEvent(ret, source, dest);
return ret;
}
ret = newType (name, name, nullptr, TYPE_STATE, father);
XBT_DEBUG("StateType %s(%s), child of %s(%s)", ret->name, ret->id, father->name, father->id);
- new_pajeDefineStateType(ret);
+ new DefineStateTypeEvent(ret);
return ret;
}
xbt_dict_set (father->values, name, ret, nullptr);
XBT_DEBUG("new value %s, child of %s", ret->name, ret->father->name);
- new_pajeDefineEntityValue(ret);
+ new DefineEntityValueEvent(ret);
return ret;
}
TYPE_EVENT
} e_entity_types;
-typedef struct s_type *type_t;
-typedef struct s_type {
+//--------------------------------------------------
+class s_type;
+typedef s_type *type_t;
+class s_type {
+ public:
char *id;
char *name;
char *color;
e_entity_types kind;
- struct s_type *father;
+ s_type *father;
xbt_dict_t children;
xbt_dict_t values; //valid for all types except variable and container
-}s_type_t;
+};
-typedef struct s_val *val_t;
-typedef struct s_val {
+typedef s_type s_type_t;
+
+//--------------------------------------------------
+class s_val;
+typedef s_val *val_t;
+
+class s_val {
+ public:
char *id;
char *name;
char *color;
type_t father;
-}s_val_t;
+};
+typedef s_val s_val_t;
+//--------------------------------------------------
typedef enum {
INSTR_HOST,
INSTR_LINK,
INSTR_MSG_TASK
} e_container_types;
-typedef struct s_container *container_t;
-typedef struct s_container {
+//--------------------------------------------------
+class s_container;
+typedef s_container *container_t;
+
+class s_container {
+ public:
sg_netpoint_t netpoint;
char *name; /* Unique name of this container */
char *id; /* Unique id of this container */
type_t type; /* Type of this container */
int level; /* Level in the hierarchy, root level is 0 */
e_container_types kind; /* This container is of what kind */
- struct s_container *father;
+ s_container *father;
xbt_dict_t children;
-}s_container_t;
+};
+typedef s_container s_container_t;
-typedef struct paje_event *paje_event_t;
-typedef struct paje_event {
+//--------------------------------------------------
+class PajeEvent {
+ public:
double timestamp;
e_event_type event_type;
- void (*print) (paje_event_t event);
- void (*free) (paje_event_t event);
+ virtual void print() = 0;
void *data;
-} s_paje_event_t;
+ virtual ~PajeEvent();
+};
-typedef struct s_defineContainerType *defineContainerType_t;
-typedef struct s_defineContainerType {
+class DefineContainerEvent : public PajeEvent
+{
+ public:
type_t type;
-}s_defineContainerType_t;
+ void print() override;
+ DefineContainerEvent(type_t);
+};
+
+//--------------------------------------------------
-typedef struct s_defineVariableType *defineVariableType_t;
-typedef struct s_defineVariableType {
+
+//--------------------------------------------------
+
+class DefineVariableTypeEvent : public PajeEvent
+{
+ public:
type_t type;
-}s_defineVariableType_t;
+ DefineVariableTypeEvent(type_t type);
+ void print() override;
+};
+//--------------------------------------------------
-typedef struct s_defineStateType *defineStateType_t;
-typedef struct s_defineStateType {
+class DefineStateTypeEvent : public PajeEvent {
type_t type;
-}s_defineStateType_t;
+ public:
+ DefineStateTypeEvent(type_t type);
+ void print() override;
+};
-typedef struct s_defineEventType *defineEventType_t;
-typedef struct s_defineEventType {
+class DefineEventTypeEvent : public PajeEvent {
type_t type;
-}s_defineEventType_t;
+ public:
+ DefineEventTypeEvent(type_t type);
+ void print() override;
+};
-typedef struct s_defineLinkType *defineLinkType_t;
-typedef struct s_defineLinkType {
+class DefineLinkTypeEvent : public PajeEvent {
type_t type;
type_t source;
type_t dest;
-}s_defineLinkType_t;
+ public:
+ DefineLinkTypeEvent(type_t type, type_t source, type_t dest);
+ void print() override;
+};
-typedef struct s_defineEntityValue *defineEntityValue_t;
-typedef struct s_defineEntityValue {
+class DefineEntityValueEvent : public PajeEvent {
val_t value;
-}s_defineEntityValue_t;
+ public:
+ DefineEntityValueEvent (val_t type);
+ void print() override;
+};
-typedef struct s_createContainer *createContainer_t;
-typedef struct s_createContainer {
+class CreateContainerEvent : public PajeEvent {
+ public:
container_t container;
-}s_createContainer_t;
+ explicit CreateContainerEvent (container_t container);
+ void print() override;
+};
-typedef struct s_destroyContainer *destroyContainer_t;
-typedef struct s_destroyContainer {
+class DestroyContainerEvent : public PajeEvent {
+ public:
container_t container;
-}s_destroyContainer_t;
+ DestroyContainerEvent (container_t container);
+ void print() override;
+};
+
-typedef struct s_setVariable *setVariable_t;
-typedef struct s_setVariable {
+class SetVariableEvent : public PajeEvent {
container_t container;
type_t type;
double value;
-}s_setVariable_t;
+ public:
+ SetVariableEvent (double timestamp, container_t container, type_t type, double value);
+ void print() override;
+};
-typedef struct s_addVariable *addVariable_t;
-typedef struct s_addVariable {
+
+class AddVariableEvent:public PajeEvent {
container_t container;
type_t type;
double value;
-}s_addVariable_t;
+ public:
+ AddVariableEvent (double timestamp, container_t container, type_t type, double value);
+ void print() override;
+};
+
+//--------------------------------------------------
-typedef struct s_subVariable *subVariable_t;
-typedef struct s_subVariable {
+
+class SubVariableEvent : public PajeEvent {
+ public:
container_t container;
type_t type;
- double value;
-}s_subVariable_t;
-
-typedef struct s_setState *setState_t;
-typedef struct s_setState {
+ double value;
+ public:
+ SubVariableEvent(double timestamp, container_t container, type_t type, double value);
+ void print() override;
+};
+//--------------------------------------------------
+
+class SetStateEvent : public PajeEvent {
+ public:
container_t container;
type_t type;
val_t value;
const char* filename;
int linenumber;
-}s_setState_t;
+ public:
+ SetStateEvent (double timestamp, container_t container, type_t type, val_t value);
+ void print() override;
+};
+
-typedef struct s_pushState *pushState_t;
-typedef struct s_pushState {
+class PushStateEvent : public PajeEvent {
+ public:
container_t container;
type_t type;
val_t value;
int size;
const char* filename;
int linenumber;
- void* extra;
-}s_pushState_t;
+ void* extra_;
+ public:
+ PushStateEvent (double timestamp, container_t container, type_t type, val_t value);
+ PushStateEvent (double timestamp, container_t container, type_t type, val_t value,
+ void* extra);
+ void print() override;
+};
-typedef struct s_popState *popState_t;
-typedef struct s_popState {
+class PopStateEvent : public PajeEvent {
container_t container;
type_t type;
- xbt_dynar_t extra;
-}s_popState_t;
+ public:
+ PopStateEvent (double timestamp, container_t container, type_t type);
+ void print() override;
+};
-typedef struct s_resetState *resetState_t;
-typedef struct s_resetState {
+class ResetStateEvent : public PajeEvent {
container_t container;
type_t type;
-}s_resetState_t;
+ public:
+ ResetStateEvent (double timestamp, container_t container, type_t type);
+ void print() override;
+};
-typedef struct s_startLink *startLink_t;
-typedef struct s_startLink {
+class StartLinkEvent : public PajeEvent {
+ public:
container_t container;
type_t type;
container_t sourceContainer;
char *value;
char *key;
int size;
-}s_startLink_t;
+ public:
+ StartLinkEvent (double timestamp, container_t container, type_t type, container_t sourceContainer,
+ const char *value, const char *key);
+ StartLinkEvent (double timestamp, container_t container, type_t type,
+ container_t sourceContainer, const char *value, const char *key, int size);
+ void print() override;
+};
-typedef struct s_endLink *endLink_t;
-typedef struct s_endLink {
+class EndLinkEvent : public PajeEvent {
container_t container;
type_t type;
container_t destContainer;
char *value;
char *key;
-}s_endLink_t;
+ public:
+ EndLinkEvent (double timestamp, container_t container, type_t type, container_t destContainer,
+ const char *value, const char *key);
+ void print() override;
+};
+
-typedef struct s_newEvent *newEvent_t;
-typedef struct s_newEvent {
+class NewEvent : public PajeEvent {
+ public:
container_t container;
type_t type;
val_t value;
-}s_newEvent_t;
+ public:
+ NewEvent (double timestamp, container_t container, type_t type, val_t value);
+ void print() override;
+
+};
+
extern XBT_PRIVATE xbt_dict_t created_categories;
extern XBT_PRIVATE xbt_dict_t declared_marks;
XBT_PRIVATE void TRACE_header(int basic, int size);
/* from paje.c */
-XBT_PRIVATE void TRACE_paje_init();
XBT_PRIVATE void TRACE_paje_start();
XBT_PRIVATE void TRACE_paje_end();
XBT_PRIVATE void TRACE_paje_dump_buffer (int force);
-XBT_PUBLIC(void) new_pajeDefineContainerType(type_t type);
-XBT_PUBLIC(void) new_pajeDefineVariableType(type_t type);
-XBT_PUBLIC(void) new_pajeDefineStateType(type_t type);
-XBT_PUBLIC(void) new_pajeDefineEventType(type_t type);
-XBT_PUBLIC(void) new_pajeDefineLinkType(type_t type, type_t source, type_t dest);
-XBT_PUBLIC(void) new_pajeDefineEntityValue (val_t type);
-XBT_PUBLIC(void) new_pajeCreateContainer (container_t container);
-XBT_PUBLIC(void) new_pajeDestroyContainer (container_t container);
-XBT_PUBLIC(void) new_pajeSetVariable (double timestamp, container_t container, type_t type, double value);
-XBT_PUBLIC(void) new_pajeAddVariable (double timestamp, container_t container, type_t type, double value);
-XBT_PUBLIC(void) new_pajeSubVariable (double timestamp, container_t container, type_t type, double value);
-XBT_PUBLIC(void) new_pajeSetState (double timestamp, container_t container, type_t type, val_t value);
-XBT_PUBLIC(void) new_pajePushState (double timestamp, container_t container, type_t type, val_t value);
-XBT_PUBLIC(void) new_pajePushStateWithExtra (double timestamp, container_t container, type_t type, val_t value,
- void* extra);
-XBT_PUBLIC(void) new_pajePopState (double timestamp, container_t container, type_t type);
-XBT_PUBLIC(void) new_pajeResetState (double timestamp, container_t container, type_t type);
-XBT_PUBLIC(void) new_pajeStartLink (double timestamp, container_t container, type_t type, container_t sourceContainer,
- const char *value, const char *key);
-XBT_PUBLIC(void) new_pajeStartLinkWithSize (double timestamp, container_t container, type_t type,
- container_t sourceContainer, const char *value, const char *key, int size);
-XBT_PUBLIC(void) new_pajeEndLink (double timestamp, container_t container, type_t type, container_t destContainer,
- const char *value, const char *key);
-XBT_PUBLIC(void) new_pajeNewEvent (double timestamp, container_t container, type_t type, val_t value);
+
/* from instr_config.c */
XBT_PRIVATE bool TRACE_needs_platform ();
XBT_PUBLIC(val_t) PJ_value_get (const char *name, const type_t father);
XBT_PRIVATE void PJ_value_free (val_t value);
-XBT_PRIVATE void print_pajeDefineContainerType(paje_event_t event);
-XBT_PRIVATE void print_pajeDefineVariableType(paje_event_t event);
-XBT_PRIVATE void print_pajeDefineStateType(paje_event_t event);
-XBT_PRIVATE void print_pajeDefineEventType(paje_event_t event);
-XBT_PRIVATE void print_pajeDefineLinkType(paje_event_t event);
-XBT_PRIVATE void print_pajeDefineEntityValue (paje_event_t event);
-XBT_PRIVATE void print_pajeCreateContainer(paje_event_t event);
-XBT_PRIVATE void print_pajeDestroyContainer(paje_event_t event);
-XBT_PRIVATE void print_pajeSetVariable(paje_event_t event);
-XBT_PRIVATE void print_pajeAddVariable(paje_event_t event);
-XBT_PRIVATE void print_pajeSubVariable(paje_event_t event);
-XBT_PRIVATE void print_pajeSetState(paje_event_t event);
-XBT_PRIVATE void print_pajePushState(paje_event_t event);
-XBT_PRIVATE void print_pajePopState(paje_event_t event);
-XBT_PRIVATE void print_pajeResetState(paje_event_t event);
-XBT_PRIVATE void print_pajeStartLink(paje_event_t event);
-XBT_PRIVATE void print_pajeEndLink(paje_event_t event);
-XBT_PRIVATE void print_pajeNewEvent (paje_event_t event);
-
-XBT_PRIVATE void print_TIPushState(paje_event_t event);
-XBT_PRIVATE void print_TICreateContainer(paje_event_t event);
-XBT_PRIVATE void print_TIDestroyContainer(paje_event_t event);
+XBT_PRIVATE void print_pajeDefineContainerType(PajeEvent* event);
+XBT_PRIVATE void print_pajeDefineVariableType(PajeEvent* event);
+XBT_PRIVATE void print_pajeDefineStateType(PajeEvent* event);
+XBT_PRIVATE void print_pajeDefineEventType(PajeEvent* event);
+XBT_PRIVATE void print_pajeDefineLinkType(PajeEvent* event);
+XBT_PRIVATE void print_pajeDefineEntityValue (PajeEvent* event);
+XBT_PRIVATE void print_pajeCreateContainer(PajeEvent* event);
+XBT_PRIVATE void print_pajeDestroyContainer(PajeEvent* event);
+XBT_PRIVATE void print_pajeSetVariable(PajeEvent* event);
+XBT_PRIVATE void print_pajeAddVariable(PajeEvent* event);
+XBT_PRIVATE void print_pajeSubVariable(PajeEvent* event);
+XBT_PRIVATE void print_pajeSetState(PajeEvent* event);
+XBT_PRIVATE void print_pajePushState(PajeEvent* event);
+XBT_PRIVATE void print_pajePopState(PajeEvent* event);
+XBT_PRIVATE void print_pajeResetState(PajeEvent* event);
+XBT_PRIVATE void print_pajeStartLink(PajeEvent* event);
+XBT_PRIVATE void print_pajeEndLink(PajeEvent* event);
+XBT_PRIVATE void print_pajeNewEvent (PajeEvent* event);
+
XBT_PRIVATE void TRACE_TI_start();
XBT_PRIVATE void TRACE_TI_end();
-XBT_PRIVATE void TRACE_TI_init();
-XBT_PRIVATE void print_NULL (paje_event_t event);
+XBT_PRIVATE void print_NULL (PajeEvent* event);
XBT_PRIVATE void TRACE_paje_dump_buffer (int force);
XBT_PRIVATE void dump_comment_file (const char *filename);
XBT_PRIVATE void dump_comment (const char *comment);
typedef struct instr_trace_writer {
- void (*print_DefineContainerType) (paje_event_t event);
- void (*print_DefineVariableType)(paje_event_t event);
- void (*print_DefineStateType)(paje_event_t event);
- void (*print_DefineEventType)(paje_event_t event);
- void (*print_DefineLinkType)(paje_event_t event);
- void (*print_DefineEntityValue)(paje_event_t event);
- void (*print_CreateContainer)(paje_event_t event);
- void (*print_DestroyContainer)(paje_event_t event);
- void (*print_SetVariable)(paje_event_t event);
- void (*print_AddVariable)(paje_event_t event);
- void (*print_SubVariable)(paje_event_t event);
- void (*print_SetState)(paje_event_t event);
- void (*print_PushState)(paje_event_t event);
- void (*print_PopState)(paje_event_t event);
- void (*print_ResetState)(paje_event_t event);
- void (*print_StartLink)(paje_event_t event);
- void (*print_EndLink)(paje_event_t event);
- void (*print_NewEvent) (paje_event_t event);
+ void (*print_DefineContainerType) (PajeEvent* event);
+ void (*print_DefineVariableType)(PajeEvent* event);
+ void (*print_DefineStateType)(PajeEvent* event);
+ void (*print_DefineEventType)(PajeEvent* event);
+ void (*print_DefineLinkType)(PajeEvent* event);
+ void (*print_DefineEntityValue)(PajeEvent* event);
+ void (*print_CreateContainer)(PajeEvent* event);
+ void (*print_DestroyContainer)(PajeEvent* event);
+ void (*print_SetVariable)(PajeEvent* event);
+ void (*print_AddVariable)(PajeEvent* event);
+ void (*print_SubVariable)(PajeEvent* event);
+ void (*print_SetState)(PajeEvent* event);
+ void (*print_PushState)(PajeEvent* event);
+ void (*print_PopState)(PajeEvent* event);
+ void (*print_ResetState)(PajeEvent* event);
+ void (*print_StartLink)(PajeEvent* event);
+ void (*print_EndLink)(PajeEvent* event);
+ void (*print_NewEvent) (PajeEvent* event);
} s_instr_trace_writer_t;
struct s_instr_extra_data;
int num_processes;
} s_instr_extra_data_t;
+/* Format of TRACING output.
+ * - paje is the regular format, that we all know
+ * - TI is a trick to reuse the tracing functions to generate a time independent trace during the execution. Such trace can easily be replayed with smpi_replay afterward.
+ * This trick should be removed and replaced by some code using the signal that we will create to cleanup the TRACING
+ */
+typedef enum { instr_fmt_paje, instr_fmt_TI } instr_fmt_type_t;
+extern instr_fmt_type_t instr_fmt_type;
+
SG_END_DECL()
#endif
if (!xbt_dict_get_or_null(platform_variables, key)) {
container_t container = PJ_container_get (resource);
type_t type = PJ_type_get (variable, container->type);
- new_pajeSetVariable (now, container, type, 0);
+ new SetVariableEvent (now, container, type, 0);
xbt_dict_set(platform_variables, key, (char*)"", nullptr);
}
xbt_free(key);
static void instr_event (double now, double delta, type_t variable, container_t resource, double value)
{
__TRACE_surf_check_variable_set_to_zero(now, variable->name, resource->name);
- new_pajeAddVariable(now, resource, variable, value);
- new_pajeSubVariable(now + delta, resource, variable, value);
+ new AddVariableEvent(now, resource, variable, value);
+ new SubVariableEvent(now + delta, resource, variable, value);
}
/* TRACE_surf_link_set_utilization: entry point from SimGrid */
+++ /dev/null
-/* Copyright (c) 2010-2015. 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/instr/instr_private.h"
-#include "src/instr/instr_smpi.h"
-#include "src/smpi/private.hpp"
-#include "xbt/virtu.h" /* sg_cmdline */
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_trace, instr, "tracing event system");
-
-FILE *tracing_file = nullptr;
-
-void print_NULL(paje_event_t event){}
-
-/* The active set of functions for the selected trace format
- * By default, they all do nothing, hence the print_NULL to avoid segfaults */
-
-s_instr_trace_writer_t active_writer = {&print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL,
- &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL,
- &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL, &print_NULL};
-
-std::vector<paje_event_t> buffer;
-
-void dump_comment (const char *comment)
-{
- if (!strlen(comment)) return;
- fprintf (tracing_file, "# %s\n", comment);
-}
-
-void dump_comment_file (const char *filename)
-{
- if (!strlen(filename)) return;
- FILE *file = fopen (filename, "r");
- if (!file){
- THROWF (system_error, 1, "Comment file %s could not be opened for reading.", filename);
- }
- while (!feof(file)){
- char c;
- c = fgetc(file);
- if (feof(file)) break;
- fprintf (tracing_file, "# ");
- while (c != '\n'){
- fprintf (tracing_file, "%c", c);
- c = fgetc(file);
- if (feof(file)) break;
- }
- fprintf (tracing_file, "\n");
- }
- fclose(file);
-}
-
-double TRACE_last_timestamp_to_dump = 0;
-//dumps the trace file until the timestamp TRACE_last_timestamp_to_dump
-void TRACE_paje_dump_buffer (int force)
-{
- if (!TRACE_is_enabled()) return;
- XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump);
- if (force){
- for (auto event :buffer){
- event->print (event);
- event->free (event);
- }
- buffer.clear();
- }else{
- std::vector<paje_event_t>::iterator i = buffer.begin();
- for (auto event :buffer){
- double head_timestamp = event->timestamp;
- if (head_timestamp > TRACE_last_timestamp_to_dump)
- break;
- event->print (event);
- event->free (event);
- ++i;
- }
- buffer.erase(buffer.begin(), i);
- }
- XBT_DEBUG("%s: ends", __FUNCTION__);
-}
-
-/* internal do the instrumentation module */
-static void insert_into_buffer (paje_event_t tbi)
-{
- if (TRACE_buffer() == 0){
- tbi->print (tbi);
- tbi->free (tbi);
- return;
- }
-
- XBT_DEBUG("%s: insert event_type=%d, timestamp=%f, buffersize=%zu)",
- __FUNCTION__, (int)tbi->event_type, tbi->timestamp, buffer.size());
- std::vector<paje_event_t>::reverse_iterator i;
- for (i = buffer.rbegin(); i != buffer.rend(); ++i) {
- paje_event_t e1 = *i;
- if (e1->timestamp <= tbi->timestamp)
- break;
- }
- buffer.insert(i.base(), tbi);
- if (i == buffer.rend())
- XBT_DEBUG("%s: inserted at beginning", __FUNCTION__);
- else
- XBT_DEBUG("%s: inserted at%s %zd", __FUNCTION__, (i == buffer.rbegin()) ? " end" :"pos =",
- std::distance(buffer.rend(),i));
-}
-
-static void free_paje_event (paje_event_t event)
-{
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
- switch (event->event_type){
- case PAJE_StartLink:
- xbt_free (((startLink_t)(event->data))->value);
- xbt_free (((startLink_t)(event->data))->key);
- break;
- case PAJE_EndLink:
- xbt_free (((endLink_t)(event->data))->value);
- xbt_free (((endLink_t)(event->data))->key);
- break;
- default:
- break;
- }
- xbt_free (event->data);
- xbt_free (event);
-}
-
-void new_pajeDefineContainerType(type_t type)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_DefineContainerType;
- event->timestamp = 0;
- event->print = active_writer.print_DefineContainerType;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_defineContainerType_t, 1);
- ((defineContainerType_t)(event->data))->type = type;
-
- XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);
-
- //print it
- event->print (event);
- event->free (event);
-}
-
-void new_pajeDefineVariableType(type_t type)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_DefineVariableType;
- event->timestamp = 0;
- event->print = active_writer.print_DefineVariableType;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_defineVariableType_t, 1);
- ((defineVariableType_t)(event->data))->type = type;
-
- XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);
-
- //print it
- event->print (event);
- event->free (event);
-}
-
-void new_pajeDefineStateType(type_t type)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_DefineStateType;
- event->timestamp = 0;
- event->print = active_writer.print_DefineStateType;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_defineStateType_t, 1);
- ((defineStateType_t)(event->data))->type = type;
-
- XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);
-
- //print it
- event->print (event);
- event->free (event);
-}
-
-void new_pajeDefineEventType(type_t type)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_DefineEventType;
- event->timestamp = 0;
- event->print = active_writer.print_DefineEventType;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_defineEventType_t, 1);
- ((defineEventType_t)(event->data))->type = type;
-
- XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);
-
- //print it
- event->print (event);
- event->free (event);
-}
-
-void new_pajeDefineLinkType(type_t type, type_t source, type_t dest)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_DefineLinkType;
- event->timestamp = 0;
- event->print = active_writer.print_DefineLinkType;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_defineLinkType_t, 1);
- ((defineLinkType_t)(event->data))->type = type;
- ((defineLinkType_t)(event->data))->source = source;
- ((defineLinkType_t)(event->data))->dest = dest;
-
- XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);
-
- //print it
- event->print (event);
- event->free (event);
-}
-
-void new_pajeDefineEntityValue (val_t value)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_DefineEntityValue;
- event->timestamp = 0;
- event->print = active_writer.print_DefineEntityValue;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_defineEntityValue_t, 1);
- ((defineEntityValue_t)(event->data))->value = value;
-
- XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);
-
- //print it
- event->print (event);
- event->free (event);
-}
-
-void new_pajeCreateContainer (container_t container)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_CreateContainer;
- event->timestamp = SIMIX_get_clock();
- event->print = active_writer.print_CreateContainer;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_createContainer_t, 1);
- ((createContainer_t)(event->data))->container = container;
-
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
- //print it
- event->print (event);
- event->free (event);
-}
-
-void new_pajeDestroyContainer (container_t container)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_DestroyContainer;
- event->timestamp = SIMIX_get_clock();
- event->print = active_writer.print_DestroyContainer;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_destroyContainer_t, 1);
- ((destroyContainer_t)(event->data))->container = container;
-
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
- //print it
- event->print (event);
- event->free (event);
-}
-
-void new_pajeSetVariable (double timestamp, container_t container, type_t type, double value)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_SetVariable;
- event->timestamp = timestamp;
- event->print = active_writer.print_SetVariable;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_setVariable_t, 1);
- ((setVariable_t)(event->data))->type = type;
- ((setVariable_t)(event->data))->container = container;
- ((setVariable_t)(event->data))->value = value;
-
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
- insert_into_buffer (event);
-}
-
-
-void new_pajeAddVariable (double timestamp, container_t container, type_t type, double value)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_AddVariable;
- event->timestamp = timestamp;
- event->print = active_writer.print_AddVariable;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_addVariable_t, 1);
- ((addVariable_t)(event->data))->type = type;
- ((addVariable_t)(event->data))->container = container;
- ((addVariable_t)(event->data))->value = value;
-
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
- insert_into_buffer (event);
-}
-
-void new_pajeSubVariable (double timestamp, container_t container, type_t type, double value)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_SubVariable;
- event->timestamp = timestamp;
- event->print = active_writer.print_SubVariable;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_subVariable_t, 1);
- ((subVariable_t)(event->data))->type = type;
- ((subVariable_t)(event->data))->container = container;
- ((subVariable_t)(event->data))->value = value;
-
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
- insert_into_buffer (event);
-}
-
-void new_pajeSetState (double timestamp, container_t container, type_t type, val_t value)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_SetState;
- event->timestamp = timestamp;
- event->print = active_writer.print_SetState;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_setState_t, 1);
- ((setState_t)(event->data))->type = type;
- ((setState_t)(event->data))->container = container;
- ((setState_t)(event->data))->value = value;
-
-#if HAVE_SMPI
- if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
- smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
- ((setState_t)(event->data))->filename = loc->filename;
- ((setState_t)(event->data))->linenumber = loc->linenumber;
- }
-#endif
-
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
- insert_into_buffer (event);
-}
-
-
-void new_pajePushStateWithExtra (double timestamp, container_t container, type_t type, val_t value, void* extra)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_PushState;
- event->timestamp = timestamp;
- event->print = active_writer.print_PushState;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_pushState_t, 1);
- ((pushState_t)(event->data))->type = type;
- ((pushState_t)(event->data))->container = container;
- ((pushState_t)(event->data))->value = value;
- ((pushState_t)(event->data))->extra = extra;
-
-#if HAVE_SMPI
- if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
- smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
- ((pushState_t)(event->data))->filename = loc->filename;
- ((pushState_t)(event->data))->linenumber = loc->linenumber;
- }
-#endif
-
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
- insert_into_buffer (event);
-}
-
-
-void new_pajePushState (double timestamp, container_t container, type_t type, val_t value)
-{
- new_pajePushStateWithExtra(timestamp, container, type, value, nullptr);
-}
-
-void new_pajePopState (double timestamp, container_t container, type_t type)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_PopState;
- event->timestamp = timestamp;
- event->print = active_writer.print_PopState;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_popState_t, 1);
- ((popState_t)(event->data))->type = type;
- ((popState_t)(event->data))->container = container;
-
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
- insert_into_buffer (event);
-}
-
-
-void new_pajeResetState (double timestamp, container_t container, type_t type)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_ResetState;
- event->timestamp = timestamp;
- event->print = active_writer.print_ResetState;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_resetState_t, 1);
- ((resetState_t)(event->data))->type = type;
- ((resetState_t)(event->data))->container = container;
-
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
- insert_into_buffer (event);
-}
-
-void new_pajeStartLink (double timestamp, container_t container, type_t type, container_t sourceContainer,
- const char *value, const char *key)
-{
- new_pajeStartLinkWithSize(timestamp, container, type, sourceContainer, value, key, -1);
-}
-
-void new_pajeStartLinkWithSize (double timestamp, container_t container, type_t type, container_t sourceContainer,
- const char *value, const char *key, int size)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_StartLink;
- event->timestamp = timestamp;
- event->print = active_writer.print_StartLink;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_startLink_t, 1);
- ((startLink_t)(event->data))->type = type;
- ((startLink_t)(event->data))->container = container;
- ((startLink_t)(event->data))->sourceContainer = sourceContainer;
- ((startLink_t)(event->data))->value = xbt_strdup(value);
- ((startLink_t)(event->data))->key = xbt_strdup(key);
- ((startLink_t)(event->data))->size = size;
-
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
- insert_into_buffer (event);
-}
-
-void new_pajeEndLink (double timestamp, container_t container, type_t type, container_t destContainer,
- const char *value, const char *key)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_EndLink;
- event->timestamp = timestamp;
- event->print = active_writer.print_EndLink;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_endLink_t, 1);
- ((endLink_t)(event->data))->type = type;
- ((endLink_t)(event->data))->container = container;
- ((endLink_t)(event->data))->destContainer = destContainer;
- ((endLink_t)(event->data))->value = xbt_strdup(value);
- ((endLink_t)(event->data))->key = xbt_strdup(key);
-
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
- insert_into_buffer (event);
-}
-
-void new_pajeNewEvent (double timestamp, container_t container, type_t type, val_t value)
-{
- paje_event_t event = xbt_new0(s_paje_event_t, 1);
- event->event_type = PAJE_NewEvent;
- event->timestamp = timestamp;
- event->print = active_writer.print_NewEvent;
- event->free = &free_paje_event;
- event->data = xbt_new0(s_newEvent_t, 1);
- ((newEvent_t)(event->data))->type = type;
- ((newEvent_t)(event->data))->container = container;
- ((newEvent_t)(event->data))->value = value;
-
- XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);
-
- insert_into_buffer (event);
-}
typedef struct graph_node_data {
int id;
int graph_id; /* used for caching internal graph id's */
-} s_graph_node_data_t, *graph_node_data_t;
+} s_graph_node_data_t;
+typedef s_graph_node_data_t* graph_node_data_t;
typedef struct graph_node_map_element {
xbt_node_t node;
-} s_graph_node_map_element_t, *graph_node_map_element_t;
+} s_graph_node_map_element_t;
+typedef s_graph_node_map_element_t* graph_node_map_element_t;
typedef struct route_cache_element {
int* pred_arr;
int size;
-} s_route_cache_element_t, *route_cache_element_t;
+} s_route_cache_element_t;
+typedef s_route_cache_element_t* route_cache_element_t;
namespace simgrid {
namespace kernel {
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());
&& expression[0].atom >= DW_OP_reg0
&& expression[0].atom <= DW_OP_reg31) {
int dwarf_register = expression[0].atom - DW_OP_reg0;
- xbt_assert(c,
- "Missing frame context for register operation DW_OP_reg%i",
- dwarf_register);
+ xbt_assert(c, "Missing frame context for register operation DW_OP_reg%i", dwarf_register);
return Location(dwarf_register_to_libunwind(dwarf_register));
}
LocationList locations;
std::ptrdiff_t offset = 0;
while (1) {
-
- Dwarf_Addr base, start, end;
+ Dwarf_Addr base;
+ Dwarf_Addr start;
+ Dwarf_Addr end;
Dwarf_Op *ops;
std::size_t len;
- offset = dwarf_getlocations(
- &attr, offset, &base, &start, &end, &ops, &len);
+ offset = dwarf_getlocations(&attr, offset, &base, &start, &end, &ops, &len);
if (offset == 0)
break;
return locations;
}
-
-
}
-}
\ No newline at end of file
+}
*/
class ModelChecker {
struct event_base *base_;
- struct event *socket_event_, *signal_event_;
+ struct event* socket_event_;
+ struct event* signal_event_;
/** String pool for host names */
// TODO, use std::set with heterogeneous comparison lookup (C++14)?
std::set<std::string> hostnames_;
public:
ModelChecker(ModelChecker const&) = delete;
ModelChecker& operator=(ModelChecker const&) = delete;
- ModelChecker(std::unique_ptr<Process> process);
+ explicit ModelChecker(std::unique_ptr<Process> process);
~ModelChecker();
Process& process()
Channel channel_;
bool running_ = false;
std::vector<simgrid::xbt::VmMap> memory_map_;
- RemotePtr<void> maestro_stack_start_, maestro_stack_end_;
+ RemotePtr<void> maestro_stack_start_;
+ RemotePtr<void> maestro_stack_end_;
int memory_file = -1;
std::vector<IgnoredRegion> ignored_regions_;
bool privatized_ = false;
Buffer(void* data, std::size_t size, Type type = Type::Malloc) :
data_(data), size_(size), type_(type) {}
public:
- Buffer() {}
+ Buffer() = default;
void clear() noexcept;
~Buffer() noexcept { clear(); }
size_(size),
permanent_addr_(permanent_addr)
{}
- ~RegionSnapshot() {}
+ ~RegionSnapshot() = default;
RegionSnapshot(RegionSnapshot const&) = default;
RegionSnapshot& operator=(RegionSnapshot const&) = default;
RegionSnapshot(RegionSnapshot&& that)
}
}
-typedef class simgrid::mc::RegionSnapshot s_mc_mem_region_t, *mc_mem_region_t;
-
+typedef class simgrid::mc::RegionSnapshot s_mc_mem_region_t;
+typedef s_mc_mem_region_t* mc_mem_region_t;
#endif
using simgrid::mc::remote;
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_comm_determinism, mc,
- "Logging specific to MC communication determinism detection");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_comm_determinism, mc, "Logging specific to MC communication determinism detection");
/********** Global variables **********/
/********** Static functions ***********/
-static e_mc_comm_pattern_difference_t compare_comm_pattern(simgrid::mc::PatternCommunication* comm1, simgrid::mc::PatternCommunication* comm2)
+static e_mc_comm_pattern_difference_t compare_comm_pattern(simgrid::mc::PatternCommunication* comm1,
+ simgrid::mc::PatternCommunication* comm2)
{
if(comm1->type != comm2->type)
return TYPE_DIFF;
return NONE_DIFF;
}
-static char* print_determinism_result(e_mc_comm_pattern_difference_t diff, int process, simgrid::mc::PatternCommunication* comm, unsigned int cursor) {
- char *type, *res;
+static char* print_determinism_result(e_mc_comm_pattern_difference_t diff, int process,
+ simgrid::mc::PatternCommunication* comm, unsigned int cursor)
+{
+ char* type;
+ char* res;
if (comm->type == simgrid::mc::PatternCommunicationType::send)
type = bprintf("The send communications pattern of the process %d is different!", process - 1);
return res;
}
-static void update_comm_pattern(
- simgrid::mc::PatternCommunication* comm_pattern,
- simgrid::mc::RemotePtr<simgrid::kernel::activity::Comm> comm_addr)
+static void update_comm_pattern(simgrid::mc::PatternCommunication* comm_pattern,
+ simgrid::mc::RemotePtr<simgrid::kernel::activity::Comm> comm_addr)
{
// HACK, type punning
simgrid::mc::Remote<simgrid::kernel::activity::Comm> temp_comm;
comm_pattern->dst_host = MC_smx_actor_get_host_name(dst_proc);
if (comm_pattern->data.size() == 0 && comm->src_buff != nullptr) {
size_t buff_size;
- mc_model_checker->process().read(
- &buff_size, remote(comm->dst_buff_size));
+ mc_model_checker->process().read(&buff_size, remote(comm->dst_buff_size));
comm_pattern->data.resize(buff_size);
- mc_model_checker->process().read_bytes(
- comm_pattern->data.data(), comm_pattern->data.size(),
- remote(comm->src_buff));
+ mc_model_checker->process().read_bytes(comm_pattern->data.data(), comm_pattern->data.size(),
+ remote(comm->src_buff));
}
}
namespace simgrid {
namespace mc {
-void CommunicationDeterminismChecker::deterministic_comm_pattern(
- int process, simgrid::mc::PatternCommunication* comm, int backtracking)
+void CommunicationDeterminismChecker::deterministic_comm_pattern(int process, simgrid::mc::PatternCommunication* comm,
+ int backtracking)
{
simgrid::mc::PatternCommunicationList* list =
xbt_dynar_get_as(initial_communications_pattern, process, simgrid::mc::PatternCommunicationList*);
if(!backtracking){
- e_mc_comm_pattern_difference_t diff =
- compare_comm_pattern(list->list[list->index_comm].get(), comm);
+ e_mc_comm_pattern_difference_t diff = compare_comm_pattern(list->list[list->index_comm].get(), comm);
if (diff != NONE_DIFF) {
if (comm->type == simgrid::mc::PatternCommunicationType::send) {
/********** Non Static functions ***********/
-void CommunicationDeterminismChecker::get_comm_pattern(xbt_dynar_t list, smx_simcall_t request, e_mc_call_type_t call_type, int backtracking)
+void CommunicationDeterminismChecker::get_comm_pattern(xbt_dynar_t list, smx_simcall_t request,
+ e_mc_call_type_t call_type, int backtracking)
{
const smx_actor_t issuer = MC_smx_simcall_get_issuer(request);
- simgrid::mc::PatternCommunicationList* initial_pattern = xbt_dynar_get_as(
- initial_communications_pattern, issuer->pid, simgrid::mc::PatternCommunicationList*);
- xbt_dynar_t incomplete_pattern = xbt_dynar_get_as(
- incomplete_communications_pattern, issuer->pid, xbt_dynar_t);
+ simgrid::mc::PatternCommunicationList* initial_pattern =
+ xbt_dynar_get_as(initial_communications_pattern, issuer->pid, simgrid::mc::PatternCommunicationList*);
+ xbt_dynar_t incomplete_pattern = xbt_dynar_get_as(incomplete_communications_pattern, issuer->pid, xbt_dynar_t);
std::unique_ptr<simgrid::mc::PatternCommunication> pattern =
- std::unique_ptr<simgrid::mc::PatternCommunication>(
- new simgrid::mc::PatternCommunication());
- pattern->index =
- initial_pattern->index_comm + xbt_dynar_length(incomplete_pattern);
+ std::unique_ptr<simgrid::mc::PatternCommunication>(new simgrid::mc::PatternCommunication());
+ pattern->index = initial_pattern->index_comm + xbt_dynar_length(incomplete_pattern);
if (call_type == MC_CALL_TYPE_SEND) {
/* Create comm pattern */
pattern->comm_addr = simcall_comm_isend__get__result(request);
simgrid::mc::Remote<simgrid::kernel::activity::Comm> temp_synchro;
- mc_model_checker->process().read(temp_synchro, remote(
- static_cast<simgrid::kernel::activity::Comm*>(pattern->comm_addr)));
- simgrid::kernel::activity::Comm* synchro =
- static_cast<simgrid::kernel::activity::Comm*>(temp_synchro.getBuffer());
+ mc_model_checker->process().read(temp_synchro,
+ remote(static_cast<simgrid::kernel::activity::Comm*>(pattern->comm_addr)));
+ simgrid::kernel::activity::Comm* synchro = static_cast<simgrid::kernel::activity::Comm*>(temp_synchro.getBuffer());
char* remote_name = mc_model_checker->process().read<char*>(
(std::uint64_t)(synchro->mbox ? &synchro->mbox->name_ : &synchro->mbox_cpy->name_));
pattern->src_host = MC_smx_actor_get_host_name(issuer);
simgrid::smpi::Request mpi_request =
- mc_model_checker->process().read<simgrid::smpi::Request>(
- (std::uint64_t) simcall_comm_isend__get__data(request));
+ mc_model_checker->process().read<simgrid::smpi::Request>((std::uint64_t)simcall_comm_isend__get__data(request));
pattern->tag = mpi_request.tag();
- if (synchro->src_buff != nullptr){
+ if (synchro->src_buff != nullptr) {
pattern->data.resize(synchro->src_buff_size);
- mc_model_checker->process().read_bytes(
- pattern->data.data(), pattern->data.size(),
- remote(synchro->src_buff));
+ mc_model_checker->process().read_bytes(pattern->data.data(), pattern->data.size(), remote(synchro->src_buff));
}
if(mpi_request.detached()){
if (!this->initial_communications_pattern_done) {
/* Store comm pattern */
- simgrid::mc::PatternCommunicationList* list = xbt_dynar_get_as(
- initial_communications_pattern, pattern->src_proc,
- simgrid::mc::PatternCommunicationList*);
+ simgrid::mc::PatternCommunicationList* list =
+ xbt_dynar_get_as(initial_communications_pattern, pattern->src_proc, simgrid::mc::PatternCommunicationList*);
list->list.push_back(std::move(pattern));
} else {
/* Evaluate comm determinism */
this->deterministic_comm_pattern(pattern->src_proc, pattern.get(), backtracking);
- xbt_dynar_get_as(
- initial_communications_pattern, pattern->src_proc, simgrid::mc::PatternCommunicationList*
- )->index_comm++;
+ xbt_dynar_get_as(initial_communications_pattern, pattern->src_proc, simgrid::mc::PatternCommunicationList*)
+ ->index_comm++;
}
return;
}
pattern->comm_addr = simcall_comm_irecv__get__result(request);
simgrid::smpi::Request mpi_request;
- mc_model_checker->process().read(
- &mpi_request, remote((simgrid::smpi::Request*)simcall_comm_irecv__get__data(request)));
+ mc_model_checker->process().read(&mpi_request,
+ remote((simgrid::smpi::Request*)simcall_comm_irecv__get__data(request)));
pattern->tag = mpi_request.tag();
simgrid::mc::Remote<simgrid::kernel::activity::Comm> temp_comm;
- mc_model_checker->process().read(temp_comm, remote(
- static_cast<simgrid::kernel::activity::Comm*>(pattern->comm_addr)));
+ mc_model_checker->process().read(temp_comm,
+ remote(static_cast<simgrid::kernel::activity::Comm*>(pattern->comm_addr)));
simgrid::kernel::activity::Comm* comm = temp_comm.getBuffer();
char* remote_name;
} else
xbt_die("Unexpected call_type %i", (int) call_type);
- XBT_DEBUG("Insert incomplete comm pattern %p for process %lu",
- pattern.get(), issuer->pid);
- xbt_dynar_t dynar =
- xbt_dynar_get_as(incomplete_communications_pattern, issuer->pid, xbt_dynar_t);
+ XBT_DEBUG("Insert incomplete comm pattern %p for process %lu", pattern.get(), issuer->pid);
+ xbt_dynar_t dynar = xbt_dynar_get_as(incomplete_communications_pattern, issuer->pid, xbt_dynar_t);
simgrid::mc::PatternCommunication* pattern2 = pattern.release();
xbt_dynar_push(dynar, &pattern2);
}
-
void CommunicationDeterminismChecker::complete_comm_pattern(
- xbt_dynar_t list, simgrid::mc::RemotePtr<simgrid::kernel::activity::Comm> comm_addr,
- unsigned int issuer, int backtracking)
+ xbt_dynar_t list, simgrid::mc::RemotePtr<simgrid::kernel::activity::Comm> comm_addr, unsigned int issuer,
+ int backtracking)
{
simgrid::mc::PatternCommunication* current_comm_pattern;
unsigned int cursor = 0;
update_comm_pattern(current_comm_pattern, comm_addr);
completed = 1;
simgrid::mc::PatternCommunication* temp;
- xbt_dynar_remove_at(
- xbt_dynar_get_as(incomplete_communications_pattern, issuer, xbt_dynar_t),
- cursor, &temp);
+ xbt_dynar_remove_at(xbt_dynar_get_as(incomplete_communications_pattern, issuer, xbt_dynar_t), cursor, &temp);
comm_pattern = std::unique_ptr<simgrid::mc::PatternCommunication>(temp);
XBT_DEBUG("Remove incomplete comm pattern for process %u at cursor %u", issuer, cursor);
break;
if(!completed)
xbt_die("Corresponding communication not found!");
- simgrid::mc::PatternCommunicationList* pattern = xbt_dynar_get_as(
- initial_communications_pattern, issuer, simgrid::mc::PatternCommunicationList*);
+ simgrid::mc::PatternCommunicationList* pattern =
+ xbt_dynar_get_as(initial_communications_pattern, issuer, simgrid::mc::PatternCommunicationList*);
if (!this->initial_communications_pattern_done)
/* Store comm pattern */
}
}
-CommunicationDeterminismChecker::CommunicationDeterminismChecker(Session& session)
- : Checker(session)
+CommunicationDeterminismChecker::CommunicationDeterminismChecker(Session& session) : Checker(session)
{
-
}
CommunicationDeterminismChecker::~CommunicationDeterminismChecker() = default;
for (auto const& state : stack_) {
smx_simcall_t req = &state->executed_req;
if (req)
- trace.push_back(simgrid::mc::request_to_string(
- req, state->transition.argument, simgrid::mc::RequestType::executed));
+ trace.push_back(
+ simgrid::mc::request_to_string(req, state->transition.argument, simgrid::mc::RequestType::executed));
}
return trace;
}
void CommunicationDeterminismChecker::logState() // override
{
Checker::logState();
- if (_sg_mc_comms_determinism &&
- !this->recv_deterministic &&
- this->send_deterministic) {
+ if (_sg_mc_comms_determinism && !this->recv_deterministic && this->send_deterministic) {
XBT_INFO("******************************************************");
XBT_INFO("**** Only-send-deterministic communication pattern ****");
XBT_INFO("******************************************************");
XBT_INFO("%s", this->recv_diff);
- } else if(_sg_mc_comms_determinism &&
- !this->send_deterministic &&
- this->recv_deterministic) {
+ } else if (_sg_mc_comms_determinism && !this->send_deterministic && this->recv_deterministic) {
XBT_INFO("******************************************************");
XBT_INFO("**** Only-recv-deterministic communication pattern ****");
XBT_INFO("******************************************************");
XBT_INFO("Executed transitions = %lu", mc_model_checker->executed_transitions);
XBT_INFO("Send-deterministic : %s", !this->send_deterministic ? "No" : "Yes");
if (_sg_mc_comms_determinism)
- XBT_INFO("Recv-deterministic : %s",
- !this->recv_deterministic ? "No" : "Yes");
+ XBT_INFO("Recv-deterministic : %s", !this->recv_deterministic ? "No" : "Yes");
}
void CommunicationDeterminismChecker::prepare()
stack_.push_back(std::move(initial_state));
}
-static inline
-bool all_communications_are_finished()
+static inline bool all_communications_are_finished()
{
for (size_t current_actor = 1; current_actor < MC_smx_get_maxpid(); current_actor++) {
xbt_dynar_t pattern = xbt_dynar_get_as(incomplete_communications_pattern, current_actor, xbt_dynar_t);
void CommunicationDeterminismChecker::restoreState()
{
/* Intermediate backtracking */
- {
- simgrid::mc::State* state = stack_.back().get();
- if (state->system_state) {
- simgrid::mc::restore_snapshot(state->system_state);
- MC_restore_communications_pattern(state);
- return;
- }
+ simgrid::mc::State* state = stack_.back().get();
+ if (state->system_state) {
+ simgrid::mc::restore_snapshot(state->system_state);
+ MC_restore_communications_pattern(state);
+ return;
}
/* Restore the initial state */
smx_simcall_t req = nullptr;
while (!stack_.empty()) {
-
/* Get current state */
simgrid::mc::State* state = stack_.back().get();
XBT_DEBUG("**************************************************");
- XBT_DEBUG("Exploration depth = %zi (state = %d, interleaved processes = %zd)",
- stack_.size(), state->num,
+ XBT_DEBUG("Exploration depth = %zi (state = %d, interleaved processes = %zd)", stack_.size(), state->num,
state->interleaveSize());
/* Update statistics */
mc_model_checker->visited_states++;
- if (stack_.size() <= (std::size_t) _sg_mc_max_depth
- && (req = MC_state_get_request(state)) != nullptr
- && (visited_state == nullptr)) {
+ if (stack_.size() <= (std::size_t)_sg_mc_max_depth && (req = MC_state_get_request(state)) != nullptr &&
+ (visited_state == nullptr)) {
int req_num = state->transition.argument;
- XBT_DEBUG("Execute: %s",
- simgrid::mc::request_to_string(
- req, req_num, simgrid::mc::RequestType::simix).c_str());
+ XBT_DEBUG("Execute: %s", simgrid::mc::request_to_string(req, req_num, simgrid::mc::RequestType::simix).c_str());
std::string req_str;
if (dot_output != nullptr)
std::unique_ptr<simgrid::mc::State> next_state =
std::unique_ptr<simgrid::mc::State>(new simgrid::mc::State(++expandedStatesCount_));
- /* If comm determinism verification, we cannot stop the exploration if
- some communications are not finished (at least, data are transferred).
- These communications are incomplete and they cannot be analyzed and
- compared with the initial pattern. */
- bool compare_snapshots = all_communications_are_finished()
- && this->initial_communications_pattern_done;
+ /* If comm determinism verification, we cannot stop the exploration if some communications are not finished (at
+ * least, data are transferred). These communications are incomplete and they cannot be analyzed and compared
+ * with the initial pattern. */
+ bool compare_snapshots = all_communications_are_finished() && this->initial_communications_pattern_done;
if (_sg_mc_max_visited_states == 0 ||
(visited_state = visitedStates_.addVisitedState(expandedStatesCount_, next_state.get(), compare_snapshots)) ==
XBT_DEBUG("State already visited (equal to state %d), exploration stopped on this path.",
visited_state->original_num == -1 ? visited_state->num : visited_state->original_num);
else
- XBT_DEBUG("There are no more processes to interleave. (depth %zi)",
- stack_.size());
+ XBT_DEBUG("There are no more processes to interleave. (depth %zi)", stack_.size());
if (!this->initial_communications_pattern_done)
this->initial_communications_pattern_done = 1;
/* Trash the current state, no longer needed */
- XBT_DEBUG("Delete state %d at depth %zi",
- state->num, stack_.size());
+ XBT_DEBUG("Delete state %d at depth %zi", state->num, stack_.size());
stack_.pop_back();
visited_state = nullptr;
while (!stack_.empty()) {
std::unique_ptr<simgrid::mc::State> state = std::move(stack_.back());
stack_.pop_back();
- if (state->interleaveSize()
- && stack_.size() < (std::size_t) _sg_mc_max_depth) {
+ if (state->interleaveSize() && stack_.size() < (std::size_t)_sg_mc_max_depth) {
/* We found a back-tracking point, let's loop */
- XBT_DEBUG("Back-tracking to state %d at depth %zi",
- state->num, stack_.size() + 1);
+ XBT_DEBUG("Back-tracking to state %d at depth %zi", state->num, stack_.size() + 1);
stack_.push_back(std::move(state));
this->restoreState();
- XBT_DEBUG("Back-tracking to state %d at depth %zi done",
- stack_.back()->num, stack_.size());
+ XBT_DEBUG("Back-tracking to state %d at depth %zi done", stack_.back()->num, stack_.size());
break;
} else {
- XBT_DEBUG("Delete state %d at depth %zi",
- state->num, stack_.size() + 1);
+ XBT_DEBUG("Delete state %d at depth %zi", state->num, stack_.size() + 1);
}
}
}
#include <simgrid_config.h>
#include <xbt/base.h>
#include <xbt/automaton.h>
-#include <xbt/memory.hpp>
#include "src/mc/mc_state.h"
#include "src/mc/checker/Checker.hpp"
#include "src/mc/mc_dwarf.hpp"
#include "src/mc/Type.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_compare, xbt,
- "Logging specific to mc_compare in mc");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_compare, xbt, "Logging specific to mc_compare in mc");
namespace simgrid {
namespace mc {
std::vector<simgrid::mc::Type*> types;
std::size_t heapsize = 0;
- void initHeapInformation(xbt_mheap_t heap,
- std::vector<simgrid::mc::IgnoredHeapRegion>* i);
+ void initHeapInformation(xbt_mheap_t heap, std::vector<simgrid::mc::IgnoredHeapRegion>* i);
};
namespace {
{
for (auto const& pair : *list) {
if (pair[0].fragment != -1) {
- this->equals_to1_(pair[0].block, pair[0].fragment) =
- simgrid::mc::HeapArea(pair[1].block, pair[1].fragment);
- this->equals_to2_(pair[1].block, pair[1].fragment) =
- simgrid::mc::HeapArea(pair[0].block, pair[0].fragment);
+ this->equals_to1_(pair[0].block, pair[0].fragment) = simgrid::mc::HeapArea(pair[1].block, pair[1].fragment);
+ this->equals_to2_(pair[1].block, pair[1].fragment) = simgrid::mc::HeapArea(pair[0].block, pair[0].fragment);
} else {
- this->equals_to1_(pair[0].block, 0) =
- simgrid::mc::HeapArea(pair[1].block, pair[1].fragment);
- this->equals_to2_(pair[1].block, 0) =
- simgrid::mc::HeapArea(pair[0].block, pair[0].fragment);
+ this->equals_to1_(pair[0].block, 0) = simgrid::mc::HeapArea(pair[1].block, pair[1].fragment);
+ this->equals_to2_(pair[1].block, 0) = simgrid::mc::HeapArea(pair[0].block, pair[0].fragment);
}
}
}
simgrid::mc::Process* process = &mc_model_checker->process();
/* Start comparison */
- size_t i1, i2, j1, j2, k;
- void *addr_block1, *addr_block2, *addr_frag1, *addr_frag2;
- int nb_diff1 = 0, nb_diff2 = 0;
-
- int equal, res_compare = 0;
+ size_t i1;
+ size_t i2;
+ size_t j1;
+ size_t j2;
+ size_t k;
+ void* addr_block1;
+ void* addr_block2;
+ void* addr_frag1;
+ void* addr_frag2;
+ int nb_diff1 = 0;
+ int nb_diff2 = 0;
+ int equal;
+ int res_compare = 0;
/* Check busy blocks */
i1 = 1;
- malloc_info heapinfo_temp1, heapinfo_temp2;
+ malloc_info heapinfo_temp1;
+ malloc_info heapinfo_temp2;
malloc_info heapinfo_temp2b;
mc_mem_region_t heap_region1 = MC_get_heap_region(snapshot1);
abort();
}
- addr_block1 =
- ((void *) (((ADDR2UINT(i1)) - 1) * BLOCKSIZE +
- (char *) state.std_heap_copy.heapbase));
+ addr_block1 = ((void*)(((ADDR2UINT(i1)) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase));
if (heapinfo1->type == MMALLOC_TYPE_UNFRAGMENTED) { /* Large block */
continue;
}
- i2 = 1;
- equal = 0;
+ i2 = 1;
+ equal = 0;
res_compare = 0;
/* Try first to associate to same block in the other heap */
if (heapinfo2->type == heapinfo1->type
&& state.equals_to2_(i1, 0).valid == 0) {
- addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE +
- (char *) state.std_heap_copy.heapbase;
- res_compare = compare_heap_area(state, simgrid::mc::ProcessIndexMissing,
- addr_block1, addr_block2, snapshot1, snapshot2,
- nullptr, nullptr, 0);
+ addr_block2 = (ADDR2UINT(i1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+ res_compare = compare_heap_area(state, simgrid::mc::ProcessIndexMissing, addr_block1, addr_block2, snapshot1,
+ snapshot2, nullptr, nullptr, 0);
if (res_compare != 1) {
for (k = 1; k < heapinfo2->busy_block.size; k++)
state.equals_to2_(i1 + k, 0) = HeapArea(i1, -1);
while (i2 < state.heaplimit && !equal) {
- addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE +
- (char *) state.std_heap_copy.heapbase;
+ addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
if (i2 == i1) {
i2++;
}
if (!equal) {
- XBT_DEBUG("Block %zu not found (size_used = %zu, addr = %p)", i1,
- heapinfo1->busy_block.busy_size, addr_block1);
+ XBT_DEBUG("Block %zu not found (size_used = %zu, addr = %p)", i1, heapinfo1->busy_block.busy_size, addr_block1);
i1 = state.heaplimit + 1;
nb_diff1++;
//i1++;
if (state.equals_to1_(i1, j1).valid)
continue;
- addr_frag1 =
- (void *) ((char *) addr_block1 + (j1 << heapinfo1->type));
+ addr_frag1 = (void*)((char*)addr_block1 + (j1 << heapinfo1->type));
i2 = 1;
equal = 0;
addr_frag2 =
(void *) ((char *) addr_block2 +
(j1 << heapinfo2->type));
- res_compare = compare_heap_area(state, simgrid::mc::ProcessIndexMissing,
- addr_frag1, addr_frag2, snapshot1, snapshot2,
- nullptr, nullptr, 0);
+ res_compare = compare_heap_area(state, simgrid::mc::ProcessIndexMissing, addr_frag1, addr_frag2, snapshot1,
+ snapshot2, nullptr, nullptr, 0);
if (res_compare != 1)
equal = 1;
}
-
-
while (i2 < state.heaplimit && !equal) {
const malloc_info* heapinfo2b = (const malloc_info*) MC_region_read(
if (state.equals_to2_(i2, j2).valid)
continue;
- addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE +
- (char *) state.std_heap_copy.heapbase;
- addr_frag2 =
- (void *) ((char *) addr_block2 +
- (j2 << heapinfo2b->type));
+ addr_block2 = (ADDR2UINT(i2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+ addr_frag2 = (void*)((char*)addr_block2 + (j2 << heapinfo2b->type));
- res_compare = compare_heap_area(
- state, simgrid::mc::ProcessIndexMissing,
- addr_frag1, addr_frag2, snapshot2, snapshot2,
- nullptr, nullptr, 0);
+ res_compare = compare_heap_area(state, simgrid::mc::ProcessIndexMissing, addr_frag1, addr_frag2, snapshot2,
+ snapshot2, nullptr, nullptr, 0);
if (res_compare != 1) {
equal = 1;
break;
}
if (!equal) {
- XBT_DEBUG
- ("Block %zu, fragment %zu not found (size_used = %zd, address = %p)\n",
- i1, j1, heapinfo1->busy_frag.frag_size[j1],
- addr_frag1);
+ XBT_DEBUG("Block %zu, fragment %zu not found (size_used = %zd, address = %p)\n", i1, j1,
+ heapinfo1->busy_frag.frag_size[j1], addr_frag1);
i2 = state.heaplimit + 1;
i1 = state.heaplimit + 1;
nb_diff1++;
}
/* All blocks/fragments are equal to another block/fragment ? */
- size_t i = 1, j = 0;
+ size_t i = 1;
+ size_t j = 0;
for(i = 1; i < state.heaplimit; i++) {
const malloc_info* heapinfo1 = (const malloc_info*) MC_region_read(
heap_region1, &heapinfo_temp1, &heapinfos1[i], sizeof(malloc_info));
- if (heapinfo1->type == MMALLOC_TYPE_UNFRAGMENTED
- && i1 == state.heaplimit
- && heapinfo1->busy_block.busy_size > 0
- && !state.equals_to1_(i, 0).valid) {
- XBT_DEBUG("Block %zu not found (size used = %zu)", i,
- heapinfo1->busy_block.busy_size);
+ if (heapinfo1->type == MMALLOC_TYPE_UNFRAGMENTED && i1 == state.heaplimit && heapinfo1->busy_block.busy_size > 0 &&
+ !state.equals_to1_(i, 0).valid) {
+ XBT_DEBUG("Block %zu not found (size used = %zu)", i, heapinfo1->busy_block.busy_size);
nb_diff1++;
}
if (heapinfo1->type <= 0)
continue;
for (j = 0; j < (size_t) (BLOCKSIZE >> heapinfo1->type); j++)
- if (i1 == state.heaplimit
- && heapinfo1->busy_frag.frag_size[j] > 0
- && !state.equals_to1_(i, j).valid) {
- XBT_DEBUG("Block %zu, Fragment %zu not found (size used = %zd)",
- i, j, heapinfo1->busy_frag.frag_size[j]);
+ if (i1 == state.heaplimit && heapinfo1->busy_frag.frag_size[j] > 0 && !state.equals_to1_(i, j).valid) {
+ XBT_DEBUG("Block %zu, Fragment %zu not found (size used = %zd)", i, j, heapinfo1->busy_frag.frag_size[j]);
nb_diff1++;
}
}
return 0;
}
- simgrid::mc::Type *subtype, *subsubtype;
- int res, elm_size;
- const void *addr_pointed1, *addr_pointed2;
+ simgrid::mc::Type* subtype;
+ simgrid::mc::Type* subsubtype;
+ int res;
+ int elm_size;
+ const void* addr_pointed1;
+ const void* addr_pointed2;
mc_mem_region_t heap_region1 = MC_get_heap_region(snapshot1);
mc_mem_region_t heap_region2 = MC_get_heap_region(snapshot2);
return compare_heap_area_without_type(state, process_index, real_area1, real_area2,
snapshot1, snapshot2, previous,
type->byte_size, check_ignore);
- return 0;
default:
return 0;
if (member.offset() == offset)
return member.type;
} else {
- void *real_member = simgrid::dwarf::resolve_member(
- real_base_address, type, &member, snapshot, process_index);
- if ((char*) real_member - (char *) real_base_address == offset)
+ void* real_member = simgrid::dwarf::resolve_member(real_base_address, type, &member, snapshot, process_index);
+ if ((char*)real_member - (char*)real_base_address == offset)
return member.type;
}
}
simgrid::mc::Process* process = &mc_model_checker->process();
int res_compare;
- ssize_t block1, frag1, block2, frag2;
+ ssize_t block1;
+ ssize_t frag1;
+ ssize_t block2;
+ ssize_t frag2;
ssize_t size;
int check_ignore = 0;
- void *real_addr_block1, *real_addr_block2, *real_addr_frag1, *real_addr_frag2;
+ void* real_addr_block1;
+ void* real_addr_block2;
+ void* real_addr_frag1;
+ void* real_addr_frag2;
int type_size = -1;
- int offset1 = 0, offset2 = 0;
- int new_size1 = -1, new_size2 = -1;
- simgrid::mc::Type *new_type1 = nullptr, *new_type2 = nullptr;
+ int offset1 = 0;
+ int offset2 = 0;
+ int new_size1 = -1;
+ int new_size2 = -1;
+
+ simgrid::mc::Type* new_type1 = nullptr;
+ simgrid::mc::Type* new_type2 = nullptr;
bool match_pairs = false;
// This is the address of std_heap->heapinfo in the application process:
void* heapinfo_address = &((xbt_mheap_t) process->heap_address)->heapinfo;
- const malloc_info* heapinfos1 = snapshot1->read(
- remote((const malloc_info**)heapinfo_address), process_index);
- const malloc_info* heapinfos2 = snapshot2->read(
- remote((const malloc_info**)heapinfo_address), process_index);
+ const malloc_info* heapinfos1 = snapshot1->read(remote((const malloc_info**)heapinfo_address), process_index);
+ const malloc_info* heapinfos2 = snapshot2->read(remote((const malloc_info**)heapinfo_address), process_index);
malloc_info heapinfo_temp1, heapinfo_temp2;
}
// Get block number:
- block1 =
- ((char *) area1 -
- (char *) state.std_heap_copy.heapbase) / BLOCKSIZE + 1;
- block2 =
- ((char *) area2 -
- (char *) state.std_heap_copy.heapbase) / BLOCKSIZE + 1;
+ block1 = ((char*)area1 - (char*)state.std_heap_copy.heapbase) / BLOCKSIZE + 1;
+ block2 = ((char*)area2 - (char*)state.std_heap_copy.heapbase) / BLOCKSIZE + 1;
// If either block is a stack block:
if (is_block_stack((int) block1) && is_block_stack((int) block2)) {
- previous->insert(simgrid::mc::makeHeapLocationPair(
- block1, -1, block2, -1));
+ previous->insert(simgrid::mc::makeHeapLocationPair(block1, -1, block2, -1));
if (match_pairs)
state.match_equals(previous);
return 0;
}
// If either block is not in the expected area of memory:
- if (((char *) area1 < (char *) state.std_heap_copy.heapbase)
- || (block1 > (ssize_t) state.processStates[0].heapsize) || (block1 < 1)
- || ((char *) area2 < (char *) state.std_heap_copy.heapbase)
- || (block2 > (ssize_t) state.processStates[1].heapsize) || (block2 < 1)) {
+ if (((char*)area1 < (char*)state.std_heap_copy.heapbase) || (block1 > (ssize_t)state.processStates[0].heapsize) ||
+ (block1 < 1) || ((char*)area2 < (char*)state.std_heap_copy.heapbase) ||
+ (block2 > (ssize_t)state.processStates[1].heapsize) || (block2 < 1)) {
return 1;
}
// Process address of the block:
- real_addr_block1 = (ADDR2UINT(block1) - 1) * BLOCKSIZE +
- (char *) state.std_heap_copy.heapbase;
- real_addr_block2 = (ADDR2UINT(block2) - 1) * BLOCKSIZE +
- (char *) state.std_heap_copy.heapbase;
+ real_addr_block1 = (ADDR2UINT(block1) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
+ real_addr_block2 = (ADDR2UINT(block2) - 1) * BLOCKSIZE + (char*)state.std_heap_copy.heapbase;
if (type) {
-
if (type->full_type)
type = type->full_type;
type = type->subtype;
// Find type_size:
- if (type->type == DW_TAG_pointer_type
- || (type->type == DW_TAG_base_type && !type->name.empty()
- && type->name == "char"))
+ if (type->type == DW_TAG_pointer_type ||
+ (type->type == DW_TAG_base_type && !type->name.empty() && type->name == "char"))
type_size = -1;
else
type_size = type->byte_size;
return 0;
}
- if (heapinfo1->type == MMALLOC_TYPE_UNFRAGMENTED
- && heapinfo2->type == MMALLOC_TYPE_UNFRAGMENTED) {
+ if (heapinfo1->type == MMALLOC_TYPE_UNFRAGMENTED && heapinfo2->type == MMALLOC_TYPE_UNFRAGMENTED) {
/* Complete block */
// TODO, lookup variable type from block type as done for fragmented blocks
- offset1 = (char *) area1 - (char *) real_addr_block1;
- offset2 = (char *) area2 - (char *) real_addr_block2;
+ offset1 = (char*)area1 - (char*)real_addr_block1;
+ offset2 = (char*)area2 - (char*)real_addr_block2;
- if (state.equals_to1_(block1, 0).valid
- && state.equals_to2_(block2, 0).valid
- && state.blocksEqual(block1, block2)) {
+ if (state.equals_to1_(block1, 0).valid && state.equals_to2_(block2, 0).valid && state.blocksEqual(block1, block2)) {
if (match_pairs)
state.match_equals(previous);
return 0;
if (heapinfo1->busy_block.busy_size != heapinfo2->busy_block.busy_size)
return 1;
- if (!previous->insert(simgrid::mc::makeHeapLocationPair(
- block1, -1, block2, -1)).second) {
+ if (!previous->insert(simgrid::mc::makeHeapLocationPair(block1, -1, block2, -1)).second) {
if (match_pairs)
state.match_equals(previous);
return 0;
} else if ((heapinfo1->type > 0) && (heapinfo2->type > 0)) { /* Fragmented block */
// Fragment number:
- frag1 =
- ((uintptr_t) (ADDR2UINT(area1) % (BLOCKSIZE))) >> heapinfo1->type;
- frag2 =
- ((uintptr_t) (ADDR2UINT(area2) % (BLOCKSIZE))) >> heapinfo2->type;
+ frag1 = ((uintptr_t)(ADDR2UINT(area1) % (BLOCKSIZE))) >> heapinfo1->type;
+ frag2 = ((uintptr_t)(ADDR2UINT(area2) % (BLOCKSIZE))) >> heapinfo2->type;
// Process address of the fragment:
- real_addr_frag1 =
- (void *) ((char *) real_addr_block1 +
- (frag1 << heapinfo1->type));
- real_addr_frag2 =
- (void *) ((char *) real_addr_block2 +
- (frag2 << heapinfo2->type));
+ real_addr_frag1 = (void*)((char*)real_addr_block1 + (frag1 << heapinfo1->type));
+ real_addr_frag2 = (void*)((char*)real_addr_block2 + (frag2 << heapinfo2->type));
// Check the size of the fragments against the size of the type:
if (type_size != -1) {
- if (heapinfo1->busy_frag.frag_size[frag1] == -1
- || heapinfo2->busy_frag.frag_size[frag2] == -1) {
+ if (heapinfo1->busy_frag.frag_size[frag1] == -1 || heapinfo2->busy_frag.frag_size[frag2] == -1) {
if (match_pairs)
state.match_equals(previous);
return -1;
}
// Check if the blocks are already matched together:
- if (state.equals_to1_(block1, frag1).valid
- && state.equals_to2_(block2, frag2).valid) {
+ if (state.equals_to1_(block1, frag1).valid && state.equals_to2_(block2, frag2).valid) {
if (offset1==offset2 && state.fragmentsEqual(block1, frag1, block2, frag2)) {
if (match_pairs)
state.match_equals(previous);
}
}
// Compare the size of both fragments:
- if (heapinfo1->busy_frag.frag_size[frag1] !=
- heapinfo2->busy_frag.frag_size[frag2]) {
+ if (heapinfo1->busy_frag.frag_size[frag1] != heapinfo2->busy_frag.frag_size[frag2]) {
if (type_size == -1) {
if (match_pairs)
state.match_equals(previous);
new_type2 = type;
}
// Type inference from the block type.
- else if (state.types1_(block1, frag1) != nullptr
- || state.types2_(block2, frag2) != nullptr) {
+ else if (state.types1_(block1, frag1) != nullptr || state.types2_(block2, frag2) != nullptr) {
- offset1 = (char *) area1 - (char *) real_addr_frag1;
- offset2 = (char *) area2 - (char *) real_addr_frag2;
+ offset1 = (char*)area1 - (char*)real_addr_frag1;
+ offset2 = (char*)area2 - (char*)real_addr_frag2;
- if (state.types1_(block1, frag1) != nullptr
- && state.types2_(block2, frag2) != nullptr) {
+ if (state.types1_(block1, frag1) != nullptr && state.types2_(block2, frag2) != nullptr) {
new_type1 =
- get_offset_type(real_addr_frag1, state.types1_(block1, frag1),
- offset1, size, snapshot1, process_index);
+ get_offset_type(real_addr_frag1, state.types1_(block1, frag1), offset1, size, snapshot1, process_index);
new_type2 =
- get_offset_type(real_addr_frag2, state.types2_(block2, frag2),
- offset1, size, snapshot2, process_index);
+ get_offset_type(real_addr_frag2, state.types2_(block2, frag2), offset1, size, snapshot2, process_index);
} else if (state.types1_(block1, frag1) != nullptr) {
new_type1 =
- get_offset_type(real_addr_frag1, state.types1_(block1, frag1),
- offset1, size, snapshot1, process_index);
+ get_offset_type(real_addr_frag1, state.types1_(block1, frag1), offset1, size, snapshot1, process_index);
new_type2 =
- get_offset_type(real_addr_frag2, state.types1_(block1, frag1),
- offset2, size, snapshot2, process_index);
+ get_offset_type(real_addr_frag2, state.types1_(block1, frag1), offset2, size, snapshot2, process_index);
} else if (state.types2_(block2, frag2) != nullptr) {
new_type1 =
- get_offset_type(real_addr_frag1, state.types2_(block2, frag2),
- offset1, size, snapshot1, process_index);
+ get_offset_type(real_addr_frag1, state.types2_(block2, frag2), offset1, size, snapshot1, process_index);
new_type2 =
- get_offset_type(real_addr_frag2, state.types2_(block2, frag2),
- offset2, size, snapshot2, process_index);
+ get_offset_type(real_addr_frag2, state.types2_(block2, frag2), offset2, size, snapshot2, process_index);
} else {
if (match_pairs)
state.match_equals(previous);
size = new_size1;
}
- if (offset1 == 0 && offset2 == 0
- && !previous->insert(simgrid::mc::makeHeapLocationPair(
- block1, frag1, block2, frag2)).second) {
- if (match_pairs)
- state.match_equals(previous);
- return 0;
- }
+ if (offset1 == 0 && offset2 == 0 &&
+ !previous->insert(simgrid::mc::makeHeapLocationPair(block1, frag1, block2, frag2)).second) {
+ if (match_pairs)
+ state.match_equals(previous);
+ return 0;
+ }
if (size <= 0) {
if (match_pairs)
return 0;
}
- if ((heapinfo1->busy_frag.ignore[frag1] > 0)
- && (heapinfo2->busy_frag.ignore[frag2] ==
- heapinfo1->busy_frag.ignore[frag1]))
+ if ((heapinfo1->busy_frag.ignore[frag1] > 0) &&
+ (heapinfo2->busy_frag.ignore[frag2] == heapinfo1->busy_frag.ignore[frag1]))
check_ignore = heapinfo1->busy_frag.ignore[frag1];
} else
/* Start comparison */
if (type)
- res_compare =
- compare_heap_area_with_type(state, process_index, area1, area2, snapshot1, snapshot2,
- previous, type, size, check_ignore,
- pointer_level);
+ res_compare = compare_heap_area_with_type(state, process_index, area1, area2, snapshot1, snapshot2, previous, type,
+ size, check_ignore, pointer_level);
else
- res_compare =
- compare_heap_area_without_type(state, process_index, area1, area2, snapshot1, snapshot2,
- previous, size, check_ignore);
+ res_compare = compare_heap_area_without_type(state, process_index, area1, area2, snapshot1, snapshot2, previous,
+ size, check_ignore);
if (res_compare == 1)
return res_compare;
simgrid::mc::Type* subtype;
simgrid::mc::Type* subsubtype;
- int elm_size, i, res;
+ int elm_size;
+ int i;
+ int res;
top:
switch (type->type) {
case DW_TAG_base_type:
case DW_TAG_enumeration_type:
case DW_TAG_union_type:
- {
- return MC_snapshot_region_memcmp(
- real_area1, region1, real_area2, region2,
- type->byte_size) != 0;
- }
+ return MC_snapshot_region_memcmp(real_area1, region1, real_area2, region2, type->byte_size) != 0;
case DW_TAG_typedef:
case DW_TAG_volatile_type:
case DW_TAG_const_type:
#include "src/internal_config.h"
#include "src/mc/mc_private.h"
-#include "xbt/module.h"
-#include <xbt/mmalloc.h>
-#include <xbt/memory.hpp>
#include "src/smpi/private.h"
+#include "xbt/mmalloc.h"
+#include "xbt/module.h"
#include "src/xbt/mmalloc/mmprivate.h"
using simgrid::mc::remote;
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc,
- "Logging specific to mc_checkpoint");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(mc_checkpoint, mc, "Logging specific to mc_checkpoint");
namespace simgrid {
namespace mc {
stack_frame.unw_cursor = c;
- unw_word_t ip, sp;
+ unw_word_t ip;
+ unw_word_t sp;
unw_get_reg(&c, UNW_REG_IP, &ip);
unw_get_reg(&c, UNW_REG_SP, &sp);
namespace {
class djb_hash {
- hash_type state_ = 5381ll;
+ hash_type state_ = 5381LL;
+
public:
template<class T>
void update(T& x)
//start link
container_t msg = PJ_container_get (instr_process_id(process, str, len));
type_t type = PJ_type_get ("MSG_PROCESS_LINK", PJ_type_get_root());
- new_pajeStartLink (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
+ new StartLinkEvent (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
//destroy existing container of this process
TRACE_msg_process_destroy (MSG_process_get_name (process), MSG_process_get_PID (process));
//end link
msg = PJ_container_get(instr_process_id(process, str, len));
type = PJ_type_get ("MSG_PROCESS_LINK", PJ_type_get_root());
- new_pajeEndLink (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
+ new EndLinkEvent (MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
}
}
container_t process_container = PJ_container_get (instr_process_id(process, str, len));
type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
val_t value = PJ_value_get ("suspend", type);
- new_pajePushState (MSG_get_clock(), process_container, type, value);
+ new PushStateEvent (MSG_get_clock(), process_container, type, value);
}
}
container_t process_container = PJ_container_get (instr_process_id(process, str, len));
type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
- new_pajePopState (MSG_get_clock(), process_container, type);
+ new PopStateEvent (MSG_get_clock(), process_container, type);
}
}
container_t process_container = PJ_container_get (instr_process_id(process, str, len));
type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
val_t value = PJ_value_get ("sleep", type);
- new_pajePushState (MSG_get_clock(), process_container, type, value);
+ new PushStateEvent (MSG_get_clock(), process_container, type, value);
}
}
container_t process_container = PJ_container_get (instr_process_id(process, str, len));
type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
- new_pajePopState (MSG_get_clock(), process_container, type);
+ new PopStateEvent (MSG_get_clock(), process_container, type);
}
}
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
val_t value = PJ_value_get ("task_execute", type);
- new_pajePushState (MSG_get_clock(), process_container, type, value);
+ new PushStateEvent (MSG_get_clock(), process_container, type, value);
}
}
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
- new_pajePopState (MSG_get_clock(), process_container, type);
+ new PopStateEvent (MSG_get_clock(), process_container, type);
}
}
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
val_t value = PJ_value_get ("receive", type);
- new_pajePushState (MSG_get_clock(), process_container, type, value);
+ new PushStateEvent (MSG_get_clock(), process_container, type, value);
}
}
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
- new_pajePopState (MSG_get_clock(), process_container, type);
+ new PopStateEvent (MSG_get_clock(), process_container, type);
char key[INSTR_DEFAULT_STR_SIZE];
snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter);
type = PJ_type_get ("MSG_PROCESS_TASK_LINK", PJ_type_get_root());
- new_pajeEndLink(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
+ new EndLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
}
}
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
val_t value = PJ_value_get ("send", type);
- new_pajePushState (MSG_get_clock(), process_container, type, value);
+ new PushStateEvent (MSG_get_clock(), process_container, type, value);
char key[INSTR_DEFAULT_STR_SIZE];
snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter);
type = PJ_type_get ("MSG_PROCESS_TASK_LINK", PJ_type_get_root());
- new_pajeStartLink(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
+ new StartLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
}
return 1;
container_t process_container = PJ_container_get (instr_process_id(MSG_process_self(), str, len));
type_t type = PJ_type_get ("MSG_PROCESS_STATE", process_container->type);
- new_pajePopState (MSG_get_clock(), process_container, type);
+ new PopStateEvent (MSG_get_clock(), process_container, type);
}
}
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);
container_t vm_container = PJ_container_get(vm->cname());
type_t type = PJ_type_get("MSG_VM_STATE", vm_container->type);
val_t value = PJ_value_get_or_new("start", "0 0 1", type); // start is blue
- new_pajePushState(MSG_get_clock(), vm_container, type, value);
+ new PushStateEvent(MSG_get_clock(), vm_container, type, value);
}
}
// start link
container_t msg = PJ_container_get(vm->cname());
type_t type = PJ_type_get("MSG_VM_LINK", PJ_type_get_root());
- new_pajeStartLink(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
+ new StartLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
// destroy existing container of this vm
container_t existing_container = PJ_container_get(vm->cname());
// end link
msg = PJ_container_get(vm->cname());
type = PJ_type_get("MSG_VM_LINK", PJ_type_get_root());
- new_pajeEndLink(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
+ new EndLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, msg, "M", key);
}
// Inform the SRC that the migration has been correctly performed
container_t vm_container = PJ_container_get(vm->cname());
type_t type = PJ_type_get("MSG_VM_STATE", vm_container->type);
val_t value = PJ_value_get_or_new("suspend", "1 0 0", type); // suspend is red
- new_pajePushState(MSG_get_clock(), vm_container, type, value);
+ new PushStateEvent(MSG_get_clock(), vm_container, type, value);
}
}
if (TRACE_msg_vm_is_enabled()) {
container_t vm_container = PJ_container_get(vm->cname());
type_t type = PJ_type_get("MSG_VM_STATE", vm_container->type);
- new_pajePopState(MSG_get_clock(), vm_container, type);
+ new PopStateEvent(MSG_get_clock(), vm_container, type);
}
}
namespace vm {
simgrid::xbt::Extension<s4u::Host, VmHostExt> VmHostExt::EXTENSION_ID;
-VmHostExt::~VmHostExt()
-{
-}
void VmHostExt::ensureVmExtInstalled()
{
if (!EXTENSION_ID.valid())
class VmHostExt {
public:
static simgrid::xbt::Extension<simgrid::s4u::Host, VmHostExt> EXTENSION_ID;
- virtual ~VmHostExt();
+ virtual ~VmHostExt() = default;
sg_size_t ramsize = 0; /* available ramsize (0= not taken into account) */
bool overcommit = true; /* Whether the host allows overcommiting more VM than the avail ramsize allows */
namespace simgrid {
namespace s4u {
-Comm::~Comm() {
-
-}
-
-
-
s4u::Comm &Comm::send_init(s4u::MailboxPtr chan) {
s4u::Comm *res = new s4u::Comm();
res->sender_ = SIMIX_process_self();
typedef struct s_smx_process_exit_fun {
int_f_pvoid_pvoid_t fun;
void *arg;
-} s_smx_process_exit_fun_t, *smx_process_exit_fun_t;
+} s_smx_process_exit_fun_t;
+typedef s_smx_process_exit_fun_t* smx_process_exit_fun_t;
namespace simgrid {
namespace simix {
char cont_name[25];\
snprintf(cont_name,25, "rank-%d", smpi_process()->index());\
val_t value = PJ_value_get_or_new(Colls::mpi_coll_##cat##_description[i].name,"1.0 1.0 1.0", type);\
- new_pajeNewEvent (SIMIX_get_clock(), PJ_container_get(cont_name), type, value);\
+ new NewEvent (SIMIX_get_clock(), PJ_container_get(cont_name), type, value);\
}
#define AUTOMATIC_COLL_BENCH(cat, ret, args, args2)\
type_t type = PJ_type_get ("MPI_STATE", container->type);
const char *color = instr_find_color (operation);
val_t value = PJ_value_get_or_new (operation, color, type);
- new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
+ new PushStateEvent (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
}
void TRACE_smpi_collective_out(int rank, int root, const char *operation)
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_STATE", container->type);
- new_pajePopState (SIMIX_get_clock(), container, type);
+ new PopStateEvent (SIMIX_get_clock(), container, type);
}
void TRACE_smpi_computing_init(int rank)
type_t type = PJ_type_get ("MPI_STATE", container->type);
const char *color = instr_find_color ("computing");
val_t value = PJ_value_get_or_new ("computing", color, type);
- new_pajePushState (SIMIX_get_clock(), container, type, value);
+ new PushStateEvent (SIMIX_get_clock(), container, type, value);
}
void TRACE_smpi_computing_in(int rank, instr_extra_data extra)
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_STATE", container->type);
val_t value = PJ_value_get_or_new ("computing", nullptr, type);
- new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
+ new PushStateEvent (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
}
void TRACE_smpi_computing_out(int rank)
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_STATE", container->type);
- new_pajePopState (SIMIX_get_clock(), container, type);
+ new PopStateEvent (SIMIX_get_clock(), container, type);
}
void TRACE_smpi_sleeping_init(int rank)
type_t type = PJ_type_get ("MPI_STATE", container->type);
const char *color = instr_find_color ("sleeping");
val_t value = PJ_value_get_or_new ("sleeping", color, type);
- new_pajePushState (SIMIX_get_clock(), container, type, value);
+ new PushStateEvent (SIMIX_get_clock(), container, type, value);
}
void TRACE_smpi_sleeping_in(int rank, instr_extra_data extra)
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_STATE", container->type);
val_t value = PJ_value_get_or_new ("sleeping", nullptr, type);
- new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
+ new PushStateEvent (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
}
void TRACE_smpi_sleeping_out(int rank)
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_STATE", container->type);
- new_pajePopState (SIMIX_get_clock(), container, type);
+ new PopStateEvent (SIMIX_get_clock(), container, type);
}
void TRACE_smpi_testing_in(int rank, instr_extra_data extra)
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_STATE", container->type);
val_t value = PJ_value_get_or_new ("test", nullptr, type);
- new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
+ new PushStateEvent (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
}
void TRACE_smpi_testing_out(int rank)
smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE);
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_STATE", container->type);
- new_pajePopState (SIMIX_get_clock(), container, type);
+ new PopStateEvent (SIMIX_get_clock(), container, type);
}
void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation, instr_extra_data extra)
type_t type = PJ_type_get ("MPI_STATE", container->type);
const char *color = instr_find_color (operation);
val_t value = PJ_value_get_or_new (operation, color, type);
- new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
+ new PushStateEvent (SIMIX_get_clock(), container, type, value, static_cast<void*>(extra));
}
void TRACE_smpi_ptp_out(int rank, int src, int dst, const char *operation)
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_STATE", container->type);
- new_pajePopState (SIMIX_get_clock(), container, type);
+ new PopStateEvent (SIMIX_get_clock(), container, type);
}
void TRACE_smpi_send(int rank, int src, int dst, int tag, int size)
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_LINK", PJ_type_get_root());
XBT_DEBUG("Send tracing from %d to %d, tag %d, with key %s", src, dst, tag, key);
- new_pajeStartLinkWithSize (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key, size);
+ new StartLinkEvent (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key, size);
}
void TRACE_smpi_recv(int rank, int src, int dst, int tag)
container_t container = PJ_container_get (str);
type_t type = PJ_type_get ("MPI_LINK", PJ_type_get_root());
XBT_DEBUG("Recv tracing from %d to %d, tag %d, with key %s", src, dst, tag, key);
- new_pajeEndLink (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key);
+ new EndLinkEvent (SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key);
}
typedef struct s_smpi_privatisation_region {
void* address;
int file_descriptor;
-} s_smpi_privatisation_region_t, *smpi_privatisation_region_t;
+} s_smpi_privatisation_region_t;
+typedef s_smpi_privatisation_region_t* smpi_privatisation_region_t;
extern XBT_PRIVATE smpi_privatisation_region_t smpi_privatisation_regions;
extern XBT_PRIVATE int smpi_loaded_page;
}
}
+void smpi_execute_benched(double duration)
+{
+ smpi_bench_end();
+ smpi_execute(duration);
+ smpi_bench_begin();
+}
+
void smpi_bench_begin()
{
if (smpi_privatize_global_variables == SMPI_PRIVATIZE_MMAP) {
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());
break;
default:
MPI_CURRENT_TYPE=MPI_DEFAULT_TYPE;
+ break;
}
return MPI_CURRENT_TYPE;
}
snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter);
counter++;
- new_pajeStartLink(SIMIX_get_clock(), father, link_type, src, "topology", key);
- new_pajeEndLink(SIMIX_get_clock(), father, link_type, dst, "topology", key);
+ new StartLinkEvent(SIMIX_get_clock(), father, link_type, src, "topology", key);
+ new EndLinkEvent(SIMIX_get_clock(), father, link_type, dst, "topology", key);
XBT_DEBUG (" linkContainers %s <-> %s", src->name, dst->name);
}
if (latency == nullptr) {
latency = PJ_type_variable_new("latency", nullptr, container->type);
}
- new_pajeSetVariable(0, container, bandwidth, bandwidth_value);
- new_pajeSetVariable(0, container, latency, latency_value);
+ new SetVariableEvent(0, container, bandwidth, bandwidth_value);
+ new SetVariableEvent(0, container, latency, latency_value);
}
if (TRACE_uncategorized()) {
type_t bandwidth_used = PJ_type_get_or_null("bandwidth_used", container->type);
}
double current_speed_state = host.speed();
- new_pajeSetVariable (0, container, speed, current_speed_state);
+ new SetVariableEvent (0, container, speed, current_speed_state);
}
if (TRACE_uncategorized()){
type_t speed_used = PJ_type_get_or_null ("power_used", container->type);
if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) {
container_t container = PJ_container_get(resource);
type_t type = PJ_type_get ("power", container->type);
- new_pajeSetVariable(date, container, type, speed);
+ new SetVariableEvent(date, container, type, speed);
}
}
if (TRACE_categorized() || TRACE_uncategorized() || TRACE_platform()) {
container_t container = PJ_container_get(resource);
type_t type = PJ_type_get ("bandwidth", container->type);
- new_pajeSetVariable(date, container, type, bandwidth);
+ new SetVariableEvent(date, container, type, bandwidth);
}
}
#include "xbt/sysdep.h"
#include "xbt/log.h"
-#include "xbt/strbuff.h"
#include "xbt/mallocator.h"
#include "maxmin_private.hpp"
#include <stdlib.h>
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>
}
if ((action->getMaxDuration() > NO_MAX_DURATION) &&
- (min == -1 || action->getStartTime() + action->getMaxDuration() < min)) {
+ (min <= -1 || action->getStartTime() + action->getMaxDuration() < min)) {
// when the task will complete anyway because of the deadline if any
min = action->getStartTime() + action->getMaxDuration();
max_dur_flag = true;
}
-
XBT_DEBUG("Action(%p) corresponds to variable %d", action, action->getVariable()->id_int);
XBT_DEBUG("Action(%p) Start %f. May finish at %f (got a share of %f). Max_duration %f", action,
action->getStartTime(), min, share,
action->getMaxDuration());
- if (min != -1) {
+ if (min > -1) {
action->heapUpdate(actionHeap_, min, max_dur_flag ? MAX_DURATION : NORMAL);
XBT_DEBUG("Insert at heap action(%p) min %f now %f", action, min, now);
} else
tmgr_trace_t state_trace;
const char* coord;
xbt_dict_t properties;
-} s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
+} s_sg_platf_host_cbarg_t;
+typedef s_sg_platf_host_cbarg_t* sg_platf_host_cbarg_t;
typedef struct {
const char* id;
const char* link_up;
const char* link_down;
-} s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
+} s_sg_platf_host_link_cbarg_t;
+typedef s_sg_platf_host_link_cbarg_t* sg_platf_host_link_cbarg_t;
class LinkCreationArgs {
public:
e_surf_link_sharing_policy_t bb_sharing_policy;
} s_sg_platf_cluster_cbarg_t;
-typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
+typedef struct s_sg_platf_cabinet_cbarg* sg_platf_cabinet_cbarg_t;
typedef struct s_sg_platf_cabinet_cbarg {
const char* id;
const char* prefix;
double lat;
} s_sg_platf_cabinet_cbarg_t;
-typedef struct {
+typedef struct s_sg_platf_storage_cbarg* sg_platf_storage_cbarg_t;
+typedef struct s_sg_platf_storage_cbarg {
const char* id;
const char* type_id;
const char* content;
const char* content_type;
xbt_dict_t properties;
const char* attach;
-} s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
+} s_sg_platf_storage_cbarg_t;
-typedef struct {
+typedef struct s_sg_platf_storage_type_cbarg* sg_platf_storage_type_cbarg_t;
+typedef struct s_sg_platf_storage_type_cbarg {
const char* id;
const char* model;
const char* content;
xbt_dict_t properties;
std::map<std::string, std::string>* model_properties;
sg_size_t size;
-} s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
+} s_sg_platf_storage_type_cbarg_t;
-typedef struct {
+typedef struct s_sg_platf_mount_cbarg* sg_platf_mount_cbarg_t;
+typedef struct s_sg_platf_mount_cbarg {
const char* storageId;
const char* name;
-} s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
+} s_sg_platf_mount_cbarg_t;
typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
typedef struct s_sg_platf_prop_cbarg {
link_name = bprintf("%s_DOWN", A_surfxml_link___ctn_id);
link = simgrid::surf::LinkImpl::byName(link_name);
break;
+ default:
+ surf_parse_error("Invalid direction for link %s", link_name);
+ break;
}
xbt_free(link_name); // no-op if it's already nullptr
sg_platf_new_trace(&trace);
}
-void STag_surfxml_trace___connect(){
+void STag_surfxml_trace___connect()
+{
parse_after_config();
s_sg_platf_trace_connect_cbarg_t trace_connect;
memset(&trace_connect,0,sizeof(trace_connect));
case A_surfxml_trace___connect_kind_LINK___AVAIL:
trace_connect.kind = SURF_TRACE_CONNECT_KIND_LINK_AVAIL;
break;
+ default:
+ surf_parse_error("Invalid trace kind");
+ break;
}
sg_platf_trace_connect(&trace_connect);
}
-void STag_surfxml_AS(){
+void STag_surfxml_AS()
+{
AX_surfxml_zone_id = AX_surfxml_AS_id;
AX_surfxml_zone_routing = (AT_surfxml_zone_routing)AX_surfxml_AS_routing;
STag_surfxml_zone();
}
-void ETag_surfxml_AS(){
+
+void ETag_surfxml_AS()
+{
ETag_surfxml_zone();
}
-void STag_surfxml_zone(){
+
+void STag_surfxml_zone()
+{
parse_after_config();
ZONE_TAG = 1;
- s_sg_platf_AS_cbarg_t AS = { A_surfxml_zone_id, (int)A_surfxml_zone_routing};
+ s_sg_platf_AS_cbarg_t AS = {A_surfxml_zone_id, (int)A_surfxml_zone_routing};
sg_platf_new_AS_begin(&AS);
}
-void ETag_surfxml_zone(){
+
+void ETag_surfxml_zone()
+{
sg_platf_new_AS_seal();
}
-void STag_surfxml_config(){
+void STag_surfxml_config()
+{
ZONE_TAG = 0;
xbt_assert(current_property_set == nullptr, "Someone forgot to reset the property set to nullptr in its closing tag (or XML malformed)");
XBT_DEBUG("START configuration name = %s",A_surfxml_config_id);
"<link>, etc).");
}
}
-void ETag_surfxml_config(){
+
+void ETag_surfxml_config()
+{
xbt_dict_cursor_t cursor = nullptr;
char *key;
char *elem;
xbt_dict_foreach(current_property_set, cursor, key, elem) {
if (xbt_cfg_is_default_value(key)) {
- char* cfg = bprintf("%s:%s", key, elem);
- xbt_cfg_set_parse(cfg);
- free(cfg);
+ std::string cfg = std::string(key) + ":" + elem;
+ xbt_cfg_set_parse(cfg.c_str());
} else
XBT_INFO("The custom configuration '%s' is already defined by user!",key);
}
case A_surfxml_actor_on___failure_RESTART:
actor.on_failure = SURF_ACTOR_ON_FAILURE_RESTART;
break;
+ default:
+ surf_parse_error("Invalid on failure behavior");
+ break;
}
sg_platf_new_process(&actor);
return surf_parse_lex();
}
-int_f_void_t surf_parse = _surf_parse;
+int_f_void_t surf_parse = &_surf_parse;
SG_END_DECL()
xbt_dictelm_t *currcell = (xbt_dictelm_t *) xbt_realloc((char *) dict->table, newsize * sizeof(xbt_dictelm_t));
memset(&currcell[oldsize], 0, oldsize * sizeof(xbt_dictelm_t)); /* zero second half */
- dict->table_size = --newsize;
+ newsize--;
+ dict->table_size = newsize;
dict->table = currcell;
XBT_DEBUG("REHASH (%d->%d)", oldsize, newsize);
total_count += size;
}
}
- printf("; %f elm per cell\n", avg / (double) total_count);
+ if (total_count > 0)
+ printf("; %f elm per cell\n", avg / (double)total_count);
+ else
+ printf("; 0 elm per cell\n");
}
}
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);
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(xbt_ex, xbt, "Exception mechanism");
-xbt_ex::~xbt_ex() {}
-
-void _xbt_throw(
- char* message, xbt_errcat_t errcat, int value,
- const char* file, int line, const char* func)
+void _xbt_throw(char* message, xbt_errcat_t errcat, int value, const char* file, int line, const char* func)
{
xbt_ex e(simgrid::xbt::ThrowPoint(file, line, func), message);
free(message);
return "io error";
case vm_error:
return "vm error";
+ default:
+ return "INVALID ERROR";
}
return "INVALID ERROR";
}
XBT_LOG_CONNECT(log);
XBT_LOG_CONNECT(module);
XBT_LOG_CONNECT(replay);
- XBT_LOG_CONNECT(strbuff);
XBT_LOG_CONNECT(xbt_cfg);
XBT_LOG_CONNECT(xbt_dict);
XBT_LOG_CONNECT(xbt_dict_cursor);
XBT_LOG_CONNECT(instr_resource);
XBT_LOG_CONNECT(instr_routing);
XBT_LOG_CONNECT(instr_surf);
- XBT_LOG_CONNECT(instr_trace);
- XBT_LOG_CONNECT(instr_TI_trace);
/* jedule */
#if SIMGRID_HAVE_JEDULE
/** An virtual memory map entry from /proc/$pid/maps */
struct VmMap {
- std::uint64_t start_addr, end_addr;
+ std::uint64_t start_addr;
+ std::uint64_t end_addr;
int prot; /* Memory protection */
int flags; /* Additional memory flags */
std::uint64_t offset; /* Offset in the file/whatever */
/* layout_simple - a dumb log layout */
-/* Copyright (c) 2007-2016. The SimGrid Team. */
+/* Copyright (c) 2007-2017. The SimGrid Team. */
/* 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" /* execinfo when available */
#include "xbt/sysdep.h"
-#include "xbt/strbuff.h"
#include "src/xbt/log_private.h"
#include "simgrid/simix.h" /* SIMIX_host_self_get_name */
#include "surf/surf.h"
#include <stdio.h>
-#if HAVE_EXECINFO_H
-# include <execinfo.h> /* Function backtrace */
-#endif
-
extern const char *xbt_log_priority_names[8];
static double format_begin_of_time = -1;
" where:\n" \
" source: %%F: file %%L: line %%M: function %%l: location (%%F:%%L)\n" \
" runtime: %%h: hostname %%t: thread %%P: process %%i: PID\n" \
- " backtrace: %%b: full %%B: short\n" \
" when: %%d: date %%r: app. age\n" \
" other: %%%%: %% %%n: new line %%e: plain space\n"
case 'M': /* method (ie, function) name; LOG4J compliant */
show_string(ev->functionName);
break;
- case 'b': /* backtrace; called %throwable in LOG4J */
- case 'B': /* short backtrace; called %throwable{short} in LOG4J */
-// TODO, backtrace
-#if 0 && HAVE_BACKTRACE && HAVE_EXECINFO_H && HAVE_POPEN && defined(ADDR2LINE)
- {
- xbt_ex_t e("");
-
- e.used = backtrace((void **) e.bt, XBT_BACKTRACE_SIZE);
- e.bt_strings = NULL;
- xbt_ex_setup_backtrace(&e);
- if (*q == 'B') {
- show_string(e.bt_strings[1] + 8);
- } else {
- xbt_strbuff_t buff = xbt_strbuff_new();
- int i;
- xbt_strbuff_append(buff, e.bt_strings[1] + 8);
- for (i = 2; i < e.used; i++) {
- xbt_strbuff_append(buff, "\n");
- xbt_strbuff_append(buff, e.bt_strings[i] + 8);
- }
- show_string(buff->data);
- xbt_strbuff_free(buff);
- }
- }
-#else
- show_string("(no backtrace on this arch)");
-#endif
- break;
case 'd': /* date; LOG4J compliant */
show_double(surf_get_clock());
break;
/* layout_simple - a dumb log layout */
-/* Copyright (c) 2007-2014. The SimGrid Team.
- * All rights reserved. */
+/* Copyright (c) 2007-2017. 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 "xbt/sysdep.h"
-#include "xbt/strbuff.h" /* For dynamic version when the static one fails */
#include "src/xbt/log_private.h"
#include "simgrid/simix.h" /* SIMIX_host_self_get_name */
#include "surf/surf.h"
#include <stdio.h>
-#include "src/internal_config.h"
extern const char *xbt_log_priority_names[8];
extern int xbt_log_no_loc;
*/
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;
public:
explicit ReplayReader(const char* filename)
{
- fs = new std::ifstream(filename, std::ifstream::in);
+ XBT_VERB("Prepare to replay file '%s'", filename);
+ fs = new std::ifstream(filename, std::ifstream::in);
+ xbt_assert(fs->is_open(), "Cannot read file %s", filename);
}
~ReplayReader()
{
* under the terms of the license (GNU LGPL) which comes with this package. */
#include <xbt/ex.hpp>
-#include "src/internal_config.h"
#include "xbt/misc.h"
#include "xbt/sysdep.h"
#include "xbt/str.h" /* headers of these functions */
-#include "xbt/strbuff.h"
/** @brief Strip whitespace (or other characters) from the end of a string.
*
}
}
-/** @brief Replaces a set of variables by their values
- *
- * @param str The input of the replacement process
- * @param patterns The changes to apply
- * @return The string modified
- *
- * Both '$toto' and '${toto}' are valid (and the two writing are equivalent).
- *
- * If the variable name contains spaces, use the brace version (ie, ${toto tutu})
- *
- * You can provide a default value to use if the variable is not set in the dict by using '${var:=default}' or
- * '${var:-default}'. These two forms are equivalent, even if they shouldn't to respect the shell standard (:= form
- * should set the value in the dict, but does not) (BUG).
- */
-char *xbt_str_varsubst(const char *str, xbt_dict_t patterns)
-{
- xbt_strbuff_t buff = xbt_strbuff_new_from(str);
- char *res;
- xbt_strbuff_varsubst(buff, patterns);
- res = buff->data;
- xbt_strbuff_free_container(buff);
- return res;
-}
-
-
/** @brief Splits a string into a dynar of strings
*
* @param s: the string to split
+++ /dev/null
-/* strbuff -- string buffers */
-
-/* Copyright (c) 2007-2015. 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 "xbt/strbuff.h"
-#include <stdarg.h>
-
-#define minimal_increment 512
-
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(strbuff, xbt, "String buffers");
-
-/** @brief Remove any content from the buffer */
-inline void xbt_strbuff_clear(xbt_strbuff_t b)
-{
- b->used = 0;
- b->data[0] = '\0';
-}
-
-/** @brief Constructor */
-xbt_strbuff_t xbt_strbuff_new(void)
-{
- xbt_strbuff_t res = xbt_malloc(sizeof(s_xbt_strbuff_t));
- res->data = xbt_malloc(512);
- res->size = 512;
- xbt_strbuff_clear(res);
- return res;
-}
-
-/** @brief creates a new string buffer containing the provided string
- *
- * Beware, the ctn is copied, you want to free it afterward, anyhow
- */
-inline xbt_strbuff_t xbt_strbuff_new_from(const char *ctn)
-{
- xbt_strbuff_t res = xbt_malloc(sizeof(s_xbt_strbuff_t));
- res->data = xbt_strdup(ctn);
- res->size = strlen(ctn);
- res->used = res->size;
- return res;
-}
-
-/** @brief frees only the container without touching to the contained string */
-inline void xbt_strbuff_free_container(xbt_strbuff_t b)
-{
- free(b);
-}
-
-/** @brief frees the buffer and its content */
-inline void xbt_strbuff_free(xbt_strbuff_t b)
-{
- if (b) {
- free(b->data);
- free(b);
- }
-}
-
-/** @brief Adds some content at the end of the buffer */
-void xbt_strbuff_append(xbt_strbuff_t b, const char *toadd)
-{
- int addlen;
- int needed_space;
-
- xbt_assert(b, "Asked to append stuff to NULL buffer");
-
- addlen = strlen(toadd);
- needed_space = b->used + addlen + 1;
-
- if (needed_space > b->size) {
- b->size = MAX(minimal_increment + b->used, needed_space);
- b->data = xbt_realloc(b->data, b->size);
- }
- strncpy(b->data + b->used, toadd, b->size-b->used);
- b->used += addlen;
-}
-
-/** @brief format some content and push it at the end of the buffer */
-void xbt_strbuff_printf(xbt_strbuff_t b, const char *fmt, ...)
-{
- va_list ap;
- va_start(ap, fmt);
- char *data = bvprintf(fmt, ap);
- xbt_strbuff_append(b, data);
- xbt_free(data);
- va_end(ap);
-}
-
-/** @brief Replaces a set of variables by their values
- *
- * @param b buffer to modify
- * @param patterns variables to substitute in the buffer
- *
- * Both '$toto' and '${toto}' are valid (and the two writing are equivalent).
- *
- * If the variable name contains spaces, use the brace version (ie, ${toto tutu})
- *
- * You can provide a default value to use if the variable is not set in the dict by using '${var:=default}' or
- * '${var:-default}'. These two forms are equivalent, even if they shouldn't to respect the shell standard (:= form
- * should set the value in the dict, but does not) (BUG).
- */
-void xbt_strbuff_varsubst(xbt_strbuff_t b, xbt_dict_t patterns)
-{
- char *end; /* pointers around the parsed chunk */
- int in_simple_quote = 0;
- int in_double_quote = 0;
- int done = 0;
-
- if (b->data[0] == '\0')
- return;
- end = b->data;
-
- while (!done) {
- switch (*end) {
- case '\\':
- /* Protected char; pass the protection */
- end++;
- xbt_assert(*end != '\0', "String ends with \\");
- break;
- case '\'':
- if (!in_double_quote) {
- /* simple quote not protected by double ones, note it */
- in_simple_quote = !in_simple_quote;
- }
- break;
- case '"':
- if (!in_simple_quote) {
- /* double quote protected by simple ones, note it */
- in_double_quote = !in_double_quote;
- }
- break;
- case '$':
- if (!in_simple_quote) {
- /* Go for the substitution. First search the variable name */
- char *beg_var;
- char *end_var; /* variable name boundary */
- char *beg_subst = end;
- char *end_subst = NULL; /* where value should be written to */
- char *value;
- char *default_value = NULL;
- int val_len;
-
- if (*(++end) == '{') {
- /* the variable name is enclosed in braces. */
- beg_var = end + 1;
- /* Search name's end */
- end_var = beg_var;
- while (*end_var != '\0' && *end_var != '}') {
- /* TODO: we do not respect the standard for ":=", we should set this value in the dict */
- if (*end_var == ':'
- && ((*(end_var + 1) == '=') || (*(end_var + 1) == '-'))) {
- /* damn, we have a default value */
- char *p = end_var + 1;
- while (*p != '\0' && *p != '}')
- p++;
- xbt_assert (*p != '\0', "Variable default value not terminated ('}' missing)");
-
- default_value = xbt_malloc(p - end_var - 1);
- memcpy(default_value, end_var + 2, p - end_var - 2);
- default_value[p - end_var - 2] = '\0';
-
- end_subst = p + 1; /* eat '}' */
- break;
- }
- end_var++;
- }
- xbt_assert(*end_var != '\0', "Variable name not terminated ('}' missing)");
-
- if (!end_subst) /* already set if there's a default value */
- end_subst = end_var + 1; /* also kill the } in the name */
-
- xbt_assert(end_var != beg_var, "Variable name empty (${} is not valid)");
- } else {
- /* name given directly */
- beg_var = end;
- end_var = beg_var;
- while (*end_var != '\0' && *end_var != ' ' && *end_var != '\t' && *end_var != '\n')
- end_var++;
- end_subst = end_var;
- xbt_assert (end_var != beg_var, "Variable name empty ($ is not valid)");
- }
-
- /* ok, we now have the variable name. Search the dictionary for the substituted value */
- value = xbt_dict_get_or_null_ext(patterns, beg_var, end_var - beg_var);
-
- if (value)
- value = xbt_strdup(value);
- else if (default_value)
- value = xbt_strdup(default_value);
- else
- value = xbt_strdup("");
-
- /* En route for the actual substitution */
- val_len = strlen(value);
- if (val_len <= end_subst - beg_subst) {
- /* enough room to do the substitute in place */
- memmove(beg_subst, value, val_len); /* substitute */
- /* move the end of the string closer */
- memmove(beg_subst + val_len, end_subst, b->used - (end_subst - b->data) + 1);
-// XBT_DEBUG("String is now: '%s'",b->data);
- end = beg_subst + val_len; /* update the currently explored char in the overall loop */
-// XBT_DEBUG("end of substituted section is now '%s'",end);
- b->used -= end_subst - beg_subst - val_len; /* update string buffer used size */
-// XBT_DEBUG("Used:%d end:%d ending char:%d",b->used,end-b->data,*end);
- } else {
- /* we have to extend the data area */
- int tooshort = val_len - (end_subst - beg_subst) + 1 /* don't forget \0 */ ;
- int newused = b->used + tooshort;
- end += tooshort; /* update the pointer of the overall loop */
-// XBT_DEBUG("Too short (by %d chars; %d chars left in area)",val_len-(end_subst-beg_subst),b->size - b->used);
- if (newused > b->size) {
- /* We have to realloc the data area before (because b->size is too small).
- * We have to update our pointers, too */
- char *newdata = xbt_realloc(b->data, b->used + MAX(minimal_increment, tooshort));
- int offset = newdata - b->data;
- b->data = newdata;
- b->size = b->used + MAX(minimal_increment, tooshort);
- end += offset;
- beg_subst += offset;
- end_subst += offset;
- }
- /* move the end of the string a bit further */
- memmove(beg_subst + val_len, end_subst, b->used - (end_subst - b->data) + 1);
- memmove(beg_subst, value, val_len); /* substitute */
- b->used = newused;
-// XBT_DEBUG("String is now: %s",b->data);
- }
- free(value);
- free(default_value);
- end--; /* compensate the next end++ */
- }
- break;
- case '\0':
- done = 1;
- break;
- }
- end++;
- }
-}
-
-#ifdef SIMGRID_TEST
-#include "xbt/strbuff.h"
-
-/* buffstr have 512 chars by default. Adding 1000 chars like this will force a resize, allowing us to test that
- * b->used and b->size are consistent */
-#define force_resize \
- "1.........1.........2.........3.........4.........5.........6.........7.........8.........9........." \
- "2.........1.........2.........3.........4.........5.........6.........7.........8.........9........." \
- "3.........1.........2.........3.........4.........5.........6.........7.........8.........9........." \
- "4.........1.........2.........3.........4.........5.........6.........7.........8.........9........." \
- "5.........1.........2.........3.........4.........5.........6.........7.........8.........9........." \
- "6.........1.........2.........3.........4.........5.........6.........7.........8.........9........." \
- "7.........1.........2.........3.........4.........5.........6.........7.........8.........9........." \
- "8.........1.........2.........3.........4.........5.........6.........7.........8.........9........." \
- "9.........1.........2.........3.........4.........5.........6.........7.........8.........9........." \
- "0.........1.........2.........3.........4.........5.........6.........7.........8.........9........."
-
-static void mytest(const char *input, const char *patterns, const char *expected)
-{
- xbt_dynar_t dyn_patterns; /* splited string */
- xbt_dict_t p; /* patterns */
- unsigned int cpt;
- char *str; /*foreach */
- xbt_strbuff_t sb; /* what we test */
-
- p = xbt_dict_new_homogeneous(free);
- dyn_patterns = xbt_str_split(patterns, " ");
- xbt_dynar_foreach(dyn_patterns, cpt, str) {
- xbt_dynar_t keyvals = xbt_str_split(str, "=");
- char *key = xbt_dynar_get_as(keyvals, 0, char *);
- char *val = xbt_dynar_get_as(keyvals, 1, char *);
- xbt_str_subst(key, '_', ' ', 0); // to put space in names without breaking the enclosing dynar_foreach
- xbt_dict_set(p, key, xbt_strdup(val), NULL);
- xbt_dynar_free(&keyvals);
- }
- xbt_dynar_free(&dyn_patterns);
- sb = xbt_strbuff_new();
- xbt_strbuff_append(sb, input);
- xbt_strbuff_varsubst(sb, p);
- xbt_dict_free(&p);
- xbt_test_assert(!strcmp(sb->data, expected), "Input (%s) with patterns (%s) leads to (%s) instead of (%s)",
- input, patterns, sb->data, expected);
- xbt_strbuff_free(sb);
-}
-
-XBT_TEST_SUITE("xbt_strbuff", "String Buffers");
-XBT_TEST_UNIT("xbt_strbuff_substitute", test_strbuff_substitute, "test the function xbt_strbuff_substitute")
-{
- xbt_test_add("Empty");
- mytest("", "", "");
-
- xbt_test_add("Value shorter, no braces, only variable");
- mytest("$tutu", "tutu=t", "t");
- xbt_test_add("Value shorter, braces, only variable");
- mytest("${tutu}", "tutu=t", "t");
- xbt_test_add("Value shorter, no braces, data after");
- mytest("$tutu toto", "tutu=t", "t toto");
- xbt_test_add("Value shorter, braces, data after");
- mytest("${tutu} toto", "tutu=t", "t toto");
- xbt_test_add("Value shorter, no braces, data before");
- mytest("toto $tutu", "tutu=t", "toto t");
- xbt_test_add("Value shorter, braces, data before");
- mytest("toto ${tutu}", "tutu=t", "toto t");
- xbt_test_add("Value shorter, no braces, data before and after");
- mytest("toto $tutu tata", "tutu=t", "toto t tata");
- xbt_test_add("Value shorter, braces, data before and after");
- mytest("toto ${tutu} tata", "tutu=t", "toto t tata");
-
- xbt_test_add("Value as long, no braces, only variable");
- mytest("$tutu", "tutu=12345", "12345");
- xbt_test_add("Value as long, braces, only variable");
- mytest("${tutu}", "tutu=1234567", "1234567");
- xbt_test_add("Value as long, no braces, data after");
- mytest("$tutu toto", "tutu=12345", "12345 toto");
- xbt_test_add("Value as long, braces, data after");
- mytest("${tutu} toto", "tutu=1234567", "1234567 toto");
- xbt_test_add("Value as long, no braces, data before");
- mytest("toto $tutu", "tutu=12345", "toto 12345");
- xbt_test_add("Value as long, braces, data before");
- mytest("toto ${tutu}", "tutu=1234567", "toto 1234567");
- xbt_test_add("Value as long, no braces, data before and after");
- mytest("toto $tutu tata", "tutu=12345", "toto 12345 tata");
- xbt_test_add("Value as long, braces, data before and after");
- mytest("toto ${tutu} tata", "tutu=1234567", "toto 1234567 tata");
-
- xbt_test_add("Value longer, no braces, only variable");
- mytest("$t", "t=tututu", "tututu");
- xbt_test_add("Value longer, braces, only variable");
- mytest("${t}", "t=tututu", "tututu");
- xbt_test_add("Value longer, no braces, data after");
- mytest("$t toto", "t=tututu", "tututu toto");
- xbt_test_add("Value longer, braces, data after");
- mytest("${t} toto", "t=tututu", "tututu toto");
- xbt_test_add("Value longer, no braces, data before");
- mytest("toto $t", "t=tututu", "toto tututu");
- xbt_test_add("Value longer, braces, data before");
- mytest("toto ${t}", "t=tututu", "toto tututu");
- xbt_test_add("Value longer, no braces, data before and after");
- mytest("toto $t tata", "t=tututu", "toto tututu tata");
- xbt_test_add("Value longer, braces, data before and after");
- mytest("toto ${t} tata", "t=tututu", "toto tututu tata");
-
- xbt_test_add("Value much longer, no braces, only variable");
- mytest("$t", "t=" force_resize, force_resize);
- xbt_test_add("Value much longer, no braces, data after");
- mytest("$t toto", "t=" force_resize, force_resize " toto");
- xbt_test_add("Value much longer, braces, data after");
- mytest("${t} toto", "t=" force_resize, force_resize " toto");
- xbt_test_add("Value much longer, no braces, data before");
- mytest("toto $t", "t=" force_resize, "toto " force_resize);
- xbt_test_add("Value much longer, braces, data before");
- mytest("toto ${t}", "t=" force_resize, "toto " force_resize);
- xbt_test_add("Value much longer, no braces, data before and after");
- mytest("toto $t tata", "t=" force_resize, "toto " force_resize " tata");
- xbt_test_add("Value much longer, braces, data before and after");
- mytest("toto ${t} tata", "t=" force_resize, "toto " force_resize " tata");
-
- xbt_test_add("Escaped $");
- mytest("\\$tutu", "tutu=t", "\\$tutu");
- xbt_test_add("Space in var name (with braces)");
- mytest("${tu ti}", "tu_ti=t", "t");
-
- xbt_test_add("Two variables");
- mytest("$toto $tutu", "toto=1 tutu=2", "1 2");
-
- // Commented: I'm too lazy to do a memmove in var name to remove the backslash after use.
- // Users should use braces.
- // xbt_test_add("Escaped space in var name", "$tu\\ ti", "tu_ti=t", "t");
-
- xbt_test_add("Default value");
- mytest("${t:-toto}", "", "toto");
- xbt_test_add("Useless default value (variable already defined)");
- mytest("${t:-toto}", "t=TRUC", "TRUC");
-}
-#endif /* SIMGRID_TEST */
{
XBT_INFO("Launching our nice bugged recursive function...");
unsigned i = 1;
- while (i <= 0x80000000u) {
+ while (i <= 0x80000000U) {
i *= 2;
unsigned res = collatz(i, i);
XBT_VERB("collatz(%u, %u) returned %u", i, i, res);
int i;
int rank;
int size;
- int *sendcounts, *recvcounts, *rdispls, *sdispls;
MPI_Init(&argc, &argv);
}
/* Create and load the arguments to alltoallv */
- sendcounts = (int *) xbt_malloc(size * sizeof(int));
- recvcounts = (int *) xbt_malloc(size * sizeof(int));
- rdispls = (int *) xbt_malloc(size * sizeof(int));
- sdispls = (int *) xbt_malloc(size * sizeof(int));
+ int* sendcounts = (int*)xbt_malloc(size * sizeof(int));
+ int* recvcounts = (int*)xbt_malloc(size * sizeof(int));
+ int* rdispls = (int*)xbt_malloc(size * sizeof(int));
+ int* sdispls = (int*)xbt_malloc(size * sizeof(int));
for (i = 0; i < size; i++) {
sendcounts[i] = i;
recvcounts[i] = rank;
/* 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]=
XBT_INFO("HeapA allocated");
- int i, size;
+ int i;
+ int size;
for (i = 0; i < TESTSIZE; i++) {
size = size_of_block(i);
pointers[i] = mmalloc(heapA, size);
static int parmap_skip_mode(e_xbt_parmap_mode_t mode)
{
- switch (mode) {
#if !HAVE_FUTEX_H
- case XBT_PARMAP_FUTEX:
+ if (mode == XBT_PARMAP_FUTEX) {
printf("not available\n");
return 1;
+ } else
#endif
- default:
return 0;
- }
}
static unsigned fibonacci(unsigned n)
src/xbt/xbt_os_time.c
src/xbt/xbt_replay.cpp
src/xbt/xbt_str.cpp
- src/xbt/xbt_strbuff.c
src/xbt/xbt_virtu.c
src/xbt_modinter.h
)
)
set(TRACING_SRC
- src/instr/instr_TI_trace.cpp
src/instr/instr_config.cpp
src/instr/instr_interface.cpp
src/instr/instr_paje_containers.cpp
src/instr/instr_private.h
src/instr/instr_smpi.h
src/instr/instr_resource_utilization.cpp
- src/instr/instr_trace.cpp
)
set(JEDULE_SRC
include/xbt/log.hpp
include/xbt/mallocator.h
include/xbt/matrix.h
- include/xbt/memory.hpp
include/xbt/misc.h
include/xbt/mmalloc.h
include/xbt/module.h
include/xbt/range.hpp
include/xbt/replay.hpp
include/xbt/str.h
- include/xbt/strbuff.h
include/xbt/swag.h
include/xbt/synchro.h
include/xbt/sysdep.h
COMMAND ${CMAKE_COMMAND} -E remove -f src/simgrid_units_main.c
COMMAND ${CMAKE_COMMAND} -E remove -f src/swag_unit.c
COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_str_unit.c
- COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_strbuff_unit.c
COMMAND ${CMAKE_COMMAND} -E remove -f src/xbt_synchro_unit.c
WORKING_DIRECTORY "${CMAKE_HOME_DIRECTORY}")
src/xbt/xbt_log_layout_format.c src/xbt/xbt_log_layout_simple.c
src/xbt/dict.cpp src/xbt/dict_elm.c src/xbt/dict_cursor.c
src/xbt/dynar.cpp src/xbt/heap.c src/xbt/swag.c
- src/xbt/str.c src/xbt/strbuff.c src/xbt/snprintf.c
+ src/xbt/str.c src src/xbt/snprintf.c
src/xbt/queue.c
src/xbt/xbt_os_time.c src/xbt/xbt_os_thread.c
src/xbt/backtrace_linux.c
src/xbt/dict.cpp
src/xbt/swag.c
src/xbt/xbt_str.cpp
- src/xbt/xbt_strbuff.c
src/xbt/config.cpp
)
smx
src
std
-strbuff
strerror
strlen
struct
# On Mac OSX or with pull requests, you don't want to run SonarQube but to exec the build command directly.
if [ ${TRAVIS_OS_NAME} != 'linux' ] || [ ${TRAVIS_PULL_REQUEST} != 'false' ]
then
- exec "$@"
+ sh "$@" && ctest --output-on-failure
+ exit $?
fi
# Passed this point, we are on Linux and not in a PR (exec never returns)
# See https://docs.travis-ci.com/user/sonarqube/ for more info on tokens
# don't show the token in the logs
set +x
-sonar-scanner -Dsonar.host.url=https://sonarqube.com -Dsonar.login=$SONAR_TOKEN \
- | grep -v 'INFO: Parsing /home/travis/build/simgrid/simgrid/Testing/CoverageInfo' \
+sonar-scanner -Dsonar.host.url=https://sonarqube.com -Dsonar.login=$SONAR_TOKEN 2>&1 \
+ | grep -v 'INFO: Parsing /home/travis/build/simgrid/simgrid/Testing/CoverageInfo' \
| grep -v 'WARN: File not analysed by Sonar, so ignoring coverage: /usr/include/'
exit $outcome
\ No newline at end of file
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:
# ,----