From 0a8277eca04b9973fef788e2cc2edebc01ccc72d Mon Sep 17 00:00:00 2001 From: Thierry <thierry.gautier@inrialpes.fr> Date: Thu, 13 Jul 2017 14:42:32 +0200 Subject: [PATCH] [fix] make coherent execution with wiki --- runtime/src/kaapi_impl.h | 2 +- runtime/src/kaapi_ompt.c | 35 +++++++++++++++++++++++------------ runtime/src/katracereader.cpp | 12 ++++++++---- 3 files changed, 32 insertions(+), 17 deletions(-) diff --git a/runtime/src/kaapi_impl.h b/runtime/src/kaapi_impl.h index 5583158..766a292 100644 --- a/runtime/src/kaapi_impl.h +++ b/runtime/src/kaapi_impl.h @@ -63,7 +63,7 @@ extern "C" { /* Meta data about performance counter */ -typedef struct kaapi_perfctr_info { +typedef struct { const char* name; /* human readable */ const char* cmdlinename; /* command line name */ const char* helpstring; diff --git a/runtime/src/kaapi_ompt.c b/runtime/src/kaapi_ompt.c index f8ce8f6..704d83d 100644 --- a/runtime/src/kaapi_ompt.c +++ b/runtime/src/kaapi_ompt.c @@ -946,11 +946,13 @@ void kaapi_ompt_initialize( /* */ +static int kaapi_ompt_init = 0; _OMP_EXTERN __attribute__ (( weak )) ompt_initialize_t ompt_tool() { printf("[OMP-TRACE] ompt-trace ompt_tool initialized\n"); + kaapi_ompt_init = 1; return &kaapi_ompt_initialize; } @@ -961,19 +963,25 @@ _OMP_EXTERN __attribute__ (( weak )) int kaapi_ext_init(void) { + int err = 0; #if USE_KAAPI - __kmp_init_lock( &__kaapi_global_lock ); - __kaapi_oth_info = (kaapi_ompt_thread_info_t*)calloc(__kaapi_oth_info_capacity, sizeof(kaapi_ompt_thread_info_t)); - int err = kaapi_tracelib_init( - getpid() - ); - if (err !=0) - printf("[OMP-TRACE] kaapi tracing, init error:%i, version: %s\n", err, get_kaapi_version()); - else - printf("[OMP-TRACE] kaapi tracing version: %s\n",get_kaapi_version()); + if (kaapi_ompt_init) + { + __kmp_init_lock( &__kaapi_global_lock ); + __kaapi_oth_info = (kaapi_ompt_thread_info_t*)calloc(__kaapi_oth_info_capacity, sizeof(kaapi_ompt_thread_info_t)); + err = kaapi_tracelib_init( + getpid() + ); + if (err !=0) + printf("[OMP-TRACE] kaapi tracing, init error:%i, version: %s\n", err, get_kaapi_version()); + else + printf("[OMP-TRACE] kaapi tracing version: %s\n",get_kaapi_version()); + } #else - int err = 0; + if (kaapi_ompt_init) + { printf("[OMP-TRACE] kaapi tracing, version compiled without function implementations\n"); + } #endif return err; @@ -986,10 +994,13 @@ _OMP_EXTERN __attribute__ (( weak )) void kaapi_ext_fini(void) { + if (kaapi_ompt_init) + { #if USE_KAAPI - kaapi_tracelib_fini(); + kaapi_tracelib_fini(); #endif - printf("[OMP-TRACE] kaapi_ext_fini\n"); + printf("[OMP-TRACE] kaapi tracing tool closed.\n"); + } } diff --git a/runtime/src/katracereader.cpp b/runtime/src/katracereader.cpp index b0a4854..a89416b 100644 --- a/runtime/src/katracereader.cpp +++ b/runtime/src/katracereader.cpp @@ -2608,14 +2608,18 @@ void csv_parallel_region_t::dump_task_info( task_info* ti ) ); if (!kaapi_perf_idset_empty(&rastello_header.task_perf_mask)) { - //int count_perfcounter = rastello_header.perfcounter_count & 0xFF; for (unsigned int i=0; i<ti->perfctr.size(); ++i) { - //int idx = ti->perfctr[i].idx; - double c = (kaapi_perfctr_info[i].ns2s ? 1e-9 : 1.0); - fprintf(csv_parallel_region_t::fout, ", %.4e", + int idx = ti->perfctr[i].idx; + double c = (kaapi_perfctr_info[idx].ns2s ? 1e-9 : 1.0); + if (kaapi_perfctr_info[idx].ns2s) + fprintf(csv_parallel_region_t::fout, ", %.4e", //rastello_header.perfcounter_name[ti->perfctr[i].idx], c*(double)ti->perfctr[i].value ); + else + fprintf(csv_parallel_region_t::fout, ", %" PRIu64 , + //rastello_header.perfcounter_name[ti->perfctr[i].idx], + ti->perfctr[i].value ); } } #if 0 /* not yet in for csv */ -- GitLab