From: Augustin Degomme Date: Wed, 30 Oct 2013 13:42:49 +0000 (+0100) Subject: add Time independent output trace format ( TI ) to output traces that can then be... X-Git-Tag: v3_10_rc1~44 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/92959d5b26387e5194b1bb4553baf90da7701f41 add Time independent output trace format ( TI ) to output traces that can then be replayed For now only handles SMPI Using -trace-ti flag with smpirun should output a smpi_simgrid.txt file by default, which could be then used for replay. All outputs are for now merged into only one file. --- diff --git a/buildtools/Cmake/DefinePackages.cmake b/buildtools/Cmake/DefinePackages.cmake index 8629c550ad..ef2c2754a7 100644 --- a/buildtools/Cmake/DefinePackages.cmake +++ b/buildtools/Cmake/DefinePackages.cmake @@ -490,7 +490,9 @@ set(TRACING_SRC src/instr/instr_config.c src/instr/instr_interface.c src/instr/instr_paje_containers.c + src/instr/instr_TI_trace.c src/instr/instr_paje_trace.c + src/instr/instr_trace.c src/instr/instr_paje_header.c src/instr/instr_paje_types.c src/instr/instr_paje_values.c diff --git a/src/include/smpi/smpi_interface.h b/src/include/smpi/smpi_interface.h index 00308703cb..2a44cfe2c8 100644 --- a/src/include/smpi/smpi_interface.h +++ b/src/include/smpi/smpi_interface.h @@ -2,16 +2,7 @@ #define _SMPI_INTERFACE_H #include "smpi/smpi.h" -/********** Tracing **********/ -/* from smpi_instr.c */ -void TRACE_smpi_alloc(void); -void TRACE_smpi_release(void); -void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation, int size); -void TRACE_smpi_ptp_out(int rank, int src, int dst, const char *operation); -void TRACE_smpi_send(int rank, int src, int dst, int size); -void TRACE_smpi_recv(int rank, int src, int dst); -void TRACE_smpi_init(int rank); -void TRACE_smpi_finalize(int rank); + /** \brief MPI collective description */ diff --git a/src/instr/instr_TI_trace.c b/src/instr/instr_TI_trace.c new file mode 100644 index 0000000000..8f247b209e --- /dev/null +++ b/src/instr/instr_TI_trace.c @@ -0,0 +1,163 @@ +/* Copyright (c) 2010-2013. 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 "instr/instr_private.h" +#include "xbt/virtu.h" /* sg_cmdline */ +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_TI_trace, instr_trace, "tracing event system"); + + +extern FILE * tracing_file; +extern s_instr_trace_writer_t active_writer; +extern xbt_dynar_t buffer; + +void TRACE_TI_init(void) +{ + active_writer.print_PushState = print_TIPushState; +} + +void TRACE_TI_start(void) +{ + char *filename = TRACE_get_filename(); + tracing_file = fopen(filename, "w"); + if (tracing_file == NULL){ + 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()); + + buffer = xbt_dynar_new (sizeof(paje_event_t), NULL); +} + +void TRACE_TI_end(void) +{ + fclose(tracing_file); + char *filename = TRACE_get_filename(); + xbt_dynar_free (&buffer); + XBT_DEBUG("Filename %s is closed", filename); +} + +void print_TIPushState(paje_event_t event) +{ + + + int i; + + //char* function=NULL; + if (((pushState_t)event->data)->extra==NULL)return; + instr_extra_data extra = (instr_extra_data) (((pushState_t)event->data)->extra); + + char* process_id=NULL; + //FIXME: dirty extract "rank-" from the name, as we want the bare process id here + if(strstr(((pushState_t)event->data)->container->name, "rank-")==NULL) + process_id=strdup(((pushState_t)event->data)->container->name); + else + process_id=strdup(((pushState_t)event->data)->container->name +5); + + switch(extra->type){ + +case TRACING_INIT: + fprintf(tracing_file, "%s init\n", process_id); + break; +case TRACING_FINALIZE: + fprintf(tracing_file, "%s finalize\n", process_id); + break; +case TRACING_SEND: + fprintf(tracing_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1); + break; +case TRACING_ISEND: + fprintf(tracing_file, "%s isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1); + break; +case TRACING_RECV: + fprintf(tracing_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1); + break; +case TRACING_IRECV: + fprintf(tracing_file, "%s irecv %d %d %s\n", process_id, extra->src, extra->send_size,extra->datatype1); + break; +case TRACING_WAIT: + fprintf(tracing_file, "%s wait\n", process_id); + break; +case TRACING_WAITALL: + fprintf(tracing_file, "%s waitall\n", process_id); + break; +case TRACING_BARRIER: + fprintf(tracing_file, "%s barrier\n", process_id); + break; +case TRACING_BCAST: // rank bcast size (root) (datatype) + fprintf(tracing_file, "%s bcast %d ", process_id, extra->send_size); + if(extra->root!=0 || (extra->datatype1 && strcmp(extra->datatype1, ""))) + fprintf(tracing_file, "%d %s", extra->root, extra->datatype1); + fprintf(tracing_file, "\n"); + break; +case TRACING_REDUCE: // rank reduce comm_size comp_size (root) (datatype) + fprintf(tracing_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size); + if(extra->root!=0 || (extra->datatype1 && strcmp(extra->datatype1, ""))) + fprintf(tracing_file, "%d %s", extra->root, extra->datatype1); + fprintf(tracing_file, "\n"); + break; +case TRACING_ALLREDUCE: // rank allreduce comm_size comp_size (datatype) + fprintf(tracing_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(tracing_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(tracing_file, "%s alltoallv %d ", process_id, extra->send_size); + for(i=0; i< extra->num_processes; i++) + fprintf(tracing_file, "%d ", extra->sendcounts[i]); + fprintf(tracing_file, "%d ", extra->recv_size); + for(i=0; i< extra->num_processes; i++) + fprintf(tracing_file, "%d ", extra->recvcounts[i]); + fprintf(tracing_file, "%s %s \n", extra->datatype1, extra->datatype2); + break; +case TRACING_GATHER:// rank gather send_size recv_size root (sendtype) (recvtype) + fprintf(tracing_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(tracing_file, "%s allgatherv %d ", process_id, extra->send_size); + for(i=0; i< extra->num_processes; i++) + fprintf(tracing_file, "%d ", extra->recvcounts[i]); + fprintf(tracing_file, "%s %s \n", extra->datatype1, extra->datatype2); + break; +case TRACING_REDUCE_SCATTER:// rank reducescatter [recvcounts] comp_size (sendtype) + fprintf(tracing_file, "%s reducescatter ", process_id); + for(i=0; i< extra->num_processes; i++) + fprintf(tracing_file, "%d ", extra->recvcounts[i]); + fprintf(tracing_file, "%f %s\n", extra->comp_size, extra->datatype1); + break; +case TRACING_COMPUTING: + fprintf(tracing_file, "%s compute %f\n", process_id, extra->comp_size); + break; +case TRACING_WAITANY: +case TRACING_SENDRECV: +case TRACING_GATHERV: +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!=NULL)xbt_free(extra->recvcounts); + if(extra->sendcounts!=NULL)xbt_free(extra->sendcounts); + xbt_free(extra); +} diff --git a/src/instr/instr_config.c b/src/instr/instr_config.c index 7ee2f54033..ec606c184d 100644 --- a/src/instr/instr_config.c +++ b/src/instr/instr_config.c @@ -102,8 +102,22 @@ int TRACE_start() if (TRACE_is_enabled() && TRACE_is_configured()) { XBT_DEBUG("Tracing starts"); + /* init the tracing module to generate the right output */ /* open the trace file */ - TRACE_paje_start(); + + const char* format = sg_cfg_get_string("tracing/smpi/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(); + TRACE_TI_start(); + }else{ + xbt_die("Unknown trace format :%s ", format); + } + + /* activate trace */ if (trace_active == 1) { @@ -558,7 +572,7 @@ void TRACE_help (int detailed) "is the more relevant to the collective (total sent by the process, usually)", detailed); print_line (OPT_TRACING_FORMAT, "Only works for SMPI now. Switch output format", - "Default format is Paje. Time independant traces are also supported, \n" + "Default format is Paje. Time independent traces are also supported, \n" "to output traces that can later be used by the trace replay tool", detailed); print_line (OPT_TRACING_COMMENT, "Comment to be added on the top of the trace file.", diff --git a/src/instr/instr_paje_trace.c b/src/instr/instr_paje_trace.c index 01680ae3ef..91bfb95931 100644 --- a/src/instr/instr_paje_trace.c +++ b/src/instr/instr_paje_trace.c @@ -7,169 +7,35 @@ #include "instr/instr_private.h" #include "xbt/virtu.h" /* sg_cmdline */ -#ifdef HAVE_TRACING - -XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_trace, instr, "Paje tracing event system"); - -typedef struct paje_event *paje_event_t; -typedef struct paje_event { - double timestamp; - e_event_type event_type; - void (*print) (paje_event_t event); - void (*free) (paje_event_t event); - void *data; -} s_paje_event_t; - -typedef struct s_defineContainerType *defineContainerType_t; -typedef struct s_defineContainerType { - type_t type; -}s_defineContainerType_t; - -typedef struct s_defineVariableType *defineVariableType_t; -typedef struct s_defineVariableType { - type_t type; -}s_defineVariableType_t; - -typedef struct s_defineStateType *defineStateType_t; -typedef struct s_defineStateType { - type_t type; -}s_defineStateType_t; - -typedef struct s_defineEventType *defineEventType_t; -typedef struct s_defineEventType { - type_t type; -}s_defineEventType_t; - -typedef struct s_defineLinkType *defineLinkType_t; -typedef struct s_defineLinkType { - type_t type; - type_t source; - type_t dest; -}s_defineLinkType_t; - -typedef struct s_defineEntityValue *defineEntityValue_t; -typedef struct s_defineEntityValue { - val_t value; -}s_defineEntityValue_t; - -typedef struct s_createContainer *createContainer_t; -typedef struct s_createContainer { - container_t container; -}s_createContainer_t; - -typedef struct s_destroyContainer *destroyContainer_t; -typedef struct s_destroyContainer { - container_t container; -}s_destroyContainer_t; - -typedef struct s_setVariable *setVariable_t; -typedef struct s_setVariable { - container_t container; - type_t type; - double value; -}s_setVariable_t; - -typedef struct s_addVariable *addVariable_t; -typedef struct s_addVariable { - container_t container; - type_t type; - double value; -}s_addVariable_t; - -typedef struct s_subVariable *subVariable_t; -typedef struct s_subVariable { - container_t container; - type_t type; - double value; -}s_subVariable_t; - -typedef struct s_setState *setState_t; -typedef struct s_setState { - container_t container; - type_t type; - val_t value; -}s_setState_t; - -typedef struct s_pushState *pushState_t; -typedef struct s_pushState { - container_t container; - type_t type; - val_t value; - int size; - xbt_dynar_t extra; -}s_pushState_t; - -typedef struct s_popState *popState_t; -typedef struct s_popState { - container_t container; - type_t type; -}s_popState_t; - -typedef struct s_resetState *resetState_t; -typedef struct s_resetState { - container_t container; - type_t type; -}s_resetState_t; - -typedef struct s_startLink *startLink_t; -typedef struct s_startLink { - container_t container; - type_t type; - container_t sourceContainer; - char *value; - char *key; - int size; -}s_startLink_t; - -typedef struct s_endLink *endLink_t; -typedef struct s_endLink { - container_t container; - type_t type; - container_t destContainer; - char *value; - char *key; -}s_endLink_t; - -typedef struct s_newEvent *newEvent_t; -typedef struct s_newEvent { - container_t container; - type_t type; - val_t value; -}s_newEvent_t; - -FILE *tracing_file = NULL; - -static xbt_dynar_t buffer = NULL; - -static void dump_comment (const char *comment) -{ - if (!strlen(comment)) return; - fprintf (tracing_file, "# %s\n", comment); -} - -static 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); +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_paje_trace, instr_trace, "tracing event system"); + +extern FILE * tracing_file; +extern s_instr_trace_writer_t active_writer; +extern xbt_dynar_t buffer; + + +void TRACE_paje_init(void) +{ + 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; } - void TRACE_paje_start(void) { char *filename = TRACE_get_filename(); @@ -210,63 +76,8 @@ void TRACE_paje_end(void) XBT_DEBUG("Filename %s is closed", filename); } -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){ - paje_event_t event; - unsigned int i; - xbt_dynar_foreach(buffer, i, event){ - event->print (event); - event->free (event); - } - xbt_dynar_free (&buffer); - buffer = xbt_dynar_new (sizeof(paje_event_t), NULL); - }else{ - paje_event_t event; - unsigned int cursor; - xbt_dynar_foreach(buffer, cursor, event) { - double head_timestamp = event->timestamp; - if (head_timestamp > TRACE_last_timestamp_to_dump){ - break; - } - event->print (event); - event->free (event); - } - xbt_dynar_remove_n_at(buffer, cursor, 0); - } - 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=%lu)", - __FUNCTION__, (int)tbi->event_type, tbi->timestamp, xbt_dynar_length(buffer)); - - unsigned int i; - for (i = xbt_dynar_length(buffer); i > 0; i--) { - paje_event_t e1 = *(paje_event_t*)xbt_dynar_get_ptr(buffer, i - 1); - if (e1->timestamp <= tbi->timestamp) - break; - } - xbt_dynar_insert_at(buffer, i, &tbi); - if (i == 0) - XBT_DEBUG("%s: inserted at beginning", __FUNCTION__); - else - XBT_DEBUG("%s: inserted at%s %u", __FUNCTION__, - (i == xbt_dynar_length(buffer) - 1 ? " end, pos =" : ""), i); -} -static void print_pajeDefineContainerType(paje_event_t event) +void print_pajeDefineContainerType(paje_event_t event) { XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type); fprintf(tracing_file, "%d %s %s %s\n", @@ -276,7 +87,7 @@ static void print_pajeDefineContainerType(paje_event_t event) ((defineContainerType_t)event->data)->type->name); } -static void print_pajeDefineVariableType(paje_event_t event) +void print_pajeDefineVariableType(paje_event_t event) { XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type); fprintf(tracing_file, "%d %s %s %s \"%s\"\n", @@ -287,7 +98,7 @@ static void print_pajeDefineVariableType(paje_event_t event) ((defineVariableType_t)event->data)->type->color); } -static void print_pajeDefineStateType(paje_event_t event) +void print_pajeDefineStateType(paje_event_t event) { XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type); fprintf(tracing_file, "%d %s %s %s\n", @@ -297,7 +108,7 @@ static void print_pajeDefineStateType(paje_event_t event) ((defineStateType_t)event->data)->type->name); } -static void print_pajeDefineEventType(paje_event_t event) +void print_pajeDefineEventType(paje_event_t event) { XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type); fprintf(tracing_file, "%d %s %s %s\n", @@ -307,7 +118,7 @@ static void print_pajeDefineEventType(paje_event_t event) ((defineEventType_t)event->data)->type->name); } -static void print_pajeDefineLinkType(paje_event_t event) +void print_pajeDefineLinkType(paje_event_t event) { XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type); fprintf(tracing_file, "%d %s %s %s %s %s\n", @@ -319,7 +130,7 @@ static void print_pajeDefineLinkType(paje_event_t event) ((defineLinkType_t)event->data)->type->name); } -static void print_pajeDefineEntityValue (paje_event_t event) +void print_pajeDefineEntityValue (paje_event_t event) { XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type); fprintf(tracing_file, "%d %s %s %s \"%s\"\n", @@ -330,7 +141,7 @@ static void print_pajeDefineEntityValue (paje_event_t event) ((defineEntityValue_t)event->data)->value->color); } -static void print_pajeCreateContainer(paje_event_t event) +void print_pajeCreateContainer(paje_event_t event) { XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); if (event->timestamp == 0){ @@ -351,7 +162,7 @@ static void print_pajeCreateContainer(paje_event_t event) } } -static void print_pajeDestroyContainer(paje_event_t event) +void print_pajeDestroyContainer(paje_event_t event) { XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); if (event->timestamp == 0){ @@ -368,7 +179,7 @@ static void print_pajeDestroyContainer(paje_event_t event) } } -static void print_pajeSetVariable(paje_event_t event) +void print_pajeSetVariable(paje_event_t event) { XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); if (event->timestamp == 0){ @@ -387,7 +198,7 @@ static void print_pajeSetVariable(paje_event_t event) } } -static void print_pajeAddVariable(paje_event_t event) +void print_pajeAddVariable(paje_event_t event) { XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); if (event->timestamp == 0){ @@ -406,7 +217,7 @@ static void print_pajeAddVariable(paje_event_t event) } } -static void print_pajeSubVariable(paje_event_t event) +void print_pajeSubVariable(paje_event_t event) { XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); if (event->timestamp == 0){ @@ -425,7 +236,7 @@ static void print_pajeSubVariable(paje_event_t event) } } -static void print_pajeSetState(paje_event_t event) +void print_pajeSetState(paje_event_t event) { XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); if (event->timestamp == 0){ @@ -444,7 +255,7 @@ static void print_pajeSetState(paje_event_t event) } } -static void print_pajePushState(paje_event_t event) +void print_pajePushState(paje_event_t event) { XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); if (!TRACE_display_sizes()){ @@ -469,11 +280,10 @@ static void print_pajePushState(paje_event_t event) ((pushState_t)event->data)->type->id, ((pushState_t)event->data)->container->id, ((pushState_t)event->data)->value->id); - - char *value = NULL; - unsigned int iter = 0; - xbt_dynar_foreach( ((pushState_t)event->data)->extra, iter, value) { - fprintf(tracing_file, "%s ", value); + if(((pushState_t)event->data)->extra !=NULL){ + fprintf(tracing_file, "%d ", ((instr_extra_data)((pushState_t)event->data)->extra)->send_size); + }else{ + fprintf(tracing_file, "0 "); } fprintf(tracing_file, "\n"); @@ -484,19 +294,25 @@ static void print_pajePushState(paje_event_t event) ((pushState_t)event->data)->type->id, ((pushState_t)event->data)->container->id, ((pushState_t)event->data)->value->id); - - char *value = NULL; - unsigned int iter = 0; - xbt_dynar_foreach( ((pushState_t)event->data)->extra, iter, value) { - fprintf(tracing_file, "%s ", value); + if(((pushState_t)event->data)->extra !=NULL){ + fprintf(tracing_file, "%d ", ((instr_extra_data)((pushState_t)event->data)->extra)->send_size); + }else{ + fprintf(tracing_file, "0 "); } fprintf(tracing_file, "\n"); + } - xbt_dynar_free(&((pushState_t)event->data)->extra); } + if(((pushState_t)event->data)->extra!=NULL){ + if(((instr_extra_data)((pushState_t)event->data)->extra)->sendcounts!=NULL) + xbt_free(((instr_extra_data)((pushState_t)event->data)->extra)->sendcounts); + if(((instr_extra_data)((pushState_t)event->data)->extra)->recvcounts!=NULL) + xbt_free(((instr_extra_data)((pushState_t)event->data)->extra)->recvcounts); + xbt_free(((pushState_t)event->data)->extra); + } } -static void print_pajePopState(paje_event_t event) +void print_pajePopState(paje_event_t event) { XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); if (event->timestamp == 0){ @@ -513,7 +329,7 @@ static void print_pajePopState(paje_event_t event) } } -static void print_pajeResetState(paje_event_t event) +void print_pajeResetState(paje_event_t event) { XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); if (event->timestamp == 0){ @@ -530,7 +346,7 @@ static void print_pajeResetState(paje_event_t event) } } -static void print_pajeStartLink(paje_event_t event) +void print_pajeStartLink(paje_event_t event) { if (!TRACE_display_sizes()){ if (event->timestamp == 0){ @@ -576,7 +392,7 @@ static void print_pajeStartLink(paje_event_t event) } } -static void print_pajeEndLink(paje_event_t event) +void print_pajeEndLink(paje_event_t event) { XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); if (event->timestamp == 0){ @@ -599,7 +415,7 @@ static void print_pajeEndLink(paje_event_t event) } } -static void print_pajeNewEvent (paje_event_t event) +void print_pajeNewEvent (paje_event_t event) { XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); if (event->timestamp == 0){ @@ -617,376 +433,3 @@ static void print_pajeNewEvent (paje_event_t event) ((newEvent_t)event->data)->value->id); } } - -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 = print_pajeDefineContainerType; - 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 = print_pajeDefineVariableType; - 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 = print_pajeDefineStateType; - 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 = print_pajeDefineEventType; - 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 = print_pajeDefineLinkType; - 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 = print_pajeDefineEntityValue; - 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 = print_pajeCreateContainer; - 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 = print_pajeDestroyContainer; - 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 = print_pajeSetVariable; - 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 = print_pajeAddVariable; - 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 = print_pajeSubVariable; - 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 = print_pajeSetState; - 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; - - 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, xbt_dynar_t extra) -{ - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_PushState; - event->timestamp = timestamp; - event->print = print_pajePushState; - 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; - - 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) -{ - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_PushState; - event->timestamp = timestamp; - event->print = print_pajePushState; - 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; - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); - - insert_into_buffer (event); -} - - -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 = print_pajePopState; - 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 = print_pajeResetState; - 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) -{ - paje_event_t event = xbt_new0(s_paje_event_t, 1); - event->event_type = PAJE_StartLink; - event->timestamp = timestamp; - event->print = print_pajeStartLink; - 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 = -1; - XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); - - insert_into_buffer (event); -} - -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 = print_pajeStartLink; - 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 = print_pajeEndLink; - 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 = print_pajeNewEvent; - 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); -} - -#endif /* HAVE_TRACING */ diff --git a/src/instr/instr_private.h b/src/instr/instr_private.h index d557de2f40..8bafe0078a 100644 --- a/src/instr/instr_private.h +++ b/src/instr/instr_private.h @@ -9,6 +9,7 @@ #include "instr/instr.h" #include "instr/instr_interface.h" +#include "internal_config.h" #include "simgrid_config.h" #ifdef HAVE_TRACING @@ -95,6 +96,133 @@ typedef struct s_container { xbt_dict_t children; }s_container_t; +typedef struct paje_event *paje_event_t; +typedef struct paje_event { + double timestamp; + e_event_type event_type; + void (*print) (paje_event_t event); + void (*free) (paje_event_t event); + void *data; +} s_paje_event_t; + +typedef struct s_defineContainerType *defineContainerType_t; +typedef struct s_defineContainerType { + type_t type; +}s_defineContainerType_t; + +typedef struct s_defineVariableType *defineVariableType_t; +typedef struct s_defineVariableType { + type_t type; +}s_defineVariableType_t; + +typedef struct s_defineStateType *defineStateType_t; +typedef struct s_defineStateType { + type_t type; +}s_defineStateType_t; + +typedef struct s_defineEventType *defineEventType_t; +typedef struct s_defineEventType { + type_t type; +}s_defineEventType_t; + +typedef struct s_defineLinkType *defineLinkType_t; +typedef struct s_defineLinkType { + type_t type; + type_t source; + type_t dest; +}s_defineLinkType_t; + +typedef struct s_defineEntityValue *defineEntityValue_t; +typedef struct s_defineEntityValue { + val_t value; +}s_defineEntityValue_t; + +typedef struct s_createContainer *createContainer_t; +typedef struct s_createContainer { + container_t container; +}s_createContainer_t; + +typedef struct s_destroyContainer *destroyContainer_t; +typedef struct s_destroyContainer { + container_t container; +}s_destroyContainer_t; + +typedef struct s_setVariable *setVariable_t; +typedef struct s_setVariable { + container_t container; + type_t type; + double value; +}s_setVariable_t; + +typedef struct s_addVariable *addVariable_t; +typedef struct s_addVariable { + container_t container; + type_t type; + double value; +}s_addVariable_t; + +typedef struct s_subVariable *subVariable_t; +typedef struct s_subVariable { + container_t container; + type_t type; + double value; +}s_subVariable_t; + +typedef struct s_setState *setState_t; +typedef struct s_setState { + container_t container; + type_t type; + val_t value; +}s_setState_t; + +typedef struct s_pushState *pushState_t; +typedef struct s_pushState { + container_t container; + type_t type; + val_t value; + int size; + void* extra; +}s_pushState_t; + +typedef struct s_popState *popState_t; +typedef struct s_popState { + container_t container; + type_t type; + xbt_dynar_t extra; +}s_popState_t; + +typedef struct s_resetState *resetState_t; +typedef struct s_resetState { + container_t container; + type_t type; +}s_resetState_t; + +typedef struct s_startLink *startLink_t; +typedef struct s_startLink { + container_t container; + type_t type; + container_t sourceContainer; + char *value; + char *key; + int size; +}s_startLink_t; + +typedef struct s_endLink *endLink_t; +typedef struct s_endLink { + container_t container; + type_t type; + container_t destContainer; + char *value; + char *key; +}s_endLink_t; + +typedef struct s_newEvent *newEvent_t; +typedef struct s_newEvent { + container_t container; + type_t type; + val_t value; +}s_newEvent_t; + extern xbt_dict_t created_categories; extern xbt_dict_t declared_marks; extern xbt_dict_t user_host_variables; @@ -106,6 +234,7 @@ extern double TRACE_last_timestamp_to_dump; void TRACE_header(int basic, int size); /* from paje.c */ +void TRACE_paje_init(void); void TRACE_paje_start(void); void TRACE_paje_end(void); void TRACE_paje_dump_buffer (int force); @@ -122,7 +251,7 @@ XBT_PUBLIC(void) new_pajeAddVariable (double timestamp, container_t container, t 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, xbt_dynar_t extra); +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); @@ -214,10 +343,126 @@ XBT_PUBLIC(val_t) PJ_value_get_or_new (const char *name, const char *color, typ XBT_PUBLIC(val_t) PJ_value_get (const char *name, const type_t father); void PJ_value_free (val_t value); + +void print_pajeDefineContainerType(paje_event_t event); +void print_pajeDefineVariableType(paje_event_t event); +void print_pajeDefineStateType(paje_event_t event); +void print_pajeDefineEventType(paje_event_t event); +void print_pajeDefineLinkType(paje_event_t event); +void print_pajeDefineEntityValue (paje_event_t event); +void print_pajeCreateContainer(paje_event_t event); +void print_pajeDestroyContainer(paje_event_t event); +void print_pajeSetVariable(paje_event_t event); +void print_pajeAddVariable(paje_event_t event); +void print_pajeSubVariable(paje_event_t event); +void print_pajeSetState(paje_event_t event); +void print_pajePushState(paje_event_t event); +void print_pajePopState(paje_event_t event); +void print_pajeResetState(paje_event_t event); +void print_pajeStartLink(paje_event_t event); +void print_pajeEndLink(paje_event_t event); +void print_pajeNewEvent (paje_event_t event); + +void print_TIPushState(paje_event_t event); +void TRACE_TI_start(void); +void TRACE_TI_end(void); +void TRACE_TI_init(void); + +void print_NULL (paje_event_t event); +void TRACE_paje_dump_buffer (int force); +void dump_comment_file (const char *filename); +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); +} s_instr_trace_writer_t; + + + +struct s_instr_extra_data; +typedef struct s_instr_extra_data *instr_extra_data; + + +typedef enum{ + TRACING_INIT, + TRACING_FINALIZE, + TRACING_COMM_SIZE, + TRACING_COMM_SPLIT, + TRACING_COMM_DUP, + TRACING_SEND, + TRACING_ISEND, + TRACING_SSEND, + TRACING_ISSEND, + TRACING_RECV, + TRACING_IRECV, + TRACING_SENDRECV, + TRACING_WAIT, + TRACING_WAITALL, + TRACING_WAITANY, + TRACING_BARRIER, + TRACING_BCAST, + TRACING_REDUCE, + TRACING_ALLREDUCE, + TRACING_ALLTOALL, + TRACING_ALLTOALLV, + TRACING_GATHER, + TRACING_GATHERV, + TRACING_SCATTER, + TRACING_SCATTERV, + TRACING_ALLGATHER, + TRACING_ALLGATHERV, + TRACING_REDUCE_SCATTER, + TRACING_COMPUTING, + TRACING_SCAN, + TRACING_EXSCAN +} e_caller_type ; + + + +typedef struct s_instr_extra_data { + e_caller_type type; + int send_size; + int recv_size; + double comp_size; + int src; + int dst; + int root; + const char* datatype1; + const char* datatype2; + int * sendcounts; + int * recvcounts; + int num_processes; +} s_instr_extra_data_t; + #endif /* HAVE_TRACING */ #ifdef HAVE_JEDULE #include "instr/jedule/jedule_sd_binding.h" #endif + + + + + #endif /* INSTR_PRIVATE_H_ */ diff --git a/src/instr/instr_trace.c b/src/instr/instr_trace.c new file mode 100644 index 0000000000..02de93aaf5 --- /dev/null +++ b/src/instr/instr_trace.c @@ -0,0 +1,492 @@ +/* Copyright (c) 2010-2013. 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 "instr/instr_private.h" +#include "xbt/virtu.h" /* sg_cmdline */ + +#ifdef HAVE_TRACING + +XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_trace, instr, "tracing event system"); + + +FILE *tracing_file = NULL; + +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 +}; + + + +xbt_dynar_t buffer = NULL; + +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){ + paje_event_t event; + unsigned int i; + xbt_dynar_foreach(buffer, i, event){ + event->print (event); + event->free (event); + } + xbt_dynar_free (&buffer); + buffer = xbt_dynar_new (sizeof(paje_event_t), NULL); + }else{ + paje_event_t event; + unsigned int cursor; + xbt_dynar_foreach(buffer, cursor, event) { + double head_timestamp = event->timestamp; + if (head_timestamp > TRACE_last_timestamp_to_dump){ + break; + } + event->print (event); + event->free (event); + } + xbt_dynar_remove_n_at(buffer, cursor, 0); + } + 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=%lu)", + __FUNCTION__, (int)tbi->event_type, tbi->timestamp, xbt_dynar_length(buffer)); + + unsigned int i; + for (i = xbt_dynar_length(buffer); i > 0; i--) { + paje_event_t e1 = *(paje_event_t*)xbt_dynar_get_ptr(buffer, i - 1); + if (e1->timestamp <= tbi->timestamp) + break; + } + xbt_dynar_insert_at(buffer, i, &tbi); + if (i == 0) + XBT_DEBUG("%s: inserted at beginning", __FUNCTION__); + else + XBT_DEBUG("%s: inserted at%s %u", __FUNCTION__, + (i == xbt_dynar_length(buffer) - 1 ? " end, pos =" : ""), 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; + + 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; + + 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) +{ + 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; + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); + + insert_into_buffer (event); +} + +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) +{ + 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 = -1; + XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp); + + insert_into_buffer (event); +} + +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); +} + +#endif /* HAVE_TRACING */ diff --git a/src/smpi/instr_smpi.c b/src/smpi/instr_smpi.c index 283e84d1c4..bba7c459fa 100644 --- a/src/smpi/instr_smpi.c +++ b/src/smpi/instr_smpi.c @@ -7,6 +7,8 @@ #include "private.h" #include #include +#include +#include #ifdef HAVE_TRACING @@ -179,7 +181,7 @@ void TRACE_smpi_finalize(int rank) PJ_container_free (container); } -void TRACE_smpi_collective_in(int rank, int root, const char *operation, int size) +void TRACE_smpi_collective_in(int rank, int root, const char *operation, instr_extra_data extra) { if (!TRACE_smpi_is_enabled()) return; @@ -189,9 +191,10 @@ void TRACE_smpi_collective_in(int rank, int root, const char *operation, int siz 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_pajePushStateWithSize (SIMIX_get_clock(), container, type, value, size); + new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, (void*)extra); } + void TRACE_smpi_collective_out(int rank, int root, const char *operation) { if (!TRACE_smpi_is_enabled()) return; @@ -214,14 +217,13 @@ void TRACE_smpi_computing_init(int rank) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t mpi = PJ_type_get("MPI", PJ_container_get_root()->type); - type_t type = PJ_type_state_new ("COMPUTATION", mpi); + 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); } -void TRACE_smpi_computing_in(int rank) +void TRACE_smpi_computing_in(int rank, instr_extra_data extra) { //do not forget to set the color first, otherwise this will explode if (!TRACE_smpi_is_enabled()|| !TRACE_smpi_is_computing()) return; @@ -229,25 +231,22 @@ void TRACE_smpi_computing_in(int rank) char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("COMPUTATION", container->type); + type_t type = PJ_type_get ("MPI_STATE", container->type); val_t value = PJ_value_get_or_new ("computing", NULL, type); - new_pajePushState (SIMIX_get_clock(), container, type, value); + new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, (void*)extra); } -void TRACE_smpi_computing_out(int rank, double flops) +void TRACE_smpi_computing_out(int rank) { if (!TRACE_smpi_is_enabled()|| !TRACE_smpi_is_computing()) return; char str[INSTR_DEFAULT_STR_SIZE]; smpi_container(rank, str, INSTR_DEFAULT_STR_SIZE); container_t container = PJ_container_get (str); - type_t type = PJ_type_get ("COMPUTATION", container->type); - xbt_dynar_t extra= xbt_dynar_new(sizeof(char*), NULL); - char* char_duration = bprintf("%g", flops); - xbt_dynar_push(extra, &char_duration); - new_pajePopStateWithExtra (SIMIX_get_clock(), container, type, extra); + type_t type = PJ_type_get ("MPI_STATE", container->type); + new_pajePopState (SIMIX_get_clock(), container, type); } -void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation, int size) +void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation, instr_extra_data extra) { if (!TRACE_smpi_is_enabled()) return; @@ -258,7 +257,7 @@ void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation, int si 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_pajePushStateWithSize (SIMIX_get_clock(), container, type, value, size); + new_pajePushStateWithExtra (SIMIX_get_clock(), container, type, value, (void*)extra); } void TRACE_smpi_ptp_out(int rank, int src, int dst, const char *operation) diff --git a/src/smpi/private.h b/src/smpi/private.h index 18049de4d5..03fdd13352 100644 --- a/src/smpi/private.h +++ b/src/smpi/private.h @@ -7,6 +7,7 @@ #ifndef SMPI_PRIVATE_H #define SMPI_PRIVATE_H +#include "internal_config.h" #include "xbt.h" #include "xbt/xbt_os_time.h" #include "simgrid/simix.h" @@ -192,6 +193,8 @@ MPI_Request smpi_isend_init(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm); MPI_Request smpi_mpi_isend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm); +MPI_Request smpi_issend_init(void *buf, int count, MPI_Datatype datatype, + int dst, int tag, MPI_Comm comm); MPI_Request smpi_mpi_issend(void *buf, int count, MPI_Datatype datatype, int dst, int tag, MPI_Comm comm); MPI_Request smpi_irecv_init(void *buf, int count, MPI_Datatype datatype, @@ -548,10 +551,22 @@ void mpi_comm_get_parent_ ( int*parent, int* ierr); /* from smpi_instr.c */ void TRACE_internal_smpi_set_category (const char *category); const char *TRACE_internal_smpi_get_category (void); -void TRACE_smpi_collective_in(int rank, int root, const char *operation, int size); +void TRACE_smpi_collective_in(int rank, int root, const char *operation, instr_extra_data extra); void TRACE_smpi_collective_out(int rank, int root, const char *operation); void TRACE_smpi_computing_init(int rank); void TRACE_smpi_computing_out(int rank); -void TRACE_smpi_computing_in(int rank); +void TRACE_smpi_computing_in(int rank, instr_extra_data extra); +void TRACE_smpi_alloc(void); +void TRACE_smpi_release(void); +void TRACE_smpi_ptp_in(int rank, int src, int dst, const char *operation, instr_extra_data extra); +void TRACE_smpi_ptp_out(int rank, int src, int dst, const char *operation); +void TRACE_smpi_send(int rank, int src, int dst, int size); +void TRACE_smpi_recv(int rank, int src, int dst); +void TRACE_smpi_init(int rank); +void TRACE_smpi_finalize(int rank); + + +const char* encode_datatype(MPI_Datatype datatype); + #endif diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index 2988648059..4b5648ca04 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -127,19 +127,8 @@ void smpi_execute_flops(double flops) { smx_action_t action; smx_host_t host; host = SIMIX_host_self(); - int rank = smpi_process_index(); -#ifdef HAVE_TRACING - TRACE_smpi_computing_in(rank); -#endif - -XBT_DEBUG("Handle real computation time: %f flops", flops); -action = simcall_host_execute("computation", host, flops, 1); - -#ifdef HAVE_TRACING - TRACE_smpi_computing_out(rank,flops); -#endif - - + XBT_DEBUG("Handle real computation time: %f flops", flops); + action = simcall_host_execute("computation", host, flops, 1); #ifdef HAVE_TRACING simcall_set_category (action, TRACE_internal_smpi_get_category()); #endif @@ -151,8 +140,21 @@ static void smpi_execute(double duration) /* FIXME: a global variable would be less expensive to consult than a call to xbt_cfg_get_double() right on the critical path */ if (duration >= sg_cfg_get_double("smpi/cpu_threshold")) { XBT_DEBUG("Sleep for %f to handle real computation time", duration); - smpi_execute_flops(duration * - sg_cfg_get_double("smpi/running_power")); + double flops = duration * + sg_cfg_get_double("smpi/running_power"); +#ifdef HAVE_TRACING + int rank = smpi_process_index(); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type=TRACING_COMPUTING; + extra->comp_size=flops; + TRACE_smpi_computing_in(rank, extra); +#endif + smpi_execute_flops(flops); + +#ifdef HAVE_TRACING + TRACE_smpi_computing_out(rank); +#endif + } else { XBT_DEBUG("Real computation took %f while option smpi/cpu_threshold is set to %f => ignore it", duration, sg_cfg_get_double("smpi/cpu_threshold")); diff --git a/src/smpi/smpi_pmpi.c b/src/smpi/smpi_pmpi.c index 7f06648848..eaa00a5056 100644 --- a/src/smpi/smpi_pmpi.c +++ b/src/smpi/smpi_pmpi.c @@ -32,7 +32,9 @@ int PMPI_Init(int *argc, char ***argv) int rank = smpi_process_index(); TRACE_smpi_init(rank); TRACE_smpi_computing_init(rank); - TRACE_smpi_collective_in(rank, -1, __FUNCTION__,0); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_INIT; + TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra); TRACE_smpi_collective_out(rank, -1, __FUNCTION__); #endif smpi_bench_begin(); @@ -44,7 +46,9 @@ int PMPI_Finalize(void) smpi_bench_end(); #ifdef HAVE_TRACING int rank = smpi_process_index(); - TRACE_smpi_collective_in(rank, -1, __FUNCTION__,0); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_FINALIZE; + TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra); #endif smpi_process_finalize(); #ifdef HAVE_TRACING @@ -1053,7 +1057,14 @@ int PMPI_Irecv(void *buf, int count, MPI_Datatype datatype, int src, #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; int src_traced = smpi_group_index(smpi_comm_group(comm), src); - TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, count*smpi_datatype_size(datatype)); + + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_IRECV; + extra->send_size = count; + extra->src = src_traced; + extra->dst = rank; + extra->datatype1 = encode_datatype(datatype); + TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra); #endif *request = smpi_mpi_irecv(buf, count, datatype, src, tag, comm); @@ -1100,7 +1111,14 @@ int PMPI_Isend(void *buf, int count, MPI_Datatype datatype, int dst, #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; int dst_traced = smpi_group_index(smpi_comm_group(comm), dst); - TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype)); + + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_ISEND; + extra->send_size = count; + extra->src = rank; + extra->dst = dst_traced; + extra->datatype1 = encode_datatype(datatype); + TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype)); #endif @@ -1147,7 +1165,13 @@ int PMPI_Issend(void* buf, int count, MPI_Datatype datatype, #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; int dst_traced = smpi_group_index(smpi_comm_group(comm), dst); - TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_ISSEND; + extra->send_size = count; + extra->src = rank; + extra->dst = dst_traced; + extra->datatype1 = encode_datatype(datatype); + TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced, count*smpi_datatype_size(datatype)); #endif @@ -1192,7 +1216,13 @@ int PMPI_Recv(void *buf, int count, MPI_Datatype datatype, int src, int tag, #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; int src_traced = smpi_group_index(smpi_comm_group(comm), src); - TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, count*smpi_datatype_size(datatype)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_RECV; + extra->send_size = count; + extra->src = src_traced; + extra->dst = rank; + extra->datatype1 = encode_datatype(datatype); + TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra); #endif smpi_mpi_recv(buf, count, datatype, src, tag, comm, status); @@ -1236,7 +1266,13 @@ int PMPI_Send(void *buf, int count, MPI_Datatype datatype, int dst, int tag, #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; int dst_traced = smpi_group_index(smpi_comm_group(comm), dst); - TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_SEND; + extra->send_size = count; + extra->src = rank; + extra->dst = dst_traced; + extra->datatype1 = encode_datatype(datatype); + TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype)); #endif @@ -1278,8 +1314,13 @@ int PMPI_Ssend(void* buf, int count, MPI_Datatype datatype, int dst, int tag, MP #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; int dst_traced = smpi_group_index(smpi_comm_group(comm), dst); - TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, count*smpi_datatype_size(datatype)); - TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_SSEND; + extra->send_size = count; + extra->src = rank; + extra->dst = dst_traced; + extra->datatype1 = encode_datatype(datatype); + TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced,count*smpi_datatype_size(datatype)); #endif smpi_mpi_ssend(buf, count, datatype, dst, tag, comm); @@ -1327,7 +1368,16 @@ int PMPI_Sendrecv(void *sendbuf, int sendcount, MPI_Datatype sendtype, int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; int dst_traced = smpi_group_index(smpi_comm_group(comm), dst); int src_traced = smpi_group_index(smpi_comm_group(comm), src); - TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, sendcount*smpi_datatype_size(sendtype)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_SENDRECV; + extra->send_size = sendcount; + extra->recv_size = recvcount; + extra->src = src_traced; + extra->dst = dst_traced; + extra->datatype1 = encode_datatype(sendtype); + extra->datatype2 = encode_datatype(recvtype); + + TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced,sendcount*smpi_datatype_size(sendtype)); #endif @@ -1490,7 +1540,9 @@ int PMPI_Wait(MPI_Request * request, MPI_Status * status) int dst_traced = (*request)->dst; MPI_Comm comm = (*request)->comm; int is_wait_for_receive = (*request)->recv; - TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__,-1); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_WAIT; + TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, extra); #endif smpi_mpi_wait(request, status); @@ -1537,8 +1589,10 @@ int PMPI_Waitany(int count, MPI_Request requests[], int *index, MPI_Status * sta } } int rank_traced = smpi_process_index(); - - TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,count); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_WAITANY; + extra->send_size=count; + TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,extra); #endif if (index == NULL) { @@ -1599,8 +1653,10 @@ int PMPI_Waitall(int count, MPI_Request requests[], MPI_Status status[]) } } int rank_traced = smpi_process_index(); - - TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,count); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_WAITALL; + extra->send_size=count; + TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,extra); #endif int retval = smpi_mpi_waitall(count, requests, status); #ifdef HAVE_TRACING @@ -1677,7 +1733,14 @@ int PMPI_Bcast(void *buf, int count, MPI_Datatype datatype, int root, MPI_Comm c #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; int root_traced = smpi_group_index(smpi_comm_group(comm), root); - TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, count*smpi_datatype_size(datatype)); + + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_BCAST; + extra->send_size = count; + extra->root = root_traced; + extra->datatype1 = encode_datatype(datatype); + TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra); + #endif mpi_coll_bcast_fun(buf, count, datatype, root, comm); retval = MPI_SUCCESS; @@ -1701,7 +1764,9 @@ int PMPI_Barrier(MPI_Comm comm) } else { #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - TRACE_smpi_collective_in(rank, -1, __FUNCTION__, smpi_comm_size(comm)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_BARRIER; + TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra); #endif mpi_coll_barrier_fun(comm); retval = MPI_SUCCESS; @@ -1742,7 +1807,15 @@ int PMPI_Gather(void *sendbuf, int sendcount, MPI_Datatype sendtype, #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; int root_traced = smpi_group_index(smpi_comm_group(comm), root); - TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,sendcount*smpi_datatype_size(sendtmptype)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_GATHER; + extra->send_size = sendtmpcount; + extra->recv_size = recvcount; + extra->root = root_traced; + extra->datatype1 = encode_datatype(sendtmptype); + extra->datatype2 = encode_datatype(recvtype); + + TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra); #endif mpi_coll_gather_fun(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcount, recvtype, root, comm); @@ -1787,7 +1860,20 @@ int PMPI_Gatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; int root_traced = smpi_group_index(smpi_comm_group(comm), root); - TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,sendcount*smpi_datatype_size(sendtmptype)); + int i=0; + int size = smpi_comm_size(comm); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_GATHERV; + extra->send_size = sendtmpcount; + extra->recvcounts= xbt_malloc(size*sizeof(int)); + for(i=0; i< size; i++)//copy data to avoid bad free + extra->recvcounts[i] = recvcounts[i]; + extra->num_processes = size; + extra->root = root_traced; + extra->datatype1 = encode_datatype(sendtmptype); + extra->datatype2 = encode_datatype(recvtype); + + TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra); #endif smpi_mpi_gatherv(sendtmpbuf, sendtmpcount, sendtmptype, recvbuf, recvcounts, displs, recvtype, root, comm); @@ -1825,7 +1911,14 @@ int PMPI_Allgather(void *sendbuf, int sendcount, MPI_Datatype sendtype, } #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - TRACE_smpi_collective_in(rank, -1, __FUNCTION__,sendcount*smpi_datatype_size(sendtype)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_ALLGATHER; + extra->send_size = sendcount; + extra->recv_size = recvcount; + extra->datatype1 = encode_datatype(sendtype); + extra->datatype2 = encode_datatype(recvtype); + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra); #endif mpi_coll_allgather_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm); @@ -1865,7 +1958,19 @@ int PMPI_Allgatherv(void *sendbuf, int sendcount, MPI_Datatype sendtype, } #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - TRACE_smpi_collective_in(rank, -1, __FUNCTION__,sendcount*smpi_datatype_size(sendtype)); + int i=0; + int size = smpi_comm_size(comm); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_ALLGATHERV; + extra->send_size = sendcount; + extra->recvcounts= xbt_malloc(size*sizeof(int)); + for(i=0; i< size; i++)//copy data to avoid bad free + extra->recvcounts[i] = recvcounts[i]; + extra->num_processes = size; + extra->datatype1 = encode_datatype(sendtype); + extra->datatype2 = encode_datatype(recvtype); + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif mpi_coll_allgatherv_fun(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, comm); @@ -1901,8 +2006,15 @@ int PMPI_Scatter(void *sendbuf, int sendcount, MPI_Datatype sendtype, #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; int root_traced = smpi_group_index(smpi_comm_group(comm), root); - - TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,sendcount*smpi_datatype_size(recvtype)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_SCATTER; + extra->send_size = sendcount; + extra->recv_size= recvcount; + extra->root = root_traced; + extra->datatype1 = encode_datatype(sendtype); + extra->datatype2 = encode_datatype(recvtype); + + TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra); #endif mpi_coll_scatter_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, root, comm); @@ -1939,9 +2051,21 @@ int PMPI_Scatterv(void *sendbuf, int *sendcounts, int *displs, #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; int root_traced = smpi_group_index(smpi_comm_group(comm), root); - int count=0, i; - for(i=0; itype = TRACING_SCATTERV; + extra->recv_size = recvcount; + extra->sendcounts= xbt_malloc(size*sizeof(int)); + for(i=0; i< size; i++)//copy data to avoid bad free + extra->sendcounts[i] = sendcounts[i]; + extra->num_processes = size; + extra->root = root_traced; + extra->datatype1 = encode_datatype(sendtype); + extra->datatype2 = encode_datatype(recvtype); + + TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra); + #endif smpi_mpi_scatterv(sendbuf, sendcounts, displs, sendtype, recvbuf, recvcount, recvtype, root, comm); @@ -1970,7 +2094,13 @@ int PMPI_Reduce(void *sendbuf, void *recvbuf, int count, #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; int root_traced = smpi_group_index(smpi_comm_group(comm), root); - TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, count*smpi_datatype_size(datatype)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_REDUCE; + extra->send_size = count; + extra->datatype1 = encode_datatype(datatype); + extra->root = root_traced; + + TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra); #endif mpi_coll_reduce_fun(sendbuf, recvbuf, count, datatype, op, root, comm); @@ -2021,7 +2151,12 @@ int PMPI_Allreduce(void *sendbuf, void *recvbuf, int count, } #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - TRACE_smpi_collective_in(rank, -1, __FUNCTION__, count*smpi_datatype_size(datatype)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_ALLREDUCE; + extra->send_size = count; + extra->datatype1 = encode_datatype(datatype); + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif mpi_coll_allreduce_fun(sendtmpbuf, recvbuf, count, datatype, op, comm); @@ -2055,7 +2190,12 @@ int PMPI_Scan(void *sendbuf, void *recvbuf, int count, } else { #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - TRACE_smpi_collective_in(rank, -1, __FUNCTION__, count*smpi_datatype_size(datatype)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_SCAN; + extra->send_size = count; + extra->datatype1 = encode_datatype(datatype); + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif smpi_mpi_scan(sendbuf, recvbuf, count, datatype, op, comm); retval = MPI_SUCCESS; @@ -2083,7 +2223,12 @@ int PMPI_Exscan(void *sendbuf, void *recvbuf, int count, MPI_Datatype datatype, } else { #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - TRACE_smpi_collective_in(rank, -1, __FUNCTION__, count*smpi_datatype_size(datatype)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_EXSCAN; + extra->send_size = count; + extra->datatype1 = encode_datatype(datatype); + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif smpi_mpi_exscan(sendbuf, recvbuf, count, datatype, op, comm); retval = MPI_SUCCESS; @@ -2113,9 +2258,18 @@ int PMPI_Reduce_scatter(void *sendbuf, void *recvbuf, int *recvcounts, } else { #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - int count=0, i; - for(i=0; itype = TRACING_REDUCE_SCATTER; + extra->send_size = 0; + extra->recvcounts= xbt_malloc(size*sizeof(int)); + for(i=0; i< size; i++)//copy data to avoid bad free + extra->recvcounts[i] = recvcounts[i]; + extra->num_processes = size; + extra->datatype1 = encode_datatype(datatype); + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif void* sendtmpbuf=sendbuf; if(sendbuf==MPI_IN_PLACE){ @@ -2149,11 +2303,21 @@ int PMPI_Reduce_scatter_block(void *sendbuf, void *recvbuf, int recvcount, } else if (recvcount < 0) { retval = MPI_ERR_ARG; } else { + int count=smpi_comm_size(comm); + #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - TRACE_smpi_collective_in(rank, -1, __FUNCTION__, recvcount*smpi_comm_size(comm)*smpi_datatype_size(datatype)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_REDUCE_SCATTER; + extra->send_size = 0; + extra->recvcounts= xbt_malloc(count*sizeof(int)); + for(i=0; i< count; i++)//copy data to avoid bad free + extra->recvcounts[i] = recvcount; + extra->num_processes = count; + extra->datatype1 = encode_datatype(datatype); + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif - int count=smpi_comm_size(comm); int* recvcounts=(int*)xbt_malloc(count); for (i=0; itype = TRACING_ALLTOALL; + extra->send_size = sendcount; + extra->recv_size = recvcount; + extra->datatype1 = encode_datatype(sendtype); + extra->datatype2 = encode_datatype(recvtype); + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif retval = mpi_coll_alltoall_fun(sendbuf, sendcount, sendtype, recvbuf, recvcount, recvtype, comm); #ifdef HAVE_TRACING @@ -2216,9 +2387,28 @@ int PMPI_Alltoallv(void *sendbuf, int *sendcounts, int *senddisps, } else { #ifdef HAVE_TRACING int rank = comm != MPI_COMM_NULL ? smpi_process_index() : -1; - int i, size=0; - for(i=0; i< smpi_comm_size(comm);i++)size+=sendcounts[i]; - TRACE_smpi_collective_in(rank, -1, __FUNCTION__, size*smpi_datatype_size(sendtype)); + int i=0; + int size = smpi_comm_size(comm); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_ALLTOALLV; + extra->send_size = 0; + extra->recv_size = 0; + extra->recvcounts= xbt_malloc(size*sizeof(int)); + extra->sendcounts= xbt_malloc(size*sizeof(int)); + + for(i=0; i< size; i++){//copy data to avoid bad free + extra->send_size += sendcounts[i]; + extra->recv_size += recvcounts[i]; + + extra->sendcounts[i] = sendcounts[i]; + extra->recvcounts[i] = recvcounts[i]; + } + extra->num_processes = size; + + extra->datatype1 = encode_datatype(sendtype); + extra->datatype2 = encode_datatype(recvtype); + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif retval = mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, sendtype, diff --git a/src/smpi/smpi_replay.c b/src/smpi/smpi_replay.c index 3d2f1be123..e41a4f29cd 100644 --- a/src/smpi/smpi_replay.c +++ b/src/smpi/smpi_replay.c @@ -77,6 +77,33 @@ static MPI_Datatype decode_datatype(const char *const action) return MPI_CURRENT_TYPE; } + +const char* encode_datatype(MPI_Datatype datatype) +{ + + //default type for output is set to MPI_BYTE + // MPI_DEFAULT_TYPE is not set for output, use directly MPI_BYTE + if (datatype==MPI_BYTE){ + return ""; + } + if(datatype==MPI_DOUBLE) + return "0"; + if(datatype==MPI_INT) + return "1"; + if(datatype==MPI_CHAR) + return "2"; + if(datatype==MPI_SHORT) + return "3"; + if(datatype==MPI_LONG) + return "4"; + if(datatype==MPI_FLOAT) + return "5"; + + // default - not implemented. + // do not warn here as we pass in this function even for other trace formats + return "-1"; +} + static void action_init(const char *const *action) { int i; @@ -140,7 +167,18 @@ static void action_comm_dup(const char *const *action) static void action_compute(const char *const *action) { double clock = smpi_process_simulated_elapsed(); - smpi_execute_flops(parse_double(action[2])); + double flops= parse_double(action[2]); +#ifdef HAVE_TRACING + int rank = smpi_comm_rank(MPI_COMM_WORLD); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type=TRACING_COMPUTING; + extra->comp_size=flops; + TRACE_smpi_computing_in(rank, extra); +#endif + smpi_execute_flops(flops); +#ifdef HAVE_TRACING + TRACE_smpi_computing_out(rank); +#endif log_timed_action (action, clock); } @@ -161,7 +199,13 @@ static void action_send(const char *const *action) int rank = smpi_comm_rank(MPI_COMM_WORLD); int dst_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), to); - TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, size*smpi_datatype_size(MPI_CURRENT_TYPE)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_SEND; + extra->send_size = size; + extra->src = rank; + extra->dst = dst_traced; + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced, size*smpi_datatype_size(MPI_CURRENT_TYPE)); #endif @@ -188,7 +232,13 @@ static void action_Isend(const char *const *action) #ifdef HAVE_TRACING int rank = smpi_comm_rank(MPI_COMM_WORLD); int dst_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), to); - TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, size*smpi_datatype_size(MPI_CURRENT_TYPE)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_ISEND; + extra->send_size = size; + extra->src = rank; + extra->dst = dst_traced; + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra); TRACE_smpi_send(rank, rank, dst_traced, size*smpi_datatype_size(MPI_CURRENT_TYPE)); #endif @@ -217,7 +267,13 @@ static void action_recv(const char *const *action) { int rank = smpi_comm_rank(MPI_COMM_WORLD); int src_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), from); - TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, size*smpi_datatype_size(MPI_CURRENT_TYPE)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_RECV; + extra->send_size = size; + extra->src = src_traced; + extra->dst = rank; + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra); #endif smpi_mpi_recv(NULL, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD, &status); @@ -246,7 +302,13 @@ static void action_Irecv(const char *const *action) #ifdef HAVE_TRACING int rank = smpi_comm_rank(MPI_COMM_WORLD); int src_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), from); - TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, size*smpi_datatype_size(MPI_CURRENT_TYPE)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_IRECV; + extra->send_size = size; + extra->src = src_traced; + extra->dst = rank; + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra); #endif request = smpi_mpi_irecv(NULL, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD); @@ -281,7 +343,9 @@ static void action_wait(const char *const *action){ int src_traced = smpi_group_rank(group, request->src); int dst_traced = smpi_group_rank(group, request->dst); int is_wait_for_receive = request->recv; - TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, -1); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_WAIT; + TRACE_smpi_ptp_in(rank, src_traced, dst_traced, __FUNCTION__, extra); #endif smpi_mpi_wait(&request, &status); #ifdef HAVE_TRACING @@ -338,8 +402,11 @@ static void action_waitall(const char *const *action){ } } int rank_traced = smpi_process_index(); - TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__, count_requests); - #endif + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_WAITALL; + extra->send_size=count_requests; + TRACE_smpi_ptp_in(rank_traced, -1, -1, __FUNCTION__,extra); + #endif smpi_mpi_waitall(count_requests, requests, status); @@ -369,7 +436,9 @@ static void action_barrier(const char *const *action){ double clock = smpi_process_simulated_elapsed(); #ifdef HAVE_TRACING int rank = smpi_comm_rank(MPI_COMM_WORLD); - TRACE_smpi_collective_in(rank, -1, __FUNCTION__, smpi_comm_size(MPI_COMM_WORLD)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_BARRIER; + TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra); #endif smpi_mpi_barrier(MPI_COMM_WORLD); #ifdef HAVE_TRACING @@ -400,11 +469,18 @@ static void action_bcast(const char *const *action) #ifdef HAVE_TRACING int rank = smpi_comm_rank(MPI_COMM_WORLD); - int root_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), 0); - TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,size*smpi_datatype_size(MPI_CURRENT_TYPE)); + int root_traced = smpi_group_index(smpi_comm_group(MPI_COMM_WORLD), root); + + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_BCAST; + extra->send_size = size; + extra->root = root_traced; + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__, extra); + #endif - smpi_mpi_bcast(NULL, size, MPI_CURRENT_TYPE, root, MPI_COMM_WORLD); + mpi_coll_bcast_fun(NULL, size, MPI_CURRENT_TYPE, root, MPI_COMM_WORLD); #ifdef HAVE_TRACING TRACE_smpi_collective_out(rank, root_traced, __FUNCTION__); #endif @@ -429,8 +505,15 @@ static void action_reduce(const char *const *action) #ifdef HAVE_TRACING int rank = smpi_comm_rank(MPI_COMM_WORLD); - int root_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), 0); - TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,comm_size*smpi_datatype_size(MPI_CURRENT_TYPE)); + int root_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), root); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_REDUCE; + extra->send_size = comm_size; + extra->comp_size = comp_size; + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + extra->root = root_traced; + + TRACE_smpi_collective_in(rank, root_traced, __FUNCTION__,extra); #endif mpi_coll_reduce_fun(NULL, NULL, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, root, MPI_COMM_WORLD); smpi_execute_flops(comp_size); @@ -451,7 +534,13 @@ static void action_allReduce(const char *const *action) { double clock = smpi_process_simulated_elapsed(); #ifdef HAVE_TRACING int rank = smpi_comm_rank(MPI_COMM_WORLD); - TRACE_smpi_collective_in(rank, -1, __FUNCTION__,comp_size*smpi_datatype_size(MPI_CURRENT_TYPE)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_ALLREDUCE; + extra->send_size = comm_size; + extra->comp_size = comp_size; + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif mpi_coll_reduce_fun(NULL, NULL, comm_size, MPI_CURRENT_TYPE, MPI_OP_NULL, 0, MPI_COMM_WORLD); smpi_execute_flops(comp_size); @@ -483,7 +572,14 @@ static void action_allToAll(const char *const *action) { #ifdef HAVE_TRACING int rank = smpi_process_index(); - TRACE_smpi_collective_in(rank, -1, __FUNCTION__,send_size*smpi_datatype_size(MPI_CURRENT_TYPE)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_ALLTOALL; + extra->send_size = send_size; + extra->recv_size = recv_size; + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2); + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif mpi_coll_alltoall_fun(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, MPI_COMM_WORLD); @@ -533,7 +629,15 @@ static void action_gather(const char *const *action) { recv = calloc(recv_size*comm_size, smpi_datatype_size(MPI_CURRENT_TYPE2)); #ifdef HAVE_TRACING - TRACE_smpi_collective_in(rank, -1, __FUNCTION__,send_size*smpi_datatype_size(MPI_CURRENT_TYPE)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_GATHER; + extra->send_size = send_size; + extra->recv_size = recv_size; + extra->root = root; + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2); + + TRACE_smpi_collective_in(rank, root, __FUNCTION__, extra); #endif smpi_mpi_gather(send, send_size, MPI_CURRENT_TYPE, recv, recv_size, MPI_CURRENT_TYPE2, @@ -586,7 +690,18 @@ static void action_reducescatter(const char *const *action) { } #ifdef HAVE_TRACING - TRACE_smpi_collective_in(rank, -1, __FUNCTION__, recv_sum*smpi_datatype_size(MPI_CURRENT_TYPE)); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_REDUCE_SCATTER; + extra->send_size = 0; + extra->recvcounts= xbt_malloc(comm_size*sizeof(int)); + for(i=0; i< comm_size; i++)//copy data to avoid bad free + extra->recvcounts[i] = recvcounts[i]; + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + extra->comp_size = comp_size; + extra->num_processes = comm_size; + + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif mpi_coll_reduce_fun(NULL, NULL, recv_sum, MPI_CURRENT_TYPE, MPI_OP_NULL, root, MPI_COMM_WORLD); @@ -644,8 +759,18 @@ static void action_allgatherv(const char *const *action) { void *recvbuf = calloc(recv_sum, smpi_datatype_size(MPI_CURRENT_TYPE2)); #ifdef HAVE_TRACING - int rank = MPI_COMM_WORLD != MPI_COMM_NULL ? smpi_process_index() : -1; - TRACE_smpi_collective_in(rank, -1, __FUNCTION__,sendcount*smpi_datatype_size(MPI_CURRENT_TYPE)); + int rank = smpi_process_index(); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_ALLGATHERV; + extra->send_size = sendcount; + extra->recvcounts= xbt_malloc(comm_size*sizeof(int)); + for(i=0; i< comm_size; i++)//copy data to avoid bad free + extra->recvcounts[i] = recvcounts[i]; + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2); + extra->num_processes = comm_size; + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif mpi_coll_allgatherv_fun(sendbuf, sendcount, MPI_CURRENT_TYPE, recvbuf, recvcounts, disps, MPI_CURRENT_TYPE2, MPI_COMM_WORLD); @@ -709,10 +834,25 @@ static void action_allToAllv(const char *const *action) { #ifdef HAVE_TRACING - int rank = MPI_COMM_WORLD != MPI_COMM_NULL ? smpi_process_index() : -1; + int rank = smpi_process_index(); int count=0; for(i=0;itype = TRACING_ALLTOALLV; + extra->send_size = count; + extra->recvcounts= xbt_malloc(comm_size*sizeof(int)); + extra->sendcounts= xbt_malloc(comm_size*sizeof(int)); + extra->num_processes = comm_size; + + for(i=0; i< comm_size; i++){//copy data to avoid bad free + extra->send_size += sendcounts[i]; + extra->sendcounts[i] = sendcounts[i]; + extra->recvcounts[i] = recvcounts[i]; + } + extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE); + extra->datatype2 = encode_datatype(MPI_CURRENT_TYPE2); + + TRACE_smpi_collective_in(rank, -1, __FUNCTION__,extra); #endif mpi_coll_alltoallv_fun(sendbuf, sendcounts, senddisps, MPI_CURRENT_TYPE, recvbuf, recvcounts, recvdisps, MPI_CURRENT_TYPE, @@ -731,7 +871,18 @@ static void action_allToAllv(const char *const *action) { } void smpi_replay_init(int *argc, char***argv){ - PMPI_Init(argc, argv); + smpi_process_init(argc, argv); + smpi_process_mark_as_initialized(); +#ifdef HAVE_TRACING + int rank = smpi_process_index(); + TRACE_smpi_init(rank); + TRACE_smpi_computing_init(rank); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_INIT; + TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra); + TRACE_smpi_collective_out(rank, -1, __FUNCTION__); +#endif + if (!smpi_process_index()){ _xbt_replay_action_init(); xbt_replay_action_register("init", action_init); @@ -777,5 +928,17 @@ int smpi_replay_finalize(){ reqq = NULL; } smpi_mpi_barrier(MPI_COMM_WORLD); - return PMPI_Finalize(); +#ifdef HAVE_TRACING + int rank = smpi_process_index(); + instr_extra_data extra = xbt_new(s_instr_extra_data_t,1); + extra->type = TRACING_FINALIZE; + TRACE_smpi_collective_in(rank, -1, __FUNCTION__, extra); +#endif + smpi_process_finalize(); +#ifdef HAVE_TRACING + TRACE_smpi_collective_out(rank, -1, __FUNCTION__); + TRACE_smpi_finalize(smpi_process_index()); +#endif + smpi_process_destroy(); + return MPI_SUCCESS; }