X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/23e9dd1f26f1f7c1bfc672d2ce92f274aa6a00f8..26a65fe3f06c8a304a1fd022eb685072d6531566:/src/smpi/smpi_bench.c diff --git a/src/smpi/smpi_bench.c b/src/smpi/smpi_bench.c index e5e18b1191..c9d2c8b4ab 100644 --- a/src/smpi/smpi_bench.c +++ b/src/smpi/smpi_bench.c @@ -7,6 +7,7 @@ #include "private.h" #include "xbt/dict.h" #include "xbt/sysdep.h" +#include "xbt/ex.h" #include "surf/surf.h" XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi, @@ -14,6 +15,7 @@ XBT_LOG_NEW_DEFAULT_SUBCATEGORY(smpi_bench, smpi, xbt_dict_t allocs = NULL; /* Allocated on first use */ xbt_dict_t samples = NULL; /* Allocated on first use */ +xbt_dict_t calls = NULL; /* Allocated on first use */ typedef struct { int count; @@ -39,6 +41,9 @@ void smpi_bench_destroy(void) if (samples) { xbt_dict_free(&samples); } + if(calls) { + xbt_dict_free(&calls); + } } static void smpi_execute_flops(double flops) @@ -134,10 +139,10 @@ int smpi_sample_2(int global, const char *file, int line) char *loc = sample_location(global, file, line); local_data_t *data; - xbt_assert0(samples, "You did something very inconsistent, didn't you?"); + xbt_assert(samples, "You did something very inconsistent, didn't you?"); data = xbt_dict_get_or_null(samples, loc); if (!data) { - xbt_assert0(data, "Please, do thing in order"); + xbt_assert(data, "Please, do thing in order"); } if (!data->started) { if ((data->iters > 0 && data->count >= data->iters) @@ -163,7 +168,7 @@ void smpi_sample_3(int global, const char *file, int line) local_data_t *data; double sample, n; - xbt_assert0(samples, "You did something very inconsistent, didn't you?"); + xbt_assert(samples, "You did something very inconsistent, didn't you?"); data = xbt_dict_get_or_null(samples, loc); smpi_bench_end(); if(data && data->started && data->count < data->iters) { @@ -223,3 +228,50 @@ void smpi_shared_free(void *ptr) xbt_dict_remove(allocs, loc); } } + +int smpi_shared_known_call(const char* func, const char* input) { + char* loc = bprintf("%s:%s", func, input); + xbt_ex_t ex; + int known; + + if(!calls) { + calls = xbt_dict_new(); + } + TRY { + xbt_dict_get(calls, loc); /* Succeed or throw */ + known = 1; + } + CATCH(ex) { + if(ex.category == not_found_error) { + known = 0; + xbt_ex_free(ex); + } else { + RETHROW; + } + } + free(loc); + return known; +} + +void* smpi_shared_get_call(const char* func, const char* input) { + char* loc = bprintf("%s:%s", func, input); + void* data; + + if(!calls) { + calls = xbt_dict_new(); + } + data = xbt_dict_get(calls, loc); + free(loc); + return data; +} + +void* smpi_shared_set_call(const char* func, const char* input, void* data) { + char* loc = bprintf("%s:%s", func, input); + + if(!calls) { + calls = xbt_dict_new(); + } + xbt_dict_set(calls, loc, data, NULL); + free(loc); + return data; +}