static void print_line (const char *option, const char *desc, const char *longdesc, int detailed)
{
- char str[INSTR_DEFAULT_STR_SIZE];
- snprintf (str, INSTR_DEFAULT_STR_SIZE, "--cfg=%s ", option);
+ std::string str = std::string("--cfg=") + option + " ";
- int len = strlen (str);
- printf ("%s%*.*s %s\n", str, 30-len, 30-len, "", desc);
+ int len = str.size();
+ printf("%s%*.*s %s\n", str.c_str(), 30 - len, 30 - len, "", desc);
if (longdesc != nullptr && detailed){
printf ("%s\n\n", longdesc);
}
created_categories.insert(category);
//define final_color
- char final_color[INSTR_DEFAULT_STR_SIZE];
+ std::string final_color;
if (not color) {
//generate a random color
double red = drand48();
double green = drand48();
double blue = drand48();
- snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%f %f %f", red, green, blue);
+ final_color = std::to_string(red) + " " + std::to_string(green) + " " + std::to_string(blue);
}else{
- snprintf (final_color, INSTR_DEFAULT_STR_SIZE, "%s", color);
+ final_color = std::string(color);
}
- XBT_DEBUG("CAT,declare %s, \"%s\" \"%s\"", category, color, final_color);
+ XBT_DEBUG("CAT,declare %s, \"%s\" \"%s\"", category, color, final_color.c_str());
//define the type of this category on top of hosts and links
instr_new_variable_type (category, final_color);
if (what == INSTR_US_DECLARE){
if (created == filter->end()) { // not declared yet
filter->insert(variable);
- instr_new_user_variable_type (father_type, variable, color);
+ instr_new_user_variable_type(father_type, variable, color == nullptr ? "" : color);
}
}else{
if (created != filter->end()) { // declared, let's work
#define drand48() (rand() / (RAND_MAX + 1.0))
#endif
-#define INSTR_DEFAULT_STR_SIZE 500
-
namespace simgrid {
namespace instr {
XBT_PRIVATE long long int instr_new_paje_id();
XBT_PUBLIC(container_t) PJ_container_get_root ();
XBT_PUBLIC(void) PJ_container_set_root (container_t root);
-void instr_new_variable_type(std::string new_typename, const char* color);
-void instr_new_user_variable_type(std::string father_type, std::string new_typename, const char* color);
+void instr_new_variable_type(std::string new_typename, std::string color);
+void instr_new_user_variable_type(std::string father_type, std::string new_typename, std::string color);
void instr_new_user_state_type(std::string father_type, std::string new_typename);
-void instr_new_value_for_user_state_type(std::string new_typename, const char* value, const char* color);
+void instr_new_value_for_user_state_type(std::string new_typename, const char* value, std::string color);
/* instr_config.c */
XBT_PRIVATE void TRACE_TI_start();
simgrid::instr::Type* type = process_container->type_->byName("MSG_PROCESS_STATE");
new simgrid::instr::PopStateEvent(MSG_get_clock(), process_container, type);
- char key[INSTR_DEFAULT_STR_SIZE];
- snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter);
+ std::string key = std::string("p") + std::to_string(task->counter);
type = simgrid::instr::Type::getRootType()->byName("MSG_PROCESS_TASK_LINK");
new simgrid::instr::EndLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
}
simgrid::instr::Value* val = type->getEntityValue("send");
new simgrid::instr::PushStateEvent(MSG_get_clock(), process_container, type, val);
- char key[INSTR_DEFAULT_STR_SIZE];
- snprintf (key, INSTR_DEFAULT_STR_SIZE, "p%lld", task->counter);
+ std::string key = std::string("p") + std::to_string(task->counter);
type = simgrid::instr::Type::getRootType()->byName("MSG_PROCESS_TASK_LINK");
new simgrid::instr::StartLinkEvent(MSG_get_clock(), PJ_container_get_root(), type, process_container, "SR", key);
}
if (TRACE_msg_vm_is_enabled()) {
static long long int counter = 0;
- char key[INSTR_DEFAULT_STR_SIZE];
- snprintf(key, INSTR_DEFAULT_STR_SIZE, "%lld", counter);
+ std::string key = std::to_string(counter);
counter++;
// start link
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_smpi, instr, "Tracing SMPI");
-static std::unordered_map<char*, std::deque<std::string>*> keys;
-
-static const char *smpi_colors[] ={
- "recv", "1 0 0",
- "irecv", "1 0.52 0.52",
- "send", "0 0 1",
- "isend", "0.52 0.52 1",
- "sendrecv", "0 1 1",
- "wait", "1 1 0",
- "waitall", "0.78 0.78 0",
- "waitany", "0.78 0.78 0.58",
- "test", "0.52 0.52 0",
-
- "allgather", "1 0 0",
- "allgatherv", "1 0.52 0.52",
- "allreduce", "1 0 1",
- "alltoall", "0.52 0 1",
- "alltoallv", "0.78 0.52 1",
- "barrier", "0 0.78 0.78",
- "bcast", "0 0.78 0.39",
- "gather", "1 1 0",
- "gatherv", "1 1 0.52",
- "reduce", "0 1 0",
- "reducescatter", "0.52 1 0.52",
- "scan", "1 0.58 0.23",
- "exscan", "1 0.54 0.25",
- "scatterv", "0.52 0 0.52",
- "scatter", "1 0.74 0.54",
-
- "computing", "0 1 1",
- "sleeping", "0 0.5 0.5",
-
- "init", "0 1 0",
- "finalize", "0 1 0",
-
- "put", "0.3 1 0",
- "get", "0 1 0.3",
- "accumulate", "1 0.3 0",
- "win_fence", "1 0 0.3",
- "win_post", "1 0 0.8",
- "win_wait", "1 0.8 0",
- "win_start", "0.8 0 1",
- "win_complete", "0.8 1 0",
- nullptr, nullptr,
+static std::unordered_map<std::string, std::deque<std::string>*> keys;
+
+static const char* smpi_colors[] = {
+ "recv", "1 0 0", "irecv", "1 0.52 0.52", "send", "0 0 1",
+ "isend", "0.52 0.52 1", "sendrecv", "0 1 1", "wait", "1 1 0",
+ "waitall", "0.78 0.78 0", "waitany", "0.78 0.78 0.58", "test", "0.52 0.52 0",
+
+ "allgather", "1 0 0", "allgatherv", "1 0.52 0.52", "allreduce", "1 0 1",
+ "alltoall", "0.52 0 1", "alltoallv", "0.78 0.52 1", "barrier", "0 0.78 0.78",
+ "bcast", "0 0.78 0.39", "gather", "1 1 0", "gatherv", "1 1 0.52",
+ "reduce", "0 1 0", "reducescatter", "0.52 1 0.52", "scan", "1 0.58 0.23",
+ "exscan", "1 0.54 0.25", "scatterv", "0.52 0 0.52", "scatter", "1 0.74 0.54",
+
+ "computing", "0 1 1", "sleeping", "0 0.5 0.5",
+
+ "init", "0 1 0", "finalize", "0 1 0",
+
+ "put", "0.3 1 0", "get", "0 1 0.3", "accumulate", "1 0.3 0",
+ "win_fence", "1 0 0.3", "win_post", "1 0 0.8", "win_wait", "1 0.8 0",
+ "win_start", "0.8 0 1", "win_complete", "0.8 1 0", nullptr, nullptr,
};
static const char* instr_find_color(const char* state)
return std::string("rank-") + std::to_string(rank);
}
-static char *TRACE_smpi_get_key(int src, int dst, int tag, char *key, int n, int send);
-
-static char *TRACE_smpi_put_key(int src, int dst, int tag, char *key, int n, int send)
+static std::string TRACE_smpi_put_key(int src, int dst, int tag, int send)
{
- //get the dynar for src#dst
- char aux[INSTR_DEFAULT_STR_SIZE];
- snprintf(aux, INSTR_DEFAULT_STR_SIZE, "%d#%d#%d#%d", src, dst, tag, send);
+ // get the deque for src#dst
+ std::string aux =
+ std::to_string(src) + "#" + std::to_string(dst) + "#" + std::to_string(tag) + "#" + std::to_string(send);
auto it = keys.find(aux);
std::deque<std::string>* d;
//generate the key
static unsigned long long counter = 0;
counter++;
- snprintf(key, n, "%d_%d_%d_%llu", src, dst, tag, counter);
+ std::string key =
+ std::to_string(src) + "_" + std::to_string(dst) + "_" + std::to_string(tag) + "_" + std::to_string(counter);
//push it
d->push_back(key);
return key;
}
-static char *TRACE_smpi_get_key(int src, int dst, int tag, char *key, int n, int send)
+static std::string TRACE_smpi_get_key(int src, int dst, int tag, int send)
{
- char aux[INSTR_DEFAULT_STR_SIZE];
- snprintf(aux, INSTR_DEFAULT_STR_SIZE, "%d#%d#%d#%d", src, dst, tag, send==1?0:1);
+ std::string key;
+ std::string aux = std::to_string(src) + "#" + std::to_string(dst) + "#" + std::to_string(tag) + "#" +
+ std::to_string(send == 1 ? 0 : 1);
auto it = keys.find(aux);
if (it == keys.end()) {
// first posted
- TRACE_smpi_put_key(src, dst, tag, key, n, send);
+ key = TRACE_smpi_put_key(src, dst, tag, send);
} else {
- snprintf(key, n, "%s", it->second->front().c_str());
+ key = it->second->front();
it->second->pop_front();
}
return key;
if (not TRACE_smpi_is_enabled())
return;
- char key[INSTR_DEFAULT_STR_SIZE] = {0};
- TRACE_smpi_get_key(src, dst, tag, key, INSTR_DEFAULT_STR_SIZE,1);
+ std::string key = TRACE_smpi_get_key(src, dst, tag, 1);
container_t container = simgrid::instr::Container::byName(smpi_container(rank));
simgrid::instr::Type* type = simgrid::instr::Type::getRootType()->byName("MPI_LINK");
- XBT_DEBUG("Send tracing from %d to %d, tag %d, with key %s", src, dst, tag, key);
+ XBT_DEBUG("Send tracing from %d to %d, tag %d, with key %s", src, dst, tag, key.c_str());
new simgrid::instr::StartLinkEvent(SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key, size);
}
if (not TRACE_smpi_is_enabled())
return;
- char key[INSTR_DEFAULT_STR_SIZE] = {0};
- TRACE_smpi_get_key(src, dst, tag, key, INSTR_DEFAULT_STR_SIZE,0);
+ std::string key = TRACE_smpi_get_key(src, dst, tag, 0);
container_t container = simgrid::instr::Container::byName(smpi_container(dst));
simgrid::instr::Type* type = simgrid::instr::Type::getRootType()->byName("MPI_LINK");
- XBT_DEBUG("Recv tracing from %d to %d, tag %d, with key %s", src, dst, tag, key);
+ XBT_DEBUG("Recv tracing from %d to %d, tag %d, with key %s", src, dst, tag, key.c_str());
new simgrid::instr::EndLinkEvent(SIMIX_get_clock(), PJ_container_get_root(), type, container, "PTP", key);
}
#if HAVE_PAPI
if (xbt_cfg_get_string("smpi/papi-events")[0] != '\0' && TRACE_smpi_is_enabled()) {
- char container_name[INSTR_DEFAULT_STR_SIZE];
- smpi_container(smpi_process()->index(), container_name, INSTR_DEFAULT_STR_SIZE);
- container_t container = PJ_container_get(container_name);
+ container_t container = new simgrid::instr::Container(smpi_container(smpi_process()->index()));
papi_counter_t& counter_data = smpi_process()->papi_counters();
for (auto const& pair : counter_data) {
- new_pajeSetVariable(surf_get_clock(), container,
- PJ_type_get(/* countername */ pair.first.c_str(), container->type), pair.second);
+ new simgrid::instr::SetVariableEvent(
+ surf_get_clock(), container, PJ_type_get(/* countername */ pair.first.c_str(), container->type), pair.second);
}
}
#endif
namespace simgrid{
namespace smpi{
-Request::Request(void *buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags) : buf_(buf), old_type_(datatype), src_(src), dst_(dst), tag_(tag), comm_(comm), flags_(flags)
+Request::Request(void* buf, int count, MPI_Datatype datatype, int src, int dst, int tag, MPI_Comm comm, unsigned flags)
+ : buf_(buf), old_type_(datatype), src_(src), dst_(dst), tag_(tag), comm_(comm), flags_(flags)
{
void *old_buf = nullptr;
// FIXME Handle the case of a partial shared malloc.
//create the link
static long long counter = 0;
- char key[INSTR_DEFAULT_STR_SIZE];
- snprintf (key, INSTR_DEFAULT_STR_SIZE, "%lld", counter);
+ std::string key = std::to_string(counter);
counter++;
new simgrid::instr::StartLinkEvent(SIMIX_get_clock(), father, link_type, src, "topology", key);
/*
* user categories support
*/
-static void recursiveNewVariableType(std::string new_typename, const char* color, simgrid::instr::Type* root)
+static void recursiveNewVariableType(std::string new_typename, std::string color, simgrid::instr::Type* root)
{
if (root->getName() == "HOST" || root->getName() == "MSG_VM")
- root->getOrCreateVariableType(std::string("p") + new_typename, color == nullptr ? "" : color);
+ root->getOrCreateVariableType(std::string("p") + new_typename, color);
if (root->getName() == "LINK")
- root->getOrCreateVariableType(std::string("b") + new_typename, color == nullptr ? "" : color);
+ root->getOrCreateVariableType(std::string("b") + new_typename, color);
for (auto elm : root->children_) {
- recursiveNewVariableType(new_typename, color == nullptr ? "" : color, elm.second);
+ recursiveNewVariableType(new_typename, color, elm.second);
}
}
-void instr_new_variable_type(std::string new_typename, const char* color)
+void instr_new_variable_type(std::string new_typename, std::string color)
{
recursiveNewVariableType(new_typename, color, simgrid::instr::Type::getRootType());
}
-static void recursiveNewUserVariableType(std::string father_type, std::string new_typename, const char* color,
+static void recursiveNewUserVariableType(std::string father_type, std::string new_typename, std::string color,
simgrid::instr::Type* root)
{
if (root->getName() == father_type) {
- root->getOrCreateVariableType(new_typename, color == nullptr ? "" : color);
+ root->getOrCreateVariableType(new_typename, color);
}
for (auto elm : root->children_)
recursiveNewUserVariableType(father_type, new_typename, color, elm.second);
}
-void instr_new_user_variable_type(std::string father_type, std::string new_typename, const char* color)
+void instr_new_user_variable_type(std::string father_type, std::string new_typename, std::string color)
{
recursiveNewUserVariableType(father_type, new_typename, color, simgrid::instr::Type::getRootType());
}
recursiveNewUserStateType(father_type, new_typename, simgrid::instr::Type::getRootType());
}
-static void recursiveNewValueForUserStateType(std::string type_name, const char* val, const char* color,
+static void recursiveNewValueForUserStateType(std::string type_name, const char* val, std::string color,
simgrid::instr::Type* root)
{
if (root->getName() == type_name)
recursiveNewValueForUserStateType(type_name, val, color, elm.second);
}
-void instr_new_value_for_user_state_type(std::string type_name, const char* value, const char* color)
+void instr_new_value_for_user_state_type(std::string type_name, const char* value, std::string color)
{
recursiveNewValueForUserStateType(type_name, value, color, simgrid::instr::Type::getRootType());
}