X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/c27e14849074c829c180ddd750c1b7bf0b91d31b..37f5b9a91a456e44ca9a312f84201b3c562e90c6:/src/instr/instr_TI_trace.c diff --git a/src/instr/instr_TI_trace.c b/src/instr/instr_TI_trace.c index 5846c77480..ef558321b1 100644 --- a/src/instr/instr_TI_trace.c +++ b/src/instr/instr_TI_trace.c @@ -1,14 +1,16 @@ -/* Copyright (c) 2010-2013. The SimGrid Team. +/* Copyright (c) 2010-2014. The SimGrid Team. * All rights reserved. */ /* This program is free software; you can redistribute it and/or modify it - * under the terms of the license (GNU LGPL) which comes with this package. */ + * under the terms of the license (GNU LGPL) which comes with this package. */ + #include "instr/instr_private.h" #include "xbt/virtu.h" /* sg_cmdline */ #include "xbt/xbt_os_time.h" #include "simgrid/sg_config.h" - +#include +#include #include XBT_LOG_NEW_DEFAULT_SUBCATEGORY(instr_TI_trace, instr_trace, "tracing event system"); @@ -48,54 +50,56 @@ void TRACE_TI_start(void) void TRACE_TI_end(void) { - if(tracing_files)xbt_dict_free(&tracing_files); + xbt_dict_free(&tracing_files); fclose(tracing_file); char *filename = TRACE_get_filename(); XBT_DEBUG("Filename %s is closed", filename); } -void print_TICreateContainer(paje_event_t event){ +void print_TICreateContainer(paje_event_t event) +{ + //if we are in the mode with only one file + static FILE *temp = NULL; - char* folder_name = bprintf("%s_files",TRACE_get_filename()); - if(tracing_files==NULL){ + if (tracing_files == NULL) { tracing_files = xbt_dict_new_homogeneous(NULL); - struct stat st; - if (stat(folder_name, &st) == -1) { - mkdir(folder_name, 0700); - } //generate unique run id with time - prefix=xbt_os_time(); + prefix = xbt_os_time(); } - //Open a file for each new container - char *filename = NULL; - - - //if we are in the mode with only one file - static FILE* temp = NULL; - - if (!xbt_cfg_get_boolean(_sg_cfg_set, "tracing/smpi/format/ti_one_file") || temp ==NULL){ - filename = bprintf("%s/%f_%s.txt", folder_name, prefix, ((createContainer_t) event->data)->container->name); - temp=fopen(filename, "w"); - if(temp==NULL){ - xbt_die("Tracefile %s could not be opened for writing.", - filename); - } + if (!xbt_cfg_get_boolean(_sg_cfg_set, "tracing/smpi/format/ti_one_file") + || temp == NULL) { + char *folder_name = bprintf("%s_files", TRACE_get_filename()); + char *filename = bprintf("%s/%f_%s.txt", folder_name, prefix, + ((createContainer_t) event->data)->container->name); +#ifdef WIN32 + mkdir(folder_name); +#else + mkdir(folder_name, S_IRWXU | S_IRWXG | S_IRWXO); +#endif + temp = fopen(filename, "w"); + if (temp == NULL) + xbt_die("Tracefile %s could not be opened for writing: %s", + filename, strerror(errno)); fprintf(tracing_file, "%s\n", filename); + xbt_free(folder_name); + xbt_free(filename); } - - - xbt_dict_set(tracing_files, ((createContainer_t) event->data)->container->name, (void*)temp, NULL); - - //Append its path to the main file - free(folder_name); - free(filename); + xbt_dict_set(tracing_files, + ((createContainer_t) event->data)->container->name, + (void *) temp, NULL); } - -void print_TIDestroyContainer(paje_event_t event){ +void print_TIDestroyContainer(paje_event_t event) +{ + if (!xbt_cfg_get_boolean(_sg_cfg_set, "tracing/smpi/format/ti_one_file")|| + xbt_dict_length(tracing_files) == 1) { + FILE* f = xbt_dict_get_or_null(tracing_files, + ((destroyContainer_t) event->data)->container->name); + fclose(f); + } xbt_dict_remove(tracing_files, ((destroyContainer_t) event->data)->container->name); } @@ -145,6 +149,9 @@ void print_TIPushState(paje_event_t event) fprintf(trace_file, "%s irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1); break; + case TRACING_TEST: + fprintf(trace_file, "%s test\n", process_id); + break; case TRACING_WAIT: fprintf(trace_file, "%s wait\n", process_id); break; @@ -205,6 +212,9 @@ void print_TIPushState(paje_event_t event) case TRACING_COMPUTING: fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size); break; + case TRACING_SLEEPING: + fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration); + break; case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype) fprintf(trace_file, "%s gatherv %d ", process_id, extra->send_size); for (i = 0; i < extra->num_processes; i++)