From 2fbf9a505f5c4a9a64a81c6a18dda8410f7b0e35 Mon Sep 17 00:00:00 2001 From: Adrian Munera Date: Thu, 7 Nov 2019 14:20:20 +0100 Subject: [PATCH 1/3] Initial commit extrae gr740 Change-Id: I8ff77d699d6393ccb63fa7583b394b594cb4b02f --- config/macros.m4 | 26 +- config/openmp.m4 | 2 +- config/posix-clock-macros.m4 | 2 +- config/show-config.m4 | 7 +- config/system.m4 | 20 +- config/ucontext.m4 | 5 + configure.ac | 15 +- src/cmd-line/Makefile.am | 2 +- src/common/hwc_version.h | 2 +- src/common/num_hwc.h | 2 + src/common/utils.c | 16 + src/loader/Makefile.am | 3 + src/merger/paraver/HardwareCounters.c | 4 +- src/merger/paraver/HardwareCounters.h | 7 +- src/merger/paraver/labels.c | 13 + src/merger/paraver/trace_to_prv.c | 48 + src/tracer/calltrace.c | 2 +- src/tracer/clocks/Makefile.am | 2 + src/tracer/defines.h | 3 +- src/tracer/hwc/Makefile.am | 5 + src/tracer/hwc/common_hwc.c | 30 +- src/tracer/hwc/common_hwc.h | 49 +- src/tracer/hwc/l4stat_hwc.c | 409 +++ src/tracer/hwc/l4stat_hwc.h | 244 ++ src/tracer/sampling/timer/sampling-timer.c | 48 + src/tracer/sampling/timer/sampling-timer.h | 5 + src/tracer/trace_hwc.h | 14 + src/tracer/wrappers/API/buffers.c | 31 +- src/tracer/wrappers/API/misc_wrapper.c | 21 +- src/tracer/wrappers/API/wrapper.c | 18 +- src/tracer/wrappers/IO/io_wrapper.c | 4 + src/tracer/wrappers/OMP/gnu-libgomp.c | 3245 +++++++++++++++++++- src/tracer/wrappers/OMP/omp-common.c | 6 + src/tracer/wrappers/OMP/omp-common_c.c | 189 +- 34 files changed, 4459 insertions(+), 40 deletions(-) create mode 100644 src/tracer/hwc/l4stat_hwc.c create mode 100644 src/tracer/hwc/l4stat_hwc.h diff --git a/config/macros.m4 b/config/macros.m4 index f4144268..78c4ff27 100644 --- a/config/macros.m4 +++ b/config/macros.m4 @@ -187,6 +187,8 @@ AC_DEFUN([AX_CHECK_POINTER_SIZE], POINTER_SIZE=64 elif test "${IS_SPARC64_MACHINE}" = "yes" ; then POINTER_SIZE=64 + elif test "${IS_GR740_MACHINE}" = "yes" ; then + POINTER_SIZE=32 else AC_TRY_RUN( [ @@ -890,6 +892,7 @@ AC_DEFUN([AX_PROG_COUNTERS], [ AC_REQUIRE([AX_PROG_PMAPI]) AC_REQUIRE([AX_PROG_PAPI]) + AC_REQUIRE([AX_PROG_L4STAT]) if test "${papi_paths}" = "not_set" ; then if test "${target_os}" = "aix" ; then @@ -901,7 +904,7 @@ AC_DEFUN([AX_PROG_COUNTERS], fi fi - if test "${PMAPI_ENABLED}" = "yes" -o "${PAPI_ENABLED}" = "yes" ; then + if test "${PMAPI_ENABLED}" = "yes" -o "${PAPI_ENABLED}" = "yes" -o "${L4STAT_ENABLED}" = "yes"; then AC_DEFINE([USE_HARDWARE_COUNTERS], 1, [Enable HWC support]) use_hw_counters="1" else @@ -914,6 +917,27 @@ AC_DEFUN([AX_PROG_COUNTERS], fi ]) +# AX_PROG_L4STAT +# ------------- +AC_DEFUN([AX_PROG_L4STAT], +[ + AC_ARG_ENABLE(l4stat, + AC_HELP_STRING( + [--enable-l4stat], + [Enable PMAPI library to gather CPU performance counters] + ), + [enable_l4stat="${enableval}"], + [enable_l4stat="not_set"] + ) + + if test "${enable_l4stat}" = "yes" ; then + L4STAT_ENABLED="yes" + AC_DEFINE([PAPI_COUNTERS], [1], [PAPI is used as API to gain access to CPU hwc]) + AC_DEFINE([L4STAT], [1], [L4STAT is used as API to gain access to CPU hwc]) + fi + + AM_CONDITIONAL(L4STAT, test "${L4STAT_ENABLED}" = "yes") +]) # AX_PROG_PMAPI # ------------- diff --git a/config/openmp.m4 b/config/openmp.m4 index dc0933df..09d1ff04 100644 --- a/config/openmp.m4 +++ b/config/openmp.m4 @@ -96,7 +96,7 @@ AC_DEFUN([AX_HAVE_SYNC_FETCH_AND_ADD], [ have_sync_fetch_and_add="yes" ] ) - if test "${have_sync_fetch_and_add}" = "yes" ; then + if test "${have_sync_fetch_and_add}" = "yes" -a "${IS_GR740_MACHINE}" = "no" ; then AC_DEFINE([HAVE__SYNC_FETCH_AND_ADD], 1, [Define if __sync_fetch_and_add is available]) AC_MSG_RESULT([yes]) else diff --git a/config/posix-clock-macros.m4 b/config/posix-clock-macros.m4 index 22af9a0a..92ab32e5 100644 --- a/config/posix-clock-macros.m4 +++ b/config/posix-clock-macros.m4 @@ -2,7 +2,7 @@ # ------------------- AC_DEFUN([AX_CHECK_POSIX_CLOCK], [ - if test "${Architecture}" = "arm" -o "${Architecture}" = "arm64" ; then + if test "${Architecture}" = "arm" -o "${Architecture}" = "arm64" -o "${Architecture}" = "sparc"; then USE_POSIX_CLOCK="yes" else USE_POSIX_CLOCK="no" diff --git a/config/show-config.m4 b/config/show-config.m4 index 83610cad..058f94f4 100644 --- a/config/show-config.m4 +++ b/config/show-config.m4 @@ -39,14 +39,17 @@ AC_DEFUN([AX_SHOW_CONFIGURATION], AX_JAVA_SHOW_CONFIGURATION echo - if test "${PMAPI_ENABLED}" = "yes" -o "${PAPI_ENABLED}" = "yes" ; then + if test "${PMAPI_ENABLED}" = "yes" -o "${PAPI_ENABLED}" = "yes" -o "${L4STAT_ENABLED}" = "yes"; then echo Performance counters: yes if test "${PMAPI_ENABLED}" = "yes" ; then echo -e \\\tPerformance API: PMAPI - else + else if test "${PAPI_ENABLED}" = "yes"; then echo -e \\\tPerformance API: PAPI echo -e \\\tPAPI home: ${PAPI_HOME} echo -e \\\tSampling support: ${PAPI_SAMPLING_ENABLED} + else + echo -e \\\tPerformance API: L4STAT + fi fi else echo Performance counters: no diff --git a/config/system.m4 b/config/system.m4 index 1cbf4718..3eda36ba 100644 --- a/config/system.m4 +++ b/config/system.m4 @@ -53,7 +53,21 @@ AC_DEFUN([AX_SYSTEM_TYPE], target_cpu="sparc64" target_os="linux" fi - + + AC_ARG_ENABLE(gr740, + AC_HELP_STRING( + [--enable-gr740], + [Enable compilation for the GR740 board] + ), + [enable_gr740="${enableval}"], + [enable_gr740="no"] + ) + IS_GR740_MACHINE=${enable_gr740} + if test "${IS_GR740_MACHINE}" = "yes" ; then + target_cpu="sparc" + target_os="rtems" + fi + AM_CONDITIONAL(IS_GR740_MACHINE, test "${IS_GR740_MACHINE}" = "yes") # Check if this is an Altix machine and if it has an /dev/mmtimer device # (which is a global clock!) AC_ARG_ENABLE(check-altix, @@ -104,6 +118,8 @@ AC_DEFUN([AX_SYSTEM_TYPE], AC_DEFINE([ARCH_MIPS], [1], [Define if architecture is MIPS]) ;; sparc64 ) Architecture="sparc64" AC_DEFINE([ARCH_SPARC64], [1], [Define if architecture is SPARC64]) ;; + sparc ) Architecture="sparc" + AC_DEFINE([ARCH_SPARC], [1], [Define if architecture is SPARC]) ;; esac case "${target_os}" in @@ -123,6 +139,8 @@ AC_DEFUN([AX_SYSTEM_TYPE], AC_DEFINE([OS_SOLARIS], [1], [Define if operating system is Solaris]) ;; darwin* ) OperatingSystem="darwin" AC_DEFINE([OS_DARWIN], [1], [Define if operating system is Darwin]) ;; + rtems* ) OperatingSystem="rtems" + AC_DEFINE([OS_RTEMS], [1], [Define if operating system is RTEMS]) ;; esac # Publish these defines for conditional compilation diff --git a/config/ucontext.m4 b/config/ucontext.m4 index 7d7cc102..bea76a4d 100644 --- a/config/ucontext.m4 +++ b/config/ucontext.m4 @@ -33,7 +33,12 @@ AC_DEFUN([AX_CHECK_UCONTEXT], AC_MSG_RESULT([${STRUCT_UCONTEXT_TYPE}]) if test "${STRUCT_UCONTEXT_TYPE}" = "unknown"; then + if test "${IS_GR740_MACHINE}" = "yes"; then + AC_MSG_WARN([Ucontext not available for GR740, sampling is driven by hardware timers]) + else AC_MSG_ERROR([Unknown definition of struct ucontext. Please check the definition in sys/ucontext.h or libc's ucontext.h and extend the configure macro]) + fi + else AC_DEFINE_UNQUOTED([STRUCT_UCONTEXT], ${STRUCT_UCONTEXT_TYPE}, [Definition of struct ucontext]) fi diff --git a/configure.ac b/configure.ac index 6d37ffd8..b7a71cc5 100644 --- a/configure.ac +++ b/configure.ac @@ -107,7 +107,7 @@ AC_PROG_FC(${wanted_F_Compilers}) AM_CONDITIONAL(HAVE_FC, test "$FC" != "") -if test "${IS_SPARC64_MACHINE}" != "yes" ; then +if test "${IS_SPARC64_MACHINE}" != "yes" -a test "${IS_GR740_MACHINE}" != "yes" ; then AC_FC_WRAPPERS fi AX_JAVA @@ -528,6 +528,17 @@ elif test "${IS_SPARC64_MACHINE}" = "yes" ; then voidp_size=8 short_size=2 char_size=1 +elif test "${IS_GR740_MACHINE}" = "yes" ; then + cross_compiling="yes" + long_long_size=8 + long_size=8 + int_size=4 + pid_t_size=4 + ssize_t_size=8 + size_t_size=8 + voidp_size=8 + short_size=2 + char_size=1 else cross_compiling="no" # Force AC_CHECK_SIZEOF calculate these values long_long_size=0 @@ -556,10 +567,12 @@ AC_CHECK_SIZEOF(ssize_t,${size_t_size}) AC_CHECK_SIZEOF(size_t,${size_t_size}) AC_CHECK_SIZEOF(void*,${voidp_size}) +if test "${IS_GR740_MACHINE}" != "yes" ; then AC_CHECK_MEMBER(struct mallinfo.arena, [AC_DEFINE([HAVE_MALLINFO], [1], [Whether the system supports mallinfo structure])], [], [#include ]) +fi AC_CHECK_MEMBER(union perf_mem_data_src.val, [AC_DEFINE([HAVE_PERF_MEM_DATA_SRC], [1], [Whether the system includes perf_mem_data_src/val])], diff --git a/src/cmd-line/Makefile.am b/src/cmd-line/Makefile.am index b5f5c196..84420564 100644 --- a/src/cmd-line/Makefile.am +++ b/src/cmd-line/Makefile.am @@ -13,7 +13,7 @@ extrae_cmd_CFLAGS = -I$(INCLUDE_DIR) -I$(COMMON_INC) -I$(TRACER_INC) \ extrae_cmd_LDADD = $(TRACER_LIB)/libseqtrace.la $(MERGER_LIB)/libmpi2prv.la -lm if HAVE_BINUTILS -extrae_cmd_LDADD += $(BFD_LDFLAGS) $(BFD_LIBS) $(LIBERTY_LDFLAGS) $(LIBERTY_LIBS) +extrae_cmd_LDADD += $(BFD_LDFLAGS) $(BFD_LIBS) $(LIBERTY_LDFLAGS) $(LIBERTY_LIBS) $(LIBZ_LIBS) endif if HAVE_SIONLIB extrae_cmd_LDADD += @SIONLIB_LIBS@ diff --git a/src/common/hwc_version.h b/src/common/hwc_version.h index 623ccc88..766b4f7c 100644 --- a/src/common/hwc_version.h +++ b/src/common/hwc_version.h @@ -30,7 +30,7 @@ # define PAPIv3 #else # if USE_HARDWARE_COUNTERS -# if defined(PAPI_COUNTERS) +# if defined(PAPI_COUNTERS) && !defined(L4STAT) # include # define PAPIv3 # elif defined(PMAPI_COUNTERS) diff --git a/src/common/num_hwc.h b/src/common/num_hwc.h index f32358b0..cd453a72 100644 --- a/src/common/num_hwc.h +++ b/src/common/num_hwc.h @@ -36,6 +36,8 @@ # define MAX_HWC 8 # elif defined (ARCH_PPC) # define MAX_HWC 8 +# elif defined (OS_RTEMS) +# define MAX_HWC 4 # else # define MAX_HWC 8 # endif diff --git a/src/common/utils.c b/src/common/utils.c index 5a5943c7..50fe181c 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -224,6 +224,22 @@ int __Extrae_Utils_append_from_to_file (const char *source, const char *destinat int __Extrae_Utils_rename_or_copy (char *origen, char *desti) { + +#if defined(OS_RTEMS) + if (strcmp(origen,desti) != 0) + { + if (remove(desti) != 0) + { + if (errno != ENOENT) + { + fprintf (stderr, PACKAGE_NAME": Error while trying to remove %s \n", desti); + fflush(stderr); + return -1; + } + } + } + else return 0; +#endif if (rename (origen, desti) == -1) { if (errno == EXDEV) diff --git a/src/loader/Makefile.am b/src/loader/Makefile.am index cdcf8990..1627e209 100644 --- a/src/loader/Makefile.am +++ b/src/loader/Makefile.am @@ -5,4 +5,7 @@ bin_PROGRAMS = extrae-loader extrae_loader_SOURCES = \ extrae-loader.c +if !IS_GR740_MACHINE extrae_loader_LDFLAGS = -ldl +endif + diff --git a/src/merger/paraver/HardwareCounters.c b/src/merger/paraver/HardwareCounters.c index 0085dcc6..80e92417 100644 --- a/src/merger/paraver/HardwareCounters.c +++ b/src/merger/paraver/HardwareCounters.c @@ -124,7 +124,7 @@ int HardwareCounters_Emit (int ptask, int task, int thread, /* If using PAPI, they can be stored in absolute or relative manner, depending whether sampling was activated or not */ #if defined(PAPI_COUNTERS) -# if defined(SAMPLING_SUPPORT) +# if defined(SAMPLING_SUPPORT) && !defined(OS_RTEMS) if (Sthread->HWCSets[set_id][cnt] != NO_COUNTER && Sthread->HWCSets[Sthread->current_HWCSet][cnt] != SAMPLE_COUNTER) # else @@ -135,7 +135,7 @@ int HardwareCounters_Emit (int ptask, int task, int thread, the previous read value from the current PAPI_read because it's always adding */ -# if defined(SAMPLING_SUPPORT) +# if defined(SAMPLING_SUPPORT) && !defined(OS_RTEMS) /* Protect when counters are incorrect (major timestamp, lower counter value) */ if (Event->HWCValues[cnt] >= Sthread->counters[cnt]) { diff --git a/src/merger/paraver/HardwareCounters.h b/src/merger/paraver/HardwareCounters.h index 82fe9405..ca158293 100644 --- a/src/merger/paraver/HardwareCounters.h +++ b/src/merger/paraver/HardwareCounters.h @@ -29,8 +29,9 @@ #include "num_hwc.h" #include "hwc_version.h" #include "record.h" -#include "papiStdEventDefs.h" - +#if !defined(L4STAT) + #include "papiStdEventDefs.h" +#endif #if !USE_HARDWARE_COUNTERS /* Little things to have configured if PAPI cannot be used */ # define PAPI_NATIVE_MASK 0x40000000 @@ -48,6 +49,8 @@ # elif defined(PAPIv3) # define HWC_COUNTER_TYPE(x) \ (x&PAPI_NATIVE_MASK)?(HWC_BASE_NATIVE + (x & 0x0000FFFF)):(HWC_BASE + (x & 0x0000FFFF)) +# elif defined(L4STAT) +# define HWC_COUNTER_TYPE(x) ((x & 0xFFFFFFFF)) # endif #elif defined(PMAPI_COUNTERS) # define HWC_COUNTER_TYPE(cnt,x) (HWC_BASE + cnt*1000 + x) diff --git a/src/merger/paraver/labels.c b/src/merger/paraver/labels.c index 81d0349c..fb872838 100644 --- a/src/merger/paraver/labels.c +++ b/src/merger/paraver/labels.c @@ -1197,6 +1197,19 @@ int Labels_GeneratePCFfile (char *name, long long options) return 0; } +#if defined(OS_RTEMS) +void Labels_loadRTEMSSymbols(char *executable_path, struct input_t * IFiles) +{ + + char path_binary2[256]; + strcpy(path_binary2,executable_path); + path_binary2[strlen(path_binary2)-strlen(".prv")] = (char) 0; + ObjectTable_AddBinaryObject (FALSE, IFiles[0].ptask, IFiles[0].task, + 0, 0xFFFFFFFF, 0, path_binary2); + +} +#endif + void Labels_loadLocalSymbols (int taskid, unsigned long nfiles, struct input_t * IFiles) { diff --git a/src/merger/paraver/trace_to_prv.c b/src/merger/paraver/trace_to_prv.c index f0550904..638957b1 100644 --- a/src/merger/paraver/trace_to_prv.c +++ b/src/merger/paraver/trace_to_prv.c @@ -252,6 +252,48 @@ int Paraver_ProcessTraceFiles (unsigned long nfiles, fset = Create_FS (nfiles, files, taskid, PRV_SEMANTICS); error = (fset == NULL); + + +#if defined(OS_RTEMS) + + char *str,*path; + char PROGRAM_NAME[256]; + char PATH_NAME[256]; + char prvfile[256]; + int binary_exists=0; + str = getenv ("EXTRAE_PROGRAM_NAME"); + path = getenv ("EXTRAE_FINAL_DIR"); + + if(!path) + strncpy (PATH_NAME, "/mnt/traces/", strlen("TRACE")+1); + else + strncpy (PATH_NAME, path, sizeof(PATH_NAME)); + if (!str) + strncpy (PROGRAM_NAME, "TRACE", strlen("TRACE")+1); + else + strncpy (PROGRAM_NAME, str, sizeof(PROGRAM_NAME)); + + strcpy(prvfile,PATH_NAME); + strcat(prvfile,"/"); + strcat(prvfile,PROGRAM_NAME); + +#if defined(HAVE_BFD) + if (__Extrae_Utils_file_exists(prvfile)){ + binary_exists=1; + } + else set_option_dump_Addresses(FALSE); +#else + binary_exists=1; +#endif + strcat(prvfile,".prv\0"); + set_merge_OutputTraceName (prvfile); + set_merge_GivenTraceName (TRUE); + + if (taskid == 0) + Labels_loadRTEMSSymbols(prvfile,files); + +#else + if (taskid == 0) Labels_loadLocalSymbols (taskid, nfiles, files); @@ -275,6 +317,8 @@ int Paraver_ProcessTraceFiles (unsigned long nfiles, } } +#endif + if (__Extrae_Utils_file_exists(get_merge_OutputTraceName()) && !get_option_merge_TraceOverwrite()) { @@ -707,6 +751,10 @@ int Paraver_ProcessTraceFiles (unsigned long nfiles, { if (error == 0) { +#if defined(OS_RTEMS) + if(!binary_exists) + fprintf (stdout, "mpi2prv: WARNING binary file can not be found at the NFS mounted folder, calltrace info (function names) will be empty \n"); +#endif fprintf (stdout, "mpi2prv: Congratulations! %s has been generated.\n", get_merge_OutputTraceName()); } else diff --git a/src/tracer/calltrace.c b/src/tracer/calltrace.c index a894f92d..98529baf 100644 --- a/src/tracer/calltrace.c +++ b/src/tracer/calltrace.c @@ -374,7 +374,7 @@ static int ValidAddress (void * Addr) { #endif /* OS_AIX */ -#if defined (OS_SOLARIS) +#if defined (OS_SOLARIS) || defined(OS_RTEMS) void Extrae_trace_callers (iotimer_t time, int offset, int type) { /* TODO */ diff --git a/src/tracer/clocks/Makefile.am b/src/tracer/clocks/Makefile.am index 00fc1b41..eeda4355 100644 --- a/src/tracer/clocks/Makefile.am +++ b/src/tracer/clocks/Makefile.am @@ -32,4 +32,6 @@ endif noinst_LTLIBRARIES = libclock.la libclock_la_SOURCES = $(CLOCKS) libclock_la_CFLAGS = -I$(CLOCKS_INC) -I$(COMMON_INC) -I$(TRACER_INC) +if !IS_GR740_MACHINE libclock_la_LDFLAGS = -lrt +endif diff --git a/src/tracer/defines.h b/src/tracer/defines.h index 6bd92817..b563a430 100644 --- a/src/tracer/defines.h +++ b/src/tracer/defines.h @@ -51,12 +51,13 @@ #else /* HAVE_MPI */ /* If we don't have MPI, rely on FC_FUNC if web have detected at configure time! */ +#if !defined(OS_RTEMS) # if defined(FC_FUNC) # define CtoF77(x) FC_FUNC(x,x) # else # error "Error! Not defined FC_FUNC, how do we deal with Fortran symbols?" # endif - +#endif #endif /* HAVE_MPI */ #endif diff --git a/src/tracer/hwc/Makefile.am b/src/tracer/hwc/Makefile.am index e6ed637a..c5915150 100644 --- a/src/tracer/hwc/Makefile.am +++ b/src/tracer/hwc/Makefile.am @@ -16,9 +16,14 @@ if HAVE_PMAPI HWC += common_hwc.c common_hwc.h \ pmapi_hwc.c pmapi_hwc.h else +if L4STAT +HWC += common_hwc.c common_hwc.h \ + l4stat_hwc.c l4stat_hwc.h +else HWC += fake_hwc.c endif endif +endif noinst_LTLIBRARIES = libhwc.la diff --git a/src/tracer/hwc/common_hwc.c b/src/tracer/hwc/common_hwc.c index 557ca65f..53ce169e 100644 --- a/src/tracer/hwc/common_hwc.c +++ b/src/tracer/hwc/common_hwc.c @@ -54,7 +54,7 @@ /*------------------------------------------------ Global Variables ---------*/ int HWCEnabled = FALSE; /* Have the HWC been started? */ -#if !defined(SAMPLING_SUPPORT) +#if !defined(SAMPLING_SUPPORT) || defined(OS_RTEMS) int Reset_After_Read = TRUE; #else int Reset_After_Read = FALSE; @@ -75,8 +75,8 @@ int AllHWCs = 0; /* Count of all the different counters from /*------------------------------------------------ Static Variables ---------*/ -#if defined(PAPI_COUNTERS) && !defined(PAPIv3) -# error "-DNEW_HWC_SYSTEM requires PAPI v3 support" +#if defined(PAPI_COUNTERS) && !defined(PAPIv3) && !defined(L4STAT) +# error "-DNEW_HWC_SYSTEM requires PAPI v3 support or L4STAT" #endif struct HWC_Set_t *HWC_sets = NULL; @@ -335,7 +335,10 @@ void HWC_Initialize (int options) HWC_current_glopsbegin = (unsigned long long *)malloc(sizeof(unsigned long long) * num_threads); ASSERT(HWC_current_glopsbegin != NULL, "Cannot allocate memory for HWC_current_glopsbegin"); +//L4STAT must parse enviorment variables before initializing the HWCs +#if !defined(L4STAT) HWCBE_INITIALIZE(options); + #endif } /** @@ -425,7 +428,7 @@ void HWC_Restart_Counters (int old_num_threads, int new_num_threads) { int i; -#if defined(PAPI_COUNTERS) +#if defined(PAPI_COUNTERS) && !defined(L4STAT) for (i = 0; i < HWC_num_sets; i++) HWCBE_PAPI_Allocate_eventsets_per_thread (i, old_num_threads, new_num_threads); #endif @@ -582,6 +585,13 @@ void HWC_Parse_Env_Config (int task_id) * \param store_buffer Buffer where the counters will be stored. * \return 1 if counters were read successfully, 0 otherwise. */ +#if defined(OS_RTEMS) +void HWC_update_sampling(unsigned int tid){ + + HWCBE_UPDATE_SAMPLING(tid); + +} +#endif int HWC_Read (unsigned int tid, UINT64 time, long long *store_buffer) { int read_ok = FALSE, reset_ok = FALSE; @@ -597,6 +607,18 @@ int HWC_Read (unsigned int tid, UINT64 time, long long *store_buffer) } return (HWCEnabled && read_ok && reset_ok); } +#if defined(OS_RTEMS) +int HWC_Read_Sampling (unsigned int tid, UINT64 time, uint32_t *store_buffer) +{ + int read_ok = FALSE; + if (HWCEnabled) + { + TOUCH_LASTFIELD( store_buffer ); + read_ok = HWCBE_READ_Sampling (tid, store_buffer); + } + return (HWCEnabled && read_ok); +} +#endif /** * Resets the counters of the given thread. diff --git a/src/tracer/hwc/common_hwc.h b/src/tracer/hwc/common_hwc.h index da36ae8b..870994de 100644 --- a/src/tracer/hwc/common_hwc.h +++ b/src/tracer/hwc/common_hwc.h @@ -35,7 +35,7 @@ struct HWC_Set_t { -#if defined(PAPI_COUNTERS) +#if defined(PAPI_COUNTERS) && !defined(L4STAT) int domain; int *eventsets; #elif defined(PMAPI_COUNTERS) @@ -106,7 +106,7 @@ extern int * HWC_current_set; /*------------------------------------------------ Backends access layer ----*/ -#if defined(PAPI_COUNTERS) /* -------------------- PAPI Backend -------------*/ +#if defined(PAPI_COUNTERS) && !defined(L4STAT) /* -------------------- PAPI Backend -------------*/ # include "papi_hwc.h" @@ -180,6 +180,51 @@ extern int * HWC_current_set; #define HWCBE_GET_COUNTER_DEFINITIONS(count) \ HWCBE_PMAPI_GetCounterDefinitions(count) + +#elif defined(L4STAT) + +# include "l4stat_hwc.h" + +# define HWCBE_INITIALIZE(options) \ + HWCBE_L4STAT_Initialize (options) + +# define HWCBE_START_COUNTERS_THREAD(time, tid, forked) \ + HWCBE_L4STAT_Init_Thread(time, tid, forked) + +# define HWCBE_START_SET(glops, time, current_set, thread_id) \ + HWCBE_L4STAT_Start_Set(glops, time, current_set, thread_id) + +# define HWCBE_STOP_SET(time, current_set, thread_id) \ + HWCBE_L4STAT_Stop_Set(time, current_set, thread_id) + +# define HWCBE_ADD_SET(pretended_set, rank, ncounters, counters, domain, \ + change_at_globalops, change_at_time, num_overflows, \ + overflow_counters, overflow_values) \ + HWCBE_L4STAT_Add_Set(pretended_set, rank, ncounters, counters, domain, \ + change_at_globalops, change_at_time, num_overflows, \ + overflow_counters, overflow_values) + +# define HWCBE_READ(thread_id, store_buffer) \ + HWCBE_L4STAT_Read(thread_id, store_buffer) + +# define HWCBE_READ_Sampling(thread_id, store_buffer) \ + HWCBE_L4STAT_Read_Sampling(thread_id, store_buffer) + +# define HWCBE_RESET(thread_id) \ + HWCBE_L4STAT_Reset(thread_id) + +#define HWCBE_UPDATE_SAMPLING(thread_id) \ + HWCBE_L4STAT_Update_Sampling_Cores(thread_id) + +# define HWCBE_ACCUM(thread_id, store_buffer) \ + HWCBE_L4STAT_Accum(thread_id, store_buffer) + +# define HWCBE_CLEANUP_COUNTERS_THREAD(nthreads) \ + HWCBE_L4STAT_CleanUp(nthreads) + +#define HWCBE_GET_COUNTER_DEFINITIONS(count) \ + HWCBE_L4STAT_GetCounterDefinitions(count) + #endif #endif /* __COMMON_HWC_H__ */ diff --git a/src/tracer/hwc/l4stat_hwc.c b/src/tracer/hwc/l4stat_hwc.c new file mode 100644 index 00000000..8e72b97e --- /dev/null +++ b/src/tracer/hwc/l4stat_hwc.c @@ -0,0 +1,409 @@ +/*****************************************************************************\ + * ANALYSIS PERFORMANCE TOOLS * + * Extrae * + * Instrumentation package for parallel applications * + ***************************************************************************** + * ___ This library is free software; you can redistribute it and/or * + * / __ modify it under the terms of the GNU LGPL as published * + * / / _____ by the Free Software Foundation; either version 2.1 * + * / / / \ of the License, or (at your option) any later version. * + * ( ( ( B S C ) * + * \ \ \_____/ This library is distributed in hope that it will be * + * \ \__ useful but WITHOUT ANY WARRANTY; without even the * + * \___ implied warranty of MERCHANTABILITY or FITNESS FOR A * + * PARTICULAR PURPOSE. See the GNU LGPL for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this library; if not, write to the Free Software Foundation, * + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + * The GNU LEsser General Public License is contained in the file COPYING. * + * --------- * + * Barcelona Supercomputing Center - Centro Nacional de Supercomputacion * +\*****************************************************************************/ + +#include "common.h" + +#ifdef HAVE_SYS_TIME_H +#include +#endif +#ifdef HAVE_STRING_H +#include +#endif +#ifdef HAVE_STRINGS_H +#include +#endif +#ifdef HAVE_STDLIB_H +#include +#endif + +#include "utils.h" +#include "events.h" +#include "clock.h" +#include "threadid.h" +#include "record.h" +#include "trace_macros.h" +#include "wrapper.h" +#include "stdio.h" +#include "common_hwc.h" +#include "l4stat_hwc.h" +#include /* for device driver prototypes */ +#include + +int sw_threads[8]; + + +/*------------------------------------------------ Static Variables ---------*/ + +static HWC_Definition_t *hwc_used = NULL; +static unsigned num_hwc_used = 0; + +static void HWCBE_L4STAT_AddDefinition(unsigned event_code, char *description) +{ + int found = FALSE; + unsigned u; + + for (u = 0; !found && (u < num_hwc_used); u++) + found = hwc_used[u].event_code == event_code; + + if (!found) + { + hwc_used = (HWC_Definition_t *)realloc(hwc_used, + sizeof(HWC_Definition_t) * (num_hwc_used + 1)); + if (hwc_used == NULL) + { + fprintf(stderr, "ERROR! Cannot allocate memory to add definitions for hardware counters\n"); + return; + } + hwc_used[num_hwc_used].event_code = event_code; + snprintf(hwc_used[num_hwc_used].description, + MAX_HWC_DESCRIPTION_LENGTH, "[%s]", description); + num_hwc_used++; + } +} + +HWC_Definition_t *HWCBE_L4STAT_GetCounterDefinitions(unsigned *count) +{ + *count = num_hwc_used; + return hwc_used; +} + +int HWCBE_L4STAT_Add_Set(int pretended_set, int rank, int ncounters, char **counters, + char *domain, char *change_at_globalops, char *change_at_time, + int num_overflows, char **overflow_counters, unsigned long long *overflow_values) +{ + int i, rc, num_set = HWC_num_sets; + char *info; + + UNREFERENCED_PARAMETER(num_overflows); + UNREFERENCED_PARAMETER(overflow_counters); + UNREFERENCED_PARAMETER(overflow_values); + + if (ncounters == 0 || counters == NULL) + return 0; + + if (ncounters > MAX_HWC) + { + fprintf(stderr, PACKAGE_NAME ": You cannot provide more HWC counters than %d (see set %d)\n", MAX_HWC, pretended_set); + ncounters = MAX_HWC; + } + + HWC_sets = (struct HWC_Set_t *)realloc(HWC_sets, sizeof(struct HWC_Set_t) * (HWC_num_sets + 1)); + if (HWC_sets == NULL) + { + fprintf(stderr, PACKAGE_NAME ": Cannot allocate memory for HWC_set (rank %d)\n", rank); + return 0; + } + + /* Initialize this set */ + HWC_sets[num_set].num_counters = 0; + + for (i = 0; i < ncounters; i++) + { + /* counter_last_position will hold the address of the end of the + counter[i] string + This shall be compared with strtoul_check to know if the hex + is correct or not + */ + char *counter_last_position = &(counters[i][strlen(counters[i])]); + char *strtoul_check; + + HWC_sets[num_set].counters[HWC_sets[num_set].num_counters] = + strtoul(counters[i], &strtoul_check, 16); + + if (strtoul_check != counter_last_position) + { + int EventCode; + + if (rank == 0) + fprintf(stderr, PACKAGE_NAME ": Currently name translation of counters is disabled, please specify the counter number \n"); + continue; + } + else if (HWC_sets[num_set].counters[HWC_sets[num_set].num_counters] > 0x9F || HWC_sets[num_set].counters[HWC_sets[num_set].num_counters] < 0x0) + { + if (rank == 0) + fprintf(stderr, PACKAGE_NAME ": Wrong counter number %s, please specify a counter in the range 0x0 to 0x9F\n", counters[i]); + continue; + } + + info = l4stat_event_names[HWC_sets[num_set].counters[HWC_sets[num_set].num_counters]]; + if (strcmp(info, L4STAT_BAD_CMD) == 0) + { + if (rank == 0) + fprintf(stderr, PACKAGE_NAME ": Error! Cannot query information for hardware counter %s (0x%08x). Check set %d.\n", counters[i], HWC_sets[num_set].counters[HWC_sets[num_set].num_counters], pretended_set); + + HWC_sets[num_set].counters[HWC_sets[num_set].num_counters] = NO_COUNTER; + } + else + { + if (rank == 0) + HWCBE_L4STAT_AddDefinition(HWC_sets[num_set].counters[HWC_sets[num_set].num_counters], info); + + HWC_sets[num_set].num_counters++; + } + } + + if (HWC_sets[num_set].num_counters == 0) + { + if (rank == 0) + fprintf(stderr, PACKAGE_NAME ": Set %d of counters seems to be empty/invalid, skipping\n", pretended_set); + return 0; + } + + HWC_sets[num_set].change_type = CHANGE_NEVER; + + //HWCBE_PAPI_Allocate_eventsets_per_thread (num_set, 0, Backend_getNumberOfThreads()); + + /* We validate this set */ + HWC_num_sets++; + + if (rank == 0) + { + fprintf(stdout, PACKAGE_NAME ": HWC set %d contains following counters < ", pretended_set); + for (i = 0; i < HWC_sets[num_set].num_counters; i++) + { + if (HWC_sets[num_set].counters[i] != NO_COUNTER) + { + fprintf(stdout, "%s (0x%08x) ", l4stat_event_names[HWC_sets[num_set].counters[i]], HWC_sets[num_set].counters[i]); + } + } + fprintf(stdout, ">"); + + if (HWC_sets[num_set].change_type == CHANGE_TIME) + fprintf(stdout, " - changing every %lld nanoseconds\n", HWC_sets[num_set].change_at); + else if (HWC_sets[num_set].change_type == CHANGE_GLOPS) + fprintf(stdout, " - changing every %lld global operations\n", HWC_sets[num_set].change_at); + else + fprintf(stdout, " - never changes\n"); + + fflush(stdout); + } + + return HWC_sets[num_set].num_counters; +} + +int HWCBE_L4STAT_Start_Set(UINT64 countglops, UINT64 time, int numset, int threadid) +{ + + int rc; + + /* The given set is a valid one? */ + if (numset < 0 || numset >= HWC_num_sets) + return FALSE; + + HWC_current_changeat = HWC_sets[numset].change_at; + HWC_current_changetype = HWC_sets[numset].change_type; + HWC_current_timebegin[threadid] = time; + HWC_current_glopsbegin[threadid] = countglops; + + TRACE_EVENT(time, HWC_CHANGE_EV, numset); + + return TRUE; +} + +int HWCBE_L4STAT_Stop_Set(UINT64 time, int numset, int threadid) +{ + //Not required currently + return 1; +} + +void HWCBE_L4STAT_CleanUp(unsigned nthreads) +{ + int ret; + int i; + + for (i = 0; i < 16; i++) + { + ret = l4stat_counter_clear(i); + if (ret != L4STAT_ERR_OK) + { + printf("Error: l4stat clear!\n"); + exit(1); + } + ret = l4stat_counter_disable(i); + if (ret != L4STAT_ERR_OK) + { + printf("Error: l4stat disable!\n"); + exit(1); + } + } +} + +/****************************************************************************** + ** Function name : L4STAT_Initialize + ** + ** Description : + ******************************************************************************/ + +void HWCBE_L4STAT_Initialize(int TRCOptions) +{ + int ret; + int i, j, counter; + for (i = 0; i < 16; i++) + { + ret = l4stat_counter_clear(i); + if (ret != L4STAT_ERR_OK) + { + printf("Error: l4stat clear!\n"); + exit(1); + } + ret = l4stat_counter_disable(i); + if (ret != L4STAT_ERR_OK) + { + printf("Error: l4stat disable!\n"); + exit(1); + } + } + + for (i = 0; i < 4; i++) + { + + counter = HWC_sets[0].num_counters * i; + + for (j = 0; j < HWC_sets[0].num_counters; j++) + { + + //printf("Enabling counter %i, cpu %i event: %i \n", counter, i, HWC_sets[0].counters[j] ); + ret = l4stat_counter_enable(counter, HWC_sets[0].counters[j], i, 0); + if (ret != L4STAT_ERR_OK) + { + printf("Error: l4stat enable!\n"); + exit(1); + } + ret = l4stat_counter_set(counter, 0); + if (ret != L4STAT_ERR_OK) + { + printf("Error: l4stat init thread!\n"); + return -1; + } + counter++; + } + } +} + +int HWCBE_L4STAT_Init_Thread(UINT64 time, int threadid, int forked) +{ + int cpu_self, i, ret; + cpu_self = (int)rtems_get_current_processor(); + sw_threads[threadid] = cpu_self; + HWC_Thread_Initialized[threadid] = HWCBE_L4STAT_Start_Set(0, time, HWC_current_set[threadid], threadid); + + return HWC_Thread_Initialized[threadid]; +} + +int HWCBE_L4STAT_Read(unsigned int tid, long long *store_buffer) +{ + int cpu_self, i, ret; + uint32_t value; + cpu_self = (int)rtems_get_current_processor(); + int counter = HWC_sets[0].num_counters * cpu_self; + for (i = 0; i < HWC_sets[0].num_counters; i++) + { + ret = l4stat_counter_get(counter, &value); + if (ret != L4STAT_ERR_OK) + { + printf("Error: l4stat read thread!\n"); + return -1; + } + counter++; + store_buffer[i] = (long long)value; + } + return TRUE; +} + +int HWCBE_L4STAT_Read_Sampling(unsigned int tid, long long *store_buffer) +{ + int cpu_self, i, ret; + uint32_t value; + cpu_self = sw_threads[tid]; + int counter = HWC_sets[0].num_counters * cpu_self; + for (i = 0; i < HWC_sets[0].num_counters; i++) + { + ret = l4stat_counter_get(counter, &value); + if (ret != L4STAT_ERR_OK) + { + printf("Error: l4stat read thread!\n"); + return -1; + } + + store_buffer[i] = value; + ret = l4stat_counter_set(counter, 0); + if (ret != L4STAT_ERR_OK) + { + printf("Error: l4stat reset thread!\n"); + return -1; + } + counter++; + } + + return TRUE; +} + +int HWCBE_L4STAT_Reset(unsigned int tid) +{ + int cpu_self, i, ret; + uint32_t value; + cpu_self = (int)rtems_get_current_processor(); + int counter = HWC_sets[0].num_counters * cpu_self; + for (i = 0; i < HWC_sets[0].num_counters; i++) + { + ret = l4stat_counter_set(counter, 0); + if (ret != L4STAT_ERR_OK) + { + printf("Error: l4stat reset thread!\n"); + return -1; + } + counter++; + } + return TRUE; +} + +void HWCBE_L4STAT_Update_Sampling_Cores(unsigned int tid) +{ + sw_threads[tid] = (int)rtems_get_current_processor(); +} + +int HWCBE_L4STAT_Accum(unsigned int tid, long long *store_buffer) +{ + int cpu_self, i, ret; + uint32_t value; + cpu_self = (int)rtems_get_current_processor(); + int counter = HWC_sets[0].num_counters * cpu_self; + for (i = 0; i < HWC_sets[0].num_counters; i++) + { + ret = l4stat_counter_get(counter, &value); + if (ret != L4STAT_ERR_OK) + { + printf("Error: l4stat read accum thread!\n"); + return -1; + } + ret = l4stat_counter_set(counter, 0); + if (ret != L4STAT_ERR_OK) + { + printf("Error: l4stat reset accum thread!\n"); + return -1; + } + counter++; + store_buffer[i] += value; + } + return TRUE; +} diff --git a/src/tracer/hwc/l4stat_hwc.h b/src/tracer/hwc/l4stat_hwc.h new file mode 100644 index 00000000..3e0f466b --- /dev/null +++ b/src/tracer/hwc/l4stat_hwc.h @@ -0,0 +1,244 @@ +/*****************************************************************************\ + * ANALYSIS PERFORMANCE TOOLS * + * Extrae * + * Instrumentation package for parallel applications * + ***************************************************************************** + * ___ This library is free software; you can redistribute it and/or * + * / __ modify it under the terms of the GNU LGPL as published * + * / / _____ by the Free Software Foundation; either version 2.1 * + * / / / \ of the License, or (at your option) any later version. * + * ( ( ( B S C ) * + * \ \ \_____/ This library is distributed in hope that it will be * + * \ \__ useful but WITHOUT ANY WARRANTY; without even the * + * \___ implied warranty of MERCHANTABILITY or FITNESS FOR A * + * PARTICULAR PURPOSE. See the GNU LGPL for more details. * + * * + * You should have received a copy of the GNU Lesser General Public License * + * along with this library; if not, write to the Free Software Foundation, * + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * + * The GNU LEsser General Public License is contained in the file COPYING. * + * --------- * + * Barcelona Supercomputing Center - Centro Nacional de Supercomputacion * +\*****************************************************************************/ + +#ifndef __L4STAT_HWC_H__ +#define __L4STAT_HWC_H__ + +#include "num_hwc.h" + +/*------------------------------------------------ Prototypes ---------------*/ + +void HWCBE_L4STAT_Initialize(int TRCOptions); +int HWCBE_L4STAT_Init_Thread(UINT64 time, int threadid, int forked); +int HWCBE_L4STAT_Allocate_eventsets_per_thread(int num_set, int old_thread_num, int new_thread_num); + +int HWCBE_L4STAT_Start_Set(UINT64 countglops, UINT64 time, int numset, int threadid); +int HWCBE_L4STAT_Stop_Set(UINT64 time, int numset, int threadid); +int HWCBE_L4STAT_Add_Set(int pretended_set, int rank, int ncounters, char **counters, char *domain, + char *change_at_globalops, char *change_at_time, int num_overflows, + char **overflow_counters, unsigned long long *overflow_values); + +int HWCBE_L4STAT_Read(unsigned int tid, long long *store_buffer); +int HWCBE_L4STAT_Read_Sampling(unsigned int tid, long long *store_buffer); +int HWCBE_L4STAT_Reset(unsigned int tid); +int HWCBE_L4STAT_Accum(unsigned int tid, long long *store_buffer); +void HWCBE_L4STAT_Update_Sampling_Cores(unsigned int tid); + +void HWCBE_L4STAT_CleanUp(unsigned nthreads); + +HWC_Definition_t *HWCBE_L4STAT_GetCounterDefinitions(unsigned *count); + +#define L4STAT_BAD_CMD "N/A. Wrong event" + +#define L4STAT_NULL -1 + +static const char *l4stat_event_names[] = { + "Instruction cache miss", /* 0x00 */ + "Instruction MMU TLB miss", /* 0x01 */ + "Instruction cache hold", /* 0x02 */ + "Instruction MMU hold", /* 0x03 */ + L4STAT_BAD_CMD, /* 0x04 */ + L4STAT_BAD_CMD, /* 0x05 */ + L4STAT_BAD_CMD, /* 0x06 */ + L4STAT_BAD_CMD, /* 0x07 */ + "Data cache (read) miss", /* 0x08 */ + "Data MMU TLB miss", /* 0x09 */ + "Data cache hold", /* 0x0a */ + "Data MMU hold", /* 0x0b */ + L4STAT_BAD_CMD, /* 0x0c */ + L4STAT_BAD_CMD, /* 0x0d */ + L4STAT_BAD_CMD, /* 0x0e */ + L4STAT_BAD_CMD, /* 0x0f */ + "Data write buffer hold", /* 0x10 */ + "Total instruction count", /* 0x11 */ + "Integer instruction count", /* 0x12 */ + "Floating-point unit instruction count", /* 0x13 */ + "Branch prediction miss", /* 0x14 */ + "Execution time, exluding debug mode", /* 0x15 */ + L4STAT_BAD_CMD, /* 0x16 */ + "AHB utilization (per AHB master)", /* 0x17 */ + "AHB utilization (total)", /* 0x18 */ + L4STAT_BAD_CMD, /* 0x19 */ + L4STAT_BAD_CMD, /* 0x1a */ + L4STAT_BAD_CMD, /* 0x1b */ + L4STAT_BAD_CMD, /* 0x1c */ + L4STAT_BAD_CMD, /* 0x1d */ + L4STAT_BAD_CMD, /* 0x1e */ + L4STAT_BAD_CMD, /* 0x1f */ + L4STAT_BAD_CMD, /* 0x20 */ + L4STAT_BAD_CMD, /* 0x21 */ + "Integer branches", /* 0x22 */ + L4STAT_BAD_CMD, /* 0x23 */ + L4STAT_BAD_CMD, /* 0x24 */ + L4STAT_BAD_CMD, /* 0x25 */ + L4STAT_BAD_CMD, /* 0x26 */ + L4STAT_BAD_CMD, /* 0x27 */ + "CALL instructions", /* 0x28 */ + L4STAT_BAD_CMD, /* 0x29 */ + L4STAT_BAD_CMD, /* 0x2a */ + L4STAT_BAD_CMD, /* 0x2b */ + L4STAT_BAD_CMD, /* 0x2c */ + L4STAT_BAD_CMD, /* 0x2d */ + L4STAT_BAD_CMD, /* 0x2e */ + L4STAT_BAD_CMD, /* 0x2f */ + "Regular type 2 instructions", /* 0x30 */ + L4STAT_BAD_CMD, /* 0x31 */ + L4STAT_BAD_CMD, /* 0x32 */ + L4STAT_BAD_CMD, /* 0x33 */ + L4STAT_BAD_CMD, /* 0x34 */ + L4STAT_BAD_CMD, /* 0x35 */ + L4STAT_BAD_CMD, /* 0x36 */ + L4STAT_BAD_CMD, /* 0x37 */ + "LOAD and STORE instructions", /* 0x38 */ + "LOAD instructions", /* 0x39 */ + "STORE instructions", /* 0x3a */ + L4STAT_BAD_CMD, /* 0x3b */ + L4STAT_BAD_CMD, /* 0x3c */ + L4STAT_BAD_CMD, /* 0x3d */ + L4STAT_BAD_CMD, /* 0x3e */ + L4STAT_BAD_CMD, /* 0x3f */ + "AHB IDLE cycles", /* 0x40 */ + "AHB BUSY cycles", /* 0x41 */ + "AHB Non-Seq. transfers", /* 0x42 */ + "AHB Seq. transfers", /* 0x43 */ + "AHB read accesses", /* 0x44 */ + "AHB write accesses", /* 0x45 */ + "AHB byte accesses", /* 0x46 */ + "AHB half-word accesses", /* 0x47 */ + "AHB word accesses", /* 0x48 */ + "AHB double word accesses", /* 0x49 */ + "AHB quad word accesses", /* 0x4A */ + "AHB eight word accesses", /* 0x4B */ + "AHB waitstates", /* 0x4C */ + "AHB RETRY responses", /* 0x4D */ + "AHB SPLIT responses", /* 0x4E */ + "AHB SPLIT delay", /* 0x4F */ + "AHB bus locked", /* 0x50 */ + L4STAT_BAD_CMD, /* 0x51 */ + L4STAT_BAD_CMD, /* 0x52 */ + L4STAT_BAD_CMD, /* 0x53 */ + L4STAT_BAD_CMD, /* 0x54 */ + L4STAT_BAD_CMD, /* 0x55 */ + L4STAT_BAD_CMD, /* 0x56 */ + L4STAT_BAD_CMD, /* 0x57 */ + L4STAT_BAD_CMD, /* 0x58 */ + L4STAT_BAD_CMD, /* 0x59 */ + L4STAT_BAD_CMD, /* 0x5a */ + L4STAT_BAD_CMD, /* 0x5b */ + L4STAT_BAD_CMD, /* 0x5c */ + L4STAT_BAD_CMD, /* 0x5d */ + L4STAT_BAD_CMD, /* 0x5e */ + L4STAT_BAD_CMD, /* 0x5f */ + "external event 0", /* 0x60 */ + "external event 1", /* 0x61 */ + "external event 2", /* 0x62 */ + "external event 3", /* 0x63 */ + "external event 4", /* 0x64 */ + "external event 5", /* 0x65 */ + "external event 6", /* 0x66 */ + "external event 7", /* 0x67 */ + "external event 8", /* 0x68 */ + "external event 9", /* 0x69 */ + "external event 10", /* 0x6A */ + "external event 11", /* 0x6B */ + "external event 12", /* 0x6C */ + "external event 13", /* 0x6D */ + "external event 14", /* 0x6E */ + "external event 15", /* 0x6F */ + "AHB IDLE cycles (2)", /* 0x70 */ + "AHB BUSY cycles (2)", /* 0x71 */ + "AHB Non-Seq. transfers (2)", /* 0x72 */ + "AHB Seq. transfers (2)", /* 0x73 */ + "AHB read accesses (2)", /* 0x74 */ + "AHB write accesses (2)", /* 0x75 */ + "AHB byte accesses (2)", /* 0x76 */ + "AHB half-word accesses (2)", /* 0x77 */ + "AHB word accesses (2)", /* 0x78 */ + "AHB double word accesses (2)", /* 0x79 */ + "AHB quad word accesses (2)", /* 0x7A */ + "AHB eight word accesses (2)", /* 0x7B */ + "AHB waitstates (2)", /* 0x7C */ + "AHB RETRY responses (2)", /* 0x7D */ + "AHB SPLIT responses (2)", /* 0x7E */ + "AHB SPLIT delay (2)", /* 0x7F */ + "PMC: master 0 has grant", /* 0x80 */ + "PMC: master 1 has grant", /* 0x81 */ + "PMC: master 2 has grant", /* 0x82 */ + "PMC: master 3 has grant", /* 0x83 */ + "PMC: master 4 has grant", /* 0x84 */ + "PMC: master 5 has grant", /* 0x85 */ + "PMC: master 6 has grant", /* 0x86 */ + "PMC: master 7 has grant", /* 0x87 */ + "PMC: master 8 has grant", /* 0x88 */ + "PMC: master 9 has grant", /* 0x89 */ + "PMC: master 10 has grant", /* 0x8A */ + "PMC: master 11 has grant", /* 0x8B */ + "PMC: master 12 has grant", /* 0x8C */ + "PMC: master 13 has grant", /* 0x8D */ + "PMC: master 14 has grant", /* 0x8E */ + "PMC: master 15 has grant", /* 0x8F */ + "PMC: master 0 lacks grant", /* 0x90 */ + "PMC: master 1 lacks grant", /* 0x91 */ + "PMC: master 2 lacks grant", /* 0x92 */ + "PMC: master 3 lacks grant", /* 0x93 */ + "PMC: master 4 lacks grant", /* 0x94 */ + "PMC: master 5 lacks grant", /* 0x95 */ + "PMC: master 6 lacks grant", /* 0x96 */ + "PMC: master 7 lacks grant", /* 0x97 */ + "PMC: master 8 lacks grant", /* 0x98 */ + "PMC: master 9 lacks grant", /* 0x99 */ + "PMC: master 10 lacks grant", /* 0x9A */ + "PMC: master 11 lacks grant", /* 0x9B */ + "PMC: master 12 lacks grant", /* 0x9C */ + "PMC: master 13 lacks grant", /* 0x9D */ + "PMC: master 14 lacks grant", /* 0x9E */ + "PMC: master 15 lacks grant", /* 0x9F */ + ""}; + +/*------------------------------------------------ Useful Macros ------------*/ + +/** + * Stores which counters did overflow in the given buffer (?). + */ +#define HARDWARE_COUNTERS_OVERFLOW(nc, counters, no, counters_ovf, values_ptr) \ + { \ + int found, cc, co; \ + \ + for (cc = 0; cc < nc; cc++) \ + { \ + for (co = 0, found = 0; co < no; co++) \ + found |= counters[cc] == counters_ovf[co]; \ + if (found) \ + values_ptr[cc] = (long long)(SAMPLE_COUNTER); \ + else \ + values_ptr[cc] = (long long)(NO_COUNTER); \ + } \ + for (cc = nc; cc < MAX_HWC; cc++) \ + values_ptr[cc] = (long long)(NO_COUNTER); \ + } + +/** + * Returns the EventSet of the given thread for the current set. + */ + +#endif /* __PAPI_HWC_H__ */ diff --git a/src/tracer/sampling/timer/sampling-timer.c b/src/tracer/sampling/timer/sampling-timer.c index 8472e0b1..68b1d2f8 100644 --- a/src/tracer/sampling/timer/sampling-timer.c +++ b/src/tracer/sampling/timer/sampling-timer.c @@ -54,6 +54,8 @@ #include "threadid.h" #include "wrapper.h" +#if !defined(OS_RTEMS) + #if defined(SAMPLING_SUPPORT) int SamplingSupport = FALSE; static int SamplingRunning = FALSE; @@ -335,3 +337,49 @@ void unsetTimeSampling (void) SamplingRunning = FALSE; } } +#else +#include /* for device driver prototypes */ +#include + +rtems_id sampling_timer; +int sampling_period; + +void sample() +{ + Backend_setInSampling(THREADID, TRUE); + for (unsigned int thread_id = 0; thread_id < Extrae_get_num_threads(); thread_id++) + { + event_t evt; + evt.time = TIME; + evt.event = SAMPLING_EV; + evt.value = 1; +#if defined (PAPI_COUNTERS) + HARDWARE_COUNTERS_READ_SAMPLING(thread_id, evt, TRUE); +#endif + BUFFER_INSERT(thread_id, SAMPLING_BUFFER(thread_id), evt); + } + Backend_setInSampling(THREADID, FALSE); +} + +rtems_timer_service_routine hwc_sampling( + rtems_id timer, + void *arg) +{ + sample(); + rtems_timer_fire_after(timer, sampling_period, hwc_sampling, NULL); +} + +void setTimeSampling (int sampling_p) +{ + sampling_period=sampling_p; + rtems_timer_create(1, &sampling_timer); + rtems_timer_fire_after(sampling_timer, sampling_period, hwc_sampling, NULL); +} + +void unsetTimeSampling (void) +{ + rtems_timer_cancel(sampling_timer); +} +void setTimeSampling_postfork (void){}; +#endif + diff --git a/src/tracer/sampling/timer/sampling-timer.h b/src/tracer/sampling/timer/sampling-timer.h index e7d51a89..80e89059 100644 --- a/src/tracer/sampling/timer/sampling-timer.h +++ b/src/tracer/sampling/timer/sampling-timer.h @@ -24,6 +24,7 @@ #ifndef _SAMPLING_H_INCLUDED_ #define _SAMPLING_H_INCLUDED_ +#if !defined(OS_RTEMS) enum { SAMPLING_TIMING_REAL, @@ -37,6 +38,10 @@ void setTimeSampling_postfork (void); void Extrae_SamplingHandler (void* address); void Extrae_SamplingHandler_PAPI (void *address); +void unsetTimeSampling (void); +#else +void setTimeSampling (int sampling_p); void unsetTimeSampling (void); #endif +#endif diff --git a/src/tracer/trace_hwc.h b/src/tracer/trace_hwc.h index 142bb139..bee5e8db 100644 --- a/src/tracer/trace_hwc.h +++ b/src/tracer/trace_hwc.h @@ -50,6 +50,20 @@ MARK_SET_READ(tid, evt, read_ok); \ } +/* Store counters values in the event and mark them as read */ +#if defined(OS_RTEMS) +# define HARDWARE_COUNTERS_READ_SAMPLING(tid, evt, filter) \ +{ \ + int read_ok = FALSE; \ + if (filter && HWC_IsEnabled()) \ + { \ + read_ok = HWC_Read_Sampling (tid, evt.time, evt.HWCValues); \ + } \ + /* We write the counters even if there are errors while reading */ \ + MARK_SET_READ(tid, evt, read_ok); \ +} +#endif + # define HARDWARE_COUNTERS_ACCUMULATE(tid, evt, filter) \ { \ if (filter && HWC_IsEnabled()) \ diff --git a/src/tracer/wrappers/API/buffers.c b/src/tracer/wrappers/API/buffers.c index f59b8b36..e86621ab 100644 --- a/src/tracer/wrappers/API/buffers.c +++ b/src/tracer/wrappers/API/buffers.c @@ -489,7 +489,7 @@ int Buffer_Flush(Buffer_t *buffer) DataBlocks_t *db = new_DataBlocks (buffer); event_t *head = NULL, *tail = NULL; int num_flushed, overflow; -#if defined(ARCH_SPARC64) +#if defined(ARCH_SPARC64) || defined(OS_RTEMS) ssize_t r; #endif @@ -503,7 +503,7 @@ int Buffer_Flush(Buffer_t *buffer) num_flushed = Buffer_GetFillCount(buffer); CIRCULAR_STEP (tail, num_flushed, buffer->FirstEvt, buffer->LastEvt, &overflow); -#if !defined(ARCH_SPARC64) +#if !defined(ARCH_SPARC64) && !defined(OS_RTEMS) # if defined(HAVE_ONLINE) /* Select events depending on the mask */ @@ -525,11 +525,30 @@ int Buffer_Flush(Buffer_t *buffer) DataBlocks_Free(db); #else /* ARCH_SPARC64 */ - - r = write (buffer->fd, head, buffer->FillCount*sizeof(event_t)); - if (r != buffer->FillCount*sizeof(event_t)) + #if !defined(OS_RTEMS) /* ARCH_SPARC64 */ + r = write (buffer->fd, head, buffer->FillCount*sizeof(event_t)); + if (r != buffer->FillCount*sizeof(event_t)) fprintf (stderr, "ERROR! Wrote %ld bytes instead of %ld bytes\n", r, buffer->FillCount*sizeof(event_t)); - + #else /* OS_RTEMS */ + /* NFS V2 has a maximun of 8192 bytes of burst write + * To avoid errors we write on the file per parts + * sizeof(event_t)=112 + * 60*112=6720 bytes write per iteration + * */ + int lines2Write=buffer->FillCount; + int iterationWrite=(lines2Write<60)? lines2Write : 60; + while (lines2Write>0){ + + r = write (buffer->fd, head, iterationWrite*sizeof(event_t)); + if (r != iterationWrite*sizeof(event_t)) + fprintf (stderr, "ERROR! Wrote %ld bytes instead of %ld bytes\n", r, buffer->FillCount*sizeof(event_t)); + + lines2Write-=iterationWrite; + head+=iterationWrite; + + iterationWrite=(lines2Writecurrent_helper = 0; + __GOMP_helpers->max_helpers = num_helpers; + __GOMP_helpers->queue = (struct parallel_helper_t *)malloc(sizeof(struct parallel_helper_t) * num_helpers); + if (__GOMP_helpers->queue == NULL) + { + fprintf (stderr, PACKAGE_NAME": ERROR! Invalid initialization of '__GOMP_helpers->queue' (%d helpers)\n", num_helpers); + exit(-1); + } + } + + pthread_mutex_unlock(&__GOMP_helpers_mtx); +} + + +/** + * __GOMP_new_helper + * + * Registers a new data helper in the __GOMP_helpers queue. When we run out of + * helpers, we start reusing. As long as the corresponding parallel region already + * finished, there will be no problems. But if that parallel region is still + * active, we'll be corrupting the pointers to fn and data. A warning is shown + * the first time the helpers are reused, and if the application is corrupted, + * we need to increase the number of helpers setting EXTRAE_OPENMP_HELPERS. + * + * @param fn The pointer to the real outlined function or task. + * @param data The pointer to the data passed to the real routine. + * + * @return The pointer to the queue slot where the data helper is stored. + */ +void *__GOMP_new_helper(void (*fn)(void *), void *data) +{ + int idx = 0; + void *helper_ptr = NULL; + static int warning_displayed = 0; + + pthread_mutex_lock(&__GOMP_helpers_mtx); + + /* Pick a slot in the queue */ + idx = __GOMP_helpers->current_helper; + __GOMP_helpers->current_helper = (__GOMP_helpers->current_helper + 1) % __GOMP_helpers->max_helpers; + + pthread_mutex_unlock(&__GOMP_helpers_mtx); + + /* Save the pointers to fn and data */ + __GOMP_helpers->queue[idx].fn = fn; + __GOMP_helpers->queue[idx].data = data; + + /* Return the pointer to the slot for this data helper */ + helper_ptr = &(__GOMP_helpers->queue[idx]); + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "__GOMP_new_helper: Registering helper #%d helper_ptr=%p fn=%p data=%p\n", THREAD_LEVEL_VAR, idx, helper_ptr, fn, data); +#endif + + if (__GOMP_helpers->current_helper < idx) + { + /* + * Display a warning (once) when we start reusing queue slots for helpers. + * Could appear more than once in the event that two concurrent threads + * evaluate warning_displayed simultaneously, but this is extremely + * unlikely and it's better not to use a mutex here to minimize overhead. + */ + if (!warning_displayed) + { + fprintf (stderr, PACKAGE_NAME": WARNING! I have run out of allocations for data helpers. If the application starts crashing or producing wrong results, please try increasing %s over %d until this warning disappears\n", ENV_VAR_EXTRAE_OPENMP_HELPERS, __GOMP_helpers->max_helpers); + warning_displayed = 1; + } + } + + return helper_ptr; +} + +/* + * When we enter a GOMP_parallel we have to store the par_uf later used in the + * loop and loop_ordered calls after opening parallelism (current level + 1). + * FIXME: This doesn't support nested because multiple threads can open a 2nd + * level of parallelism, and they would all overwrite the same position of the + * array as they're all in the same nesting level. Can we index by thread id? + * Previously, this was just a global variable. + */ +static void * __GOMP_parallel_uf[MAX_NESTING_LEVEL]; + +void SAVE_PARALLEL_UF(void *par_uf) +{ + int level = omp_get_level(); + CHECK_NESTING_LEVEL(level); + __GOMP_parallel_uf[level] = par_uf; +} + +void * RETRIEVE_PARALLEL_UF() +{ + int level = omp_get_level(); + CHECK_NESTING_LEVEL(level-1); + return __GOMP_parallel_uf[level-1]; +} + +/* + * Counter to enumerate tasks executed from GOMP_task + */ +static volatile long long __GOMP_task_ctr = 1; +#if !defined(HAVE__SYNC_FETCH_AND_ADD) +static pthread_mutex_t __GOMP_task_ctr_mtx = PTHREAD_MUTEX_INITIALIZER; +#endif + +/* + * Counter to enumerate tasks executed from GOMP_taskloop + */ +static volatile long long __GOMP_taskloop_ctr = 1; +#if !defined(HAVE__SYNC_FETCH_AND_ADD) +static pthread_mutex_t __GOMP_taskloop_ctr_mtx = PTHREAD_MUTEX_INITIALIZER; +#endif + +typedef struct tracked_taskloop_helper_t tracked_taskloop_helper_t; + +struct tracked_taskloop_helper_t +{ + void *taskloop_helper_ptr; + tracked_taskloop_helper_t *next; + +}; + +tracked_taskloop_helper_t *tracked_taskloop_helpers = NULL; +pthread_mutex_t mtx_taskloop_helpers = PTHREAD_MUTEX_INITIALIZER; + +void *taskloop_global_fn = NULL; +void *taskloop_global_data = NULL; + + +/* + * Instrumentation of doacross is split in several routines. In the *_start + * routines (e.g. GOMP_loop_doacross_static_start) we need to save the parameter + * 'ncounts', which is later needed in the routine GOMP_doacross_wait. Since the + * latter does not receive any parameter that we can replace with a data helper, + * what we do is to store ncounts in the thread TLS. This can be done because + * all threads execute the *_start routine. This parameter is saved per nesting + * level, to support nowait clauses and nested parallelism. + */ +static __thread unsigned __GOMP_doacross_ncounts[MAX_NESTING_LEVEL]; + +/** + * SAVE_DOACROSS_NCOUNTS + * + * Save the ncounts parameter from the doacross *_start routine in the thread + * TLS to be retrieved later in GOMP_doacross_wait. This is stored in an array + * indexed per current nesting level, in order to allow nowait clauses and + * nested loops. + * + * @param ncounts The parameter to save in the TLS + */ +void SAVE_DOACROSS_NCOUNTS(unsigned ncounts) +{ + int level = omp_get_level(); + CHECK_NESTING_LEVEL(level); + __GOMP_doacross_ncounts[level] = ncounts; +} + +/** + * RETRIEVE_DOACROSS_NCOUNTS + * + * Retrieve the ncounts parameter from the thread TLS (previously stored in the + * GOMP_loop_doacross_*_start function). This is stored in an array indexed per + * current nesting level, in order to allow nowait clauses and nested loops. + * + * @return the ncounts parameter previously saved in the TLS. + */ +unsigned RETRIEVE_DOACROSS_NCOUNTS() +{ + int level = omp_get_level(); + CHECK_NESTING_LEVEL(level); + return __GOMP_doacross_ncounts[level]; +} + + +/******************************************************************************\ + * * + * CALLBACKS * + * * + ****************************************************************************** + * The following callme_* routines replace the real outlined functions and * + * tasks, so that when the runtime would actually execute the task, it runs * + * our function instead where we emit events that mark when the task is * + * executed. From these functions we retrieve the pointer to the original * + * routine from the various data helpers, and invoke it. * +\******************************************************************************/ + +static void callme_parsections (void *parsections_helper_ptr) +{ + struct parallel_helper_t *parsections_helper = parsections_helper_ptr; + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_parsections enter: parsections_helper=%p fn=%p data=%p\n", THREAD_LEVEL_VAR, parsections_helper, parsections_helper->fn, parsections_helper->data); +#endif + + if ((parsections_helper == NULL) || (parsections_helper->fn == NULL)) + { + fprintf (stderr, PACKAGE_NAME": ERROR! Invalid initialization of 'parsections_helper'\n"); + exit (-1); + } + + Extrae_OpenMP_UF_Entry (parsections_helper->fn); + Backend_setInInstrumentation (THREADID, FALSE); /* We're about to execute user code */ + parsections_helper->fn (parsections_helper->data); + Backend_setInInstrumentation (THREADID, TRUE); /* We're about to execute OpenMP code */ + Extrae_OpenMP_UF_Exit (); +} + +static void callme_pardo (void *pardo_helper_ptr) +{ + struct parallel_helper_t *pardo_helper = pardo_helper_ptr; + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_pardo enter: pardo_helper=%p fn=%p data=%p\n", THREAD_LEVEL_VAR, pardo_helper, pardo_helper->fn, pardo_helper->data); +#endif + + if ((pardo_helper == NULL) || (pardo_helper->fn == NULL)) + { + fprintf (stderr, PACKAGE_NAME": ERROR! Invalid initialization of 'pardo_helper'\n"); + exit (-1); + } + + Extrae_OpenMP_DO_Entry (); + Extrae_OpenMP_UF_Entry (pardo_helper->fn); + Backend_setInInstrumentation (THREADID, FALSE); /* We're about to execute user code */ + pardo_helper->fn (pardo_helper->data); + Backend_setInInstrumentation (THREADID, TRUE); /* We're about to execute OpenMP code */ + Extrae_OpenMP_UF_Exit (); +} + +static void callme_par (void *par_helper_ptr) +{ + struct parallel_helper_t *par_helper = par_helper_ptr; + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_par enter: par_helper=%p fn=%p data=%p\n", THREAD_LEVEL_VAR, par_helper, par_helper->fn, par_helper->data); +#endif + + if ((par_helper == NULL) || (par_helper->fn == NULL)) + { + fprintf (stderr, PACKAGE_NAME": ERROR! Invalid initialization of 'par_helper'\n"); + exit (-1); + } + + Extrae_OpenMP_UF_Entry (par_helper->fn); + Backend_setInInstrumentation (THREADID, FALSE); /* We're about to execute user code */ + par_helper->fn (par_helper->data); + Backend_setInInstrumentation (THREADID, TRUE); /* We're back to execute OpenMP code */ + Extrae_OpenMP_UF_Exit (); + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_par ends\n", THREAD_LEVEL_VAR); +#endif + +} + +static void callme_task (void *task_helper_ptr) +{ + struct task_helper_t *task_helper = *(struct task_helper_t **)task_helper_ptr; + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_task enter: task_helper_ptr=%p\n", THREAD_LEVEL_VAR, task_helper_ptr); +#endif + + if (task_helper != NULL) + { + Extrae_OpenMP_TaskUF_Entry (task_helper->fn); + Extrae_OpenMP_TaskID (task_helper->counter); + + task_helper->fn (task_helper->data); + if (task_helper->buf != NULL) + free(task_helper->buf); + free(task_helper); + + Extrae_OpenMP_Notify_NewExecutedTask(); + Extrae_OpenMP_TaskUF_Exit (); + } +} + +static void callme_taskloop (void (*fn)(void *), void *data) +{ +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop enter: fn=%p data=%p data[0]=%ld data[1]=%ld\n", THREAD_LEVEL_VAR, fn, data, *((long *)data), *((long *)(data+sizeof(long)))); +#endif + +#if defined(HAVE__SYNC_FETCH_AND_ADD) + long long taskloop_ctr = __sync_fetch_and_add(&__GOMP_taskloop_ctr, 1); +#else + pthread_mutex_lock (&__GOMP_taskloop_ctr_mtx); + long long taskloop_ctr = __GOMP_taskloop_ctr++; + pthread_mutex_unlock (&__GOMP_taskloop_ctr_mtx); +#endif + + Extrae_OpenMP_TaskUF_Entry (fn); + Extrae_OpenMP_TaskLoopID (taskloop_ctr); + + fn(data); + + Extrae_OpenMP_Notify_NewExecutedTask(); + Extrae_OpenMP_TaskUF_Exit (); +} + +/* + * This callback is invoked when taskloop doesn't use copy function. Then the + * data helper is prefixed to the argument data in the GOMP_taskloop wrapper. + * + * taskloop_helper \ data \ + * -------------------------------------------- + * | cpyfn? | *fn | long start | long end | + * -------------------------------------------- + */ +static void callme_taskloop_prefix_helper (void *data) +{ + /* Look for the data argument in our tracked list, if we don't find it, that means + * that the runtime did an internal copy of data and our prefixed pointers + * are gone, so we use a fallback mechanism using a global pointer that stores the + * original function and data (this only allows 1 simultaneous taskloop) + */ + pthread_mutex_lock (&mtx_taskloop_helpers); + tracked_taskloop_helper_t *current_tracked_taskloop_helper = tracked_taskloop_helpers; + int found = 0; + while ((current_tracked_taskloop_helper != NULL) && (!found)) + { + if (current_tracked_taskloop_helper->taskloop_helper_ptr == data) + { + found = 1; + } + current_tracked_taskloop_helper = current_tracked_taskloop_helper->next; + } + pthread_mutex_unlock (&mtx_taskloop_helpers); + + if (!found) + { +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop_prefix_helper: Using fallback global pointers taskloop_global_fn=%p taskloop_global_data=%p\n", THREAD_LEVEL_VAR, taskloop_global_fn, taskloop_global_data); +#endif + callme_taskloop(taskloop_global_fn, taskloop_global_data); + } + else + { + /* Retrieve the data helper */ + void *taskloop_helper = data - sizeof(void *); + void (*fn)(void *) = *(void **)(taskloop_helper); + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop_prefix_helper: Using injected pointers fn=%p data=%p\n", THREAD_LEVEL_VAR, fn, data); +#endif + callme_taskloop(fn, data); + } +} + +/* + * This callback is invoked when taskloop uses copy function. Then the data + * helper is suffixed to the argument data in the callme_taskloop_cpyfn callback. + * + * data \ taskloop_helper \ + * --------------------------------- + * | long start | long end | *fn ... + * --------------------------------- + */ +static void callme_taskloop_suffix_helper (void *data) +{ + /* Look for the data argument in our tracked list, if we don't find it, that means + * that the runtime did an internal copy of data and our suffixed pointers + * are gone, so we use a fallback mechanism using a global pointer that stores the + * original function and data (this only allows 1 simultaneous taskloop) + */ + pthread_mutex_lock (&mtx_taskloop_helpers); + tracked_taskloop_helper_t *current_tracked_taskloop_helper = tracked_taskloop_helpers; + int found = 0; + while ((current_tracked_taskloop_helper != NULL) && (!found)) + { + if (current_tracked_taskloop_helper->taskloop_helper_ptr == data) + { + found = 1; + } + current_tracked_taskloop_helper = current_tracked_taskloop_helper->next; + } + pthread_mutex_unlock (&mtx_taskloop_helpers); + + if (!found) + { +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop_suffix_helper: Using fallback global pointers taskloop_global_fn=%p taskloop_global_data=%p\n", THREAD_LEVEL_VAR, taskloop_global_fn, taskloop_global_data); +#endif + callme_taskloop(taskloop_global_fn, taskloop_global_data); + } + else + { + /* Retrieve the data helper */ + void *taskloop_helper = data + (2 * sizeof(long)); + void (*fn)(void *) = *(void **)(taskloop_helper); + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop_suffix_helper: Using injected pointers fn=%p data=%p\n", THREAD_LEVEL_VAR, fn, data); +#endif + callme_taskloop(fn, data); + } +} + +/* + * This callback is invoked when taskloop uses copy function. The data helper + * is prefixed to the argument data in the GOMP_taskloop wrapper. The helper is + * copied from data to arg by suffixing it (see GOMP_taskloop wrapper), after + * the real copy takes place. + * + * taskloop_helper ↴ data ↴ + * ---------------------------------------- + * | *cpyfn | *fn | long start | long end | + * ---------------------------------------- + * + * arg ↴ arg+(2*sizeof(long)) ↴ arg+arg_size ↴ + * --------------------------------------------------------------------------- + * | long start | long end | *fn | ... | long start | long end | *fn | ... + * --------------------------------------------------------------------------- + */ +void callme_taskloop_cpyfn(void *arg, void *data) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop_cpyfn enter: arg=%p data=%p\n", THREAD_LEVEL_VAR, arg, data); +#endif + + /* Retrieve the data helper */ + void *taskloop_helper = data - sizeof(void *) - sizeof(void *); + void (*cpyfn)(void *, void*) = *((void **)(taskloop_helper)); + void (*fn)(void *) = *((void **)(taskloop_helper+sizeof(void *))); + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop_cpyfn: taskloop_helper=%p cpyfn=%p fn=%p\n", THREAD_LEVEL_VAR, taskloop_helper, cpyfn, fn); +#endif + + /* Real copy function */ + cpyfn(arg, data); + + /* Save the pointer to the real fn in arg, after the 2 longs that mark the + * start/end iterations + */ + *(void **)(arg+(2 * sizeof(long))) = fn; +} + + +/******************************************************************************\ + * * + * WRAPPERS * + * * +\******************************************************************************/ + +/**************************************************************/ +/***** Added (or changed) in OpenMP 3.1 or prior versions *****/ +/**************************************************************/ + +void __wrap_GOMP_atomic_start (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_atomic_start_real); +#endif + + RECHECK_INIT(GOMP_atomic_start_real); + + if (TRACE(GOMP_atomic_start_real)) + { + Extrae_OpenMP_Unnamed_Lock_Entry(); + GOMP_atomic_start_real(); + Extrae_OpenMP_Unnamed_Lock_Exit(); + } + else if (GOMP_atomic_start_real != NULL) + { + GOMP_atomic_start_real(); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_start exit\n", THREAD_LEVEL_VAR); +#endif +} + +void __wrap_GOMP_atomic_end (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_atomic_end_real); +#endif + + RECHECK_INIT(GOMP_atomic_end_real); + + if (TRACE(GOMP_atomic_end_real)) + { + Extrae_OpenMP_Unnamed_Unlock_Entry(); + GOMP_atomic_end_real (); + Extrae_OpenMP_Unnamed_Unlock_Exit(); + } + else if (GOMP_atomic_end_real != NULL) + { + GOMP_atomic_end_real (); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_end: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_end exit\n", THREAD_LEVEL_VAR); +#endif +} + +void __wrap_GOMP_barrier (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_barrier enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_barrier_real); +#endif + + RECHECK_INIT(GOMP_barrier_real); + + if (TRACE(GOMP_barrier_real)) + { + Extrae_OpenMP_Barrier_Entry (); + GOMP_barrier_real (); + Extrae_OpenMP_Barrier_Exit (); + } + else if (GOMP_barrier_real != NULL) + { + GOMP_barrier_real (); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_barrier: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_barrier exit\n", THREAD_LEVEL_VAR); +#endif +} + +void __wrap_GOMP_critical_start (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_critical_start_real); +#endif + + RECHECK_INIT(GOMP_critical_start_real); + + if (TRACE(GOMP_critical_start_real)) + { + Extrae_OpenMP_Unnamed_Lock_Entry(); + GOMP_critical_start_real(); + Extrae_OpenMP_Unnamed_Lock_Exit(); + } + else if (GOMP_critical_start_real != NULL) + { + GOMP_critical_start_real(); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_start exit\n", THREAD_LEVEL_VAR); +#endif +} + +void __wrap_GOMP_critical_end (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_critical_end_real); +#endif + + RECHECK_INIT(GOMP_critical_end_real); + + if (TRACE(GOMP_critical_end_real)) + { + Extrae_OpenMP_Unnamed_Unlock_Entry(); + GOMP_critical_end_real (); + Extrae_OpenMP_Unnamed_Unlock_Exit(); + } + else if (GOMP_critical_end_real != NULL) + { + GOMP_critical_end_real (); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_end: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_end exit\n", THREAD_LEVEL_VAR); +#endif +} + +void __wrap_GOMP_critical_name_start (void **pptr) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_start enter: @=%p args=(%p)\n", THREAD_LEVEL_VAR, GOMP_critical_name_start_real, pptr); +#endif + + RECHECK_INIT(GOMP_critical_name_start_real); + + if (TRACE(GOMP_critical_name_start_real)) + { + Extrae_OpenMP_Named_Lock_Entry(); + GOMP_critical_name_start_real (pptr); + Extrae_OpenMP_Named_Lock_Exit(pptr); + } + else if (GOMP_critical_name_start_real != NULL) + { + GOMP_critical_name_start_real (pptr); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_start exit\n", THREAD_LEVEL_VAR); +#endif +} + +void __wrap_GOMP_critical_name_end (void **pptr) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_end enter: @=%p args=(%p)\n", THREAD_LEVEL_VAR, GOMP_critical_name_end_real, pptr); +#endif + + RECHECK_INIT(GOMP_critical_name_end_real); + + if (TRACE(GOMP_critical_name_end_real)) + { + Extrae_OpenMP_Named_Unlock_Entry(pptr); + GOMP_critical_name_end_real (pptr); + Extrae_OpenMP_Named_Unlock_Exit(); + } + else if (GOMP_critical_name_end_real != NULL) + { + GOMP_critical_name_end_real (pptr); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_end: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_end exit\n", THREAD_LEVEL_VAR); +#endif +} + +int __wrap_GOMP_loop_static_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +{ + int res = 0; + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_static_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_static_start_real, start, end, incr, chunk_size, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_static_start_real); + + if (TRACE(GOMP_loop_static_start_real)) + { + Extrae_OpenMP_DO_Entry (); + res = GOMP_loop_static_start_real (start, end, incr, chunk_size, istart, iend); + Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); + Backend_Leave_Instrumentation(); + } + else if (GOMP_loop_static_start_real != NULL) + { + res = GOMP_loop_static_start_real (start, end, incr, chunk_size, istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_static_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_static_start exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_dynamic_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_dynamic_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_dynamic_start_real, start, end, incr, chunk_size, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_dynamic_start_real); + + if (TRACE(GOMP_loop_dynamic_start_real)) + { + Extrae_OpenMP_DO_Entry (); + res = GOMP_loop_dynamic_start_real (start, end, incr, chunk_size, istart, iend); + Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); + Backend_Leave_Instrumentation(); + } + else if (GOMP_loop_dynamic_start_real != NULL) + { + res = GOMP_loop_dynamic_start_real (start, end, incr, chunk_size, istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_dynamic_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_dynamic_start exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_guided_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_guided_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_guided_start_real, start, end, incr, chunk_size, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_guided_start_real); + + if (TRACE(GOMP_loop_guided_start_real)) + { + Extrae_OpenMP_DO_Entry (); + res = GOMP_loop_guided_start_real (start, end, incr, chunk_size, istart, iend); + Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); + Backend_Leave_Instrumentation(); + } + else if (GOMP_loop_guided_start_real != NULL) + { + res = GOMP_loop_guided_start_real (start, end, incr, chunk_size, istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_guided_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_guided_start exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_runtime_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_runtime_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_runtime_start_real, start, end, incr, chunk_size, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_runtime_start_real); + + if (TRACE(GOMP_loop_runtime_start_real)) + { + Extrae_OpenMP_DO_Entry (); + res = GOMP_loop_runtime_start_real (start, end, incr, chunk_size, istart, iend); + Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); + Backend_Leave_Instrumentation(); + } + else if (GOMP_loop_runtime_start_real != NULL) + { + res = GOMP_loop_runtime_start_real (start, end, incr, chunk_size, istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_runtime_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_runtime_start exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_static_next (long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_static_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_static_next_real, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_static_next_real); + + if (TRACE(GOMP_loop_static_next_real)) + { + Extrae_OpenMP_Work_Entry(); + res = GOMP_loop_static_next_real (istart, iend); + Extrae_OpenMP_Work_Exit(); + } + else if (GOMP_loop_static_next_real != NULL) + { + res = GOMP_loop_static_next_real (istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_static_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_static_next exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_dynamic_next (long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_dynamic_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_dynamic_next_real, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_dynamic_next_real); + + if (TRACE(GOMP_loop_dynamic_next_real)) + { + Extrae_OpenMP_Work_Entry(); + res = GOMP_loop_dynamic_next_real (istart, iend); + Extrae_OpenMP_Work_Exit(); + } + else if (GOMP_loop_dynamic_next_real != NULL) + { + res = GOMP_loop_dynamic_next_real (istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_dynamic_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_dynamic_next exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_guided_next (long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_guided_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_guided_next_real, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_guided_next_real); + + if (TRACE(GOMP_loop_guided_next_real)) + { + Extrae_OpenMP_Work_Entry(); + res = GOMP_loop_guided_next_real (istart, iend); + Extrae_OpenMP_Work_Exit(); + } + else if (GOMP_loop_guided_next_real != NULL) + { + res = GOMP_loop_guided_next_real (istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_guided_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_guided_next exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + + +int __wrap_GOMP_loop_runtime_next (long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_runtime_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_runtime_next_real, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_runtime_next_real); + + if (TRACE(GOMP_loop_runtime_next_real)) + { + Extrae_OpenMP_Work_Entry(); + res = GOMP_loop_runtime_next_real (istart, iend); + Extrae_OpenMP_Work_Exit(); + } + else if (GOMP_loop_runtime_next_real != NULL) + { + res = GOMP_loop_runtime_next_real (istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_runtime_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_runtime_next exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_ordered_static_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_static_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_static_start_real, start, end, incr, chunk_size, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_ordered_static_start_real); + + if (TRACE(GOMP_loop_ordered_static_start_real)) + { + Extrae_OpenMP_DO_Entry (); + res = GOMP_loop_ordered_static_start_real (start, end, incr, chunk_size, istart, iend); + Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); + } + else if (GOMP_loop_ordered_static_start_real != NULL) + { + res = GOMP_loop_ordered_static_start_real (start, end, incr, chunk_size, istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_static_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_static_start exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_ordered_dynamic_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_dynamic_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_dynamic_start_real, start, end, incr, chunk_size, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_ordered_dynamic_start_real); + + if (TRACE(GOMP_loop_ordered_dynamic_start_real)) + { + Extrae_OpenMP_DO_Entry (); + res = GOMP_loop_ordered_dynamic_start_real (start, end, incr, chunk_size, istart, iend); + Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); + } + else if (GOMP_loop_ordered_dynamic_start_real != NULL) + { + res = GOMP_loop_ordered_dynamic_start_real (start, end, incr, chunk_size, istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_dynamic_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_dynamic_start exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_ordered_guided_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_guided_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_guided_start_real, start, end, incr, chunk_size, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_ordered_guided_start_real); + + if (TRACE(GOMP_loop_ordered_guided_start_real)) + { + Extrae_OpenMP_DO_Entry (); + res = GOMP_loop_ordered_guided_start_real (start, end, incr, chunk_size, istart, iend); + Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); + } + else if (GOMP_loop_ordered_guided_start_real != NULL) + { + res = GOMP_loop_ordered_guided_start_real (start, end, incr, chunk_size, istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_guided_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_guided_start exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_ordered_runtime_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_runtime_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_runtime_start_real, start, end, incr, chunk_size, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_ordered_runtime_start_real); + + if (TRACE(GOMP_loop_ordered_runtime_start_real)) + { + Extrae_OpenMP_DO_Entry (); + res = GOMP_loop_ordered_runtime_start_real (start, end, incr, chunk_size, istart, iend); + Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); + } + else if (GOMP_loop_ordered_runtime_start_real != NULL) + { + res = GOMP_loop_ordered_runtime_start_real (start, end, incr, chunk_size, istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_runtime_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_runtime_start exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + + +int __wrap_GOMP_loop_ordered_static_next (long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_static_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_static_next_real, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_ordered_static_next_real); + + if (TRACE(GOMP_loop_ordered_static_next_real)) + { + Extrae_OpenMP_Work_Entry(); + res = GOMP_loop_ordered_static_next_real (istart, iend); + Extrae_OpenMP_Work_Exit(); + } + else if (GOMP_loop_ordered_static_next_real != NULL) + { + res = GOMP_loop_ordered_static_next_real (istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_static_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_static_next exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_ordered_dynamic_next (long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_dynamic_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_dynamic_next_real, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_ordered_dynamic_next_real); + + if (TRACE(GOMP_loop_ordered_dynamic_next_real)) + { + Extrae_OpenMP_Work_Entry(); + res = GOMP_loop_ordered_dynamic_next_real (istart, iend); + Extrae_OpenMP_Work_Exit(); + } + else if (GOMP_loop_ordered_dynamic_next_real != NULL) + { + res = GOMP_loop_ordered_dynamic_next_real (istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_dynamic_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_dynamic_next exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_ordered_guided_next (long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_guided_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_guided_next_real, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_ordered_guided_next_real); + + if (TRACE(GOMP_loop_ordered_guided_next_real)) + { + Extrae_OpenMP_Work_Entry(); + res = GOMP_loop_ordered_guided_next_real (istart, iend); + Extrae_OpenMP_Work_Exit(); + } + else if (GOMP_loop_ordered_guided_next_real != NULL) + { + res = GOMP_loop_ordered_guided_next_real (istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_guided_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_guided_next exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_ordered_runtime_next (long *istart, long *iend) +{ + int res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_runtime_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_runtime_next_real, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_ordered_runtime_next_real); + + if (TRACE(GOMP_loop_ordered_runtime_next_real)) + { + Extrae_OpenMP_Work_Entry(); + res = GOMP_loop_ordered_runtime_next_real (istart, iend); + Extrae_OpenMP_Work_Exit(); + } + else if (GOMP_loop_ordered_runtime_next_real != NULL) + { + res = GOMP_loop_ordered_runtime_next_real (istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_runtime_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_runtime_next exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +void +__wrap_GOMP_parallel_loop_static_start(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size) +{ +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_static_start enter: @=%p args=(%p %p %u %ld %ld %ld %ld)\n", + THREAD_LEVEL_VAR, GOMP_parallel_loop_static_start_real, fn, data, num_threads, start, end, incr, chunk_size); +#endif + + OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); + + RECHECK_INIT(GOMP_parallel_loop_static_start_real); + + if (TRACE(GOMP_parallel_loop_static_start_real)) + { + void *pardo_helper = __GOMP_new_helper(fn, data); + + /* + * Change number of threads if specified by parallel directive only if + * in a library not mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); + + Extrae_OpenMP_ParDO_Entry(); + GOMP_parallel_loop_static_start_real(callme_pardo, pardo_helper, num_threads, start, end, incr, chunk_size); + + /* + * The master thread continues the execution and then calls fn + */ + if (THREADID == 0) + { + Extrae_OpenMP_DO_Entry (); + Extrae_OpenMP_UF_Entry(fn); + } + + /* + * Return to the original number of threads only if in a library not + * mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); + } + else if (GOMP_parallel_loop_static_start_real != NULL) + { + GOMP_parallel_loop_static_start_real(fn, data, num_threads, start, end, incr, chunk_size); + } + else + { + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_static_start: This function is not hooked! Exiting!!\n", + THREAD_LEVEL_VAR); + exit(-1); + } + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_static_start exit\n", THREAD_LEVEL_VAR); +#endif +} + + +void +__wrap_GOMP_parallel_loop_dynamic_start(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size) +{ +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_dynamic_start enter: @=%p args=(%p %p %u %ld %ld %ld %ld)\n", + THREAD_LEVEL_VAR, GOMP_parallel_loop_dynamic_start_real, fn, data, num_threads, start, end, incr, chunk_size); +#endif + + OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); + + RECHECK_INIT(GOMP_parallel_loop_dynamic_start_real); + + if (TRACE(GOMP_parallel_loop_dynamic_start_real)) + { + void *pardo_helper = __GOMP_new_helper(fn, data); + + /* + * Change number of threads if specified by parallel directive only if + * in a library not mixing runtimes. + */ + + OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); + + Extrae_OpenMP_ParDO_Entry(); + GOMP_parallel_loop_dynamic_start_real(callme_pardo, pardo_helper, num_threads, start, end, incr, chunk_size); + + /* + * The master thread continues the execution and then calls fn + */ + if (THREADID == 0) + { + Extrae_OpenMP_DO_Entry (); + Extrae_OpenMP_UF_Entry(fn); + } + + /* + * Return to the original number of threads only if in a library not + * mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); + } + else if (GOMP_parallel_loop_dynamic_start_real != NULL) + { + GOMP_parallel_loop_dynamic_start_real(fn, data, num_threads, start, end, incr, chunk_size); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_dynamic_start: This function is not hooked! Exiting!!\n", + THREAD_LEVEL_VAR); + exit(-1); + } + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_dynamic_start exit\n", THREAD_LEVEL_VAR); +#endif +} + +void +__wrap_GOMP_parallel_loop_guided_start(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size) +{ +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_guided_start enter: @=%p args=(%p %p %u %ld %ld %ld %ld)\n", + THREAD_LEVEL_VAR, GOMP_parallel_loop_guided_start_real, fn, data, num_threads, start, end, incr, chunk_size); +#endif + + OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); + + RECHECK_INIT(GOMP_parallel_loop_guided_start_real); + + if (TRACE(GOMP_parallel_loop_guided_start_real)) + { + void *pardo_helper = __GOMP_new_helper(fn, data); + + /* + * Change number of threads if specified by parallel directive only if + * in a library not mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); + + Extrae_OpenMP_ParDO_Entry(); + GOMP_parallel_loop_guided_start_real(callme_pardo, pardo_helper, num_threads, start, end, incr, chunk_size); + + /* + * The master thread continues the execution and then calls fn + */ + if (THREADID == 0) + { + Extrae_OpenMP_DO_Entry (); + Extrae_OpenMP_UF_Entry(fn); + } + + /* + * Return to the original number of threads only if in a library not + * mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); + } + else if (GOMP_parallel_loop_guided_start_real != NULL) + { + GOMP_parallel_loop_guided_start_real(fn, data, num_threads, start, end, incr, chunk_size); + } + else + { + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_guided_start: This function is not hooked! Exiting!!\n", + THREAD_LEVEL_VAR); + exit(-1); + } + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_guided_start exit\n", THREAD_LEVEL_VAR); +#endif +} +// +void +__wrap_GOMP_parallel_loop_runtime_start(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_runtime_start enter: @=%p args=(%p %p %u %ld %ld %ld)\n", + THREAD_LEVEL_VAR, GOMP_parallel_loop_runtime_start_real, fn, data, num_threads, start, end, incr); +#endif + + OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); + + RECHECK_INIT(GOMP_parallel_loop_runtime_start_real); + + if (TRACE(GOMP_parallel_loop_runtime_start_real)) + { + void *pardo_helper = __GOMP_new_helper(fn, data); + + /* + * Change number of threads if specified by parallel directive only if + * in a library not mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); + + Extrae_OpenMP_ParDO_Entry(); + GOMP_parallel_loop_runtime_start_real(callme_pardo, pardo_helper, num_threads, start, end, incr); + + /* + * The master thread continues the execution and then calls fn + */ + if (THREADID == 0) + { + Extrae_OpenMP_DO_Entry (); + Extrae_OpenMP_UF_Entry(fn); + } + + /* + * Return to the original number of threads only if in a library not + * mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); + } + else if (GOMP_parallel_loop_runtime_start_real != NULL) + { + GOMP_parallel_loop_runtime_start_real(fn, data, num_threads, start, end, incr); + } + else + { + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_runtime_start: This function is not hooked! Exiting!!\n", + THREAD_LEVEL_VAR); + exit(-1); + } + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_runtime_start exit\n", THREAD_LEVEL_VAR); +#endif +} + +void __wrap_GOMP_loop_end (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_loop_end_real); +#endif + + RECHECK_INIT(GOMP_loop_end_real); + + if (TRACE(GOMP_loop_end_real)) + { + Extrae_OpenMP_Join_Wait_Entry(); + GOMP_loop_end_real(); + Extrae_OpenMP_Join_Wait_Exit(); + Extrae_OpenMP_DO_Exit (); + } + else if (GOMP_loop_end_real != NULL) + { + GOMP_loop_end_real(); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end exit\n", THREAD_LEVEL_VAR); +#endif +} + + +void __wrap_GOMP_loop_end_nowait (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end_nowait enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_loop_end_nowait_real); +#endif + + RECHECK_INIT(GOMP_loop_end_nowait_real); + + if (TRACE(GOMP_loop_end_nowait_real)) + { + Extrae_OpenMP_Join_NoWait_Entry(); + GOMP_loop_end_nowait_real(); + Extrae_OpenMP_Join_NoWait_Exit(); + Extrae_OpenMP_DO_Exit (); + } + else if (GOMP_loop_end_nowait_real != NULL) + { + GOMP_loop_end_nowait_real(); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end_nowait: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end_nowait exit\n", THREAD_LEVEL_VAR); +#endif +} +// +void __wrap_GOMP_ordered_start (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_ordered_start_real); +#endif + + RECHECK_INIT(GOMP_ordered_start_real); + + if (TRACE(GOMP_ordered_start_real)) + { + Extrae_OpenMP_Ordered_Wait_Entry(); + GOMP_ordered_start_real (); + Extrae_OpenMP_Ordered_Wait_Exit(); + } + else if (GOMP_ordered_start_real != NULL) + { + GOMP_ordered_start_real (); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_start exit\n", THREAD_LEVEL_VAR); +#endif +} + +void __wrap_GOMP_ordered_end (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_ordered_end_real); +#endif + + RECHECK_INIT(GOMP_ordered_end_real); + + if (TRACE(GOMP_ordered_end_real)) + { + Extrae_OpenMP_Ordered_Post_Entry(); + GOMP_ordered_end_real(); + Extrae_OpenMP_Ordered_Post_Exit(); + } + else if (GOMP_ordered_end_real != NULL) + { + GOMP_ordered_end_real(); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_end_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_end exit\n", THREAD_LEVEL_VAR); +#endif +} + +void +__wrap_GOMP_parallel_start(void (*fn)(void *), void *data, unsigned num_threads) +{ + //fprintf("Start parallel instrument \n"); +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_start enter: @=%p args=(%p %p %u)\n", + THREAD_LEVEL_VAR, GOMP_parallel_start_real, fn, data, num_threads); +#endif + + RECHECK_INIT(GOMP_parallel_start_real); + + if (TRACE(GOMP_parallel_start_real)) + { + SAVE_PARALLEL_UF(fn); + + void *par_helper = __GOMP_new_helper(fn, data); + + /* + * Change number of threads if specified by parallel directive only if + * in a library not mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); + + Extrae_OpenMP_ParRegion_Entry(); + Extrae_OpenMP_EmitTaskStatistics(); + + GOMP_parallel_start_real (callme_par, par_helper, num_threads); + + /* GCC/libgomp does not execute callme_par per root thread, emit + the required event here - call Backend to get a new time! */ + Extrae_OpenMP_UF_Entry(fn); + } + else if (GOMP_parallel_start_real != NULL) + { + GOMP_parallel_start_real(fn, data, num_threads); + } + else + { + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_start: This function is not hooked! Exiting!!\n", + THREAD_LEVEL_VAR); + exit(-1); + } + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_start exit\n", THREAD_LEVEL_VAR); +#endif +} + +void +__wrap_GOMP_parallel_end(void) +{ +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_end enter: @=%p\n", + THREAD_LEVEL_VAR, GOMP_parallel_end_real); +#endif + + RECHECK_INIT(GOMP_parallel_end_real); + + if (TRACE(GOMP_parallel_end_real)) + { + Extrae_OpenMP_UF_Exit(); + GOMP_parallel_end_real(); + Extrae_OpenMP_ParRegion_Exit(); + Extrae_OpenMP_EmitTaskStatistics(); + + /* + * Return to the original number of threads only if in a library not + * mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); + OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); + } + else if (GOMP_parallel_end_real != NULL) + { + GOMP_parallel_end_real(); + } + else + { + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_end: This function is not hooked! Exiting!!\n", + THREAD_LEVEL_VAR); + exit(-1); + } + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_end exit\n", THREAD_LEVEL_VAR); +#endif +} + + +OMP_parallel_sections_start(void (*fn)(void *), void *data, unsigned num_threads, unsigned count) +{ +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_sections_start enter: @=%p args=(%p %p %u %u)\n", + THREAD_LEVEL_VAR, GOMP_sections_start_real, fn, data, num_threads, count); +#endif + + RECHECK_INIT(GOMP_parallel_sections_start_real); + + if (TRACE(GOMP_parallel_sections_start_real)) + { + void *parsections_helper = __GOMP_new_helper(fn, data); + + /* + * Change number of threads if specified by parallel directive only if + * in a library not mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); + + Extrae_OpenMP_ParSections_Entry(); + GOMP_parallel_sections_start_real(callme_parsections, parsections_helper, num_threads, count); + + /* The master thread continues the execution and then calls parsections_helper->fn */ + if (THREADID == 0) + { + Extrae_OpenMP_UF_Entry(fn); + } + } + else if (GOMP_parallel_sections_start_real != NULL) + { + GOMP_parallel_sections_start_real(fn, data, num_threads, count); + } + else + { + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_sections_start: This function is not hooked! Exiting!!\n", + THREAD_LEVEL_VAR); + exit(-1); + } + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_sections_start exit\n", THREAD_LEVEL_VAR); +#endif +} + +unsigned __wrap_GOMP_sections_start (unsigned count) +{ + unsigned res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_start enter: @=%p args=(%u)\n", THREAD_LEVEL_VAR, GOMP_sections_start_real, count); +#endif + + RECHECK_INIT(GOMP_sections_start_real); + + if (TRACE(GOMP_sections_start_real)) + { + Extrae_OpenMP_Section_Entry(); + res = GOMP_sections_start_real (count); + Extrae_OpenMP_Section_Exit(); + } + else if (GOMP_sections_start_real != NULL) + { + res = GOMP_sections_start_real (count); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_start exit: res=%u\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +unsigned __wrap_GOMP_sections_next (void) +{ + unsigned res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_next enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_sections_next_real); +#endif + + RECHECK_INIT(GOMP_sections_next_real); + + if (TRACE(GOMP_sections_next_real)) + { + Extrae_OpenMP_Work_Entry(); + res = GOMP_sections_next_real(); + Extrae_OpenMP_Work_Exit(); + } + else if (GOMP_sections_next_real != NULL) + { + res = GOMP_sections_next_real(); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_next exit: res=%u\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +void __wrap_GOMP_sections_end (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_sections_end_real); +#endif + + RECHECK_INIT(GOMP_sections_end_real); + + if (TRACE(GOMP_sections_end_real)) + { + Extrae_OpenMP_Join_Wait_Entry(); + GOMP_sections_end_real(); + Extrae_OpenMP_Join_Wait_Exit(); + } + else if (GOMP_sections_end_real != NULL) + { + GOMP_sections_end_real(); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end exit\n", THREAD_LEVEL_VAR); +#endif +} + +void __wrap_GOMP_sections_end_nowait (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end_nowait enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_sections_end_nowait_real); +#endif + + RECHECK_INIT(GOMP_sections_end_nowait_real); + + if (TRACE(GOMP_sections_end_nowait_real)) + { + Extrae_OpenMP_Join_NoWait_Entry(); + GOMP_sections_end_nowait_real(); + Extrae_OpenMP_Join_NoWait_Exit(); + } + else if (GOMP_sections_end_nowait_real != NULL) + { + GOMP_sections_end_nowait_real(); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end_nowait: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end_nowait exit\n", THREAD_LEVEL_VAR); +#endif +} + +unsigned __wrap_GOMP_single_start (void) +{ + unsigned res = 0; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_single_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_single_start_real); +#endif + + RECHECK_INIT(GOMP_single_start_real); + + if (TRACE(GOMP_single_start_real)) + { + Extrae_OpenMP_Single_Entry(); + res = GOMP_single_start_real (); + Extrae_OpenMP_Single_Exit(); + } + else if (GOMP_single_start_real != NULL) + { + res = GOMP_single_start_real (); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_single_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_single_start exit: res=%u\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +void __wrap_GOMP_taskwait (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskwait enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_taskwait_real); +#endif + + RECHECK_INIT(GOMP_taskwait_real); + + if (TRACE(GOMP_taskwait_real)) + { + Extrae_OpenMP_Taskwait_Entry(); + Extrae_OpenMP_EmitTaskStatistics(); + GOMP_taskwait_real (); + Extrae_OpenMP_Taskwait_Exit(); + Extrae_OpenMP_EmitTaskStatistics(); + } + else if (GOMP_taskwait_real != NULL) + { + GOMP_taskwait_real (); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskwait: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskwait exit\n", THREAD_LEVEL_VAR); +#endif +} + +///********************************************/ +///***** Added (or changed) in OpenMP 4.0 *****/ +///********************************************/ +// +void +__wrap_GOMP_parallel(void (*fn)(void *), void *data, unsigned num_threads, unsigned int flags) +{ +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel enter: @=%p args=(%p %p %u %u)\n", + THREAD_LEVEL_VAR, GOMP_parallel_real, fn, data, num_threads, flags); +#endif + + OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); + + RECHECK_INIT(GOMP_parallel_real); + + if (TRACE(GOMP_parallel_real)) + { + SAVE_PARALLEL_UF(fn); + + /* + * Change number of threads if specified by parallel directive only if + * in a library not mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); + + /* + * GOMP_parallel has an implicit join, so when we return, the helpers + * can be freed, so rather than using the static array of active + * helpers, we statically declare a private helper and pass it by + * reference. + * void *par_helper = __GOMP_new_helper(fn, data); + */ + struct parallel_helper_t par_helper; + par_helper.fn = fn; + par_helper.data = data; + + Extrae_OpenMP_ParRegion_Entry(); + Extrae_OpenMP_EmitTaskStatistics(); + + + GOMP_parallel_real(callme_par, &par_helper, num_threads, flags); + + Extrae_OpenMP_ParRegion_Exit(); + Extrae_OpenMP_EmitTaskStatistics(); + + /* + * Return to the original number of threads only if in a library not + * mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); + } + else if (GOMP_parallel_real != NULL) + { + GOMP_parallel_real(fn, data, num_threads, flags); + } + else + { + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel: This function is not hooked! Exiting!!\n", + THREAD_LEVEL_VAR); + exit(-1); + } + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_parallel exit\n", THREAD_LEVEL_VAR); +#endif +} + + +void +__wrap_GOMP_parallel_loop_static(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size, unsigned flags) +{ +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_static enter: @=%p args=(%p %p %u %ld %ld %ld %ld %u)\n", + THREAD_LEVEL_VAR, GOMP_parallel_loop_static_real, fn, data, num_threads, start, end, incr, chunk_size, flags); +#endif + + OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); + + RECHECK_INIT(GOMP_parallel_loop_static_real); + + if (TRACE(GOMP_parallel_loop_static_real)) + { + void *pardo_helper = __GOMP_new_helper(fn, data); + + /* + * Change number of threads if specified by parallel directive only if + * in a library not mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); + + Extrae_OpenMP_ParDO_Entry(); + GOMP_parallel_loop_static_real(callme_pardo, pardo_helper, num_threads, start, end, incr, chunk_size, flags); + Extrae_OpenMP_ParDO_Exit(); + + /* + * Return to the original number of threads only if in a library not + * mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); + } + else if (GOMP_parallel_loop_static_real != NULL) + { + GOMP_parallel_loop_static_real(fn, data, num_threads, start, end, incr, chunk_size, flags); + } + else + { + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_static: This function is not hooked! Exiting!!\n", + THREAD_LEVEL_VAR); + exit(-1); + } + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_static exit\n", THREAD_LEVEL_VAR); +#endif +} + +void +__wrap_GOMP_parallel_loop_dynamic(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size, unsigned flags) +{ +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_dynamic enter: @=%p args=(%p %p %u %ld %ld %ld %ld %u)\n", + THREAD_LEVEL_VAR, GOMP_parallel_loop_dynamic_real, fn, data, num_threads, start, end, incr, chunk_size, flags); +#endif + + OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); + + RECHECK_INIT(GOMP_parallel_loop_dynamic_real); + + if (TRACE(GOMP_parallel_loop_dynamic_real)) + { + void *pardo_helper = __GOMP_new_helper(fn, data); + + /* + * Change number of threads if specified by parallel directive only if + * in a library not mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); + + Extrae_OpenMP_ParDO_Entry(); + GOMP_parallel_loop_dynamic_real(callme_pardo, pardo_helper, num_threads, start, end, incr, chunk_size, flags); + Extrae_OpenMP_ParDO_Exit(); + + /* + * Return to the original number of threads only if in a library not + * mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); + } + else if (GOMP_parallel_loop_dynamic_real != NULL) + { + GOMP_parallel_loop_dynamic_real(fn, data, num_threads, start, end, incr, chunk_size, flags); + } + else + { + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_dynamic: This function is not hooked! Exiting!!\n", + THREAD_LEVEL_VAR); + exit(-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_parallel_loop_dynamic exit\n", THREAD_LEVEL_VAR); +#endif +} + +void __wrap_GOMP_parallel_loop_guided(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size, unsigned flags) +{ +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_guided enter: @=%p args=(%p %p %u %ld %ld %ld %ld %u)\n", + THREAD_LEVEL_VAR, GOMP_parallel_loop_guided_real, fn, data, num_threads, start, end, incr, chunk_size, flags); +#endif + + OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); + + RECHECK_INIT(GOMP_parallel_loop_guided_real); + + if (TRACE(GOMP_parallel_loop_guided_real)) + { + void *pardo_helper = __GOMP_new_helper(fn, data); + + /* + * Change number of threads if specified by parallel directive only if + * in a library not mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); + + Extrae_OpenMP_ParDO_Entry(); + GOMP_parallel_loop_guided_real(callme_pardo, pardo_helper, num_threads, start, end, incr, chunk_size, flags); + Extrae_OpenMP_ParDO_Exit(); + + /* + * Return to the original number of threads only if in a library not + * mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); + } + else if (GOMP_parallel_loop_guided_real != NULL) + { + GOMP_parallel_loop_guided_real(fn, data, num_threads, start, end, incr, chunk_size, flags); + } + else + { + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_guided: This function is not hooked! Exiting!!\n", + THREAD_LEVEL_VAR); + exit(-1); + } + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_guided exit\n", THREAD_LEVEL_VAR); +#endif +} + +void +__wrap_GOMP_parallel_loop_runtime(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, unsigned flags) +{ +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_runtime enter: @=%p args=(%p %p %u %ld %ld %ld %u)\n", + THREAD_LEVEL_VAR, GOMP_parallel_loop_runtime_real, fn, data, num_threads, start, end, incr, flags); +#endif + + OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); + + RECHECK_INIT(GOMP_parallel_loop_runtime_real); + + if (TRACE(GOMP_parallel_loop_runtime_real)) + { + void *pardo_helper = __GOMP_new_helper(fn, data); + + /* + * Change number of threads if specified by parallel directive only if + * in a library not mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); + + Extrae_OpenMP_ParDO_Entry(); + GOMP_parallel_loop_runtime_real(callme_pardo, pardo_helper, num_threads, start, end, incr, flags); + Extrae_OpenMP_ParDO_Exit(); + + /* + * Return to the original number of threads only if in a library not + * mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); + } + else if (GOMP_parallel_loop_runtime_real != NULL) + { + GOMP_parallel_loop_runtime_real(fn, data, num_threads, start, end, incr, flags); + } + else + { + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_runtime: This function is not hooked! Exiting!!\n", + THREAD_LEVEL_VAR); + exit(-1); + } + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_loop_runtime exit\n", THREAD_LEVEL_VAR); +#endif +} + +void +__wrap_GOMP_parallel_sections(void (*fn) (void *), void *data, unsigned num_threads, unsigned count, unsigned flags) +{ +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_sections enter: @=%p args=(%p %p %u %u %u)\n", + THREAD_LEVEL_VAR, GOMP_parallel_sections_real, fn, data, num_threads, count, flags); +#endif + + OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); + + RECHECK_INIT(GOMP_parallel_sections_real); + + if (TRACE(GOMP_parallel_sections_real)) + { + void *parsections_helper = __GOMP_new_helper(fn, data); + + /* + * Change number of threads if specified by parallel directive only if + * in a library not mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); + + Extrae_OpenMP_ParSections_Entry(); + GOMP_parallel_sections_real(callme_parsections, parsections_helper, num_threads, count, flags); + Extrae_OpenMP_ParSections_Exit(); + + /* The master thread continues the execution and then calls parsections_helper->fn */ + if (THREADID == 0) + { + Extrae_OpenMP_UF_Entry(fn); + } + + /* + * Return to the original number of threads only if in a library not + * mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); + } + else if (GOMP_parallel_sections_real != NULL) + { + GOMP_parallel_sections_real(fn, data, num_threads, count, flags); + } + else + { + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_sections: This function is not hooked! Exiting!!\n", + THREAD_LEVEL_VAR); + exit(-1); + } + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL + "GOMP_parallel_sections exit\n", THREAD_LEVEL_VAR); +#endif +} + + +void __wrap_GOMP_taskgroup_start (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_taskgroup_start_real); +#endif + + RECHECK_INIT(GOMP_taskgroup_start_real); + + if (TRACE(GOMP_taskgroup_start_real)) + { + Extrae_OpenMP_Taskgroup_start_Entry(); + Extrae_OpenMP_EmitTaskStatistics(); + GOMP_taskgroup_start_real (); + Extrae_OpenMP_Taskgroup_start_Exit(); + } + else if (GOMP_taskgroup_start_real != NULL) + { + GOMP_taskgroup_start_real (); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_start exit\n", THREAD_LEVEL_VAR); +#endif +} + +void __wrap_GOMP_taskgroup_end (void) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_taskgroup_end_real); +#endif + + RECHECK_INIT(GOMP_taskgroup_end_real); + + if (TRACE(GOMP_taskgroup_end_real)) + { + Extrae_OpenMP_Taskgroup_end_Entry(); + GOMP_taskgroup_end_real (); + Extrae_OpenMP_Taskgroup_end_Exit(); + Extrae_OpenMP_EmitTaskStatistics(); + } + else if (GOMP_taskgroup_end_real != NULL) + { + GOMP_taskgroup_end_real (); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_end: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_end exit\n", THREAD_LEVEL_VAR); +#endif +} + +///********************************************/ +///***** Added (or changed) in OpenMP 4.5 *****/ +///********************************************/ + +///* +// * The prototype of GOMP_task changed in 4.0 to add a new parameter 'depend', +// * and again in 4.5 to add 'priority'. We define this prototype as receiving +// * varargs, and we check the runtime version to decide with how many parameters +// * we will make the call to the real function. +// */ + +void __wrap_GOMP_task (void (*fn)(void *), void *data, void (*cpyfn)(void *, void *), long arg_size, long arg_align, int if_clause, unsigned flags, ...) +{ + void **depend = NULL; + int priority = 0; + va_list ap; + + va_start (ap, flags); + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_task enter: @=%p args=(%p %p %p %ld %ld %d %u) (GOMP version: %s)\n", THREAD_LEVEL_VAR, GOMP_task_real, fn, data, cpyfn, arg_size, arg_align, if_clause, flags, __GOMP_version); +#endif + + RECHECK_INIT(GOMP_task_real); + + if (TRACE(GOMP_task_real)) + { + Extrae_OpenMP_Task_Entry (fn); + Extrae_OpenMP_Notify_NewInstantiatedTask(); + + /* + * Helpers for GOMP_task don't use the array of active helpers, as we know + * that we can free them right away after the task is executed. + */ + struct task_helper_t *task_helper = (struct task_helper_t *) malloc(sizeof(struct task_helper_t)); + task_helper->fn = fn; + task_helper->data = data; + + if (cpyfn != NULL) + { + char *buf = malloc(sizeof(char) * (arg_size + arg_align - 1)); + char *arg = (char *) (((uintptr_t) buf + arg_align - 1) + & ~(uintptr_t) (arg_align - 1)); + cpyfn (arg, data); + task_helper->data = arg; + // Saved for deallocation purposes, arg is not valid since includes offset + task_helper->buf = buf; + } + else + { + char *buf = malloc(sizeof(char) * (arg_size + arg_align - 1)); + memcpy (buf, data, arg_size); + task_helper->data = buf; + // Saved for deallocation purposes, arg is not valid since includes offset + task_helper->buf = buf; + } + +#if defined(HAVE__SYNC_FETCH_AND_ADD) + task_helper->counter = __sync_fetch_and_add(&__GOMP_task_ctr, 1); +#else + pthread_mutex_lock (&__GOMP_task_ctr_mtx); + task_helper->counter = __GOMP_task_ctr++; + pthread_mutex_unlock (&__GOMP_task_ctr_mtx); +#endif + + Extrae_OpenMP_TaskID (task_helper->counter); + + if (strcmp(__GOMP_version, GOMP_API_3_1) == 0) { + GOMP_task_real (callme_task, &task_helper, NULL, sizeof(task_helper), arg_align, if_clause, flags); + } else if (strcmp(__GOMP_version, GOMP_API_4_0) == 0) { + depend = va_arg(ap, void **); + GOMP_task_real (callme_task, &task_helper, NULL, sizeof(task_helper), arg_align, if_clause, flags, depend); + } else if (strcmp(__GOMP_version, GOMP_API_4_5) == 0) { + depend = va_arg(ap, void **); + priority = va_arg(ap, int); + GOMP_task_real (callme_task, &task_helper, NULL, sizeof(task_helper), arg_align, if_clause, flags, depend, priority); + } + + Extrae_OpenMP_Task_Exit (); + } + else if (GOMP_task_real != NULL) + { + if (strcmp(__GOMP_version, GOMP_API_3_1) == 0) { + GOMP_task_real (fn, data, cpyfn, arg_size, arg_align, if_clause, flags); + } else if (strcmp(__GOMP_version, GOMP_API_4_0) == 0) { + depend = va_arg(ap, void **); + GOMP_task_real (fn, data, cpyfn, arg_size, arg_align, if_clause, flags, depend); + } else if (strcmp(__GOMP_version, GOMP_API_4_5) == 0) { + depend = va_arg(ap, void **); + priority = va_arg(ap, int); + GOMP_task_real (fn, data, cpyfn, arg_size, arg_align, if_clause, flags, depend, priority); + } + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_task: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + + va_end(ap); + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_task exit\n", THREAD_LEVEL_VAR); +#endif +} + + +///* +// * taskloop_helper ↴ data ↴ +// * ---------------------------------------- +// * | *cpyfn | *fn | long start | long end | +// * ---------------------------------------- +// */ + +void __wrap_GOMP_taskloop (void *fn, void *data, void *cpyfn, long arg_size, long arg_align, unsigned flags, unsigned long num_tasks, int priority, long start, long end, long step) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskloop enter: @=%p args=(%p %p %p %ld %ld %u %lu %d %ld %ld %ld)\n", THREAD_LEVEL_VAR, GOMP_taskloop_real, fn, data, cpyfn, arg_size, arg_align, flags, num_tasks, priority, start, end, step); + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskloop: instrumentation is %s\n", THREAD_LEVEL_VAR, (getTrace_OMPTaskloop() ? "enabled" : "disabled")); +#endif + + RECHECK_INIT(GOMP_taskloop_real); + + if (TRACE(GOMP_taskloop_real) && (getTrace_OMPTaskloop())) + { + /* Store global pointers to fn and data. This is a fallback mechanism in case the runtime changes data, + * breaking our injected pointers. Using the global pointers only allows 1 simultaneous taskloop. + */ + taskloop_global_fn = fn; + taskloop_global_data = data; + + Extrae_OpenMP_TaskLoop_Entry (); + + /* Modify the input 'data' to prefix the pointers to cpyfn and fn */ + long payload = sizeof(void *) + sizeof(void *); + void *taskloop_helper = (void *)malloc(payload + arg_size); +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskloop taskloop_helper=%p\n", THREAD_LEVEL_VAR, taskloop_helper); +#endif + *((void **)(taskloop_helper)) = cpyfn; + *((void **)(taskloop_helper+sizeof(void *))) = fn; + memcpy(taskloop_helper+payload, data, arg_size); + + /* Store our modified data in a list */ + pthread_mutex_lock (&mtx_taskloop_helpers); + tracked_taskloop_helper_t *new_tracked_taskloop_helper = malloc(sizeof(tracked_taskloop_helper_t)); + new_tracked_taskloop_helper->taskloop_helper_ptr = taskloop_helper+payload; + new_tracked_taskloop_helper->next = tracked_taskloop_helpers; + tracked_taskloop_helpers = new_tracked_taskloop_helper; + pthread_mutex_unlock (&mtx_taskloop_helpers); + + if (cpyfn != NULL) + { + GOMP_taskloop_real (callme_taskloop_suffix_helper, taskloop_helper+payload, callme_taskloop_cpyfn, arg_size+payload, arg_align, flags, num_tasks, priority, start, end, step); + } + else + { + GOMP_taskloop_real (callme_taskloop_prefix_helper, taskloop_helper+payload, cpyfn, arg_size, arg_align, flags, num_tasks, priority, start, end, step); + } + + /* At this point the runtime has invoked all loop tasks so the helper can be freed */ + if (taskloop_helper != NULL) + { + free(taskloop_helper); + } + + /* Remove our modified data from the list */ + pthread_mutex_lock (&mtx_taskloop_helpers); + tracked_taskloop_helper_t *current_tracked_taskloop_helper = tracked_taskloop_helpers, *prev = NULL; + while (current_tracked_taskloop_helper != NULL) + { + if (current_tracked_taskloop_helper->taskloop_helper_ptr == taskloop_helper+payload) + { + if (prev != NULL) + { + prev->next = current_tracked_taskloop_helper->next; + } + else + { + tracked_taskloop_helpers = current_tracked_taskloop_helper->next; + } + free (current_tracked_taskloop_helper); + + break; + } + prev = current_tracked_taskloop_helper; + current_tracked_taskloop_helper = current_tracked_taskloop_helper->next; + } + pthread_mutex_unlock (&mtx_taskloop_helpers); + + Extrae_OpenMP_TaskLoop_Exit (); + } + else if (GOMP_taskloop_real != NULL) + { + GOMP_taskloop_real (fn, data, cpyfn, arg_size, arg_align, flags, num_tasks, priority, start, end, step); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskloop: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskloop exit\n", THREAD_LEVEL_VAR); +#endif +} + +int __wrap_GOMP_loop_doacross_static_start (unsigned ncounts, long *counts, long chunk_size, long *istart, long *iend) +{ + int res; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_static_start enter: @=%p args=(%u %p %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_doacross_static_start_real, ncounts, counts, chunk_size, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_doacross_static_start_real); + + /* Save ncounts in the thread TLS */ + SAVE_DOACROSS_NCOUNTS(ncounts); + + if (TRACE(GOMP_loop_doacross_static_start_real)) + { + Extrae_OpenMP_DO_Entry (); + res = GOMP_loop_doacross_static_start_real (ncounts, counts, chunk_size, istart, iend); + } + else if (GOMP_loop_doacross_static_start_real != NULL) + { + res = GOMP_loop_doacross_static_start_real (ncounts, counts, chunk_size, istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_static_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_static_start exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_doacross_dynamic_start (unsigned ncounts, long *counts, long chunk_size, long *istart, long *iend) +{ + int res; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_dynamic_start enter: @=%p args=(%u %p %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_doacross_dynamic_start_real, ncounts, counts, chunk_size, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_doacross_dynamic_start_real); + + /* Save ncounts in the thread TLS */ + SAVE_DOACROSS_NCOUNTS(ncounts); + + if (TRACE(GOMP_loop_doacross_dynamic_start_real)) + { + Extrae_OpenMP_DO_Entry (); + res = GOMP_loop_doacross_dynamic_start_real (ncounts, counts, chunk_size, istart, iend); + } + else if (GOMP_loop_doacross_dynamic_start_real != NULL) + { + res = GOMP_loop_doacross_dynamic_start_real (ncounts, counts, chunk_size, istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_dynamic_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_dynamic_start exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_doacross_guided_start (unsigned ncounts, long *counts, long chunk_size, long *istart, long *iend) +{ + int res; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_guided_start enter: @=%p args=(%u %p %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_doacross_guided_start_real, ncounts, counts, chunk_size, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_doacross_guided_start_real); + + /* Save ncounts in the thread TLS */ + SAVE_DOACROSS_NCOUNTS(ncounts); + + if (TRACE(GOMP_loop_doacross_guided_start_real)) + { + Extrae_OpenMP_DO_Entry (); + res = GOMP_loop_doacross_guided_start_real (ncounts, counts, chunk_size, istart, iend); + } + else if (GOMP_loop_doacross_guided_start_real != NULL) + { + res = GOMP_loop_doacross_guided_start_real (ncounts, counts, chunk_size, istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_guided_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_guided_start exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +int __wrap_GOMP_loop_doacross_runtime_start (unsigned ncounts, long *counts, long *istart, long *iend) +{ + int res; +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_runtime_start enter: @=%p args=(%u %p %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_doacross_runtime_start_real, ncounts, counts, istart, iend); +#endif + + RECHECK_INIT(GOMP_loop_doacross_runtime_start_real); + + /* Save ncounts in the thread TLS */ + SAVE_DOACROSS_NCOUNTS(ncounts); + + if (TRACE(GOMP_loop_doacross_runtime_start_real)) + { + Extrae_OpenMP_DO_Entry (); + res = GOMP_loop_doacross_runtime_start_real (ncounts, counts, istart, iend); + } + else if (GOMP_loop_doacross_runtime_start_real != NULL) + { + res = GOMP_loop_doacross_runtime_start_real (ncounts, counts, istart, iend); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_runtime_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_runtime_start exit: res=%d\n", THREAD_LEVEL_VAR, res); +#endif + + return res; +} + +void __wrap_GOMP_doacross_post (long *counts) +{ +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_doacross_post enter: @=%p args=(%p)\n", THREAD_LEVEL_VAR, GOMP_doacross_post_real, counts); +#endif + + RECHECK_INIT(GOMP_doacross_post_real); + + if (TRACE(GOMP_doacross_post_real)) + { + Extrae_OpenMP_Ordered_Post_Entry(); + GOMP_doacross_post_real (counts); + Extrae_OpenMP_Ordered_Post_Exit(); + } + else if (GOMP_doacross_post_real != NULL) + { + GOMP_doacross_post_real (counts); + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_doacross_post: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_doacross_post exit\n", THREAD_LEVEL_VAR); +#endif +} + +///* +// * The body of GOMP_doacross_wait needs a switch with as many cases as possible +// * values of 'ncounts'. These cases are generated dynamically with the script +// * 'genstubs-libgomp.sh' up to a maximum of DOACROSS_MAX_NESTING, defined in +// * that script. +// */ +void __wrap_GOMP_doacross_wait (long first, ...) +{ + unsigned i = 0; + long args[MAX_DOACROSS_ARGS]; + va_list ap; + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_doacross_wait enter: @=%p args=(%ld)\n", THREAD_LEVEL_VAR, GOMP_doacross_wait_real, first); +#endif + + RECHECK_INIT(GOMP_doacross_wait_real); + + /* Retrieve ncounts from the thread TLS */ + unsigned ncounts = RETRIEVE_DOACROSS_NCOUNTS(); + + if (TRACE(GOMP_doacross_wait_real)) + { + va_start(ap, first); + for (i = 0; i < ncounts; i++) + { + args[i] = va_arg(ap, long); + } + va_end(ap); + + Extrae_OpenMP_Ordered_Wait_Entry(); + + switch (ncounts) + { + #include "gnu-libgomp-intermediate/libgomp-doacross-intermediate-switch.c" + default: + fprintf (stderr, PACKAGE_NAME": ERROR! Unhandled GOMP_doacross_wait call with %d arguments! Re-run the script 'genstubs-libgomp.sh' increasing the value of DOACROSS_MAX_NESTING. Quitting!\n", ncounts); + exit(-1); + break; + } + + Extrae_OpenMP_Ordered_Wait_Exit(); + } + else if (GOMP_doacross_wait_real != NULL) + { + va_start(ap, first); + for (i = 0; i < ncounts; i++) + { + args[i] = va_arg(ap, long); + } + va_end(ap); + + switch (ncounts) + { + #include "gnu-libgomp-intermediate/libgomp-doacross-intermediate-switch.c" + default: + fprintf (stderr, PACKAGE_NAME": ERROR! Unhandled GOMP_doacross_wait call with %d arguments! Re-run the script 'genstubs-libgomp.sh' increasing the value of DOACROSS_MAX_NESTING. Quitting!\n", ncounts); + exit(-1); + break; + } + } + else + { + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "ERROR! GOMP_doacross_wait_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_doacross_wait exit\n", THREAD_LEVEL_VAR); +#endif +} + + +/******************************************************************************\ + * * + * INITIALIZATIONS * + * * +\******************************************************************************/ + +/** + * gnu_libgomp_get_hook_points + * + * Find the real implementation of the functions. We use dlsym to find the next + * definition of the different symbols of the OpenMP runtime (i.e. skip our + * wrapper, find the real one). + * + * @param rank The current process ID (not used). + * + * @return 1 if any hook was found; 0 otherwise. + */ +static int gnu_libgomp_get_hook_points (int rank) +{ + int count = 0; + + UNREFERENCED_PARAMETER(rank); + + // Detect the OpenMP version supported by the runtime + if ((__GOMP_version = getenv("EXTRAE___GOMP_version")) != NULL) { + if ((strcmp(__GOMP_version, GOMP_API_4_5) != 0) && + (strcmp(__GOMP_version, GOMP_API_4_0) != 0) && + (strcmp(__GOMP_version, GOMP_API_3_1) != 0)) { + fprintf(stderr, PACKAGE_NAME": ERROR! Unsupported GOMP version (%s). Valid versions are: 3.1, 4.0 and 4.5. Exiting ...\n", __GOMP_version); + exit (-1); + } + } + if (TASKID == 0) + { + fprintf (stdout, PACKAGE_NAME": Detected GOMP version is %s\n", __GOMP_version); + } + + /**********************/ + /***** OpenMP 3.1 *****/ + /**********************/ + + /* Obtain @ for GOMP_atomic_start */ + GOMP_atomic_start_real = + (void(*)(void)) __real_GOMP_atomic_start; + INC_IF_NOT_NULL(GOMP_atomic_start_real,count); + + /* Obtain @ for GOMP_atomic_end */ + GOMP_atomic_end_real = + (void(*)(void)) __real_GOMP_atomic_end; + INC_IF_NOT_NULL(GOMP_atomic_end_real,count); + + /* Obtain @ for GOMP_barrier */ + GOMP_barrier_real = + (void(*)(void)) __real_GOMP_barrier; // Wrap + INC_IF_NOT_NULL(GOMP_barrier_real,count); + + /* Obtain @ for GOMP_critical_enter */ + GOMP_critical_start_real = + (void(*)(void)) __real_GOMP_critical_start; + INC_IF_NOT_NULL(GOMP_critical_start_real,count); + + /* Obtain @ for GOMP_critical_end */ + GOMP_critical_end_real = + (void(*)(void)) __real_GOMP_critical_end; + INC_IF_NOT_NULL(GOMP_critical_end_real,count); + + /* Obtain @ for GOMP_critical_name_start */ + GOMP_critical_name_start_real = + (void(*)(void**)) __real_GOMP_critical_name_start; + INC_IF_NOT_NULL(GOMP_critical_name_start_real,count); + + /* Obtain @ for GOMP_critical_name_end */ + GOMP_critical_name_end_real = + (void(*)(void**)) __real_GOMP_critical_name_end; + INC_IF_NOT_NULL(GOMP_critical_name_end_real,count); + + /* Obtain @ for GOMP_loop_static_start */ + GOMP_loop_static_start_real = + (int(*)(long,long,long,long,long*,long*)) __real_GOMP_loop_static_start; + INC_IF_NOT_NULL(GOMP_loop_static_start_real,count); + + /* Obtain @ for GOMP_loop_dynamic_start */ + GOMP_loop_dynamic_start_real = + (int(*)(long,long,long,long,long*,long*)) __real_GOMP_loop_dynamic_start; + INC_IF_NOT_NULL(GOMP_loop_dynamic_start_real,count); + + /* Obtain @ for GOMP_loop_guided_start */ + GOMP_loop_guided_start_real = + (int(*)(long,long,long,long,long*,long*)) __real_GOMP_loop_guided_start; + INC_IF_NOT_NULL(GOMP_loop_guided_start_real,count); + + /* Obtain @ for GOMP_loop_runtime_start */ + GOMP_loop_runtime_start_real = + (int(*)(long,long,long,long,long*,long*)) __real_GOMP_loop_runtime_start; + INC_IF_NOT_NULL(GOMP_loop_runtime_start_real,count); + + /* Obtain @ for GOMP_loop_static_next */ + GOMP_loop_static_next_real = + (int(*)(long*,long*)) __real_GOMP_loop_static_next; + INC_IF_NOT_NULL(GOMP_loop_static_next_real,count); + + /* Obtain @ for GOMP_loop_dynamic_next */ + GOMP_loop_dynamic_next_real = + (int(*)(long*,long*)) __real_GOMP_loop_dynamic_next; + INC_IF_NOT_NULL(GOMP_loop_dynamic_next_real,count); + + + /* Obtain @ for GOMP_loop_guided_next */ + GOMP_loop_guided_next_real = + (int(*)(long*,long*)) __real_GOMP_loop_guided_next; + INC_IF_NOT_NULL(GOMP_loop_guided_next_real,count); + + /* Obtain @ for GOMP_loop_runtime_next */ + GOMP_loop_runtime_next_real = + (int(*)(long*,long*)) __real_GOMP_loop_runtime_next; + INC_IF_NOT_NULL(GOMP_loop_runtime_next_real,count); + + + /* Obtain @ for GOMP_loop_ordered_static_start */ + GOMP_loop_ordered_static_start_real = + (int(*)(long, long, long, long, long *, long *)) __real_GOMP_loop_ordered_static_start; + INC_IF_NOT_NULL(GOMP_loop_ordered_static_start_real, count); + + + /* Obtain @ for GOMP_loop_ordered_dynamic_start */ + GOMP_loop_ordered_dynamic_start_real = + (int(*)(long, long, long, long, long *, long *)) __real_GOMP_loop_ordered_dynamic_start; + INC_IF_NOT_NULL(GOMP_loop_ordered_dynamic_start_real, count); + + /* Obtain @ for GOMP_loop_ordered_guided_start */ + GOMP_loop_ordered_guided_start_real = + (int(*)(long, long, long, long, long *, long *)) __real_GOMP_loop_ordered_guided_start; + INC_IF_NOT_NULL(GOMP_loop_ordered_guided_start_real, count); + + /* Obtain @ for GOMP_loop_ordered_runtime_start */ + GOMP_loop_ordered_runtime_start_real = + (int(*)(long, long, long, long, long *, long *))__real_GOMP_loop_ordered_runtime_start; + INC_IF_NOT_NULL(GOMP_loop_ordered_runtime_start_real, count); + + /* Obtain @ for GOMP_loop_ordered_static_next */ + GOMP_loop_ordered_static_next_real = + (int(*)(long*,long*)) __real_GOMP_loop_ordered_static_next; + INC_IF_NOT_NULL(GOMP_loop_ordered_static_next_real,count); + + /* Obtain @ for GOMP_loop_ordered_dynamic_next */ + GOMP_loop_ordered_dynamic_next_real = + (int(*)(long*,long*))__real_GOMP_loop_ordered_dynamic_next; + INC_IF_NOT_NULL(GOMP_loop_ordered_dynamic_next_real,count); + + /* Obtain @ for GOMP_loop_ordered_guided_next */ + GOMP_loop_ordered_guided_next_real = + (int(*)(long*,long*)) __real_GOMP_loop_ordered_guided_next; + INC_IF_NOT_NULL(GOMP_loop_ordered_guided_next_real,count); + + /* Obtain @ for GOMP_loop_runtime_next */ + GOMP_loop_ordered_runtime_next_real = + (int(*)(long*,long*)) __real_GOMP_loop_ordered_runtime_next; + INC_IF_NOT_NULL(GOMP_loop_ordered_runtime_next_real,count); + + + /* Obtain @ for GOMP_parallel_loop_static_start */ + GOMP_parallel_loop_static_start_real = + (void(*)(void*,void*,unsigned, long, long, long, long)) __real_GOMP_parallel_loop_static_start; + INC_IF_NOT_NULL(GOMP_parallel_loop_static_start_real,count); + + + /* Obtain @ for GOMP_parallel_loop_dynamic_start */ + GOMP_parallel_loop_dynamic_start_real = + (void(*)(void*,void*,unsigned, long, long, long, long)) __real_GOMP_parallel_loop_dynamic_start; + INC_IF_NOT_NULL(GOMP_parallel_loop_dynamic_start_real,count); + + /* Obtain @ for GOMP_parallel_loop_guided_start */ + GOMP_parallel_loop_guided_start_real = + (void(*)(void*,void*,unsigned, long, long, long, long)) __real_GOMP_parallel_loop_guided_start; + INC_IF_NOT_NULL(GOMP_parallel_loop_guided_start_real,count); + + /* Obtain @ for GOMP_parallel_loop_runtime_start */ + GOMP_parallel_loop_runtime_start_real = + (void(*)(void*,void*,unsigned, long, long, long)) __real_GOMP_parallel_loop_runtime_start; + INC_IF_NOT_NULL(GOMP_parallel_loop_runtime_start_real,count); + + /* Obtain @ for GOMP_loop_end */ + GOMP_loop_end_real = + (void(*)(void)) __real_GOMP_loop_end; + INC_IF_NOT_NULL(GOMP_loop_end_real,count); + + /* Obtain @ for GOMP_loop_end_nowait */ + GOMP_loop_end_nowait_real = + (void(*)(void)) __real_GOMP_loop_end_nowait; + INC_IF_NOT_NULL(GOMP_loop_end_nowait_real,count); + + /* Obtain @ for GOMP_ordered_start */ + GOMP_ordered_start_real = (void(*)(void))__real_GOMP_ordered_start; + INC_IF_NOT_NULL(GOMP_ordered_start_real,count); + + /* Obtain @ for GOMP_ordered_end */ + GOMP_ordered_end_real = (void(*)(void)) __real_GOMP_ordered_end; + INC_IF_NOT_NULL(GOMP_ordered_end_real,count); + + /* Obtain @ for GOMP_parallel_start */ + GOMP_parallel_start_real = + (void(*)(void*,void*,unsigned)) __real_GOMP_parallel_start; // Wrap + INC_IF_NOT_NULL(GOMP_parallel_start_real,count); + + /* Obtain @ for GOMP_parallel_end */ + GOMP_parallel_end_real = + (void(*)(void)) __real_GOMP_parallel_end; // Wrap + INC_IF_NOT_NULL(GOMP_parallel_end_real,count); + + /* Obtain @ for GOMP_parallel_sections_start */ + GOMP_parallel_sections_start_real = + (void(*)(void*,void*,unsigned,unsigned)) dlsym (RTLD_NEXT, "GOMP_parallel_sections_start"); + INC_IF_NOT_NULL(GOMP_parallel_sections_start_real,count); + + /* Obtain @ for GOMP_sections_start */ + GOMP_sections_start_real = + (unsigned(*)(unsigned)) __real_GOMP_sections_start; + INC_IF_NOT_NULL(GOMP_sections_start_real,count); + + /* Obtain @ for GOMP_sections_next */ + GOMP_sections_next_real = + (unsigned(*)(void)) __real_GOMP_sections_next; + INC_IF_NOT_NULL(GOMP_sections_next_real,count); + + /* Obtain @ for GOMP_sections_end */ + GOMP_sections_end_real = + (void(*)(void)) __real_GOMP_sections_end; + INC_IF_NOT_NULL(GOMP_sections_end_real,count); + + /* Obtain @ for GOMP_sections_end_nowait */ + GOMP_sections_end_nowait_real = + (void(*)(void)) __real_GOMP_sections_end_nowait; + INC_IF_NOT_NULL(GOMP_sections_end_nowait_real,count); + + /* Obtain @ for GOMP_single_start */ + GOMP_single_start_real = + (unsigned(*)(void)) __real_GOMP_single_start; // Wrap + INC_IF_NOT_NULL(GOMP_single_start_real,count); + + /* Obtain @ for GOMP_taskwait */ + GOMP_taskwait_real = (void(*)(void)) __real_GOMP_taskwait; // Wrap + INC_IF_NOT_NULL(GOMP_taskwait_real,count); + + /**********************/ + /***** OpenMP 4.0 *****/ + /**********************/ + + /* Obtain @ for GOMP_parallel */ + GOMP_parallel_real = + (void(*)(void*,void*,unsigned,unsigned int)) __real_GOMP_parallel; // Wrap + INC_IF_NOT_NULL(GOMP_parallel_real,count); + + /* Obtain @ for GOMP_parallel_loop_static */ + GOMP_parallel_loop_static_real = + (void(*)(void*, void*, unsigned, long, long, long, long, unsigned))__real_GOMP_parallel_loop_static; + INC_IF_NOT_NULL(GOMP_parallel_loop_static_real,count); + + /* Obtain @ for GOMP_parallel_loop_dynamic */ + GOMP_parallel_loop_dynamic_real = + (void(*)(void*, void*, unsigned, long, long, long, long, unsigned))__real_GOMP_parallel_loop_dynamic; + INC_IF_NOT_NULL(GOMP_parallel_loop_dynamic_real,count); + + /* Obtain @ for GOMP_parallel_loop_guided */ + GOMP_parallel_loop_guided_real = + (void(*)(void*, void*, unsigned, long, long, long, long, unsigned))__real_GOMP_parallel_loop_guided; + INC_IF_NOT_NULL(GOMP_parallel_loop_guided_real,count); + + /* Obtain @ for GOMP_parallel_loop_runtime */ + GOMP_parallel_loop_runtime_real = + (void(*)(void*, void*, unsigned, long, long, long, unsigned)) __real_GOMP_parallel_loop_runtime; + INC_IF_NOT_NULL(GOMP_parallel_loop_runtime_real,count); + + /* Obtain @ for GOMP_parallel_sections */ + GOMP_parallel_sections_real = + (void(*)(void *, void *, unsigned, unsigned, unsigned)) __real_GOMP_parallel_sections; + INC_IF_NOT_NULL(GOMP_parallel_sections_real,count); + + /* Obtain @ for GOMP_taskgroup_start */ + GOMP_taskgroup_start_real = (void(*)(void)) __real_GOMP_taskgroup_start; + INC_IF_NOT_NULL(GOMP_taskgroup_start_real,count); + + /* Obtain @ for GOMP_taskgroup_end */ + GOMP_taskgroup_end_real = (void(*)(void)) __real_GOMP_taskgroup_end; + INC_IF_NOT_NULL(GOMP_taskgroup_end_real,count); + + /**********************/ + /***** OpenMP 4.5 *****/ + /**********************/ + + /* Obtain @ for GOMP_task */ + GOMP_task_real = + (void(*)(void*,void*,void*,long,long,int,unsigned,...))__real_GOMP_task; // Wrap + INC_IF_NOT_NULL(GOMP_task_real,count); + + /* Obtain @ for GOMP_taskloop */ + GOMP_taskloop_real = + (void(*)(void*,void*,void*,long,long,unsigned,unsigned long,int,long,long,long))__real_GOMP_taskloop; // Wrap + INC_IF_NOT_NULL(GOMP_taskloop_real,count); + + /* Obtain @ for GOMP_loop_doacross_static_start */ + GOMP_loop_doacross_static_start_real = (int(*)(unsigned, long *, long, long *, long *))__real_GOMP_loop_doacross_static_start; + INC_IF_NOT_NULL(GOMP_loop_doacross_static_start_real,count); + + /* Obtain @ for GOMP_loop_doacross_dynamic_start */ + GOMP_loop_doacross_dynamic_start_real = (int(*)(unsigned, long *, long, long *, long *))__real_GOMP_loop_doacross_dynamic_start; + INC_IF_NOT_NULL(GOMP_loop_doacross_dynamic_start_real,count); + + /* Obtain @ for GOMP_loop_doacross_guided_start */ + GOMP_loop_doacross_guided_start_real = (int(*)(unsigned, long *, long, long *, long *))__real_GOMP_loop_doacross_guided_start; + INC_IF_NOT_NULL(GOMP_loop_doacross_guided_start_real,count); + + /* Obtain @ for GOMP_loop_doacross_runtime_start */ + GOMP_loop_doacross_runtime_start_real = (int(*)(unsigned, long *, long *, long *))__real_GOMP_loop_doacross_runtime_start; + INC_IF_NOT_NULL(GOMP_loop_doacross_runtime_start_real,count); + + /* Obtain @ for GOMP_doacross_post */ + GOMP_doacross_post_real = (void(*)(long *))__real_GOMP_doacross_post; + INC_IF_NOT_NULL(GOMP_doacross_post_real,count); + + /* Obtain @ for GOMP_doacross_wait */ + GOMP_doacross_wait_real = (void(*)(long, ...))__real_GOMP_doacross_wait; + INC_IF_NOT_NULL(GOMP_doacross_wait_real,count); + + /* Any hook point? */ + return (count > 0); +} + +#else #if defined(PIC) /**************************************************************/ @@ -513,7 +3751,7 @@ static void callme_taskloop (void (*fn)(void *), void *data) long long taskloop_ctr = __sync_fetch_and_add(&__GOMP_taskloop_ctr, 1); #else pthread_mutex_lock (&__GOMP_taskloop_ctr_mtx); - taskloop_ctr = __GOMP_taskloop_ctr++; + long long taskloop_ctr = __GOMP_taskloop_ctr++; pthread_mutex_unlock (&__GOMP_taskloop_ctr_mtx); #endif @@ -3238,6 +6476,9 @@ static int gnu_libgomp_get_hook_points (int rank) return (count > 0); } +#endif /* PIC */ +#endif + /** * _extrae_gnu_libgomp_init * @@ -3252,5 +6493,5 @@ int _extrae_gnu_libgomp_init (int rank) return gnu_libgomp_get_hook_points (rank); } -#endif /* PIC */ + diff --git a/src/tracer/wrappers/OMP/omp-common.c b/src/tracer/wrappers/OMP/omp-common.c index dad8a8fe..cf794dff 100644 --- a/src/tracer/wrappers/OMP/omp-common.c +++ b/src/tracer/wrappers/OMP/omp-common.c @@ -145,7 +145,13 @@ void Extrae_OpenMP_init(int me) #else /* PIC */ if (me == 0) { +#if defined(OS_RTEMS) + fprintf (stderr, PACKAGE_NAME": Alpha version static library linked wrapping\n"); + _extrae_gnu_libgomp_init(0); + omp_common_get_hook_points_c(0); +#else fprintf (stderr, PACKAGE_NAME": Warning! OpenMP instrumentation requires linking with shared library!\n"); +#endif } #endif /* PIC */ diff --git a/src/tracer/wrappers/OMP/omp-common_c.c b/src/tracer/wrappers/OMP/omp-common_c.c index 151b8b3c..8dcedcd9 100644 --- a/src/tracer/wrappers/OMP/omp-common_c.c +++ b/src/tracer/wrappers/OMP/omp-common_c.c @@ -41,18 +41,50 @@ omp_common_get_hook_points_c(TASKID); \ } \ } +#if defined (OS_RTEMS) +int (*omp_get_thread_num_real)(void) = NULL; +void (*omp_set_num_threads_real)(int) = NULL; +void (*omp_set_lock_real)(omp_lock_t *) = NULL; +void (*omp_unset_lock_real)(omp_lock_t *) = NULL; + + +extern int __real_omp_get_thread_num (void ) __attribute__((weak)); +extern void __real_omp_set_num_threads(int num) __attribute__((weak)); +extern void __real_omp_set_lock (omp_lock_t *lock) __attribute__((weak)); +extern void __real_omp_unset_lock (omp_lock_t *lock) __attribute__((weak)); + + +#else #if defined(PIC) int (*omp_get_thread_num_real)(void) = NULL; void (*omp_set_num_threads_real)(int) = NULL; void (*omp_set_lock_real)(omp_lock_t *) = NULL; void (*omp_unset_lock_real)(omp_lock_t *) = NULL; #endif /* PIC */ - +#endif void omp_common_get_hook_points_c (int rank) { UNREFERENCED_PARAMETER(rank); +#if defined(OS_RTEMS) +/* Obtain @ for omp_get_thread_num_real */ + omp_get_thread_num_real = + (int(*)(void)) __real_omp_get_thread_num; + + /* Obtain @ for omp_set_num_threads */ + omp_set_num_threads_real = + (void(*)(int)) __real_omp_set_num_threads; + + /* Obtain @ for omp_set_lock */ + omp_set_lock_real = + (void(*)(omp_lock_t*)) __real_omp_set_lock; + + /* Obtain @ for omp_unset_lock */ + omp_unset_lock_real = + (void(*)(omp_lock_t*)) __real_omp_unset_lock; + +#else #if defined(PIC) /* Obtain @ for omp_get_thread_num_real */ omp_get_thread_num_real = @@ -71,6 +103,7 @@ void omp_common_get_hook_points_c (int rank) (void(*)(omp_lock_t*)) dlsym (RTLD_NEXT, "omp_unset_lock"); #endif /* PIC */ +#endif } /******************************************************************************\ @@ -78,7 +111,160 @@ void omp_common_get_hook_points_c (int rank) * C WRAPPERS * * * \******************************************************************************/ +#if defined(OS_RTEMS) + +int __wrap_omp_get_thread_num (void) +{ + static int shown = FALSE; + int res = 0; + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME": omp_get_thread_num starts (real=%p) params=(void)\n", omp_get_thread_num_real); +#endif + + RECHECK_INIT_C(omp_get_thread_num_real); + + if (omp_get_thread_num_real != NULL) + { + res = omp_get_thread_num_real(); + } + else + { + res = 0; + + if (!shown) + { + fprintf (stderr, + PACKAGE_NAME": WARNING! You have ended executing Extrae's omp_get_thread_num weak symbol! " + "That's likely to happen when you load the tracing library for OpenMP, " + "but your application is not compiled/linked against OpenMP.\n" ); + shown = TRUE; + } + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME": THREAD %d: omp_get_thread_num ends\n", res); +#endif + + return res; +} + +void +__wrap_omp_set_num_threads(int num_threads) +{ +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME + ": THREAD %d: omp_set_num_threads starts (real=%p) params=(%d)\n", + THREADID, omp_set_num_threads_real, num_threads); +#endif + + RECHECK_INIT_C(omp_set_num_threads_real); + + int canInstrument = EXTRAE_INITIALIZED() && + omp_set_num_threads_real != NULL; + + if (canInstrument && !Backend_inInstrumentation(THREADID)) + { + /* + * Change number of threads only if in a library not mixing runtimes. + */ + OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); + + Backend_Enter_Instrumentation(); + Probe_OpenMP_SetNumThreads_Entry(num_threads); + omp_set_num_threads_real(num_threads); + Probe_OpenMP_SetNumThreads_Exit(); + Backend_Leave_Instrumentation(); + } + else if (omp_set_num_threads_real != NULL) + { + omp_set_num_threads_real(num_threads); + } + else + { + fprintf(stderr, PACKAGE_NAME + ": ERROR! omp_set_num_threads is not hooked! Exiting!!\n"); + exit(-1); + } + +#if defined(DEBUG) + fprintf(stderr, PACKAGE_NAME": THREAD %d: omp_set_num_threads ends\n", + THREADID); +#endif +} + +void __wrap_omp_set_lock (omp_lock_t *lock) +{ + void *lock_ptr = (void *)lock; + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME": THREAD %d: omp_set_lock starts (real=%p) params=(%p)\n", THREADID, omp_set_lock_real, lock_ptr); +#endif + RECHECK_INIT_C(omp_set_lock_real); + + int canInstrument = EXTRAE_INITIALIZED() && + omp_set_lock_real != NULL; + + if (canInstrument && !Backend_inInstrumentation(THREADID)) + { + Backend_Enter_Instrumentation (); + Probe_OpenMP_Named_Lock_Entry(); + omp_set_lock_real (lock_ptr); + Probe_OpenMP_Named_Lock_Exit(lock_ptr); + Backend_Leave_Instrumentation (); + } + else if (omp_set_lock_real != NULL) + { + omp_set_lock_real (lock); + } + else + { + fprintf (stderr, PACKAGE_NAME": ERROR! omp_set_lock is not hooked! Exiting!!\n"); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME": THREAD %d: omp_set_lock ends\n", THREADID); +#endif +} + +void __wrap_omp_unset_lock (omp_lock_t *lock) +{ + void *lock_ptr = (void *)lock; + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME": THREAD %d: omp_unset_lock starts (real=%p) params=(%p)\n", THREADID, omp_unset_lock_real, lock_ptr); +#endif + + RECHECK_INIT_C(omp_unset_lock_real); + + int canInstrument = EXTRAE_INITIALIZED() && + omp_unset_lock_real != NULL; + + if (canInstrument && !Backend_inInstrumentation(THREADID)) + { + Backend_Enter_Instrumentation (); + Probe_OpenMP_Named_Unlock_Entry(lock_ptr); + omp_unset_lock_real (lock_ptr); + Probe_OpenMP_Named_Unlock_Exit(); + Backend_Leave_Instrumentation (); + } + else if (omp_unset_lock_real != NULL) + { + omp_unset_lock_real (lock); + } + else + { + fprintf (stderr, PACKAGE_NAME": ERROR! omp_unset_lock is not hooked! Exiting!!\n"); + exit (-1); + } + +#if defined(DEBUG) + fprintf (stderr, PACKAGE_NAME": THREAD %d: omp_unset_lock ends\n", THREADID); +#endif +} +#else #if defined(PIC) int omp_get_thread_num (void) @@ -234,3 +420,4 @@ void omp_unset_lock (omp_lock_t *lock) } #endif /* PIC */ +#endif From 1d19c30a1115804e766d655db7002300cf24fee6 Mon Sep 17 00:00:00 2001 From: Adrian Munera Date: Thu, 5 Dec 2019 12:53:19 +0100 Subject: [PATCH 2/3] Code refactor Change-Id: I1bd5b07d41088046f8cc3860199fb3ee6dfd9430 --- config/macros.m4 | 5 +- config/show-config.m4 | 3 +- src/common/hwc_version.h | 2 +- src/common/utils.c | 23 +- src/merger/paraver/HardwareCounters.c | 12 +- src/merger/paraver/HardwareCounters.h | 9 +- src/merger/paraver/labels.c | 4 +- src/merger/paraver/trace_to_prv.c | 14 +- src/tracer/defines.h | 7 +- src/tracer/hwc/common_hwc.c | 14 +- src/tracer/hwc/common_hwc.h | 4 +- src/tracer/hwc/l4stat_hwc.c | 2 - src/tracer/wrappers/API/buffers.c | 4 +- src/tracer/wrappers/API/wrapper.c | 22 +- src/tracer/wrappers/OMP/gnu-libgomp.c | 3565 ++---------------------- src/tracer/wrappers/OMP/omp-common_c.c | 218 +- 16 files changed, 291 insertions(+), 3617 deletions(-) diff --git a/config/macros.m4 b/config/macros.m4 index 78c4ff27..e7fc3d60 100644 --- a/config/macros.m4 +++ b/config/macros.m4 @@ -924,7 +924,7 @@ AC_DEFUN([AX_PROG_L4STAT], AC_ARG_ENABLE(l4stat, AC_HELP_STRING( [--enable-l4stat], - [Enable PMAPI library to gather CPU performance counters] + [Enable L4STAT driver to gather CPU performance counters] ), [enable_l4stat="${enableval}"], [enable_l4stat="not_set"] @@ -932,11 +932,10 @@ AC_DEFUN([AX_PROG_L4STAT], if test "${enable_l4stat}" = "yes" ; then L4STAT_ENABLED="yes" - AC_DEFINE([PAPI_COUNTERS], [1], [PAPI is used as API to gain access to CPU hwc]) AC_DEFINE([L4STAT], [1], [L4STAT is used as API to gain access to CPU hwc]) fi - AM_CONDITIONAL(L4STAT, test "${L4STAT_ENABLED}" = "yes") + AM_CONDITIONAL(L4STAT, test "${L4STAT_ENABLED}" = "yes") ]) # AX_PROG_PMAPI diff --git a/config/show-config.m4 b/config/show-config.m4 index 058f94f4..b0fcfa61 100644 --- a/config/show-config.m4 +++ b/config/show-config.m4 @@ -43,14 +43,13 @@ AC_DEFUN([AX_SHOW_CONFIGURATION], echo Performance counters: yes if test "${PMAPI_ENABLED}" = "yes" ; then echo -e \\\tPerformance API: PMAPI - else if test "${PAPI_ENABLED}" = "yes"; then + elif test "${PAPI_ENABLED}" = "yes"; then echo -e \\\tPerformance API: PAPI echo -e \\\tPAPI home: ${PAPI_HOME} echo -e \\\tSampling support: ${PAPI_SAMPLING_ENABLED} else echo -e \\\tPerformance API: L4STAT fi - fi else echo Performance counters: no fi diff --git a/src/common/hwc_version.h b/src/common/hwc_version.h index 766b4f7c..623ccc88 100644 --- a/src/common/hwc_version.h +++ b/src/common/hwc_version.h @@ -30,7 +30,7 @@ # define PAPIv3 #else # if USE_HARDWARE_COUNTERS -# if defined(PAPI_COUNTERS) && !defined(L4STAT) +# if defined(PAPI_COUNTERS) # include # define PAPIv3 # elif defined(PMAPI_COUNTERS) diff --git a/src/common/utils.c b/src/common/utils.c index 50fe181c..96203da1 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -224,22 +224,6 @@ int __Extrae_Utils_append_from_to_file (const char *source, const char *destinat int __Extrae_Utils_rename_or_copy (char *origen, char *desti) { - -#if defined(OS_RTEMS) - if (strcmp(origen,desti) != 0) - { - if (remove(desti) != 0) - { - if (errno != ENOENT) - { - fprintf (stderr, PACKAGE_NAME": Error while trying to remove %s \n", desti); - fflush(stderr); - return -1; - } - } - } - else return 0; -#endif if (rename (origen, desti) == -1) { if (errno == EXDEV) @@ -293,6 +277,13 @@ int __Extrae_Utils_rename_or_copy (char *origen, char *desti) /* Remove the files */ unlink (origen); } +#if defined (OS_RTEMS) + else if (errno == EEXIST) + { + if (remove(desti) != -1) + __Extrae_Utils_rename_or_copy (origen, desti); + } +#endif else { perror("rename"); diff --git a/src/merger/paraver/HardwareCounters.c b/src/merger/paraver/HardwareCounters.c index 80e92417..de4cd696 100644 --- a/src/merger/paraver/HardwareCounters.c +++ b/src/merger/paraver/HardwareCounters.c @@ -84,7 +84,7 @@ int HardwareCounters_Emit (int ptask, int task, int thread, However, we must track the value of counters if SAMPLING_SUPPORT */ if (Sthread->last_hw_group_change == time && Sthread->HWCChange_count == 1) { -#if defined(PAPI_COUNTERS) && defined (SAMPLING_SUPPORT) +#if defined(PAPI_COUNTERS) || defined(L4STAT) && defined (SAMPLING_SUPPORT) for (cnt = 0; cnt < MAX_HWC; cnt++) if (Sthread->HWCSets[set_id][cnt] != NO_COUNTER && Sthread->HWCSets[Sthread->current_HWCSet][cnt] != SAMPLE_COUNTER) @@ -110,7 +110,7 @@ int HardwareCounters_Emit (int ptask, int task, int thread, } else if (Sthread->last_hw_group_change == time && Sthread->HWCChange_count > 1) { -#if defined(PAPI_COUNTERS) && defined (SAMPLING_SUPPORT) +#if defined(PAPI_COUNTERS) || defined(L4STAT) && defined (SAMPLING_SUPPORT) for (cnt = 0; cnt < MAX_HWC; cnt++) if (Sthread->HWCSets[set_id][cnt] != NO_COUNTER && Sthread->HWCSets[Sthread->current_HWCSet][cnt] != SAMPLE_COUNTER) @@ -123,8 +123,8 @@ int HardwareCounters_Emit (int ptask, int task, int thread, { /* If using PAPI, they can be stored in absolute or relative manner, depending whether sampling was activated or not */ -#if defined(PAPI_COUNTERS) -# if defined(SAMPLING_SUPPORT) && !defined(OS_RTEMS) +#if defined (PAPI_COUNTERS) || defined(L4STAT) +# if defined(SAMPLING_SUPPORT) && !defined(L4STAT) if (Sthread->HWCSets[set_id][cnt] != NO_COUNTER && Sthread->HWCSets[Sthread->current_HWCSet][cnt] != SAMPLE_COUNTER) # else @@ -135,7 +135,7 @@ int HardwareCounters_Emit (int ptask, int task, int thread, the previous read value from the current PAPI_read because it's always adding */ -# if defined(SAMPLING_SUPPORT) && !defined(OS_RTEMS) +# if defined(SAMPLING_SUPPORT) && !defined(L4STAT) /* Protect when counters are incorrect (major timestamp, lower counter value) */ if (Event->HWCValues[cnt] >= Sthread->counters[cnt]) { @@ -346,7 +346,7 @@ void HardwareCounters_Change (int ptask, int task, int thread, { #if defined(PMAPI_COUNTERS) outtypes[cnt+1] = HWC_COUNTER_TYPE(cnt, Sthread->HWCSets[newSet][cnt]); -#elif defined(PAPI_COUNTERS) +#elif defined(PAPI_COUNTERS) || defined(L4STAT) outtypes[cnt+1] = Sthread->HWCSets_types[newSet][cnt]; #endif outvalues[cnt+1] = 0; diff --git a/src/merger/paraver/HardwareCounters.h b/src/merger/paraver/HardwareCounters.h index ca158293..1ceb5dc2 100644 --- a/src/merger/paraver/HardwareCounters.h +++ b/src/merger/paraver/HardwareCounters.h @@ -29,7 +29,7 @@ #include "num_hwc.h" #include "hwc_version.h" #include "record.h" -#if !defined(L4STAT) +#if defined(PAPI_COUNTERS) #include "papiStdEventDefs.h" #endif #if !USE_HARDWARE_COUNTERS @@ -43,14 +43,15 @@ * per tant, nomes cal tenir en compte el byte mes baix per * no tenir numeros inmensos. */ -#if defined(PAPI_COUNTERS) +# if defined(L4STAT) +# define HWC_L4STAT_BASE 72000000 +# define HWC_COUNTER_TYPE(x) HWC_L4STAT_BASE + ((x & 0x000000FF)) +#elif defined(PAPI_COUNTERS) # if defined(PAPIv2) # define HWC_COUNTER_TYPE(x) (HWC_BASE + (x & 0x000000FF)) # elif defined(PAPIv3) # define HWC_COUNTER_TYPE(x) \ (x&PAPI_NATIVE_MASK)?(HWC_BASE_NATIVE + (x & 0x0000FFFF)):(HWC_BASE + (x & 0x0000FFFF)) -# elif defined(L4STAT) -# define HWC_COUNTER_TYPE(x) ((x & 0xFFFFFFFF)) # endif #elif defined(PMAPI_COUNTERS) # define HWC_COUNTER_TYPE(cnt,x) (HWC_BASE + cnt*1000 + x) diff --git a/src/merger/paraver/labels.c b/src/merger/paraver/labels.c index fb872838..d9bf7f2a 100644 --- a/src/merger/paraver/labels.c +++ b/src/merger/paraver/labels.c @@ -422,7 +422,7 @@ static int Exist_Counter (fcounter_t *fcounter, long long EvCnt) static void HWC_PARAVER_Labels (FILE * pcfFD) { -#if defined(PAPI_COUNTERS) +#if defined (PAPI_COUNTERS) || defined(L4STAT) struct fcounter_t *fcounter=NULL; #elif defined(PMAPI_COUNTERS) pm_info2_t ProcessorMetric_Info; /* On AIX pre 5.3 it was pm_info_t */ @@ -450,7 +450,7 @@ static void HWC_PARAVER_Labels (FILE * pcfFD) { if (ptmp->Traced[cnt]) { -#if defined(PAPI_COUNTERS) +#if defined(PAPI_COUNTERS) || defined(L4STAT) if (!Exist_Counter(fcounter,ptmp->Events[cnt])) { unsigned position; diff --git a/src/merger/paraver/trace_to_prv.c b/src/merger/paraver/trace_to_prv.c index 638957b1..159b1ee0 100644 --- a/src/merger/paraver/trace_to_prv.c +++ b/src/merger/paraver/trace_to_prv.c @@ -260,7 +260,6 @@ int Paraver_ProcessTraceFiles (unsigned long nfiles, char PROGRAM_NAME[256]; char PATH_NAME[256]; char prvfile[256]; - int binary_exists=0; str = getenv ("EXTRAE_PROGRAM_NAME"); path = getenv ("EXTRAE_FINAL_DIR"); @@ -278,13 +277,12 @@ int Paraver_ProcessTraceFiles (unsigned long nfiles, strcat(prvfile,PROGRAM_NAME); #if defined(HAVE_BFD) - if (__Extrae_Utils_file_exists(prvfile)){ - binary_exists=1; + if (!__Extrae_Utils_file_exists(prvfile)){ + fprintf (stdout, "mpi2prv: WARNING binary file can not be found at the NFS mounted folder, calltrace info (function names) will be empty \n"); + set_option_dump_Addresses(FALSE); } - else set_option_dump_Addresses(FALSE); -#else - binary_exists=1; #endif + strcat(prvfile,".prv\0"); set_merge_OutputTraceName (prvfile); set_merge_GivenTraceName (TRUE); @@ -751,10 +749,6 @@ int Paraver_ProcessTraceFiles (unsigned long nfiles, { if (error == 0) { -#if defined(OS_RTEMS) - if(!binary_exists) - fprintf (stdout, "mpi2prv: WARNING binary file can not be found at the NFS mounted folder, calltrace info (function names) will be empty \n"); -#endif fprintf (stdout, "mpi2prv: Congratulations! %s has been generated.\n", get_merge_OutputTraceName()); } else diff --git a/src/tracer/defines.h b/src/tracer/defines.h index b563a430..08b11398 100644 --- a/src/tracer/defines.h +++ b/src/tracer/defines.h @@ -51,13 +51,14 @@ #else /* HAVE_MPI */ /* If we don't have MPI, rely on FC_FUNC if web have detected at configure time! */ -#if !defined(OS_RTEMS) # if defined(FC_FUNC) # define CtoF77(x) FC_FUNC(x,x) # else -# error "Error! Not defined FC_FUNC, how do we deal with Fortran symbols?" +# if !defined(OS_RTEMS) +# error "Error! Not defined FC_FUNC, how do we deal with Fortran symbols?" +# endif # endif -#endif + #endif /* HAVE_MPI */ #endif diff --git a/src/tracer/hwc/common_hwc.c b/src/tracer/hwc/common_hwc.c index 53ce169e..00fded9b 100644 --- a/src/tracer/hwc/common_hwc.c +++ b/src/tracer/hwc/common_hwc.c @@ -75,8 +75,8 @@ int AllHWCs = 0; /* Count of all the different counters from /*------------------------------------------------ Static Variables ---------*/ -#if defined(PAPI_COUNTERS) && !defined(PAPIv3) && !defined(L4STAT) -# error "-DNEW_HWC_SYSTEM requires PAPI v3 support or L4STAT" +#if defined(PAPI_COUNTERS) && !defined(PAPIv3) +# error "-DNEW_HWC_SYSTEM requires PAPI v3 support" #endif struct HWC_Set_t *HWC_sets = NULL; @@ -335,10 +335,10 @@ void HWC_Initialize (int options) HWC_current_glopsbegin = (unsigned long long *)malloc(sizeof(unsigned long long) * num_threads); ASSERT(HWC_current_glopsbegin != NULL, "Cannot allocate memory for HWC_current_glopsbegin"); -//L4STAT must parse enviorment variables before initializing the HWCs +//L4STAT must parse enviorment variables before initializing the HWCs, also the HWC_current_* arrays must be allocated before #if !defined(L4STAT) HWCBE_INITIALIZE(options); - #endif +#endif } /** @@ -428,7 +428,7 @@ void HWC_Restart_Counters (int old_num_threads, int new_num_threads) { int i; -#if defined(PAPI_COUNTERS) && !defined(L4STAT) +#if defined(PAPI_COUNTERS) for (i = 0; i < HWC_num_sets; i++) HWCBE_PAPI_Allocate_eventsets_per_thread (i, old_num_threads, new_num_threads); #endif @@ -576,6 +576,10 @@ void HWC_Parse_Env_Config (int task_id) numofcounters = __Extrae_Utils_explode (getenv("EXTRAE_COUNTERS"), ",", &setofcounters); HWC_Add_Set (1, task_id, numofcounters, setofcounters, getenv("EXTRAE_COUNTERS_DOMAIN"), 0, 0, 0, NULL, 0); + +#if defined(L4STAT) + HWCBE_INITIALIZE(0); +#endif } /** diff --git a/src/tracer/hwc/common_hwc.h b/src/tracer/hwc/common_hwc.h index 870994de..e2291287 100644 --- a/src/tracer/hwc/common_hwc.h +++ b/src/tracer/hwc/common_hwc.h @@ -35,7 +35,7 @@ struct HWC_Set_t { -#if defined(PAPI_COUNTERS) && !defined(L4STAT) +#if defined(PAPI_COUNTERS) int domain; int *eventsets; #elif defined(PMAPI_COUNTERS) @@ -106,7 +106,7 @@ extern int * HWC_current_set; /*------------------------------------------------ Backends access layer ----*/ -#if defined(PAPI_COUNTERS) && !defined(L4STAT) /* -------------------- PAPI Backend -------------*/ +#if defined(PAPI_COUNTERS) /* -------------------- PAPI Backend -------------*/ # include "papi_hwc.h" diff --git a/src/tracer/hwc/l4stat_hwc.c b/src/tracer/hwc/l4stat_hwc.c index 8e72b97e..e597b8bf 100644 --- a/src/tracer/hwc/l4stat_hwc.c +++ b/src/tracer/hwc/l4stat_hwc.c @@ -171,8 +171,6 @@ int HWCBE_L4STAT_Add_Set(int pretended_set, int rank, int ncounters, char **coun HWC_sets[num_set].change_type = CHANGE_NEVER; - //HWCBE_PAPI_Allocate_eventsets_per_thread (num_set, 0, Backend_getNumberOfThreads()); - /* We validate this set */ HWC_num_sets++; diff --git a/src/tracer/wrappers/API/buffers.c b/src/tracer/wrappers/API/buffers.c index e86621ab..ea2b455a 100644 --- a/src/tracer/wrappers/API/buffers.c +++ b/src/tracer/wrappers/API/buffers.c @@ -489,7 +489,7 @@ int Buffer_Flush(Buffer_t *buffer) DataBlocks_t *db = new_DataBlocks (buffer); event_t *head = NULL, *tail = NULL; int num_flushed, overflow; -#if defined(ARCH_SPARC64) || defined(OS_RTEMS) +#if defined(ARCH_SPARC64) || defined(ARCH_SPARC) ssize_t r; #endif @@ -503,7 +503,7 @@ int Buffer_Flush(Buffer_t *buffer) num_flushed = Buffer_GetFillCount(buffer); CIRCULAR_STEP (tail, num_flushed, buffer->FirstEvt, buffer->LastEvt, &overflow); -#if !defined(ARCH_SPARC64) && !defined(OS_RTEMS) +#if !defined(ARCH_SPARC64) && !defined(ARCH_SPARC) # if defined(HAVE_ONLINE) /* Select events depending on the mask */ diff --git a/src/tracer/wrappers/API/wrapper.c b/src/tracer/wrappers/API/wrapper.c index aae10ff0..cca5db59 100644 --- a/src/tracer/wrappers/API/wrapper.c +++ b/src/tracer/wrappers/API/wrapper.c @@ -403,11 +403,7 @@ event_t *circular_HEAD; static void Extrae_getExecutableInfo (void); #if defined(EMBED_MERGE_IN_TRACE) - #if defined(OS_RTEMS) - int MergeAfterTracing = TRUE; - #else - int MergeAfterTracing = FALSE; - #endif +int MergeAfterTracing = FALSE; #endif static int AppendingEventsToGivenPID = FALSE; @@ -627,9 +623,6 @@ static int read_environment_variables (int me) { HWC_Initialize (0); HWC_Parse_Env_Config (me); -#if defined(OS_RTEMS) - HWCBE_INITIALIZE(0); -#endif } #endif @@ -974,10 +967,18 @@ static int read_environment_variables (int me) } } + str = getenv ("EXTRAE_MERGE_AFTER_TRACING"); + if (str != NULL && (strcmp (str, "1") == 0)) + { + if (me == 0) + fprintf (stdout, PACKAGE_NAME": Merge after tracing active.\n"); + MergeAfterTracing = TRUE; + } + /* Add sampling capabilities */ #if defined(SAMPLING_SUPPORT) -#if !defined(OS_RTEMS) str = getenv ("EXTRAE_SAMPLING_PERIOD"); + #if !defined(OS_RTEMS) if (str != NULL) { unsigned long long sampling_period = __Extrae_Utils_getTimeFromStr ( @@ -1022,7 +1023,6 @@ static int read_environment_variables (int me) if (getenv ("EXTRAE_SAMPLING_CALLER") != NULL) Parse_Callers (me, getenv("EXTRAE_SAMPLING_CALLER"), CALLER_SAMPLING); #else - str = getenv ("EXTRAE_SAMPLING_PERIOD"); if(str!=NULL) setTimeSampling(atoi(str)); #endif @@ -2608,7 +2608,7 @@ void Backend_Enter_Instrumentation () if (Trace_Mode_FirstMode(thread)) Trace_Mode_Change (thread, current_time); -#if defined(PAPI_COUNTERS) || defined(PMAPI_COUNTERS) +#if defined(PAPI_COUNTERS) || defined(PMAPI_COUNTERS) || defined(L4STAT) /* Must change counters? check only at detail tracing, at bursty tracing it is leveraged to the mpi macros at BURSTS_MODE_TRACE_MPIEVENT */ if (CURRENT_TRACE_MODE(thread) == TRACE_MODE_DETAIL) diff --git a/src/tracer/wrappers/OMP/gnu-libgomp.c b/src/tracer/wrappers/OMP/gnu-libgomp.c index b85404e4..3e477318 100644 --- a/src/tracer/wrappers/OMP/gnu-libgomp.c +++ b/src/tracer/wrappers/OMP/gnu-libgomp.c @@ -55,6 +55,17 @@ #define GOMP_API_4_0 "4.0" #define GOMP_API_4_5 "4.5" +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + +#if defined (OS_RTEMS) + #define GET_REAL_FUNCTION(f) __real_##f + #define WRAP(f) __wrap_##f +#else + #define GET_REAL_FUNCTION(f) dlsym (RTLD_NEXT, TOSTRING(f)); + #define WRAP(f) f +#endif + char *__GOMP_version = NULL; /* @@ -74,7 +85,9 @@ char *__GOMP_version = NULL; } \ } + #if defined(OS_RTEMS) + extern void __real_GOMP_atomic_start (void) __attribute__((weak)); extern void __real_GOMP_atomic_end (void) __attribute__((weak)); extern void __real_GOMP_barrier (void) __attribute__((weak)); @@ -111,8 +124,7 @@ extern void __real_GOMP_parallel_end (void) __attribute__((weak)); extern void __real_GOMP_barrier (void) __attribute__((weak)); extern void __real_GOMP_parallel (void*,void*,unsigned,unsigned int) __attribute__((weak)); - - +extern void __real_GOMP_parallel_sections_start (void*,void*,unsigned,unsigned) __attribute__((weak)); extern unsigned __real_GOMP_sections_start (unsigned count) __attribute__((weak)); extern unsigned __real_GOMP_sections_next (void) __attribute__((weak)); extern void __real_GOMP_sections_end (void) __attribute__((weak)); @@ -145,6 +157,13 @@ extern int __real_GOMP_loop_doacross_guided_start (unsigned ncounts, long *count extern int __real_GOMP_loop_doacross_runtime_start (unsigned ncounts, long *counts, long *istart, long *iend) __attribute__((weak)); extern void __real_GOMP_doacross_post (long *counts) __attribute__((weak)); extern void __real_GOMP_doacross_wait (long first, ...) __attribute__((weak)); +#endif + +#if defined(PIC) || defined(OS_RTEMS) + +/**************************************************************/ +/***** Added (or changed) in OpenMP 3.1 or prior versions *****/ +/**************************************************************/ static int gnu_libgomp_get_hook_points (int rank); @@ -206,8 +225,7 @@ static void (*GOMP_taskwait_real)(void) = NULL; /***** Added (or changed) in OpenMP 4.0 *****/ /********************************************/ -//~ static void (*GOMP_parallel_real)(void*, void*, unsigned, unsigned int) = NULL; -static void (*GOMP_parallel_real)(void*, void*, unsigned, unsigned int) = __real_GOMP_parallel; +static void (*GOMP_parallel_real)(void*,void*,unsigned,unsigned int) = NULL; static void (*GOMP_parallel_loop_static_real)(void*, void*, unsigned, long, long, long, long, unsigned) = NULL; static void (*GOMP_parallel_loop_dynamic_real)(void*, void*, unsigned, long, long, long, long, unsigned) = NULL; @@ -742,7 +760,7 @@ void callme_taskloop_cpyfn(void *arg, void *data) /***** Added (or changed) in OpenMP 3.1 or prior versions *****/ /**************************************************************/ -void __wrap_GOMP_atomic_start (void) +void WRAP(GOMP_atomic_start) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_atomic_start_real); @@ -771,7 +789,7 @@ void __wrap_GOMP_atomic_start (void) #endif } -void __wrap_GOMP_atomic_end (void) +void WRAP(GOMP_atomic_end) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_atomic_end_real); @@ -800,7 +818,7 @@ void __wrap_GOMP_atomic_end (void) #endif } -void __wrap_GOMP_barrier (void) +void WRAP(GOMP_barrier) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_barrier enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_barrier_real); @@ -829,7 +847,7 @@ void __wrap_GOMP_barrier (void) #endif } -void __wrap_GOMP_critical_start (void) +void WRAP(GOMP_critical_start) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_critical_start_real); @@ -858,7 +876,7 @@ void __wrap_GOMP_critical_start (void) #endif } -void __wrap_GOMP_critical_end (void) +void WRAP(GOMP_critical_end) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_critical_end_real); @@ -887,7 +905,7 @@ void __wrap_GOMP_critical_end (void) #endif } -void __wrap_GOMP_critical_name_start (void **pptr) +void WRAP(GOMP_critical_name_start) (void **pptr) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_start enter: @=%p args=(%p)\n", THREAD_LEVEL_VAR, GOMP_critical_name_start_real, pptr); @@ -916,7 +934,7 @@ void __wrap_GOMP_critical_name_start (void **pptr) #endif } -void __wrap_GOMP_critical_name_end (void **pptr) +void WRAP(GOMP_critical_name_end) (void **pptr) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_end enter: @=%p args=(%p)\n", THREAD_LEVEL_VAR, GOMP_critical_name_end_real, pptr); @@ -945,7 +963,7 @@ void __wrap_GOMP_critical_name_end (void **pptr) #endif } -int __wrap_GOMP_loop_static_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +int WRAP(GOMP_loop_static_start) (long start, long end, long incr, long chunk_size, long *istart, long *iend) { int res = 0; @@ -979,7 +997,7 @@ int __wrap_GOMP_loop_static_start (long start, long end, long incr, long chunk_s return res; } -int __wrap_GOMP_loop_dynamic_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +int WRAP(GOMP_loop_dynamic_start) (long start, long end, long incr, long chunk_size, long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1012,7 +1030,7 @@ int __wrap_GOMP_loop_dynamic_start (long start, long end, long incr, long chunk_ return res; } -int __wrap_GOMP_loop_guided_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +int WRAP(GOMP_loop_guided_start) (long start, long end, long incr, long chunk_size, long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1045,7 +1063,7 @@ int __wrap_GOMP_loop_guided_start (long start, long end, long incr, long chunk_s return res; } -int __wrap_GOMP_loop_runtime_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +int WRAP(GOMP_loop_runtime_start) (long start, long end, long incr, long chunk_size, long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1078,7 +1096,7 @@ int __wrap_GOMP_loop_runtime_start (long start, long end, long incr, long chunk_ return res; } -int __wrap_GOMP_loop_static_next (long *istart, long *iend) +int WRAP(GOMP_loop_static_next) (long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1110,7 +1128,7 @@ int __wrap_GOMP_loop_static_next (long *istart, long *iend) return res; } -int __wrap_GOMP_loop_dynamic_next (long *istart, long *iend) +int WRAP(GOMP_loop_dynamic_next) (long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1142,7 +1160,7 @@ int __wrap_GOMP_loop_dynamic_next (long *istart, long *iend) return res; } -int __wrap_GOMP_loop_guided_next (long *istart, long *iend) +int WRAP(GOMP_loop_guided_next) (long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1174,8 +1192,7 @@ int __wrap_GOMP_loop_guided_next (long *istart, long *iend) return res; } - -int __wrap_GOMP_loop_runtime_next (long *istart, long *iend) +int WRAP(GOMP_loop_runtime_next) (long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1207,7 +1224,7 @@ int __wrap_GOMP_loop_runtime_next (long *istart, long *iend) return res; } -int __wrap_GOMP_loop_ordered_static_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +int WRAP(GOMP_loop_ordered_static_start) (long start, long end, long incr, long chunk_size, long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1239,7 +1256,7 @@ int __wrap_GOMP_loop_ordered_static_start (long start, long end, long incr, long return res; } -int __wrap_GOMP_loop_ordered_dynamic_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +int WRAP(GOMP_loop_ordered_dynamic_start) (long start, long end, long incr, long chunk_size, long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1271,7 +1288,7 @@ int __wrap_GOMP_loop_ordered_dynamic_start (long start, long end, long incr, lon return res; } -int __wrap_GOMP_loop_ordered_guided_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +int WRAP(GOMP_loop_ordered_guided_start) (long start, long end, long incr, long chunk_size, long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1303,7 +1320,7 @@ int __wrap_GOMP_loop_ordered_guided_start (long start, long end, long incr, long return res; } -int __wrap_GOMP_loop_ordered_runtime_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) +int WRAP(GOMP_loop_ordered_runtime_start) (long start, long end, long incr, long chunk_size, long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1335,8 +1352,7 @@ int __wrap_GOMP_loop_ordered_runtime_start (long start, long end, long incr, lon return res; } - -int __wrap_GOMP_loop_ordered_static_next (long *istart, long *iend) +int WRAP(GOMP_loop_ordered_static_next) (long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1368,7 +1384,7 @@ int __wrap_GOMP_loop_ordered_static_next (long *istart, long *iend) return res; } -int __wrap_GOMP_loop_ordered_dynamic_next (long *istart, long *iend) +int WRAP(GOMP_loop_ordered_dynamic_next) (long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1400,7 +1416,7 @@ int __wrap_GOMP_loop_ordered_dynamic_next (long *istart, long *iend) return res; } -int __wrap_GOMP_loop_ordered_guided_next (long *istart, long *iend) +int WRAP(GOMP_loop_ordered_guided_next) (long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1432,7 +1448,7 @@ int __wrap_GOMP_loop_ordered_guided_next (long *istart, long *iend) return res; } -int __wrap_GOMP_loop_ordered_runtime_next (long *istart, long *iend) +int WRAP(GOMP_loop_ordered_runtime_next) (long *istart, long *iend) { int res = 0; #if defined(DEBUG) @@ -1465,7 +1481,7 @@ int __wrap_GOMP_loop_ordered_runtime_next (long *istart, long *iend) } void -__wrap_GOMP_parallel_loop_static_start(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size) +WRAP(GOMP_parallel_loop_static_start) (void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size) { #if defined(DEBUG) fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL @@ -1523,9 +1539,8 @@ __wrap_GOMP_parallel_loop_static_start(void (*fn)(void *), void *data, unsigned #endif } - void -__wrap_GOMP_parallel_loop_dynamic_start(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size) +WRAP(GOMP_parallel_loop_dynamic_start) (void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size) { #if defined(DEBUG) fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL @@ -1545,7 +1560,6 @@ __wrap_GOMP_parallel_loop_dynamic_start(void (*fn)(void *), void *data, unsigned * Change number of threads if specified by parallel directive only if * in a library not mixing runtimes. */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); Extrae_OpenMP_ParDO_Entry(); @@ -1585,7 +1599,7 @@ __wrap_GOMP_parallel_loop_dynamic_start(void (*fn)(void *), void *data, unsigned } void -__wrap_GOMP_parallel_loop_guided_start(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size) +WRAP(GOMP_parallel_loop_guided_start) (void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size) { #if defined(DEBUG) fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL @@ -1642,9 +1656,9 @@ __wrap_GOMP_parallel_loop_guided_start(void (*fn)(void *), void *data, unsigned "GOMP_parallel_loop_guided_start exit\n", THREAD_LEVEL_VAR); #endif } -// + void -__wrap_GOMP_parallel_loop_runtime_start(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr) +WRAP(GOMP_parallel_loop_runtime_start) (void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL @@ -1702,7 +1716,7 @@ __wrap_GOMP_parallel_loop_runtime_start(void (*fn)(void *), void *data, unsigned #endif } -void __wrap_GOMP_loop_end (void) +void WRAP(GOMP_loop_end) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_loop_end_real); @@ -1715,7 +1729,7 @@ void __wrap_GOMP_loop_end (void) Extrae_OpenMP_Join_Wait_Entry(); GOMP_loop_end_real(); Extrae_OpenMP_Join_Wait_Exit(); - Extrae_OpenMP_DO_Exit (); + Extrae_OpenMP_DO_Exit (); } else if (GOMP_loop_end_real != NULL) { @@ -1732,8 +1746,7 @@ void __wrap_GOMP_loop_end (void) #endif } - -void __wrap_GOMP_loop_end_nowait (void) +void WRAP(GOMP_loop_end_nowait) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end_nowait enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_loop_end_nowait_real); @@ -1746,7 +1759,7 @@ void __wrap_GOMP_loop_end_nowait (void) Extrae_OpenMP_Join_NoWait_Entry(); GOMP_loop_end_nowait_real(); Extrae_OpenMP_Join_NoWait_Exit(); - Extrae_OpenMP_DO_Exit (); + Extrae_OpenMP_DO_Exit (); } else if (GOMP_loop_end_nowait_real != NULL) { @@ -1762,8 +1775,8 @@ void __wrap_GOMP_loop_end_nowait (void) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end_nowait exit\n", THREAD_LEVEL_VAR); #endif } -// -void __wrap_GOMP_ordered_start (void) + +void WRAP(GOMP_ordered_start) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_ordered_start_real); @@ -1792,7 +1805,7 @@ void __wrap_GOMP_ordered_start (void) #endif } -void __wrap_GOMP_ordered_end (void) +void WRAP(GOMP_ordered_end) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_ordered_end_real); @@ -1822,9 +1835,8 @@ void __wrap_GOMP_ordered_end (void) } void -__wrap_GOMP_parallel_start(void (*fn)(void *), void *data, unsigned num_threads) +WRAP(GOMP_parallel_start) (void (*fn)(void *), void *data, unsigned num_threads) { - //fprintf("Start parallel instrument \n"); #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_parallel_start enter: @=%p args=(%p %p %u)\n", @@ -1873,7 +1885,7 @@ __wrap_GOMP_parallel_start(void (*fn)(void *), void *data, unsigned num_threads) } void -__wrap_GOMP_parallel_end(void) +WRAP(GOMP_parallel_end)(void) { #if defined(DEBUG) fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL @@ -1915,8 +1927,8 @@ __wrap_GOMP_parallel_end(void) #endif } - -OMP_parallel_sections_start(void (*fn)(void *), void *data, unsigned num_threads, unsigned count) +void +WRAP(GOMP_parallel_sections_start)(void (*fn)(void *), void *data, unsigned num_threads, unsigned count) { #if defined(DEBUG) fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL @@ -1963,7 +1975,7 @@ OMP_parallel_sections_start(void (*fn)(void *), void *data, unsigned num_threads #endif } -unsigned __wrap_GOMP_sections_start (unsigned count) +unsigned WRAP(GOMP_sections_start) (unsigned count) { unsigned res = 0; #if defined(DEBUG) @@ -1995,7 +2007,7 @@ unsigned __wrap_GOMP_sections_start (unsigned count) return res; } -unsigned __wrap_GOMP_sections_next (void) +unsigned WRAP(GOMP_sections_next) (void) { unsigned res = 0; #if defined(DEBUG) @@ -2027,7 +2039,7 @@ unsigned __wrap_GOMP_sections_next (void) return res; } -void __wrap_GOMP_sections_end (void) +void WRAP(GOMP_sections_end) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_sections_end_real); @@ -2056,7 +2068,7 @@ void __wrap_GOMP_sections_end (void) #endif } -void __wrap_GOMP_sections_end_nowait (void) +void WRAP(GOMP_sections_end_nowait) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end_nowait enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_sections_end_nowait_real); @@ -2085,7 +2097,7 @@ void __wrap_GOMP_sections_end_nowait (void) #endif } -unsigned __wrap_GOMP_single_start (void) +unsigned WRAP(GOMP_single_start) (void) { unsigned res = 0; #if defined(DEBUG) @@ -2117,7 +2129,7 @@ unsigned __wrap_GOMP_single_start (void) return res; } -void __wrap_GOMP_taskwait (void) +void WRAP(GOMP_taskwait) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskwait enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_taskwait_real); @@ -2148,12 +2160,12 @@ void __wrap_GOMP_taskwait (void) #endif } -///********************************************/ -///***** Added (or changed) in OpenMP 4.0 *****/ -///********************************************/ -// +/********************************************/ +/***** Added (or changed) in OpenMP 4.0 *****/ +/********************************************/ + void -__wrap_GOMP_parallel(void (*fn)(void *), void *data, unsigned num_threads, unsigned int flags) +WRAP(GOMP_parallel) (void (*fn)(void *), void *data, unsigned num_threads, unsigned int flags) { #if defined(DEBUG) fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL @@ -2189,7 +2201,6 @@ __wrap_GOMP_parallel(void (*fn)(void *), void *data, unsigned num_threads, unsig Extrae_OpenMP_ParRegion_Entry(); Extrae_OpenMP_EmitTaskStatistics(); - GOMP_parallel_real(callme_par, &par_helper, num_threads, flags); Extrae_OpenMP_ParRegion_Exit(); @@ -2218,9 +2229,8 @@ __wrap_GOMP_parallel(void (*fn)(void *), void *data, unsigned num_threads, unsig #endif } - void -__wrap_GOMP_parallel_loop_static(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size, unsigned flags) +WRAP(GOMP_parallel_loop_static) (void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size, unsigned flags) { #if defined(DEBUG) fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL @@ -2271,7 +2281,7 @@ __wrap_GOMP_parallel_loop_static(void (*fn)(void *), void *data, unsigned num_th } void -__wrap_GOMP_parallel_loop_dynamic(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size, unsigned flags) +WRAP(GOMP_parallel_loop_dynamic) (void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size, unsigned flags) { #if defined(DEBUG) fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL @@ -2320,7 +2330,8 @@ __wrap_GOMP_parallel_loop_dynamic(void (*fn)(void *), void *data, unsigned num_t #endif } -void __wrap_GOMP_parallel_loop_guided(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size, unsigned flags) +void +WRAP(GOMP_parallel_loop_guided) (void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size, unsigned flags) { #if defined(DEBUG) fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL @@ -2371,7 +2382,7 @@ void __wrap_GOMP_parallel_loop_guided(void (*fn)(void *), void *data, unsigned n } void -__wrap_GOMP_parallel_loop_runtime(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, unsigned flags) +WRAP(GOMP_parallel_loop_runtime) (void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, unsigned flags) { #if defined(DEBUG) fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL @@ -2422,7 +2433,7 @@ __wrap_GOMP_parallel_loop_runtime(void (*fn)(void *), void *data, unsigned num_t } void -__wrap_GOMP_parallel_sections(void (*fn) (void *), void *data, unsigned num_threads, unsigned count, unsigned flags) +WRAP(GOMP_parallel_sections) (void (*fn) (void *), void *data, unsigned num_threads, unsigned count, unsigned flags) { #if defined(DEBUG) fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL @@ -2479,7 +2490,7 @@ __wrap_GOMP_parallel_sections(void (*fn) (void *), void *data, unsigned num_thre } -void __wrap_GOMP_taskgroup_start (void) +void WRAP(GOMP_taskgroup_start) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_taskgroup_start_real); @@ -2509,7 +2520,7 @@ void __wrap_GOMP_taskgroup_start (void) #endif } -void __wrap_GOMP_taskgroup_end (void) +void WRAP(GOMP_taskgroup_end) (void) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_taskgroup_end_real); @@ -2539,18 +2550,17 @@ void __wrap_GOMP_taskgroup_end (void) #endif } -///********************************************/ -///***** Added (or changed) in OpenMP 4.5 *****/ -///********************************************/ - -///* -// * The prototype of GOMP_task changed in 4.0 to add a new parameter 'depend', -// * and again in 4.5 to add 'priority'. We define this prototype as receiving -// * varargs, and we check the runtime version to decide with how many parameters -// * we will make the call to the real function. -// */ +/********************************************/ +/***** Added (or changed) in OpenMP 4.5 *****/ +/********************************************/ -void __wrap_GOMP_task (void (*fn)(void *), void *data, void (*cpyfn)(void *, void *), long arg_size, long arg_align, int if_clause, unsigned flags, ...) +/* + * The prototype of GOMP_task changed in 4.0 to add a new parameter 'depend', + * and again in 4.5 to add 'priority'. We define this prototype as receiving + * varargs, and we check the runtime version to decide with how many parameters + * we will make the call to the real function. + */ +void WRAP(GOMP_task) (void (*fn)(void *), void *data, void (*cpyfn)(void *, void *), long arg_size, long arg_align, int if_clause, unsigned flags, ...) { void **depend = NULL; int priority = 0; @@ -2569,8 +2579,8 @@ void __wrap_GOMP_task (void (*fn)(void *), void *data, void (*cpyfn)(void *, voi Extrae_OpenMP_Task_Entry (fn); Extrae_OpenMP_Notify_NewInstantiatedTask(); - /* - * Helpers for GOMP_task don't use the array of active helpers, as we know + /* + * Helpers for GOMP_task don't use the array of active helpers, as we know * that we can free them right away after the task is executed. */ struct task_helper_t *task_helper = (struct task_helper_t *) malloc(sizeof(struct task_helper_t)); @@ -2585,7 +2595,7 @@ void __wrap_GOMP_task (void (*fn)(void *), void *data, void (*cpyfn)(void *, voi cpyfn (arg, data); task_helper->data = arg; // Saved for deallocation purposes, arg is not valid since includes offset - task_helper->buf = buf; + task_helper->buf = buf; } else { @@ -2646,14 +2656,14 @@ void __wrap_GOMP_task (void (*fn)(void *), void *data, void (*cpyfn)(void *, voi } -///* -// * taskloop_helper ↴ data ↴ -// * ---------------------------------------- -// * | *cpyfn | *fn | long start | long end | -// * ---------------------------------------- -// */ +/* + * taskloop_helper ↴ data ↴ + * ---------------------------------------- + * | *cpyfn | *fn | long start | long end | + * ---------------------------------------- + */ -void __wrap_GOMP_taskloop (void *fn, void *data, void *cpyfn, long arg_size, long arg_align, unsigned flags, unsigned long num_tasks, int priority, long start, long end, long step) +void WRAP(GOMP_taskloop) (void *fn, void *data, void *cpyfn, long arg_size, long arg_align, unsigned flags, unsigned long num_tasks, int priority, long start, long end, long step) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskloop enter: @=%p args=(%p %p %p %ld %ld %u %lu %d %ld %ld %ld)\n", THREAD_LEVEL_VAR, GOMP_taskloop_real, fn, data, cpyfn, arg_size, arg_align, flags, num_tasks, priority, start, end, step); @@ -2664,7 +2674,7 @@ void __wrap_GOMP_taskloop (void *fn, void *data, void *cpyfn, long arg_size, lon if (TRACE(GOMP_taskloop_real) && (getTrace_OMPTaskloop())) { - /* Store global pointers to fn and data. This is a fallback mechanism in case the runtime changes data, + /* Store global pointers to fn and data. This is a fallback mechanism in case the runtime changes data, * breaking our injected pointers. Using the global pointers only allows 1 simultaneous taskloop. */ taskloop_global_fn = fn; @@ -2694,7 +2704,7 @@ void __wrap_GOMP_taskloop (void *fn, void *data, void *cpyfn, long arg_size, lon { GOMP_taskloop_real (callme_taskloop_suffix_helper, taskloop_helper+payload, callme_taskloop_cpyfn, arg_size+payload, arg_align, flags, num_tasks, priority, start, end, step); } - else + else { GOMP_taskloop_real (callme_taskloop_prefix_helper, taskloop_helper+payload, cpyfn, arg_size, arg_align, flags, num_tasks, priority, start, end, step); } @@ -2746,7 +2756,7 @@ void __wrap_GOMP_taskloop (void *fn, void *data, void *cpyfn, long arg_size, lon #endif } -int __wrap_GOMP_loop_doacross_static_start (unsigned ncounts, long *counts, long chunk_size, long *istart, long *iend) +int WRAP(GOMP_loop_doacross_static_start) (unsigned ncounts, long *counts, long chunk_size, long *istart, long *iend) { int res; #if defined(DEBUG) @@ -2780,7 +2790,7 @@ int __wrap_GOMP_loop_doacross_static_start (unsigned ncounts, long *counts, long return res; } -int __wrap_GOMP_loop_doacross_dynamic_start (unsigned ncounts, long *counts, long chunk_size, long *istart, long *iend) +int WRAP(GOMP_loop_doacross_dynamic_start) (unsigned ncounts, long *counts, long chunk_size, long *istart, long *iend) { int res; #if defined(DEBUG) @@ -2814,7 +2824,7 @@ int __wrap_GOMP_loop_doacross_dynamic_start (unsigned ncounts, long *counts, lon return res; } -int __wrap_GOMP_loop_doacross_guided_start (unsigned ncounts, long *counts, long chunk_size, long *istart, long *iend) +int WRAP(GOMP_loop_doacross_guided_start) (unsigned ncounts, long *counts, long chunk_size, long *istart, long *iend) { int res; #if defined(DEBUG) @@ -2848,7 +2858,7 @@ int __wrap_GOMP_loop_doacross_guided_start (unsigned ncounts, long *counts, long return res; } -int __wrap_GOMP_loop_doacross_runtime_start (unsigned ncounts, long *counts, long *istart, long *iend) +int WRAP(GOMP_loop_doacross_runtime_start) (unsigned ncounts, long *counts, long *istart, long *iend) { int res; #if defined(DEBUG) @@ -2882,7 +2892,7 @@ int __wrap_GOMP_loop_doacross_runtime_start (unsigned ncounts, long *counts, lon return res; } -void __wrap_GOMP_doacross_post (long *counts) +void WRAP(GOMP_doacross_post) (long *counts) { #if defined(DEBUG) fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_doacross_post enter: @=%p args=(%p)\n", THREAD_LEVEL_VAR, GOMP_doacross_post_real, counts); @@ -2911,13 +2921,13 @@ void __wrap_GOMP_doacross_post (long *counts) #endif } -///* -// * The body of GOMP_doacross_wait needs a switch with as many cases as possible -// * values of 'ncounts'. These cases are generated dynamically with the script -// * 'genstubs-libgomp.sh' up to a maximum of DOACROSS_MAX_NESTING, defined in -// * that script. -// */ -void __wrap_GOMP_doacross_wait (long first, ...) +/* + * The body of GOMP_doacross_wait needs a switch with as many cases as possible + * values of 'ncounts'. These cases are generated dynamically with the script + * 'genstubs-libgomp.sh' up to a maximum of DOACROSS_MAX_NESTING, defined in + * that script. + */ +void WRAP(GOMP_doacross_wait) (long first, ...) { unsigned i = 0; long args[MAX_DOACROSS_ARGS]; @@ -2935,11 +2945,11 @@ void __wrap_GOMP_doacross_wait (long first, ...) if (TRACE(GOMP_doacross_wait_real)) { va_start(ap, first); - for (i = 0; i < ncounts; i++) - { - args[i] = va_arg(ap, long); - } - va_end(ap); + for (i = 0; i < ncounts; i++) + { + args[i] = va_arg(ap, long); + } + va_end(ap); Extrae_OpenMP_Ordered_Wait_Entry(); @@ -2950,7 +2960,7 @@ void __wrap_GOMP_doacross_wait (long first, ...) fprintf (stderr, PACKAGE_NAME": ERROR! Unhandled GOMP_doacross_wait call with %d arguments! Re-run the script 'genstubs-libgomp.sh' increasing the value of DOACROSS_MAX_NESTING. Quitting!\n", ncounts); exit(-1); break; - } + } Extrae_OpenMP_Ordered_Wait_Exit(); } @@ -3006,7 +3016,20 @@ static int gnu_libgomp_get_hook_points (int rank) int count = 0; UNREFERENCED_PARAMETER(rank); +#if defined (OS_RTEMS) +if ((__GOMP_version = getenv("EXTRAE___GOMP_version")) != NULL) { + if ((strcmp(__GOMP_version, GOMP_API_4_5) != 0) && + (strcmp(__GOMP_version, GOMP_API_4_0) != 0) && + (strcmp(__GOMP_version, GOMP_API_3_1) != 0)) { + fprintf(stderr, PACKAGE_NAME": ERROR! Unsupported GOMP version (%s). Valid versions are: 3.1, 4.0 and 4.5. Exiting ...\n", __GOMP_version); + exit (-1); + } + } + else{ + printf("GOMP version not found, please specify the EXTRAE___GOMP_version environment variable"); + } +#else // Detect the OpenMP version supported by the runtime if ((__GOMP_version = getenv("EXTRAE___GOMP_version")) != NULL) { if ((strcmp(__GOMP_version, GOMP_API_4_5) != 0) && @@ -3015,216 +3038,220 @@ static int gnu_libgomp_get_hook_points (int rank) fprintf(stderr, PACKAGE_NAME": ERROR! Unsupported GOMP version (%s). Valid versions are: 3.1, 4.0 and 4.5. Exiting ...\n", __GOMP_version); exit (-1); } + } else if (dlsym(RTLD_NEXT, "GOMP_taskloop") != NULL) { + __GOMP_version = GOMP_API_4_5; + } else if (dlsym(RTLD_NEXT, "GOMP_taskgroup_start") != NULL) { + __GOMP_version = GOMP_API_4_0; + } else { + __GOMP_version = GOMP_API_3_1; } + if (TASKID == 0) { fprintf (stdout, PACKAGE_NAME": Detected GOMP version is %s\n", __GOMP_version); } +#endif + /**********************/ /***** OpenMP 3.1 *****/ /**********************/ /* Obtain @ for GOMP_atomic_start */ GOMP_atomic_start_real = - (void(*)(void)) __real_GOMP_atomic_start; + (void(*)(void)) GET_REAL_FUNCTION(GOMP_atomic_start); INC_IF_NOT_NULL(GOMP_atomic_start_real,count); /* Obtain @ for GOMP_atomic_end */ GOMP_atomic_end_real = - (void(*)(void)) __real_GOMP_atomic_end; + (void(*)(void)) GET_REAL_FUNCTION(GOMP_atomic_end); INC_IF_NOT_NULL(GOMP_atomic_end_real,count); /* Obtain @ for GOMP_barrier */ GOMP_barrier_real = - (void(*)(void)) __real_GOMP_barrier; // Wrap + (void(*)(void)) GET_REAL_FUNCTION(GOMP_barrier); INC_IF_NOT_NULL(GOMP_barrier_real,count); /* Obtain @ for GOMP_critical_enter */ GOMP_critical_start_real = - (void(*)(void)) __real_GOMP_critical_start; + (void(*)(void)) GET_REAL_FUNCTION(GOMP_critical_start); INC_IF_NOT_NULL(GOMP_critical_start_real,count); /* Obtain @ for GOMP_critical_end */ GOMP_critical_end_real = - (void(*)(void)) __real_GOMP_critical_end; + (void(*)(void)) GET_REAL_FUNCTION(GOMP_critical_end); INC_IF_NOT_NULL(GOMP_critical_end_real,count); /* Obtain @ for GOMP_critical_name_start */ GOMP_critical_name_start_real = - (void(*)(void**)) __real_GOMP_critical_name_start; + (void(*)(void**)) GET_REAL_FUNCTION(GOMP_critical_name_start); INC_IF_NOT_NULL(GOMP_critical_name_start_real,count); /* Obtain @ for GOMP_critical_name_end */ GOMP_critical_name_end_real = - (void(*)(void**)) __real_GOMP_critical_name_end; + (void(*)(void**)) GET_REAL_FUNCTION(GOMP_critical_name_end); INC_IF_NOT_NULL(GOMP_critical_name_end_real,count); /* Obtain @ for GOMP_loop_static_start */ GOMP_loop_static_start_real = - (int(*)(long,long,long,long,long*,long*)) __real_GOMP_loop_static_start; + (int(*)(long,long,long,long,long*,long*)) GET_REAL_FUNCTION(GOMP_loop_static_start); INC_IF_NOT_NULL(GOMP_loop_static_start_real,count); /* Obtain @ for GOMP_loop_dynamic_start */ GOMP_loop_dynamic_start_real = - (int(*)(long,long,long,long,long*,long*)) __real_GOMP_loop_dynamic_start; + (int(*)(long,long,long,long,long*,long*)) GET_REAL_FUNCTION(GOMP_loop_dynamic_start); INC_IF_NOT_NULL(GOMP_loop_dynamic_start_real,count); /* Obtain @ for GOMP_loop_guided_start */ GOMP_loop_guided_start_real = - (int(*)(long,long,long,long,long*,long*)) __real_GOMP_loop_guided_start; + (int(*)(long,long,long,long,long*,long*)) GET_REAL_FUNCTION(GOMP_loop_guided_start); INC_IF_NOT_NULL(GOMP_loop_guided_start_real,count); /* Obtain @ for GOMP_loop_runtime_start */ GOMP_loop_runtime_start_real = - (int(*)(long,long,long,long,long*,long*)) __real_GOMP_loop_runtime_start; + (int(*)(long,long,long,long,long*,long*)) GET_REAL_FUNCTION(GOMP_loop_runtime_start); INC_IF_NOT_NULL(GOMP_loop_runtime_start_real,count); /* Obtain @ for GOMP_loop_static_next */ GOMP_loop_static_next_real = - (int(*)(long*,long*)) __real_GOMP_loop_static_next; + (int(*)(long*,long*)) GET_REAL_FUNCTION(GOMP_loop_static_next); INC_IF_NOT_NULL(GOMP_loop_static_next_real,count); /* Obtain @ for GOMP_loop_dynamic_next */ GOMP_loop_dynamic_next_real = - (int(*)(long*,long*)) __real_GOMP_loop_dynamic_next; + (int(*)(long*,long*)) GET_REAL_FUNCTION(GOMP_loop_dynamic_next); INC_IF_NOT_NULL(GOMP_loop_dynamic_next_real,count); - /* Obtain @ for GOMP_loop_guided_next */ GOMP_loop_guided_next_real = - (int(*)(long*,long*)) __real_GOMP_loop_guided_next; + (int(*)(long*,long*)) GET_REAL_FUNCTION(GOMP_loop_guided_next); INC_IF_NOT_NULL(GOMP_loop_guided_next_real,count); /* Obtain @ for GOMP_loop_runtime_next */ GOMP_loop_runtime_next_real = - (int(*)(long*,long*)) __real_GOMP_loop_runtime_next; + (int(*)(long*,long*)) GET_REAL_FUNCTION(GOMP_loop_runtime_next); INC_IF_NOT_NULL(GOMP_loop_runtime_next_real,count); - /* Obtain @ for GOMP_loop_ordered_static_start */ GOMP_loop_ordered_static_start_real = - (int(*)(long, long, long, long, long *, long *)) __real_GOMP_loop_ordered_static_start; + (int(*)(long, long, long, long, long *, long *)) GET_REAL_FUNCTION(GOMP_loop_ordered_static_start); INC_IF_NOT_NULL(GOMP_loop_ordered_static_start_real, count); - /* Obtain @ for GOMP_loop_ordered_dynamic_start */ GOMP_loop_ordered_dynamic_start_real = - (int(*)(long, long, long, long, long *, long *)) __real_GOMP_loop_ordered_dynamic_start; + (int(*)(long, long, long, long, long *, long *)) GET_REAL_FUNCTION(GOMP_loop_ordered_dynamic_start); INC_IF_NOT_NULL(GOMP_loop_ordered_dynamic_start_real, count); /* Obtain @ for GOMP_loop_ordered_guided_start */ GOMP_loop_ordered_guided_start_real = - (int(*)(long, long, long, long, long *, long *)) __real_GOMP_loop_ordered_guided_start; + (int(*)(long, long, long, long, long *, long *)) GET_REAL_FUNCTION(GOMP_loop_ordered_guided_start); INC_IF_NOT_NULL(GOMP_loop_ordered_guided_start_real, count); /* Obtain @ for GOMP_loop_ordered_runtime_start */ GOMP_loop_ordered_runtime_start_real = - (int(*)(long, long, long, long, long *, long *))__real_GOMP_loop_ordered_runtime_start; + (int(*)(long, long, long, long, long *, long *)) GET_REAL_FUNCTION(GOMP_loop_ordered_runtime_start); INC_IF_NOT_NULL(GOMP_loop_ordered_runtime_start_real, count); /* Obtain @ for GOMP_loop_ordered_static_next */ GOMP_loop_ordered_static_next_real = - (int(*)(long*,long*)) __real_GOMP_loop_ordered_static_next; + (int(*)(long*,long*)) GET_REAL_FUNCTION(GOMP_loop_ordered_static_next); INC_IF_NOT_NULL(GOMP_loop_ordered_static_next_real,count); /* Obtain @ for GOMP_loop_ordered_dynamic_next */ GOMP_loop_ordered_dynamic_next_real = - (int(*)(long*,long*))__real_GOMP_loop_ordered_dynamic_next; + (int(*)(long*,long*)) GET_REAL_FUNCTION(GOMP_loop_ordered_dynamic_next); INC_IF_NOT_NULL(GOMP_loop_ordered_dynamic_next_real,count); /* Obtain @ for GOMP_loop_ordered_guided_next */ GOMP_loop_ordered_guided_next_real = - (int(*)(long*,long*)) __real_GOMP_loop_ordered_guided_next; + (int(*)(long*,long*)) GET_REAL_FUNCTION(GOMP_loop_ordered_guided_next); INC_IF_NOT_NULL(GOMP_loop_ordered_guided_next_real,count); /* Obtain @ for GOMP_loop_runtime_next */ GOMP_loop_ordered_runtime_next_real = - (int(*)(long*,long*)) __real_GOMP_loop_ordered_runtime_next; + (int(*)(long*,long*)) GET_REAL_FUNCTION(GOMP_loop_ordered_runtime_next); INC_IF_NOT_NULL(GOMP_loop_ordered_runtime_next_real,count); - /* Obtain @ for GOMP_parallel_loop_static_start */ GOMP_parallel_loop_static_start_real = - (void(*)(void*,void*,unsigned, long, long, long, long)) __real_GOMP_parallel_loop_static_start; + (void(*)(void*,void*,unsigned, long, long, long, long)) GET_REAL_FUNCTION(GOMP_parallel_loop_static_start); INC_IF_NOT_NULL(GOMP_parallel_loop_static_start_real,count); - /* Obtain @ for GOMP_parallel_loop_dynamic_start */ GOMP_parallel_loop_dynamic_start_real = - (void(*)(void*,void*,unsigned, long, long, long, long)) __real_GOMP_parallel_loop_dynamic_start; + (void(*)(void*,void*,unsigned, long, long, long, long)) GET_REAL_FUNCTION(GOMP_parallel_loop_dynamic_start); INC_IF_NOT_NULL(GOMP_parallel_loop_dynamic_start_real,count); /* Obtain @ for GOMP_parallel_loop_guided_start */ GOMP_parallel_loop_guided_start_real = - (void(*)(void*,void*,unsigned, long, long, long, long)) __real_GOMP_parallel_loop_guided_start; + (void(*)(void*,void*,unsigned, long, long, long, long)) GET_REAL_FUNCTION(GOMP_parallel_loop_guided_start); INC_IF_NOT_NULL(GOMP_parallel_loop_guided_start_real,count); /* Obtain @ for GOMP_parallel_loop_runtime_start */ GOMP_parallel_loop_runtime_start_real = - (void(*)(void*,void*,unsigned, long, long, long)) __real_GOMP_parallel_loop_runtime_start; + (void(*)(void*,void*,unsigned, long, long, long)) GET_REAL_FUNCTION(GOMP_parallel_loop_runtime_start); INC_IF_NOT_NULL(GOMP_parallel_loop_runtime_start_real,count); /* Obtain @ for GOMP_loop_end */ GOMP_loop_end_real = - (void(*)(void)) __real_GOMP_loop_end; + (void(*)(void)) GET_REAL_FUNCTION(GOMP_loop_end); INC_IF_NOT_NULL(GOMP_loop_end_real,count); /* Obtain @ for GOMP_loop_end_nowait */ GOMP_loop_end_nowait_real = - (void(*)(void)) __real_GOMP_loop_end_nowait; + (void(*)(void)) GET_REAL_FUNCTION(GOMP_loop_end_nowait); INC_IF_NOT_NULL(GOMP_loop_end_nowait_real,count); /* Obtain @ for GOMP_ordered_start */ - GOMP_ordered_start_real = (void(*)(void))__real_GOMP_ordered_start; + GOMP_ordered_start_real = (void(*)(void)) GET_REAL_FUNCTION(GOMP_ordered_start); INC_IF_NOT_NULL(GOMP_ordered_start_real,count); /* Obtain @ for GOMP_ordered_end */ - GOMP_ordered_end_real = (void(*)(void)) __real_GOMP_ordered_end; + GOMP_ordered_end_real = (void(*)(void)) GET_REAL_FUNCTION(GOMP_ordered_end); INC_IF_NOT_NULL(GOMP_ordered_end_real,count); /* Obtain @ for GOMP_parallel_start */ GOMP_parallel_start_real = - (void(*)(void*,void*,unsigned)) __real_GOMP_parallel_start; // Wrap + (void(*)(void*,void*,unsigned)) GET_REAL_FUNCTION(GOMP_parallel_start); INC_IF_NOT_NULL(GOMP_parallel_start_real,count); /* Obtain @ for GOMP_parallel_end */ GOMP_parallel_end_real = - (void(*)(void)) __real_GOMP_parallel_end; // Wrap + (void(*)(void)) GET_REAL_FUNCTION(GOMP_parallel_end); INC_IF_NOT_NULL(GOMP_parallel_end_real,count); /* Obtain @ for GOMP_parallel_sections_start */ - GOMP_parallel_sections_start_real = - (void(*)(void*,void*,unsigned,unsigned)) dlsym (RTLD_NEXT, "GOMP_parallel_sections_start"); + GOMP_parallel_sections_start_real = + (void(*)(void*,void*,unsigned,unsigned)) GET_REAL_FUNCTION(GOMP_parallel_sections_start); INC_IF_NOT_NULL(GOMP_parallel_sections_start_real,count); /* Obtain @ for GOMP_sections_start */ GOMP_sections_start_real = - (unsigned(*)(unsigned)) __real_GOMP_sections_start; + (unsigned(*)(unsigned)) GET_REAL_FUNCTION(GOMP_sections_start); INC_IF_NOT_NULL(GOMP_sections_start_real,count); /* Obtain @ for GOMP_sections_next */ GOMP_sections_next_real = - (unsigned(*)(void)) __real_GOMP_sections_next; + (unsigned(*)(void)) GET_REAL_FUNCTION(GOMP_sections_next); INC_IF_NOT_NULL(GOMP_sections_next_real,count); /* Obtain @ for GOMP_sections_end */ GOMP_sections_end_real = - (void(*)(void)) __real_GOMP_sections_end; + (void(*)(void)) GET_REAL_FUNCTION(GOMP_sections_end); INC_IF_NOT_NULL(GOMP_sections_end_real,count); /* Obtain @ for GOMP_sections_end_nowait */ GOMP_sections_end_nowait_real = - (void(*)(void)) __real_GOMP_sections_end_nowait; + (void(*)(void)) GET_REAL_FUNCTION(GOMP_sections_end_nowait); INC_IF_NOT_NULL(GOMP_sections_end_nowait_real,count); /* Obtain @ for GOMP_single_start */ GOMP_single_start_real = - (unsigned(*)(void)) __real_GOMP_single_start; // Wrap + (unsigned(*)(void)) GET_REAL_FUNCTION(GOMP_single_start); INC_IF_NOT_NULL(GOMP_single_start_real,count); /* Obtain @ for GOMP_taskwait */ - GOMP_taskwait_real = (void(*)(void)) __real_GOMP_taskwait; // Wrap + GOMP_taskwait_real = (void(*)(void)) GET_REAL_FUNCTION(GOMP_taskwait); INC_IF_NOT_NULL(GOMP_taskwait_real,count); /**********************/ @@ -3233,40 +3260,40 @@ static int gnu_libgomp_get_hook_points (int rank) /* Obtain @ for GOMP_parallel */ GOMP_parallel_real = - (void(*)(void*,void*,unsigned,unsigned int)) __real_GOMP_parallel; // Wrap + (void(*)(void*,void*,unsigned,unsigned int)) GET_REAL_FUNCTION(GOMP_parallel); INC_IF_NOT_NULL(GOMP_parallel_real,count); /* Obtain @ for GOMP_parallel_loop_static */ GOMP_parallel_loop_static_real = - (void(*)(void*, void*, unsigned, long, long, long, long, unsigned))__real_GOMP_parallel_loop_static; + (void(*)(void*, void*, unsigned, long, long, long, long, unsigned)) GET_REAL_FUNCTION(GOMP_parallel_loop_static); INC_IF_NOT_NULL(GOMP_parallel_loop_static_real,count); /* Obtain @ for GOMP_parallel_loop_dynamic */ GOMP_parallel_loop_dynamic_real = - (void(*)(void*, void*, unsigned, long, long, long, long, unsigned))__real_GOMP_parallel_loop_dynamic; + (void(*)(void*, void*, unsigned, long, long, long, long, unsigned)) GET_REAL_FUNCTION(GOMP_parallel_loop_dynamic); INC_IF_NOT_NULL(GOMP_parallel_loop_dynamic_real,count); /* Obtain @ for GOMP_parallel_loop_guided */ GOMP_parallel_loop_guided_real = - (void(*)(void*, void*, unsigned, long, long, long, long, unsigned))__real_GOMP_parallel_loop_guided; + (void(*)(void*, void*, unsigned, long, long, long, long, unsigned)) GET_REAL_FUNCTION(GOMP_parallel_loop_guided); INC_IF_NOT_NULL(GOMP_parallel_loop_guided_real,count); /* Obtain @ for GOMP_parallel_loop_runtime */ GOMP_parallel_loop_runtime_real = - (void(*)(void*, void*, unsigned, long, long, long, unsigned)) __real_GOMP_parallel_loop_runtime; + (void(*)(void*, void*, unsigned, long, long, long, unsigned)) GET_REAL_FUNCTION(GOMP_parallel_loop_runtime); INC_IF_NOT_NULL(GOMP_parallel_loop_runtime_real,count); /* Obtain @ for GOMP_parallel_sections */ GOMP_parallel_sections_real = - (void(*)(void *, void *, unsigned, unsigned, unsigned)) __real_GOMP_parallel_sections; + (void(*)(void *, void *, unsigned, unsigned, unsigned)) GET_REAL_FUNCTION(GOMP_parallel_sections); INC_IF_NOT_NULL(GOMP_parallel_sections_real,count); /* Obtain @ for GOMP_taskgroup_start */ - GOMP_taskgroup_start_real = (void(*)(void)) __real_GOMP_taskgroup_start; + GOMP_taskgroup_start_real = (void(*)(void)) GET_REAL_FUNCTION(GOMP_taskgroup_start); INC_IF_NOT_NULL(GOMP_taskgroup_start_real,count); /* Obtain @ for GOMP_taskgroup_end */ - GOMP_taskgroup_end_real = (void(*)(void)) __real_GOMP_taskgroup_end; + GOMP_taskgroup_end_real = (void(*)(void)) GET_REAL_FUNCTION(GOMP_taskgroup_end); INC_IF_NOT_NULL(GOMP_taskgroup_end_real,count); /**********************/ @@ -3275,3223 +3302,55 @@ static int gnu_libgomp_get_hook_points (int rank) /* Obtain @ for GOMP_task */ GOMP_task_real = - (void(*)(void*,void*,void*,long,long,int,unsigned,...))__real_GOMP_task; // Wrap + (void(*)(void*,void*,void*,long,long,int,unsigned,...)) GET_REAL_FUNCTION(GOMP_task); INC_IF_NOT_NULL(GOMP_task_real,count); /* Obtain @ for GOMP_taskloop */ GOMP_taskloop_real = - (void(*)(void*,void*,void*,long,long,unsigned,unsigned long,int,long,long,long))__real_GOMP_taskloop; // Wrap + (void(*)(void*,void*,void*,long,long,unsigned,unsigned long,int,long,long,long)) GET_REAL_FUNCTION(GOMP_taskloop); INC_IF_NOT_NULL(GOMP_taskloop_real,count); /* Obtain @ for GOMP_loop_doacross_static_start */ - GOMP_loop_doacross_static_start_real = (int(*)(unsigned, long *, long, long *, long *))__real_GOMP_loop_doacross_static_start; + GOMP_loop_doacross_static_start_real = (int(*)(unsigned, long *, long, long *, long *)) GET_REAL_FUNCTION(GOMP_loop_doacross_static_start); INC_IF_NOT_NULL(GOMP_loop_doacross_static_start_real,count); - + /* Obtain @ for GOMP_loop_doacross_dynamic_start */ - GOMP_loop_doacross_dynamic_start_real = (int(*)(unsigned, long *, long, long *, long *))__real_GOMP_loop_doacross_dynamic_start; + GOMP_loop_doacross_dynamic_start_real = (int(*)(unsigned, long *, long, long *, long *)) GET_REAL_FUNCTION(GOMP_loop_doacross_dynamic_start); INC_IF_NOT_NULL(GOMP_loop_doacross_dynamic_start_real,count); - + /* Obtain @ for GOMP_loop_doacross_guided_start */ - GOMP_loop_doacross_guided_start_real = (int(*)(unsigned, long *, long, long *, long *))__real_GOMP_loop_doacross_guided_start; + GOMP_loop_doacross_guided_start_real = (int(*)(unsigned, long *, long, long *, long *)) GET_REAL_FUNCTION(GOMP_loop_doacross_guided_start); INC_IF_NOT_NULL(GOMP_loop_doacross_guided_start_real,count); - + /* Obtain @ for GOMP_loop_doacross_runtime_start */ - GOMP_loop_doacross_runtime_start_real = (int(*)(unsigned, long *, long *, long *))__real_GOMP_loop_doacross_runtime_start; + GOMP_loop_doacross_runtime_start_real = (int(*)(unsigned, long *, long *, long *)) GET_REAL_FUNCTION(GOMP_loop_doacross_runtime_start); INC_IF_NOT_NULL(GOMP_loop_doacross_runtime_start_real,count); - + /* Obtain @ for GOMP_doacross_post */ - GOMP_doacross_post_real = (void(*)(long *))__real_GOMP_doacross_post; + GOMP_doacross_post_real = (void(*)(long *)) GET_REAL_FUNCTION(GOMP_doacross_post); INC_IF_NOT_NULL(GOMP_doacross_post_real,count); - + /* Obtain @ for GOMP_doacross_wait */ - GOMP_doacross_wait_real = (void(*)(long, ...))__real_GOMP_doacross_wait; + GOMP_doacross_wait_real = (void(*)(long, ...)) GET_REAL_FUNCTION(GOMP_doacross_wait); INC_IF_NOT_NULL(GOMP_doacross_wait_real,count); /* Any hook point? */ return (count > 0); } -#else -#if defined(PIC) - -/**************************************************************/ -/***** Added (or changed) in OpenMP 3.1 or prior versions *****/ -/**************************************************************/ - -static int gnu_libgomp_get_hook_points (int rank); - -static void (*GOMP_atomic_start_real)(void) = NULL; -static void (*GOMP_atomic_end_real)(void) = NULL; - -static void (*GOMP_barrier_real)(void) = NULL; - -static void (*GOMP_critical_start_real)(void) = NULL; -static void (*GOMP_critical_end_real)(void) = NULL; -static void (*GOMP_critical_name_start_real)(void**) = NULL; -static void (*GOMP_critical_name_end_real)(void**) = NULL; - -static int (*GOMP_loop_static_start_real)(long,long,long,long,long*,long*) = NULL; -static int (*GOMP_loop_dynamic_start_real)(long,long,long,long,long*,long*) = NULL; -static int (*GOMP_loop_guided_start_real)(long,long,long,long,long*,long*) = NULL; -static int (*GOMP_loop_runtime_start_real)(long,long,long,long,long*,long*) = NULL; - -static int (*GOMP_loop_static_next_real)(long*,long*) = NULL; -static int (*GOMP_loop_dynamic_next_real)(long*,long*) = NULL; -static int (*GOMP_loop_guided_next_real)(long*,long*) = NULL; -static int (*GOMP_loop_runtime_next_real)(long*,long*) = NULL; - -static int (*GOMP_loop_ordered_static_start_real)(long, long, long, long, long *, long *) = NULL; -static int (*GOMP_loop_ordered_dynamic_start_real)(long, long, long, long, long *, long *) = NULL; -static int (*GOMP_loop_ordered_guided_start_real)(long, long, long, long, long *, long *) = NULL; -static int (*GOMP_loop_ordered_runtime_start_real)(long, long, long, long, long *, long *) = NULL; - -static int (*GOMP_loop_ordered_static_next_real)(long*,long*) = NULL; -static int (*GOMP_loop_ordered_dynamic_next_real)(long*,long*) = NULL; -static int (*GOMP_loop_ordered_guided_next_real)(long*,long*) = NULL; -static int (*GOMP_loop_ordered_runtime_next_real)(long*,long*) = NULL; - -static void (*GOMP_parallel_loop_static_start_real)(void*, void*,unsigned, long, long, long, long) = NULL; -static void (*GOMP_parallel_loop_dynamic_start_real)(void*, void*,unsigned, long, long, long, long) = NULL; -static void (*GOMP_parallel_loop_guided_start_real)(void*, void*,unsigned, long, long, long, long) = NULL; -static void (*GOMP_parallel_loop_runtime_start_real)(void*, void*,unsigned, long, long, long) = NULL; - -static void (*GOMP_loop_end_real)(void) = NULL; -static void (*GOMP_loop_end_nowait_real)(void) = NULL; - -static void (*GOMP_ordered_start_real)(void) = NULL; -static void (*GOMP_ordered_end_real)(void) = NULL; - -static void (*GOMP_parallel_start_real)(void*,void*,unsigned) = NULL; -static void (*GOMP_parallel_end_real)(void) = NULL; - -static void (*GOMP_parallel_sections_start_real)(void*,void*,unsigned,unsigned) = NULL; -static unsigned (*GOMP_sections_start_real)(unsigned) = NULL; -static unsigned (*GOMP_sections_next_real)(void) = NULL; -static void (*GOMP_sections_end_real)(void) = NULL; -static void (*GOMP_sections_end_nowait_real)(void) = NULL; - -static unsigned (*GOMP_single_start_real)(void) = NULL; - -static void (*GOMP_taskwait_real)(void) = NULL; - -/********************************************/ -/***** Added (or changed) in OpenMP 4.0 *****/ -/********************************************/ - -static void (*GOMP_parallel_real)(void*,void*,unsigned,unsigned int) = NULL; - -static void (*GOMP_parallel_loop_static_real)(void*, void*, unsigned, long, long, long, long, unsigned) = NULL; -static void (*GOMP_parallel_loop_dynamic_real)(void*, void*, unsigned, long, long, long, long, unsigned) = NULL; -static void (*GOMP_parallel_loop_guided_real)(void*, void*, unsigned, long, long, long, long, unsigned) = NULL; -static void (*GOMP_parallel_loop_runtime_real)(void*, void*, unsigned, long, long, long, unsigned) = NULL; - -static void (*GOMP_parallel_sections_real)(void *, void *, unsigned, unsigned, unsigned) = NULL; - -static void (*GOMP_taskgroup_start_real)(void) = NULL; -static void (*GOMP_taskgroup_end_real)(void) = NULL; - -/********************************************/ -/***** Added (or changed) in OpenMP 4.5 *****/ -/********************************************/ - -// Appeared in OpenMP 3.1 but increased the #parameters in 4.0 and later in 4.5 -static void (*GOMP_task_real)(void*,void*,void*,long,long,int,unsigned,...) = NULL; -static void (*GOMP_taskloop_real)(void*,void*,void*,long,long,unsigned,unsigned long,int,long,long,long) = NULL; - -static int (*GOMP_loop_doacross_static_start_real)(unsigned, long *, long, long *, long *) = NULL; -static int (*GOMP_loop_doacross_dynamic_start_real)(unsigned, long *, long, long *, long *) = NULL; -static int (*GOMP_loop_doacross_guided_start_real)(unsigned, long *, long, long *, long *) = NULL; -static int (*GOMP_loop_doacross_runtime_start_real)(unsigned, long *, long *, long *) = NULL; -static void (*GOMP_doacross_post_real)(long *) = NULL; -static void (*GOMP_doacross_wait_real)(long, ...) = NULL; - - -/******************************************************************************\ - * * - * HELPERS * - * * - ****************************************************************************** - * The following structures are used to encapsulate the parameters of the * - * runtime routines, allowing us to modify them so as to change the outlined * - * routines to our own methods to emit instrumentation. Then we retrieve the * - * real data from the helpers to callback the real outlined functions. * -\******************************************************************************/ - -/* - * __GOMP_helpers is a structure that contains an array of all active data helpers. - * The array of the queue can be increased from DEFAULT_OPENMP_HELPERS to the - * value set by the EXTRAE_OPENMP_HELPERS environment variable. - */ -pthread_mutex_t __GOMP_helpers_mtx = PTHREAD_MUTEX_INITIALIZER; -struct helpers_queue_t *__GOMP_helpers = NULL; - /** - * preallocate_GOMP_helpers + * _extrae_gnu_libgomp_init * - * Allocates the structure __GOMP_helpers to hold a queue of active data helpers. + * Initializes the instrumentation module for GNU libgomp. + * + * @param rank The current process ID (not used). */ -static void preallocate_GOMP_helpers() +int _extrae_gnu_libgomp_init (int rank) { - int num_helpers = 0; - char *env_helpers = NULL; - - pthread_mutex_lock(&__GOMP_helpers_mtx); + preallocate_GOMP_helpers(); - if (__GOMP_helpers == NULL) - { - __GOMP_helpers = (struct helpers_queue_t *)malloc(sizeof(struct helpers_queue_t)); - if (__GOMP_helpers == NULL) - { - fprintf (stderr, PACKAGE_NAME": ERROR! Invalid initialization of '__GOMP_helpers'\n"); - exit(-1); - } - - /* - * If the environment variable ENV_VAR_EXTRAE_OPENMP_HELPERS is defined, this - * will be the size of the queue. Otherwise, DEFAULT_OPENMP_HELPERS is used. - */ - env_helpers = getenv(ENV_VAR_EXTRAE_OPENMP_HELPERS); - if (env_helpers != NULL) - { - num_helpers = atoi(env_helpers); - } - if (num_helpers <= 0) - { - num_helpers = DEFAULT_OPENMP_HELPERS; - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "Allocating %d data helpers\n", THREAD_LEVEL_VAR, num_helpers); -#endif - - __GOMP_helpers->current_helper = 0; - __GOMP_helpers->max_helpers = num_helpers; - __GOMP_helpers->queue = (struct parallel_helper_t *)malloc(sizeof(struct parallel_helper_t) * num_helpers); - if (__GOMP_helpers->queue == NULL) - { - fprintf (stderr, PACKAGE_NAME": ERROR! Invalid initialization of '__GOMP_helpers->queue' (%d helpers)\n", num_helpers); - exit(-1); - } - } - - pthread_mutex_unlock(&__GOMP_helpers_mtx); -} - - -/** - * __GOMP_new_helper - * - * Registers a new data helper in the __GOMP_helpers queue. When we run out of - * helpers, we start reusing. As long as the corresponding parallel region already - * finished, there will be no problems. But if that parallel region is still - * active, we'll be corrupting the pointers to fn and data. A warning is shown - * the first time the helpers are reused, and if the application is corrupted, - * we need to increase the number of helpers setting EXTRAE_OPENMP_HELPERS. - * - * @param fn The pointer to the real outlined function or task. - * @param data The pointer to the data passed to the real routine. - * - * @return The pointer to the queue slot where the data helper is stored. - */ -void *__GOMP_new_helper(void (*fn)(void *), void *data) -{ - int idx = 0; - void *helper_ptr = NULL; - static int warning_displayed = 0; - - pthread_mutex_lock(&__GOMP_helpers_mtx); - - /* Pick a slot in the queue */ - idx = __GOMP_helpers->current_helper; - __GOMP_helpers->current_helper = (__GOMP_helpers->current_helper + 1) % __GOMP_helpers->max_helpers; - - pthread_mutex_unlock(&__GOMP_helpers_mtx); - - /* Save the pointers to fn and data */ - __GOMP_helpers->queue[idx].fn = fn; - __GOMP_helpers->queue[idx].data = data; - - /* Return the pointer to the slot for this data helper */ - helper_ptr = &(__GOMP_helpers->queue[idx]); - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "__GOMP_new_helper: Registering helper #%d helper_ptr=%p fn=%p data=%p\n", THREAD_LEVEL_VAR, idx, helper_ptr, fn, data); -#endif - - if (__GOMP_helpers->current_helper < idx) - { - /* - * Display a warning (once) when we start reusing queue slots for helpers. - * Could appear more than once in the event that two concurrent threads - * evaluate warning_displayed simultaneously, but this is extremely - * unlikely and it's better not to use a mutex here to minimize overhead. - */ - if (!warning_displayed) - { - fprintf (stderr, PACKAGE_NAME": WARNING! I have run out of allocations for data helpers. If the application starts crashing or producing wrong results, please try increasing %s over %d until this warning disappears\n", ENV_VAR_EXTRAE_OPENMP_HELPERS, __GOMP_helpers->max_helpers); - warning_displayed = 1; - } - } - - return helper_ptr; -} - -/* - * When we enter a GOMP_parallel we have to store the par_uf later used in the - * loop and loop_ordered calls after opening parallelism (current level + 1). - * FIXME: This doesn't support nested because multiple threads can open a 2nd - * level of parallelism, and they would all overwrite the same position of the - * array as they're all in the same nesting level. Can we index by thread id? - * Previously, this was just a global variable. - */ -static void * __GOMP_parallel_uf[MAX_NESTING_LEVEL]; - -void SAVE_PARALLEL_UF(void *par_uf) -{ - int level = omp_get_level(); - CHECK_NESTING_LEVEL(level); - __GOMP_parallel_uf[level] = par_uf; -} - -void * RETRIEVE_PARALLEL_UF() -{ - int level = omp_get_level(); - CHECK_NESTING_LEVEL(level-1); - return __GOMP_parallel_uf[level-1]; -} - -/* - * Counter to enumerate tasks executed from GOMP_task - */ -static volatile long long __GOMP_task_ctr = 1; -#if !defined(HAVE__SYNC_FETCH_AND_ADD) -static pthread_mutex_t __GOMP_task_ctr_mtx = PTHREAD_MUTEX_INITIALIZER; -#endif - -/* - * Counter to enumerate tasks executed from GOMP_taskloop - */ -static volatile long long __GOMP_taskloop_ctr = 1; -#if !defined(HAVE__SYNC_FETCH_AND_ADD) -static pthread_mutex_t __GOMP_taskloop_ctr_mtx = PTHREAD_MUTEX_INITIALIZER; -#endif - -typedef struct tracked_taskloop_helper_t tracked_taskloop_helper_t; - -struct tracked_taskloop_helper_t -{ - void *taskloop_helper_ptr; - tracked_taskloop_helper_t *next; - -}; - -tracked_taskloop_helper_t *tracked_taskloop_helpers = NULL; -pthread_mutex_t mtx_taskloop_helpers = PTHREAD_MUTEX_INITIALIZER; - -void *taskloop_global_fn = NULL; -void *taskloop_global_data = NULL; - - -/* - * Instrumentation of doacross is split in several routines. In the *_start - * routines (e.g. GOMP_loop_doacross_static_start) we need to save the parameter - * 'ncounts', which is later needed in the routine GOMP_doacross_wait. Since the - * latter does not receive any parameter that we can replace with a data helper, - * what we do is to store ncounts in the thread TLS. This can be done because - * all threads execute the *_start routine. This parameter is saved per nesting - * level, to support nowait clauses and nested parallelism. - */ -static __thread unsigned __GOMP_doacross_ncounts[MAX_NESTING_LEVEL]; - -/** - * SAVE_DOACROSS_NCOUNTS - * - * Save the ncounts parameter from the doacross *_start routine in the thread - * TLS to be retrieved later in GOMP_doacross_wait. This is stored in an array - * indexed per current nesting level, in order to allow nowait clauses and - * nested loops. - * - * @param ncounts The parameter to save in the TLS - */ -void SAVE_DOACROSS_NCOUNTS(unsigned ncounts) -{ - int level = omp_get_level(); - CHECK_NESTING_LEVEL(level); - __GOMP_doacross_ncounts[level] = ncounts; -} - -/** - * RETRIEVE_DOACROSS_NCOUNTS - * - * Retrieve the ncounts parameter from the thread TLS (previously stored in the - * GOMP_loop_doacross_*_start function). This is stored in an array indexed per - * current nesting level, in order to allow nowait clauses and nested loops. - * - * @return the ncounts parameter previously saved in the TLS. - */ -unsigned RETRIEVE_DOACROSS_NCOUNTS() -{ - int level = omp_get_level(); - CHECK_NESTING_LEVEL(level); - return __GOMP_doacross_ncounts[level]; -} - - -/******************************************************************************\ - * * - * CALLBACKS * - * * - ****************************************************************************** - * The following callme_* routines replace the real outlined functions and * - * tasks, so that when the runtime would actually execute the task, it runs * - * our function instead where we emit events that mark when the task is * - * executed. From these functions we retrieve the pointer to the original * - * routine from the various data helpers, and invoke it. * -\******************************************************************************/ - -static void callme_parsections (void *parsections_helper_ptr) -{ - struct parallel_helper_t *parsections_helper = parsections_helper_ptr; - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_parsections enter: parsections_helper=%p fn=%p data=%p\n", THREAD_LEVEL_VAR, parsections_helper, parsections_helper->fn, parsections_helper->data); -#endif - - if ((parsections_helper == NULL) || (parsections_helper->fn == NULL)) - { - fprintf (stderr, PACKAGE_NAME": ERROR! Invalid initialization of 'parsections_helper'\n"); - exit (-1); - } - - Extrae_OpenMP_UF_Entry (parsections_helper->fn); - Backend_setInInstrumentation (THREADID, FALSE); /* We're about to execute user code */ - parsections_helper->fn (parsections_helper->data); - Backend_setInInstrumentation (THREADID, TRUE); /* We're about to execute OpenMP code */ - Extrae_OpenMP_UF_Exit (); -} - -static void callme_pardo (void *pardo_helper_ptr) -{ - struct parallel_helper_t *pardo_helper = pardo_helper_ptr; - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_pardo enter: pardo_helper=%p fn=%p data=%p\n", THREAD_LEVEL_VAR, pardo_helper, pardo_helper->fn, pardo_helper->data); -#endif - - if ((pardo_helper == NULL) || (pardo_helper->fn == NULL)) - { - fprintf (stderr, PACKAGE_NAME": ERROR! Invalid initialization of 'pardo_helper'\n"); - exit (-1); - } - - Extrae_OpenMP_DO_Entry (); - Extrae_OpenMP_UF_Entry (pardo_helper->fn); - Backend_setInInstrumentation (THREADID, FALSE); /* We're about to execute user code */ - pardo_helper->fn (pardo_helper->data); - Backend_setInInstrumentation (THREADID, TRUE); /* We're about to execute OpenMP code */ - Extrae_OpenMP_UF_Exit (); -} - -static void callme_par (void *par_helper_ptr) -{ - struct parallel_helper_t *par_helper = par_helper_ptr; - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_par enter: par_helper=%p fn=%p data=%p\n", THREAD_LEVEL_VAR, par_helper, par_helper->fn, par_helper->data); -#endif - - if ((par_helper == NULL) || (par_helper->fn == NULL)) - { - fprintf (stderr, PACKAGE_NAME": ERROR! Invalid initialization of 'par_helper'\n"); - exit (-1); - } - - Extrae_OpenMP_UF_Entry (par_helper->fn); - Backend_setInInstrumentation (THREADID, FALSE); /* We're about to execute user code */ - par_helper->fn (par_helper->data); - Backend_setInInstrumentation (THREADID, TRUE); /* We're back to execute OpenMP code */ - Extrae_OpenMP_UF_Exit (); - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_par ends\n", THREAD_LEVEL_VAR); -#endif - -} - -static void callme_task (void *task_helper_ptr) -{ - struct task_helper_t *task_helper = *(struct task_helper_t **)task_helper_ptr; - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_task enter: task_helper_ptr=%p\n", THREAD_LEVEL_VAR, task_helper_ptr); -#endif - - if (task_helper != NULL) - { - Extrae_OpenMP_TaskUF_Entry (task_helper->fn); - Extrae_OpenMP_TaskID (task_helper->counter); - - task_helper->fn (task_helper->data); - if (task_helper->buf != NULL) - free(task_helper->buf); - free(task_helper); - - Extrae_OpenMP_Notify_NewExecutedTask(); - Extrae_OpenMP_TaskUF_Exit (); - } -} - -static void callme_taskloop (void (*fn)(void *), void *data) -{ -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop enter: fn=%p data=%p data[0]=%ld data[1]=%ld\n", THREAD_LEVEL_VAR, fn, data, *((long *)data), *((long *)(data+sizeof(long)))); -#endif - -#if defined(HAVE__SYNC_FETCH_AND_ADD) - long long taskloop_ctr = __sync_fetch_and_add(&__GOMP_taskloop_ctr, 1); -#else - pthread_mutex_lock (&__GOMP_taskloop_ctr_mtx); - long long taskloop_ctr = __GOMP_taskloop_ctr++; - pthread_mutex_unlock (&__GOMP_taskloop_ctr_mtx); -#endif - - Extrae_OpenMP_TaskUF_Entry (fn); - Extrae_OpenMP_TaskLoopID (taskloop_ctr); - - fn(data); - - Extrae_OpenMP_Notify_NewExecutedTask(); - Extrae_OpenMP_TaskUF_Exit (); -} - -/* - * This callback is invoked when taskloop doesn't use copy function. Then the - * data helper is prefixed to the argument data in the GOMP_taskloop wrapper. - * - * taskloop_helper \ data \ - * -------------------------------------------- - * | cpyfn? | *fn | long start | long end | - * -------------------------------------------- - */ -static void callme_taskloop_prefix_helper (void *data) -{ - /* Look for the data argument in our tracked list, if we don't find it, that means - * that the runtime did an internal copy of data and our prefixed pointers - * are gone, so we use a fallback mechanism using a global pointer that stores the - * original function and data (this only allows 1 simultaneous taskloop) - */ - pthread_mutex_lock (&mtx_taskloop_helpers); - tracked_taskloop_helper_t *current_tracked_taskloop_helper = tracked_taskloop_helpers; - int found = 0; - while ((current_tracked_taskloop_helper != NULL) && (!found)) - { - if (current_tracked_taskloop_helper->taskloop_helper_ptr == data) - { - found = 1; - } - current_tracked_taskloop_helper = current_tracked_taskloop_helper->next; - } - pthread_mutex_unlock (&mtx_taskloop_helpers); - - if (!found) - { -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop_prefix_helper: Using fallback global pointers taskloop_global_fn=%p taskloop_global_data=%p\n", THREAD_LEVEL_VAR, taskloop_global_fn, taskloop_global_data); -#endif - callme_taskloop(taskloop_global_fn, taskloop_global_data); - } - else - { - /* Retrieve the data helper */ - void *taskloop_helper = data - sizeof(void *); - void (*fn)(void *) = *(void **)(taskloop_helper); - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop_prefix_helper: Using injected pointers fn=%p data=%p\n", THREAD_LEVEL_VAR, fn, data); -#endif - callme_taskloop(fn, data); - } -} - -/* - * This callback is invoked when taskloop uses copy function. Then the data - * helper is suffixed to the argument data in the callme_taskloop_cpyfn callback. - * - * data \ taskloop_helper \ - * --------------------------------- - * | long start | long end | *fn ... - * --------------------------------- - */ -static void callme_taskloop_suffix_helper (void *data) -{ - /* Look for the data argument in our tracked list, if we don't find it, that means - * that the runtime did an internal copy of data and our suffixed pointers - * are gone, so we use a fallback mechanism using a global pointer that stores the - * original function and data (this only allows 1 simultaneous taskloop) - */ - pthread_mutex_lock (&mtx_taskloop_helpers); - tracked_taskloop_helper_t *current_tracked_taskloop_helper = tracked_taskloop_helpers; - int found = 0; - while ((current_tracked_taskloop_helper != NULL) && (!found)) - { - if (current_tracked_taskloop_helper->taskloop_helper_ptr == data) - { - found = 1; - } - current_tracked_taskloop_helper = current_tracked_taskloop_helper->next; - } - pthread_mutex_unlock (&mtx_taskloop_helpers); - - if (!found) - { -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop_suffix_helper: Using fallback global pointers taskloop_global_fn=%p taskloop_global_data=%p\n", THREAD_LEVEL_VAR, taskloop_global_fn, taskloop_global_data); -#endif - callme_taskloop(taskloop_global_fn, taskloop_global_data); - } - else - { - /* Retrieve the data helper */ - void *taskloop_helper = data + (2 * sizeof(long)); - void (*fn)(void *) = *(void **)(taskloop_helper); - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop_suffix_helper: Using injected pointers fn=%p data=%p\n", THREAD_LEVEL_VAR, fn, data); -#endif - callme_taskloop(fn, data); - } -} - -/* - * This callback is invoked when taskloop uses copy function. The data helper - * is prefixed to the argument data in the GOMP_taskloop wrapper. The helper is - * copied from data to arg by suffixing it (see GOMP_taskloop wrapper), after - * the real copy takes place. - * - * taskloop_helper ↴ data ↴ - * ---------------------------------------- - * | *cpyfn | *fn | long start | long end | - * ---------------------------------------- - * - * arg ↴ arg+(2*sizeof(long)) ↴ arg+arg_size ↴ - * --------------------------------------------------------------------------- - * | long start | long end | *fn | ... | long start | long end | *fn | ... - * --------------------------------------------------------------------------- - */ -void callme_taskloop_cpyfn(void *arg, void *data) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop_cpyfn enter: arg=%p data=%p\n", THREAD_LEVEL_VAR, arg, data); -#endif - - /* Retrieve the data helper */ - void *taskloop_helper = data - sizeof(void *) - sizeof(void *); - void (*cpyfn)(void *, void*) = *((void **)(taskloop_helper)); - void (*fn)(void *) = *((void **)(taskloop_helper+sizeof(void *))); - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "callme_taskloop_cpyfn: taskloop_helper=%p cpyfn=%p fn=%p\n", THREAD_LEVEL_VAR, taskloop_helper, cpyfn, fn); -#endif - - /* Real copy function */ - cpyfn(arg, data); - - /* Save the pointer to the real fn in arg, after the 2 longs that mark the - * start/end iterations - */ - *(void **)(arg+(2 * sizeof(long))) = fn; -} - - -/******************************************************************************\ - * * - * WRAPPERS * - * * -\******************************************************************************/ - -/**************************************************************/ -/***** Added (or changed) in OpenMP 3.1 or prior versions *****/ -/**************************************************************/ - -void GOMP_atomic_start (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_atomic_start_real); -#endif - - RECHECK_INIT(GOMP_atomic_start_real); - - if (TRACE(GOMP_atomic_start_real)) - { - Extrae_OpenMP_Unnamed_Lock_Entry(); - GOMP_atomic_start_real(); - Extrae_OpenMP_Unnamed_Lock_Exit(); - } - else if (GOMP_atomic_start_real != NULL) - { - GOMP_atomic_start_real(); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_start exit\n", THREAD_LEVEL_VAR); -#endif -} - -void GOMP_atomic_end (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_atomic_end_real); -#endif - - RECHECK_INIT(GOMP_atomic_end_real); - - if (TRACE(GOMP_atomic_end_real)) - { - Extrae_OpenMP_Unnamed_Unlock_Entry(); - GOMP_atomic_end_real (); - Extrae_OpenMP_Unnamed_Unlock_Exit(); - } - else if (GOMP_atomic_end_real != NULL) - { - GOMP_atomic_end_real (); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_end: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_atomic_end exit\n", THREAD_LEVEL_VAR); -#endif -} - -void GOMP_barrier (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_barrier enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_barrier_real); -#endif - - RECHECK_INIT(GOMP_barrier_real); - - if (TRACE(GOMP_barrier_real)) - { - Extrae_OpenMP_Barrier_Entry (); - GOMP_barrier_real (); - Extrae_OpenMP_Barrier_Exit (); - } - else if (GOMP_barrier_real != NULL) - { - GOMP_barrier_real (); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_barrier: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_barrier exit\n", THREAD_LEVEL_VAR); -#endif -} - -void GOMP_critical_start (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_critical_start_real); -#endif - - RECHECK_INIT(GOMP_critical_start_real); - - if (TRACE(GOMP_critical_start_real)) - { - Extrae_OpenMP_Unnamed_Lock_Entry(); - GOMP_critical_start_real(); - Extrae_OpenMP_Unnamed_Lock_Exit(); - } - else if (GOMP_critical_start_real != NULL) - { - GOMP_critical_start_real(); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_start exit\n", THREAD_LEVEL_VAR); -#endif -} - -void GOMP_critical_end (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_critical_end_real); -#endif - - RECHECK_INIT(GOMP_critical_end_real); - - if (TRACE(GOMP_critical_end_real)) - { - Extrae_OpenMP_Unnamed_Unlock_Entry(); - GOMP_critical_end_real (); - Extrae_OpenMP_Unnamed_Unlock_Exit(); - } - else if (GOMP_critical_end_real != NULL) - { - GOMP_critical_end_real (); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_end: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_end exit\n", THREAD_LEVEL_VAR); -#endif -} - -void GOMP_critical_name_start (void **pptr) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_start enter: @=%p args=(%p)\n", THREAD_LEVEL_VAR, GOMP_critical_name_start_real, pptr); -#endif - - RECHECK_INIT(GOMP_critical_name_start_real); - - if (TRACE(GOMP_critical_name_start_real)) - { - Extrae_OpenMP_Named_Lock_Entry(); - GOMP_critical_name_start_real (pptr); - Extrae_OpenMP_Named_Lock_Exit(pptr); - } - else if (GOMP_critical_name_start_real != NULL) - { - GOMP_critical_name_start_real (pptr); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_start exit\n", THREAD_LEVEL_VAR); -#endif -} - -void GOMP_critical_name_end (void **pptr) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_end enter: @=%p args=(%p)\n", THREAD_LEVEL_VAR, GOMP_critical_name_end_real, pptr); -#endif - - RECHECK_INIT(GOMP_critical_name_end_real); - - if (TRACE(GOMP_critical_name_end_real)) - { - Extrae_OpenMP_Named_Unlock_Entry(pptr); - GOMP_critical_name_end_real (pptr); - Extrae_OpenMP_Named_Unlock_Exit(); - } - else if (GOMP_critical_name_end_real != NULL) - { - GOMP_critical_name_end_real (pptr); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_end: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_critical_name_end exit\n", THREAD_LEVEL_VAR); -#endif -} - -int GOMP_loop_static_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) -{ - int res = 0; - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_static_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_static_start_real, start, end, incr, chunk_size, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_static_start_real); - - if (TRACE(GOMP_loop_static_start_real)) - { - Extrae_OpenMP_DO_Entry (); - res = GOMP_loop_static_start_real (start, end, incr, chunk_size, istart, iend); - Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); - Backend_Leave_Instrumentation(); - } - else if (GOMP_loop_static_start_real != NULL) - { - res = GOMP_loop_static_start_real (start, end, incr, chunk_size, istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_static_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_static_start exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_dynamic_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_dynamic_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_dynamic_start_real, start, end, incr, chunk_size, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_dynamic_start_real); - - if (TRACE(GOMP_loop_dynamic_start_real)) - { - Extrae_OpenMP_DO_Entry (); - res = GOMP_loop_dynamic_start_real (start, end, incr, chunk_size, istart, iend); - Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); - Backend_Leave_Instrumentation(); - } - else if (GOMP_loop_dynamic_start_real != NULL) - { - res = GOMP_loop_dynamic_start_real (start, end, incr, chunk_size, istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_dynamic_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_dynamic_start exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_guided_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_guided_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_guided_start_real, start, end, incr, chunk_size, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_guided_start_real); - - if (TRACE(GOMP_loop_guided_start_real)) - { - Extrae_OpenMP_DO_Entry (); - res = GOMP_loop_guided_start_real (start, end, incr, chunk_size, istart, iend); - Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); - Backend_Leave_Instrumentation(); - } - else if (GOMP_loop_guided_start_real != NULL) - { - res = GOMP_loop_guided_start_real (start, end, incr, chunk_size, istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_guided_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_guided_start exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_runtime_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_runtime_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_runtime_start_real, start, end, incr, chunk_size, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_runtime_start_real); - - if (TRACE(GOMP_loop_runtime_start_real)) - { - Extrae_OpenMP_DO_Entry (); - res = GOMP_loop_runtime_start_real (start, end, incr, chunk_size, istart, iend); - Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); - Backend_Leave_Instrumentation(); - } - else if (GOMP_loop_runtime_start_real != NULL) - { - res = GOMP_loop_runtime_start_real (start, end, incr, chunk_size, istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_runtime_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_runtime_start exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_static_next (long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_static_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_static_next_real, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_static_next_real); - - if (TRACE(GOMP_loop_static_next_real)) - { - Extrae_OpenMP_Work_Entry(); - res = GOMP_loop_static_next_real (istart, iend); - Extrae_OpenMP_Work_Exit(); - } - else if (GOMP_loop_static_next_real != NULL) - { - res = GOMP_loop_static_next_real (istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_static_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_static_next exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_dynamic_next (long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_dynamic_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_dynamic_next_real, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_dynamic_next_real); - - if (TRACE(GOMP_loop_dynamic_next_real)) - { - Extrae_OpenMP_Work_Entry(); - res = GOMP_loop_dynamic_next_real (istart, iend); - Extrae_OpenMP_Work_Exit(); - } - else if (GOMP_loop_dynamic_next_real != NULL) - { - res = GOMP_loop_dynamic_next_real (istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_dynamic_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_dynamic_next exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_guided_next (long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_guided_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_guided_next_real, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_guided_next_real); - - if (TRACE(GOMP_loop_guided_next_real)) - { - Extrae_OpenMP_Work_Entry(); - res = GOMP_loop_guided_next_real (istart, iend); - Extrae_OpenMP_Work_Exit(); - } - else if (GOMP_loop_guided_next_real != NULL) - { - res = GOMP_loop_guided_next_real (istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_guided_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_guided_next exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_runtime_next (long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_runtime_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_runtime_next_real, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_runtime_next_real); - - if (TRACE(GOMP_loop_runtime_next_real)) - { - Extrae_OpenMP_Work_Entry(); - res = GOMP_loop_runtime_next_real (istart, iend); - Extrae_OpenMP_Work_Exit(); - } - else if (GOMP_loop_runtime_next_real != NULL) - { - res = GOMP_loop_runtime_next_real (istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_runtime_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_runtime_next exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_ordered_static_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_static_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_static_start_real, start, end, incr, chunk_size, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_ordered_static_start_real); - - if (TRACE(GOMP_loop_ordered_static_start_real)) - { - Extrae_OpenMP_DO_Entry (); - res = GOMP_loop_ordered_static_start_real (start, end, incr, chunk_size, istart, iend); - Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); - } - else if (GOMP_loop_ordered_static_start_real != NULL) - { - res = GOMP_loop_ordered_static_start_real (start, end, incr, chunk_size, istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_static_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_static_start exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_ordered_dynamic_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_dynamic_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_dynamic_start_real, start, end, incr, chunk_size, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_ordered_dynamic_start_real); - - if (TRACE(GOMP_loop_ordered_dynamic_start_real)) - { - Extrae_OpenMP_DO_Entry (); - res = GOMP_loop_ordered_dynamic_start_real (start, end, incr, chunk_size, istart, iend); - Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); - } - else if (GOMP_loop_ordered_dynamic_start_real != NULL) - { - res = GOMP_loop_ordered_dynamic_start_real (start, end, incr, chunk_size, istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_dynamic_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_dynamic_start exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_ordered_guided_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_guided_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_guided_start_real, start, end, incr, chunk_size, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_ordered_guided_start_real); - - if (TRACE(GOMP_loop_ordered_guided_start_real)) - { - Extrae_OpenMP_DO_Entry (); - res = GOMP_loop_ordered_guided_start_real (start, end, incr, chunk_size, istart, iend); - Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); - } - else if (GOMP_loop_ordered_guided_start_real != NULL) - { - res = GOMP_loop_ordered_guided_start_real (start, end, incr, chunk_size, istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_guided_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_guided_start exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_ordered_runtime_start (long start, long end, long incr, long chunk_size, long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_runtime_start enter: @=%p args=(%ld %ld %ld %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_runtime_start_real, start, end, incr, chunk_size, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_ordered_runtime_start_real); - - if (TRACE(GOMP_loop_ordered_runtime_start_real)) - { - Extrae_OpenMP_DO_Entry (); - res = GOMP_loop_ordered_runtime_start_real (start, end, incr, chunk_size, istart, iend); - Extrae_OpenMP_UF_Entry (RETRIEVE_PARALLEL_UF()); - } - else if (GOMP_loop_ordered_runtime_start_real != NULL) - { - res = GOMP_loop_ordered_runtime_start_real (start, end, incr, chunk_size, istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_runtime_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_runtime_start exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_ordered_static_next (long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_static_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_static_next_real, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_ordered_static_next_real); - - if (TRACE(GOMP_loop_ordered_static_next_real)) - { - Extrae_OpenMP_Work_Entry(); - res = GOMP_loop_ordered_static_next_real (istart, iend); - Extrae_OpenMP_Work_Exit(); - } - else if (GOMP_loop_ordered_static_next_real != NULL) - { - res = GOMP_loop_ordered_static_next_real (istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_static_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_static_next exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_ordered_dynamic_next (long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_dynamic_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_dynamic_next_real, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_ordered_dynamic_next_real); - - if (TRACE(GOMP_loop_ordered_dynamic_next_real)) - { - Extrae_OpenMP_Work_Entry(); - res = GOMP_loop_ordered_dynamic_next_real (istart, iend); - Extrae_OpenMP_Work_Exit(); - } - else if (GOMP_loop_ordered_dynamic_next_real != NULL) - { - res = GOMP_loop_ordered_dynamic_next_real (istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_dynamic_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_dynamic_next exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_ordered_guided_next (long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_guided_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_guided_next_real, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_ordered_guided_next_real); - - if (TRACE(GOMP_loop_ordered_guided_next_real)) - { - Extrae_OpenMP_Work_Entry(); - res = GOMP_loop_ordered_guided_next_real (istart, iend); - Extrae_OpenMP_Work_Exit(); - } - else if (GOMP_loop_ordered_guided_next_real != NULL) - { - res = GOMP_loop_ordered_guided_next_real (istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_guided_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_guided_next exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_ordered_runtime_next (long *istart, long *iend) -{ - int res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_runtime_next enter: @=%p args=(%p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_ordered_runtime_next_real, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_ordered_runtime_next_real); - - if (TRACE(GOMP_loop_ordered_runtime_next_real)) - { - Extrae_OpenMP_Work_Entry(); - res = GOMP_loop_ordered_runtime_next_real (istart, iend); - Extrae_OpenMP_Work_Exit(); - } - else if (GOMP_loop_ordered_runtime_next_real != NULL) - { - res = GOMP_loop_ordered_runtime_next_real (istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_runtime_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_ordered_runtime_next exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -void -GOMP_parallel_loop_static_start(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size) -{ -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_static_start enter: @=%p args=(%p %p %u %ld %ld %ld %ld)\n", - THREAD_LEVEL_VAR, GOMP_parallel_loop_static_start_real, fn, data, num_threads, start, end, incr, chunk_size); -#endif - - OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); - - RECHECK_INIT(GOMP_parallel_loop_static_start_real); - - if (TRACE(GOMP_parallel_loop_static_start_real)) - { - void *pardo_helper = __GOMP_new_helper(fn, data); - - /* - * Change number of threads if specified by parallel directive only if - * in a library not mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); - - Extrae_OpenMP_ParDO_Entry(); - GOMP_parallel_loop_static_start_real(callme_pardo, pardo_helper, num_threads, start, end, incr, chunk_size); - - /* - * The master thread continues the execution and then calls fn - */ - if (THREADID == 0) - { - Extrae_OpenMP_DO_Entry (); - Extrae_OpenMP_UF_Entry(fn); - } - - /* - * Return to the original number of threads only if in a library not - * mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); - } - else if (GOMP_parallel_loop_static_start_real != NULL) - { - GOMP_parallel_loop_static_start_real(fn, data, num_threads, start, end, incr, chunk_size); - } - else - { - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_static_start: This function is not hooked! Exiting!!\n", - THREAD_LEVEL_VAR); - exit(-1); - } - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_static_start exit\n", THREAD_LEVEL_VAR); -#endif -} - -void -GOMP_parallel_loop_dynamic_start(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size) -{ -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_dynamic_start enter: @=%p args=(%p %p %u %ld %ld %ld %ld)\n", - THREAD_LEVEL_VAR, GOMP_parallel_loop_dynamic_start_real, fn, data, num_threads, start, end, incr, chunk_size); -#endif - - OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); - - RECHECK_INIT(GOMP_parallel_loop_dynamic_start_real); - - if (TRACE(GOMP_parallel_loop_dynamic_start_real)) - { - void *pardo_helper = __GOMP_new_helper(fn, data); - - /* - * Change number of threads if specified by parallel directive only if - * in a library not mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); - - Extrae_OpenMP_ParDO_Entry(); - GOMP_parallel_loop_dynamic_start_real(callme_pardo, pardo_helper, num_threads, start, end, incr, chunk_size); - - /* - * The master thread continues the execution and then calls fn - */ - if (THREADID == 0) - { - Extrae_OpenMP_DO_Entry (); - Extrae_OpenMP_UF_Entry(fn); - } - - /* - * Return to the original number of threads only if in a library not - * mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); - } - else if (GOMP_parallel_loop_dynamic_start_real != NULL) - { - GOMP_parallel_loop_dynamic_start_real(fn, data, num_threads, start, end, incr, chunk_size); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_dynamic_start: This function is not hooked! Exiting!!\n", - THREAD_LEVEL_VAR); - exit(-1); - } - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_dynamic_start exit\n", THREAD_LEVEL_VAR); -#endif -} - -void -GOMP_parallel_loop_guided_start(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size) -{ -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_guided_start enter: @=%p args=(%p %p %u %ld %ld %ld %ld)\n", - THREAD_LEVEL_VAR, GOMP_parallel_loop_guided_start_real, fn, data, num_threads, start, end, incr, chunk_size); -#endif - - OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); - - RECHECK_INIT(GOMP_parallel_loop_guided_start_real); - - if (TRACE(GOMP_parallel_loop_guided_start_real)) - { - void *pardo_helper = __GOMP_new_helper(fn, data); - - /* - * Change number of threads if specified by parallel directive only if - * in a library not mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); - - Extrae_OpenMP_ParDO_Entry(); - GOMP_parallel_loop_guided_start_real(callme_pardo, pardo_helper, num_threads, start, end, incr, chunk_size); - - /* - * The master thread continues the execution and then calls fn - */ - if (THREADID == 0) - { - Extrae_OpenMP_DO_Entry (); - Extrae_OpenMP_UF_Entry(fn); - } - - /* - * Return to the original number of threads only if in a library not - * mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); - } - else if (GOMP_parallel_loop_guided_start_real != NULL) - { - GOMP_parallel_loop_guided_start_real(fn, data, num_threads, start, end, incr, chunk_size); - } - else - { - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_guided_start: This function is not hooked! Exiting!!\n", - THREAD_LEVEL_VAR); - exit(-1); - } - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_guided_start exit\n", THREAD_LEVEL_VAR); -#endif -} - -void -GOMP_parallel_loop_runtime_start(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_runtime_start enter: @=%p args=(%p %p %u %ld %ld %ld)\n", - THREAD_LEVEL_VAR, GOMP_parallel_loop_runtime_start_real, fn, data, num_threads, start, end, incr); -#endif - - OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); - - RECHECK_INIT(GOMP_parallel_loop_runtime_start_real); - - if (TRACE(GOMP_parallel_loop_runtime_start_real)) - { - void *pardo_helper = __GOMP_new_helper(fn, data); - - /* - * Change number of threads if specified by parallel directive only if - * in a library not mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); - - Extrae_OpenMP_ParDO_Entry(); - GOMP_parallel_loop_runtime_start_real(callme_pardo, pardo_helper, num_threads, start, end, incr); - - /* - * The master thread continues the execution and then calls fn - */ - if (THREADID == 0) - { - Extrae_OpenMP_DO_Entry (); - Extrae_OpenMP_UF_Entry(fn); - } - - /* - * Return to the original number of threads only if in a library not - * mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); - } - else if (GOMP_parallel_loop_runtime_start_real != NULL) - { - GOMP_parallel_loop_runtime_start_real(fn, data, num_threads, start, end, incr); - } - else - { - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_runtime_start: This function is not hooked! Exiting!!\n", - THREAD_LEVEL_VAR); - exit(-1); - } - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_runtime_start exit\n", THREAD_LEVEL_VAR); -#endif -} - -void GOMP_loop_end (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_loop_end_real); -#endif - - RECHECK_INIT(GOMP_loop_end_real); - - if (TRACE(GOMP_loop_end_real)) - { - Extrae_OpenMP_Join_Wait_Entry(); - GOMP_loop_end_real(); - Extrae_OpenMP_Join_Wait_Exit(); - Extrae_OpenMP_DO_Exit (); - } - else if (GOMP_loop_end_real != NULL) - { - GOMP_loop_end_real(); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end exit\n", THREAD_LEVEL_VAR); -#endif -} - -void GOMP_loop_end_nowait (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end_nowait enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_loop_end_nowait_real); -#endif - - RECHECK_INIT(GOMP_loop_end_nowait_real); - - if (TRACE(GOMP_loop_end_nowait_real)) - { - Extrae_OpenMP_Join_NoWait_Entry(); - GOMP_loop_end_nowait_real(); - Extrae_OpenMP_Join_NoWait_Exit(); - Extrae_OpenMP_DO_Exit (); - } - else if (GOMP_loop_end_nowait_real != NULL) - { - GOMP_loop_end_nowait_real(); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end_nowait: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_end_nowait exit\n", THREAD_LEVEL_VAR); -#endif -} - -void GOMP_ordered_start (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_ordered_start_real); -#endif - - RECHECK_INIT(GOMP_ordered_start_real); - - if (TRACE(GOMP_ordered_start_real)) - { - Extrae_OpenMP_Ordered_Wait_Entry(); - GOMP_ordered_start_real (); - Extrae_OpenMP_Ordered_Wait_Exit(); - } - else if (GOMP_ordered_start_real != NULL) - { - GOMP_ordered_start_real (); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_start exit\n", THREAD_LEVEL_VAR); -#endif -} - -void GOMP_ordered_end (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_ordered_end_real); -#endif - - RECHECK_INIT(GOMP_ordered_end_real); - - if (TRACE(GOMP_ordered_end_real)) - { - Extrae_OpenMP_Ordered_Post_Entry(); - GOMP_ordered_end_real(); - Extrae_OpenMP_Ordered_Post_Exit(); - } - else if (GOMP_ordered_end_real != NULL) - { - GOMP_ordered_end_real(); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_end_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_ordered_end exit\n", THREAD_LEVEL_VAR); -#endif -} - -void -GOMP_parallel_start(void (*fn)(void *), void *data, unsigned num_threads) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_start enter: @=%p args=(%p %p %u)\n", - THREAD_LEVEL_VAR, GOMP_parallel_start_real, fn, data, num_threads); -#endif - - RECHECK_INIT(GOMP_parallel_start_real); - - if (TRACE(GOMP_parallel_start_real)) - { - SAVE_PARALLEL_UF(fn); - - void *par_helper = __GOMP_new_helper(fn, data); - - /* - * Change number of threads if specified by parallel directive only if - * in a library not mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); - - Extrae_OpenMP_ParRegion_Entry(); - Extrae_OpenMP_EmitTaskStatistics(); - - GOMP_parallel_start_real (callme_par, par_helper, num_threads); - - /* GCC/libgomp does not execute callme_par per root thread, emit - the required event here - call Backend to get a new time! */ - Extrae_OpenMP_UF_Entry(fn); - } - else if (GOMP_parallel_start_real != NULL) - { - GOMP_parallel_start_real(fn, data, num_threads); - } - else - { - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_start: This function is not hooked! Exiting!!\n", - THREAD_LEVEL_VAR); - exit(-1); - } - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_start exit\n", THREAD_LEVEL_VAR); -#endif -} - -void -GOMP_parallel_end(void) -{ -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_end enter: @=%p\n", - THREAD_LEVEL_VAR, GOMP_parallel_end_real); -#endif - - RECHECK_INIT(GOMP_parallel_end_real); - - if (TRACE(GOMP_parallel_end_real)) - { - Extrae_OpenMP_UF_Exit(); - GOMP_parallel_end_real(); - Extrae_OpenMP_ParRegion_Exit(); - Extrae_OpenMP_EmitTaskStatistics(); - - /* - * Return to the original number of threads only if in a library not - * mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); - OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); - } - else if (GOMP_parallel_end_real != NULL) - { - GOMP_parallel_end_real(); - } - else - { - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_end: This function is not hooked! Exiting!!\n", - THREAD_LEVEL_VAR); - exit(-1); - } - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_end exit\n", THREAD_LEVEL_VAR); -#endif -} - -void -GOMP_parallel_sections_start(void (*fn)(void *), void *data, unsigned num_threads, unsigned count) -{ -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_sections_start enter: @=%p args=(%p %p %u %u)\n", - THREAD_LEVEL_VAR, GOMP_sections_start_real, fn, data, num_threads, count); -#endif - - RECHECK_INIT(GOMP_parallel_sections_start_real); - - if (TRACE(GOMP_parallel_sections_start_real)) - { - void *parsections_helper = __GOMP_new_helper(fn, data); - - /* - * Change number of threads if specified by parallel directive only if - * in a library not mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); - - Extrae_OpenMP_ParSections_Entry(); - GOMP_parallel_sections_start_real(callme_parsections, parsections_helper, num_threads, count); - - /* The master thread continues the execution and then calls parsections_helper->fn */ - if (THREADID == 0) - { - Extrae_OpenMP_UF_Entry(fn); - } - } - else if (GOMP_parallel_sections_start_real != NULL) - { - GOMP_parallel_sections_start_real(fn, data, num_threads, count); - } - else - { - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_sections_start: This function is not hooked! Exiting!!\n", - THREAD_LEVEL_VAR); - exit(-1); - } - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_sections_start exit\n", THREAD_LEVEL_VAR); -#endif -} - -unsigned GOMP_sections_start (unsigned count) -{ - unsigned res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_start enter: @=%p args=(%u)\n", THREAD_LEVEL_VAR, GOMP_sections_start_real, count); -#endif - - RECHECK_INIT(GOMP_sections_start_real); - - if (TRACE(GOMP_sections_start_real)) - { - Extrae_OpenMP_Section_Entry(); - res = GOMP_sections_start_real (count); - Extrae_OpenMP_Section_Exit(); - } - else if (GOMP_sections_start_real != NULL) - { - res = GOMP_sections_start_real (count); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_start exit: res=%u\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -unsigned GOMP_sections_next (void) -{ - unsigned res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_next enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_sections_next_real); -#endif - - RECHECK_INIT(GOMP_sections_next_real); - - if (TRACE(GOMP_sections_next_real)) - { - Extrae_OpenMP_Work_Entry(); - res = GOMP_sections_next_real(); - Extrae_OpenMP_Work_Exit(); - } - else if (GOMP_sections_next_real != NULL) - { - res = GOMP_sections_next_real(); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_next: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_next exit: res=%u\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -void GOMP_sections_end (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_sections_end_real); -#endif - - RECHECK_INIT(GOMP_sections_end_real); - - if (TRACE(GOMP_sections_end_real)) - { - Extrae_OpenMP_Join_Wait_Entry(); - GOMP_sections_end_real(); - Extrae_OpenMP_Join_Wait_Exit(); - } - else if (GOMP_sections_end_real != NULL) - { - GOMP_sections_end_real(); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end exit\n", THREAD_LEVEL_VAR); -#endif -} - -void GOMP_sections_end_nowait (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end_nowait enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_sections_end_nowait_real); -#endif - - RECHECK_INIT(GOMP_sections_end_nowait_real); - - if (TRACE(GOMP_sections_end_nowait_real)) - { - Extrae_OpenMP_Join_NoWait_Entry(); - GOMP_sections_end_nowait_real(); - Extrae_OpenMP_Join_NoWait_Exit(); - } - else if (GOMP_sections_end_nowait_real != NULL) - { - GOMP_sections_end_nowait_real(); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end_nowait: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_sections_end_nowait exit\n", THREAD_LEVEL_VAR); -#endif -} - -unsigned GOMP_single_start (void) -{ - unsigned res = 0; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_single_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_single_start_real); -#endif - - RECHECK_INIT(GOMP_single_start_real); - - if (TRACE(GOMP_single_start_real)) - { - Extrae_OpenMP_Single_Entry(); - res = GOMP_single_start_real (); - Extrae_OpenMP_Single_Exit(); - } - else if (GOMP_single_start_real != NULL) - { - res = GOMP_single_start_real (); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_single_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_single_start exit: res=%u\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -void GOMP_taskwait (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskwait enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_taskwait_real); -#endif - - RECHECK_INIT(GOMP_taskwait_real); - - if (TRACE(GOMP_taskwait_real)) - { - Extrae_OpenMP_Taskwait_Entry(); - Extrae_OpenMP_EmitTaskStatistics(); - GOMP_taskwait_real (); - Extrae_OpenMP_Taskwait_Exit(); - Extrae_OpenMP_EmitTaskStatistics(); - } - else if (GOMP_taskwait_real != NULL) - { - GOMP_taskwait_real (); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskwait: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskwait exit\n", THREAD_LEVEL_VAR); -#endif -} - -/********************************************/ -/***** Added (or changed) in OpenMP 4.0 *****/ -/********************************************/ - -void -GOMP_parallel(void (*fn)(void *), void *data, unsigned num_threads, unsigned int flags) -{ -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel enter: @=%p args=(%p %p %u %u)\n", - THREAD_LEVEL_VAR, GOMP_parallel_real, fn, data, num_threads, flags); -#endif - - OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); - - RECHECK_INIT(GOMP_parallel_real); - - if (TRACE(GOMP_parallel_real)) - { - SAVE_PARALLEL_UF(fn); - - /* - * Change number of threads if specified by parallel directive only if - * in a library not mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); - - /* - * GOMP_parallel has an implicit join, so when we return, the helpers - * can be freed, so rather than using the static array of active - * helpers, we statically declare a private helper and pass it by - * reference. - * void *par_helper = __GOMP_new_helper(fn, data); - */ - struct parallel_helper_t par_helper; - par_helper.fn = fn; - par_helper.data = data; - - Extrae_OpenMP_ParRegion_Entry(); - Extrae_OpenMP_EmitTaskStatistics(); - - GOMP_parallel_real(callme_par, &par_helper, num_threads, flags); - - Extrae_OpenMP_ParRegion_Exit(); - Extrae_OpenMP_EmitTaskStatistics(); - - /* - * Return to the original number of threads only if in a library not - * mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); - } - else if (GOMP_parallel_real != NULL) - { - GOMP_parallel_real(fn, data, num_threads, flags); - } - else - { - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel: This function is not hooked! Exiting!!\n", - THREAD_LEVEL_VAR); - exit(-1); - } - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_parallel exit\n", THREAD_LEVEL_VAR); -#endif -} - -void -GOMP_parallel_loop_static(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size, unsigned flags) -{ -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_static enter: @=%p args=(%p %p %u %ld %ld %ld %ld %u)\n", - THREAD_LEVEL_VAR, GOMP_parallel_loop_static_real, fn, data, num_threads, start, end, incr, chunk_size, flags); -#endif - - OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); - - RECHECK_INIT(GOMP_parallel_loop_static_real); - - if (TRACE(GOMP_parallel_loop_static_real)) - { - void *pardo_helper = __GOMP_new_helper(fn, data); - - /* - * Change number of threads if specified by parallel directive only if - * in a library not mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); - - Extrae_OpenMP_ParDO_Entry(); - GOMP_parallel_loop_static_real(callme_pardo, pardo_helper, num_threads, start, end, incr, chunk_size, flags); - Extrae_OpenMP_ParDO_Exit(); - - /* - * Return to the original number of threads only if in a library not - * mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); - } - else if (GOMP_parallel_loop_static_real != NULL) - { - GOMP_parallel_loop_static_real(fn, data, num_threads, start, end, incr, chunk_size, flags); - } - else - { - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_static: This function is not hooked! Exiting!!\n", - THREAD_LEVEL_VAR); - exit(-1); - } - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_static exit\n", THREAD_LEVEL_VAR); -#endif -} - -void -GOMP_parallel_loop_dynamic(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size, unsigned flags) -{ -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_dynamic enter: @=%p args=(%p %p %u %ld %ld %ld %ld %u)\n", - THREAD_LEVEL_VAR, GOMP_parallel_loop_dynamic_real, fn, data, num_threads, start, end, incr, chunk_size, flags); -#endif - - OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); - - RECHECK_INIT(GOMP_parallel_loop_dynamic_real); - - if (TRACE(GOMP_parallel_loop_dynamic_real)) - { - void *pardo_helper = __GOMP_new_helper(fn, data); - - /* - * Change number of threads if specified by parallel directive only if - * in a library not mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); - - Extrae_OpenMP_ParDO_Entry(); - GOMP_parallel_loop_dynamic_real(callme_pardo, pardo_helper, num_threads, start, end, incr, chunk_size, flags); - Extrae_OpenMP_ParDO_Exit(); - - /* - * Return to the original number of threads only if in a library not - * mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); - } - else if (GOMP_parallel_loop_dynamic_real != NULL) - { - GOMP_parallel_loop_dynamic_real(fn, data, num_threads, start, end, incr, chunk_size, flags); - } - else - { - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_dynamic: This function is not hooked! Exiting!!\n", - THREAD_LEVEL_VAR); - exit(-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_parallel_loop_dynamic exit\n", THREAD_LEVEL_VAR); -#endif -} - -void -GOMP_parallel_loop_guided(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, long chunk_size, unsigned flags) -{ -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_guided enter: @=%p args=(%p %p %u %ld %ld %ld %ld %u)\n", - THREAD_LEVEL_VAR, GOMP_parallel_loop_guided_real, fn, data, num_threads, start, end, incr, chunk_size, flags); -#endif - - OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); - - RECHECK_INIT(GOMP_parallel_loop_guided_real); - - if (TRACE(GOMP_parallel_loop_guided_real)) - { - void *pardo_helper = __GOMP_new_helper(fn, data); - - /* - * Change number of threads if specified by parallel directive only if - * in a library not mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); - - Extrae_OpenMP_ParDO_Entry(); - GOMP_parallel_loop_guided_real(callme_pardo, pardo_helper, num_threads, start, end, incr, chunk_size, flags); - Extrae_OpenMP_ParDO_Exit(); - - /* - * Return to the original number of threads only if in a library not - * mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); - } - else if (GOMP_parallel_loop_guided_real != NULL) - { - GOMP_parallel_loop_guided_real(fn, data, num_threads, start, end, incr, chunk_size, flags); - } - else - { - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_guided: This function is not hooked! Exiting!!\n", - THREAD_LEVEL_VAR); - exit(-1); - } - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_guided exit\n", THREAD_LEVEL_VAR); -#endif -} - -void -GOMP_parallel_loop_runtime(void (*fn)(void *), void *data, unsigned num_threads, long start, long end, long incr, unsigned flags) -{ -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_runtime enter: @=%p args=(%p %p %u %ld %ld %ld %u)\n", - THREAD_LEVEL_VAR, GOMP_parallel_loop_runtime_real, fn, data, num_threads, start, end, incr, flags); -#endif - - OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); - - RECHECK_INIT(GOMP_parallel_loop_runtime_real); - - if (TRACE(GOMP_parallel_loop_runtime_real)) - { - void *pardo_helper = __GOMP_new_helper(fn, data); - - /* - * Change number of threads if specified by parallel directive only if - * in a library not mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); - - Extrae_OpenMP_ParDO_Entry(); - GOMP_parallel_loop_runtime_real(callme_pardo, pardo_helper, num_threads, start, end, incr, flags); - Extrae_OpenMP_ParDO_Exit(); - - /* - * Return to the original number of threads only if in a library not - * mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); - } - else if (GOMP_parallel_loop_runtime_real != NULL) - { - GOMP_parallel_loop_runtime_real(fn, data, num_threads, start, end, incr, flags); - } - else - { - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_runtime: This function is not hooked! Exiting!!\n", - THREAD_LEVEL_VAR); - exit(-1); - } - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_loop_runtime exit\n", THREAD_LEVEL_VAR); -#endif -} - -void -GOMP_parallel_sections(void (*fn) (void *), void *data, unsigned num_threads, unsigned count, unsigned flags) -{ -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_sections enter: @=%p args=(%p %p %u %u %u)\n", - THREAD_LEVEL_VAR, GOMP_parallel_sections_real, fn, data, num_threads, count, flags); -#endif - - OMP_CLAUSE_NUM_THREADS_SAVE(original_num_threads); - - RECHECK_INIT(GOMP_parallel_sections_real); - - if (TRACE(GOMP_parallel_sections_real)) - { - void *parsections_helper = __GOMP_new_helper(fn, data); - - /* - * Change number of threads if specified by parallel directive only if - * in a library not mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); - - Extrae_OpenMP_ParSections_Entry(); - GOMP_parallel_sections_real(callme_parsections, parsections_helper, num_threads, count, flags); - Extrae_OpenMP_ParSections_Exit(); - - /* The master thread continues the execution and then calls parsections_helper->fn */ - if (THREADID == 0) - { - Extrae_OpenMP_UF_Entry(fn); - } - - /* - * Return to the original number of threads only if in a library not - * mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(original_num_threads); - } - else if (GOMP_parallel_sections_real != NULL) - { - GOMP_parallel_sections_real(fn, data, num_threads, count, flags); - } - else - { - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_sections: This function is not hooked! Exiting!!\n", - THREAD_LEVEL_VAR); - exit(-1); - } - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL - "GOMP_parallel_sections exit\n", THREAD_LEVEL_VAR); -#endif -} - - -void GOMP_taskgroup_start (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_start enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_taskgroup_start_real); -#endif - - RECHECK_INIT(GOMP_taskgroup_start_real); - - if (TRACE(GOMP_taskgroup_start_real)) - { - Extrae_OpenMP_Taskgroup_start_Entry(); - Extrae_OpenMP_EmitTaskStatistics(); - GOMP_taskgroup_start_real (); - Extrae_OpenMP_Taskgroup_start_Exit(); - } - else if (GOMP_taskgroup_start_real != NULL) - { - GOMP_taskgroup_start_real (); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_start: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_start exit\n", THREAD_LEVEL_VAR); -#endif -} - -void GOMP_taskgroup_end (void) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_end enter: @=%p\n", THREAD_LEVEL_VAR, GOMP_taskgroup_end_real); -#endif - - RECHECK_INIT(GOMP_taskgroup_end_real); - - if (TRACE(GOMP_taskgroup_end_real)) - { - Extrae_OpenMP_Taskgroup_end_Entry(); - GOMP_taskgroup_end_real (); - Extrae_OpenMP_Taskgroup_end_Exit(); - Extrae_OpenMP_EmitTaskStatistics(); - } - else if (GOMP_taskgroup_end_real != NULL) - { - GOMP_taskgroup_end_real (); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_end: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskgroup_end exit\n", THREAD_LEVEL_VAR); -#endif -} - -/********************************************/ -/***** Added (or changed) in OpenMP 4.5 *****/ -/********************************************/ - -/* - * The prototype of GOMP_task changed in 4.0 to add a new parameter 'depend', - * and again in 4.5 to add 'priority'. We define this prototype as receiving - * varargs, and we check the runtime version to decide with how many parameters - * we will make the call to the real function. - */ -void GOMP_task (void (*fn)(void *), void *data, void (*cpyfn)(void *, void *), long arg_size, long arg_align, int if_clause, unsigned flags, ...) -{ - void **depend = NULL; - int priority = 0; - va_list ap; - - va_start (ap, flags); - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_task enter: @=%p args=(%p %p %p %ld %ld %d %u) (GOMP version: %s)\n", THREAD_LEVEL_VAR, GOMP_task_real, fn, data, cpyfn, arg_size, arg_align, if_clause, flags, __GOMP_version); -#endif - - RECHECK_INIT(GOMP_task_real); - - if (TRACE(GOMP_task_real)) - { - Extrae_OpenMP_Task_Entry (fn); - Extrae_OpenMP_Notify_NewInstantiatedTask(); - - /* - * Helpers for GOMP_task don't use the array of active helpers, as we know - * that we can free them right away after the task is executed. - */ - struct task_helper_t *task_helper = (struct task_helper_t *) malloc(sizeof(struct task_helper_t)); - task_helper->fn = fn; - task_helper->data = data; - - if (cpyfn != NULL) - { - char *buf = malloc(sizeof(char) * (arg_size + arg_align - 1)); - char *arg = (char *) (((uintptr_t) buf + arg_align - 1) - & ~(uintptr_t) (arg_align - 1)); - cpyfn (arg, data); - task_helper->data = arg; - // Saved for deallocation purposes, arg is not valid since includes offset - task_helper->buf = buf; - } - else - { - char *buf = malloc(sizeof(char) * (arg_size + arg_align - 1)); - memcpy (buf, data, arg_size); - task_helper->data = buf; - // Saved for deallocation purposes, arg is not valid since includes offset - task_helper->buf = buf; - } - -#if defined(HAVE__SYNC_FETCH_AND_ADD) - task_helper->counter = __sync_fetch_and_add(&__GOMP_task_ctr, 1); -#else - pthread_mutex_lock (&__GOMP_task_ctr_mtx); - task_helper->counter = __GOMP_task_ctr++; - pthread_mutex_unlock (&__GOMP_task_ctr_mtx); -#endif - - Extrae_OpenMP_TaskID (task_helper->counter); - - if (strcmp(__GOMP_version, GOMP_API_3_1) == 0) { - GOMP_task_real (callme_task, &task_helper, NULL, sizeof(task_helper), arg_align, if_clause, flags); - } else if (strcmp(__GOMP_version, GOMP_API_4_0) == 0) { - depend = va_arg(ap, void **); - GOMP_task_real (callme_task, &task_helper, NULL, sizeof(task_helper), arg_align, if_clause, flags, depend); - } else if (strcmp(__GOMP_version, GOMP_API_4_5) == 0) { - depend = va_arg(ap, void **); - priority = va_arg(ap, int); - GOMP_task_real (callme_task, &task_helper, NULL, sizeof(task_helper), arg_align, if_clause, flags, depend, priority); - } - - Extrae_OpenMP_Task_Exit (); - } - else if (GOMP_task_real != NULL) - { - if (strcmp(__GOMP_version, GOMP_API_3_1) == 0) { - GOMP_task_real (fn, data, cpyfn, arg_size, arg_align, if_clause, flags); - } else if (strcmp(__GOMP_version, GOMP_API_4_0) == 0) { - depend = va_arg(ap, void **); - GOMP_task_real (fn, data, cpyfn, arg_size, arg_align, if_clause, flags, depend); - } else if (strcmp(__GOMP_version, GOMP_API_4_5) == 0) { - depend = va_arg(ap, void **); - priority = va_arg(ap, int); - GOMP_task_real (fn, data, cpyfn, arg_size, arg_align, if_clause, flags, depend, priority); - } - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_task: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - - va_end(ap); - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_task exit\n", THREAD_LEVEL_VAR); -#endif -} - - -/* - * taskloop_helper ↴ data ↴ - * ---------------------------------------- - * | *cpyfn | *fn | long start | long end | - * ---------------------------------------- - */ - -void GOMP_taskloop (void *fn, void *data, void *cpyfn, long arg_size, long arg_align, unsigned flags, unsigned long num_tasks, int priority, long start, long end, long step) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskloop enter: @=%p args=(%p %p %p %ld %ld %u %lu %d %ld %ld %ld)\n", THREAD_LEVEL_VAR, GOMP_taskloop_real, fn, data, cpyfn, arg_size, arg_align, flags, num_tasks, priority, start, end, step); - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskloop: instrumentation is %s\n", THREAD_LEVEL_VAR, (getTrace_OMPTaskloop() ? "enabled" : "disabled")); -#endif - - RECHECK_INIT(GOMP_taskloop_real); - - if (TRACE(GOMP_taskloop_real) && (getTrace_OMPTaskloop())) - { - /* Store global pointers to fn and data. This is a fallback mechanism in case the runtime changes data, - * breaking our injected pointers. Using the global pointers only allows 1 simultaneous taskloop. - */ - taskloop_global_fn = fn; - taskloop_global_data = data; - - Extrae_OpenMP_TaskLoop_Entry (); - - /* Modify the input 'data' to prefix the pointers to cpyfn and fn */ - long payload = sizeof(void *) + sizeof(void *); - void *taskloop_helper = (void *)malloc(payload + arg_size); -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskloop taskloop_helper=%p\n", THREAD_LEVEL_VAR, taskloop_helper); -#endif - *((void **)(taskloop_helper)) = cpyfn; - *((void **)(taskloop_helper+sizeof(void *))) = fn; - memcpy(taskloop_helper+payload, data, arg_size); - - /* Store our modified data in a list */ - pthread_mutex_lock (&mtx_taskloop_helpers); - tracked_taskloop_helper_t *new_tracked_taskloop_helper = malloc(sizeof(tracked_taskloop_helper_t)); - new_tracked_taskloop_helper->taskloop_helper_ptr = taskloop_helper+payload; - new_tracked_taskloop_helper->next = tracked_taskloop_helpers; - tracked_taskloop_helpers = new_tracked_taskloop_helper; - pthread_mutex_unlock (&mtx_taskloop_helpers); - - if (cpyfn != NULL) - { - GOMP_taskloop_real (callme_taskloop_suffix_helper, taskloop_helper+payload, callme_taskloop_cpyfn, arg_size+payload, arg_align, flags, num_tasks, priority, start, end, step); - } - else - { - GOMP_taskloop_real (callme_taskloop_prefix_helper, taskloop_helper+payload, cpyfn, arg_size, arg_align, flags, num_tasks, priority, start, end, step); - } - - /* At this point the runtime has invoked all loop tasks so the helper can be freed */ - if (taskloop_helper != NULL) - { - free(taskloop_helper); - } - - /* Remove our modified data from the list */ - pthread_mutex_lock (&mtx_taskloop_helpers); - tracked_taskloop_helper_t *current_tracked_taskloop_helper = tracked_taskloop_helpers, *prev = NULL; - while (current_tracked_taskloop_helper != NULL) - { - if (current_tracked_taskloop_helper->taskloop_helper_ptr == taskloop_helper+payload) - { - if (prev != NULL) - { - prev->next = current_tracked_taskloop_helper->next; - } - else - { - tracked_taskloop_helpers = current_tracked_taskloop_helper->next; - } - free (current_tracked_taskloop_helper); - - break; - } - prev = current_tracked_taskloop_helper; - current_tracked_taskloop_helper = current_tracked_taskloop_helper->next; - } - pthread_mutex_unlock (&mtx_taskloop_helpers); - - Extrae_OpenMP_TaskLoop_Exit (); - } - else if (GOMP_taskloop_real != NULL) - { - GOMP_taskloop_real (fn, data, cpyfn, arg_size, arg_align, flags, num_tasks, priority, start, end, step); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskloop: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_taskloop exit\n", THREAD_LEVEL_VAR); -#endif -} - -int GOMP_loop_doacross_static_start (unsigned ncounts, long *counts, long chunk_size, long *istart, long *iend) -{ - int res; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_static_start enter: @=%p args=(%u %p %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_doacross_static_start_real, ncounts, counts, chunk_size, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_doacross_static_start_real); - - /* Save ncounts in the thread TLS */ - SAVE_DOACROSS_NCOUNTS(ncounts); - - if (TRACE(GOMP_loop_doacross_static_start_real)) - { - Extrae_OpenMP_DO_Entry (); - res = GOMP_loop_doacross_static_start_real (ncounts, counts, chunk_size, istart, iend); - } - else if (GOMP_loop_doacross_static_start_real != NULL) - { - res = GOMP_loop_doacross_static_start_real (ncounts, counts, chunk_size, istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_static_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_static_start exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_doacross_dynamic_start (unsigned ncounts, long *counts, long chunk_size, long *istart, long *iend) -{ - int res; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_dynamic_start enter: @=%p args=(%u %p %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_doacross_dynamic_start_real, ncounts, counts, chunk_size, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_doacross_dynamic_start_real); - - /* Save ncounts in the thread TLS */ - SAVE_DOACROSS_NCOUNTS(ncounts); - - if (TRACE(GOMP_loop_doacross_dynamic_start_real)) - { - Extrae_OpenMP_DO_Entry (); - res = GOMP_loop_doacross_dynamic_start_real (ncounts, counts, chunk_size, istart, iend); - } - else if (GOMP_loop_doacross_dynamic_start_real != NULL) - { - res = GOMP_loop_doacross_dynamic_start_real (ncounts, counts, chunk_size, istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_dynamic_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_dynamic_start exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_doacross_guided_start (unsigned ncounts, long *counts, long chunk_size, long *istart, long *iend) -{ - int res; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_guided_start enter: @=%p args=(%u %p %ld %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_doacross_guided_start_real, ncounts, counts, chunk_size, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_doacross_guided_start_real); - - /* Save ncounts in the thread TLS */ - SAVE_DOACROSS_NCOUNTS(ncounts); - - if (TRACE(GOMP_loop_doacross_guided_start_real)) - { - Extrae_OpenMP_DO_Entry (); - res = GOMP_loop_doacross_guided_start_real (ncounts, counts, chunk_size, istart, iend); - } - else if (GOMP_loop_doacross_guided_start_real != NULL) - { - res = GOMP_loop_doacross_guided_start_real (ncounts, counts, chunk_size, istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_guided_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_guided_start exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -int GOMP_loop_doacross_runtime_start (unsigned ncounts, long *counts, long *istart, long *iend) -{ - int res; -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_runtime_start enter: @=%p args=(%u %p %p %p)\n", THREAD_LEVEL_VAR, GOMP_loop_doacross_runtime_start_real, ncounts, counts, istart, iend); -#endif - - RECHECK_INIT(GOMP_loop_doacross_runtime_start_real); - - /* Save ncounts in the thread TLS */ - SAVE_DOACROSS_NCOUNTS(ncounts); - - if (TRACE(GOMP_loop_doacross_runtime_start_real)) - { - Extrae_OpenMP_DO_Entry (); - res = GOMP_loop_doacross_runtime_start_real (ncounts, counts, istart, iend); - } - else if (GOMP_loop_doacross_runtime_start_real != NULL) - { - res = GOMP_loop_doacross_runtime_start_real (ncounts, counts, istart, iend); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_runtime_start_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_loop_doacross_runtime_start exit: res=%d\n", THREAD_LEVEL_VAR, res); -#endif - - return res; -} - -void GOMP_doacross_post (long *counts) -{ -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_doacross_post enter: @=%p args=(%p)\n", THREAD_LEVEL_VAR, GOMP_doacross_post_real, counts); -#endif - - RECHECK_INIT(GOMP_doacross_post_real); - - if (TRACE(GOMP_doacross_post_real)) - { - Extrae_OpenMP_Ordered_Post_Entry(); - GOMP_doacross_post_real (counts); - Extrae_OpenMP_Ordered_Post_Exit(); - } - else if (GOMP_doacross_post_real != NULL) - { - GOMP_doacross_post_real (counts); - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_doacross_post: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_doacross_post exit\n", THREAD_LEVEL_VAR); -#endif -} - -/* - * The body of GOMP_doacross_wait needs a switch with as many cases as possible - * values of 'ncounts'. These cases are generated dynamically with the script - * 'genstubs-libgomp.sh' up to a maximum of DOACROSS_MAX_NESTING, defined in - * that script. - */ -void GOMP_doacross_wait (long first, ...) -{ - unsigned i = 0; - long args[MAX_DOACROSS_ARGS]; - va_list ap; - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_doacross_wait enter: @=%p args=(%ld)\n", THREAD_LEVEL_VAR, GOMP_doacross_wait_real, first); -#endif - - RECHECK_INIT(GOMP_doacross_wait_real); - - /* Retrieve ncounts from the thread TLS */ - unsigned ncounts = RETRIEVE_DOACROSS_NCOUNTS(); - - if (TRACE(GOMP_doacross_wait_real)) - { - va_start(ap, first); - for (i = 0; i < ncounts; i++) - { - args[i] = va_arg(ap, long); - } - va_end(ap); - - Extrae_OpenMP_Ordered_Wait_Entry(); - - switch (ncounts) - { - #include "gnu-libgomp-intermediate/libgomp-doacross-intermediate-switch.c" - default: - fprintf (stderr, PACKAGE_NAME": ERROR! Unhandled GOMP_doacross_wait call with %d arguments! Re-run the script 'genstubs-libgomp.sh' increasing the value of DOACROSS_MAX_NESTING. Quitting!\n", ncounts); - exit(-1); - break; - } - - Extrae_OpenMP_Ordered_Wait_Exit(); - } - else if (GOMP_doacross_wait_real != NULL) - { - va_start(ap, first); - for (i = 0; i < ncounts; i++) - { - args[i] = va_arg(ap, long); - } - va_end(ap); - - switch (ncounts) - { - #include "gnu-libgomp-intermediate/libgomp-doacross-intermediate-switch.c" - default: - fprintf (stderr, PACKAGE_NAME": ERROR! Unhandled GOMP_doacross_wait call with %d arguments! Re-run the script 'genstubs-libgomp.sh' increasing the value of DOACROSS_MAX_NESTING. Quitting!\n", ncounts); - exit(-1); - break; - } - } - else - { - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "ERROR! GOMP_doacross_wait_real: This function is not hooked! Exiting!!\n", THREAD_LEVEL_VAR); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME ":" THREAD_LEVEL_LBL "GOMP_doacross_wait exit\n", THREAD_LEVEL_VAR); -#endif -} - - -/******************************************************************************\ - * * - * INITIALIZATIONS * - * * -\******************************************************************************/ - -/** - * gnu_libgomp_get_hook_points - * - * Find the real implementation of the functions. We use dlsym to find the next - * definition of the different symbols of the OpenMP runtime (i.e. skip our - * wrapper, find the real one). - * - * @param rank The current process ID (not used). - * - * @return 1 if any hook was found; 0 otherwise. - */ -static int gnu_libgomp_get_hook_points (int rank) -{ - int count = 0; - - UNREFERENCED_PARAMETER(rank); - - // Detect the OpenMP version supported by the runtime - if ((__GOMP_version = getenv("EXTRAE___GOMP_version")) != NULL) { - if ((strcmp(__GOMP_version, GOMP_API_4_5) != 0) && - (strcmp(__GOMP_version, GOMP_API_4_0) != 0) && - (strcmp(__GOMP_version, GOMP_API_3_1) != 0)) { - fprintf(stderr, PACKAGE_NAME": ERROR! Unsupported GOMP version (%s). Valid versions are: 3.1, 4.0 and 4.5. Exiting ...\n", __GOMP_version); - exit (-1); - } - } else if (dlsym(RTLD_NEXT, "GOMP_taskloop") != NULL) { - __GOMP_version = GOMP_API_4_5; - } else if (dlsym(RTLD_NEXT, "GOMP_taskgroup_start") != NULL) { - __GOMP_version = GOMP_API_4_0; - } else { - __GOMP_version = GOMP_API_3_1; - } - - if (TASKID == 0) - { - fprintf (stdout, PACKAGE_NAME": Detected GOMP version is %s\n", __GOMP_version); - } - - /**********************/ - /***** OpenMP 3.1 *****/ - /**********************/ - - /* Obtain @ for GOMP_atomic_start */ - GOMP_atomic_start_real = - (void(*)(void)) dlsym (RTLD_NEXT, "GOMP_atomic_start"); - INC_IF_NOT_NULL(GOMP_atomic_start_real,count); - - /* Obtain @ for GOMP_atomic_end */ - GOMP_atomic_end_real = - (void(*)(void)) dlsym (RTLD_NEXT, "GOMP_atomic_end"); - INC_IF_NOT_NULL(GOMP_atomic_end_real,count); - - /* Obtain @ for GOMP_barrier */ - GOMP_barrier_real = - (void(*)(void)) dlsym (RTLD_NEXT, "GOMP_barrier"); - INC_IF_NOT_NULL(GOMP_barrier_real,count); - - /* Obtain @ for GOMP_critical_enter */ - GOMP_critical_start_real = - (void(*)(void)) dlsym (RTLD_NEXT, "GOMP_critical_start"); - INC_IF_NOT_NULL(GOMP_critical_start_real,count); - - /* Obtain @ for GOMP_critical_end */ - GOMP_critical_end_real = - (void(*)(void)) dlsym (RTLD_NEXT, "GOMP_critical_end"); - INC_IF_NOT_NULL(GOMP_critical_end_real,count); - - /* Obtain @ for GOMP_critical_name_start */ - GOMP_critical_name_start_real = - (void(*)(void**)) dlsym (RTLD_NEXT, "GOMP_critical_name_start"); - INC_IF_NOT_NULL(GOMP_critical_name_start_real,count); - - /* Obtain @ for GOMP_critical_name_end */ - GOMP_critical_name_end_real = - (void(*)(void**)) dlsym (RTLD_NEXT, "GOMP_critical_name_end"); - INC_IF_NOT_NULL(GOMP_critical_name_end_real,count); - - /* Obtain @ for GOMP_loop_static_start */ - GOMP_loop_static_start_real = - (int(*)(long,long,long,long,long*,long*)) dlsym (RTLD_NEXT, "GOMP_loop_static_start"); - INC_IF_NOT_NULL(GOMP_loop_static_start_real,count); - - /* Obtain @ for GOMP_loop_dynamic_start */ - GOMP_loop_dynamic_start_real = - (int(*)(long,long,long,long,long*,long*)) dlsym (RTLD_NEXT, "GOMP_loop_dynamic_start"); - INC_IF_NOT_NULL(GOMP_loop_dynamic_start_real,count); - - /* Obtain @ for GOMP_loop_guided_start */ - GOMP_loop_guided_start_real = - (int(*)(long,long,long,long,long*,long*)) dlsym (RTLD_NEXT, "GOMP_loop_guided_start"); - INC_IF_NOT_NULL(GOMP_loop_guided_start_real,count); - - /* Obtain @ for GOMP_loop_runtime_start */ - GOMP_loop_runtime_start_real = - (int(*)(long,long,long,long,long*,long*)) dlsym (RTLD_NEXT, "GOMP_loop_runtime_start"); - INC_IF_NOT_NULL(GOMP_loop_runtime_start_real,count); - - /* Obtain @ for GOMP_loop_static_next */ - GOMP_loop_static_next_real = - (int(*)(long*,long*)) dlsym (RTLD_NEXT, "GOMP_loop_static_next"); - INC_IF_NOT_NULL(GOMP_loop_static_next_real,count); - - /* Obtain @ for GOMP_loop_dynamic_next */ - GOMP_loop_dynamic_next_real = - (int(*)(long*,long*)) dlsym (RTLD_NEXT, "GOMP_loop_dynamic_next"); - INC_IF_NOT_NULL(GOMP_loop_dynamic_next_real,count); - - /* Obtain @ for GOMP_loop_guided_next */ - GOMP_loop_guided_next_real = - (int(*)(long*,long*)) dlsym (RTLD_NEXT, "GOMP_loop_guided_next"); - INC_IF_NOT_NULL(GOMP_loop_guided_next_real,count); - - /* Obtain @ for GOMP_loop_runtime_next */ - GOMP_loop_runtime_next_real = - (int(*)(long*,long*)) dlsym (RTLD_NEXT, "GOMP_loop_runtime_next"); - INC_IF_NOT_NULL(GOMP_loop_runtime_next_real,count); - - /* Obtain @ for GOMP_loop_ordered_static_start */ - GOMP_loop_ordered_static_start_real = - (int(*)(long, long, long, long, long *, long *)) dlsym (RTLD_NEXT, "GOMP_loop_ordered_static_start"); - INC_IF_NOT_NULL(GOMP_loop_ordered_static_start_real, count); - - /* Obtain @ for GOMP_loop_ordered_dynamic_start */ - GOMP_loop_ordered_dynamic_start_real = - (int(*)(long, long, long, long, long *, long *)) dlsym (RTLD_NEXT, "GOMP_loop_ordered_dynamic_start"); - INC_IF_NOT_NULL(GOMP_loop_ordered_dynamic_start_real, count); - - /* Obtain @ for GOMP_loop_ordered_guided_start */ - GOMP_loop_ordered_guided_start_real = - (int(*)(long, long, long, long, long *, long *)) dlsym (RTLD_NEXT, "GOMP_loop_ordered_guided_start"); - INC_IF_NOT_NULL(GOMP_loop_ordered_guided_start_real, count); - - /* Obtain @ for GOMP_loop_ordered_runtime_start */ - GOMP_loop_ordered_runtime_start_real = - (int(*)(long, long, long, long, long *, long *)) dlsym (RTLD_NEXT, "GOMP_loop_ordered_runtime_start"); - INC_IF_NOT_NULL(GOMP_loop_ordered_runtime_start_real, count); - - /* Obtain @ for GOMP_loop_ordered_static_next */ - GOMP_loop_ordered_static_next_real = - (int(*)(long*,long*)) dlsym (RTLD_NEXT, "GOMP_loop_ordered_static_next"); - INC_IF_NOT_NULL(GOMP_loop_ordered_static_next_real,count); - - /* Obtain @ for GOMP_loop_ordered_dynamic_next */ - GOMP_loop_ordered_dynamic_next_real = - (int(*)(long*,long*)) dlsym (RTLD_NEXT, "GOMP_loop_ordered_dynamic_next"); - INC_IF_NOT_NULL(GOMP_loop_ordered_dynamic_next_real,count); - - /* Obtain @ for GOMP_loop_ordered_guided_next */ - GOMP_loop_ordered_guided_next_real = - (int(*)(long*,long*)) dlsym (RTLD_NEXT, "GOMP_loop_ordered_guided_next"); - INC_IF_NOT_NULL(GOMP_loop_ordered_guided_next_real,count); - - /* Obtain @ for GOMP_loop_runtime_next */ - GOMP_loop_ordered_runtime_next_real = - (int(*)(long*,long*)) dlsym (RTLD_NEXT, "GOMP_loop_ordered_runtime_next"); - INC_IF_NOT_NULL(GOMP_loop_ordered_runtime_next_real,count); - - /* Obtain @ for GOMP_parallel_loop_static_start */ - GOMP_parallel_loop_static_start_real = - (void(*)(void*,void*,unsigned, long, long, long, long)) dlsym (RTLD_NEXT, "GOMP_parallel_loop_static_start"); - INC_IF_NOT_NULL(GOMP_parallel_loop_static_start_real,count); - - /* Obtain @ for GOMP_parallel_loop_dynamic_start */ - GOMP_parallel_loop_dynamic_start_real = - (void(*)(void*,void*,unsigned, long, long, long, long)) dlsym (RTLD_NEXT, "GOMP_parallel_loop_dynamic_start"); - INC_IF_NOT_NULL(GOMP_parallel_loop_dynamic_start_real,count); - - /* Obtain @ for GOMP_parallel_loop_guided_start */ - GOMP_parallel_loop_guided_start_real = - (void(*)(void*,void*,unsigned, long, long, long, long)) dlsym (RTLD_NEXT, "GOMP_parallel_loop_guided_start"); - INC_IF_NOT_NULL(GOMP_parallel_loop_guided_start_real,count); - - /* Obtain @ for GOMP_parallel_loop_runtime_start */ - GOMP_parallel_loop_runtime_start_real = - (void(*)(void*,void*,unsigned, long, long, long)) dlsym (RTLD_NEXT, "GOMP_parallel_loop_runtime_start"); - INC_IF_NOT_NULL(GOMP_parallel_loop_runtime_start_real,count); - - /* Obtain @ for GOMP_loop_end */ - GOMP_loop_end_real = - (void(*)(void)) dlsym (RTLD_NEXT, "GOMP_loop_end"); - INC_IF_NOT_NULL(GOMP_loop_end_real,count); - - /* Obtain @ for GOMP_loop_end_nowait */ - GOMP_loop_end_nowait_real = - (void(*)(void)) dlsym (RTLD_NEXT, "GOMP_loop_end_nowait"); - INC_IF_NOT_NULL(GOMP_loop_end_nowait_real,count); - - /* Obtain @ for GOMP_ordered_start */ - GOMP_ordered_start_real = (void(*)(void)) dlsym (RTLD_NEXT, "GOMP_ordered_start"); - INC_IF_NOT_NULL(GOMP_ordered_start_real,count); - - /* Obtain @ for GOMP_ordered_end */ - GOMP_ordered_end_real = (void(*)(void)) dlsym (RTLD_NEXT, "GOMP_ordered_end"); - INC_IF_NOT_NULL(GOMP_ordered_end_real,count); - - /* Obtain @ for GOMP_parallel_start */ - GOMP_parallel_start_real = - (void(*)(void*,void*,unsigned)) dlsym (RTLD_NEXT, "GOMP_parallel_start"); - INC_IF_NOT_NULL(GOMP_parallel_start_real,count); - - /* Obtain @ for GOMP_parallel_end */ - GOMP_parallel_end_real = - (void(*)(void)) dlsym (RTLD_NEXT, "GOMP_parallel_end"); - INC_IF_NOT_NULL(GOMP_parallel_end_real,count); - - /* Obtain @ for GOMP_parallel_sections_start */ - GOMP_parallel_sections_start_real = - (void(*)(void*,void*,unsigned,unsigned)) dlsym (RTLD_NEXT, "GOMP_parallel_sections_start"); - INC_IF_NOT_NULL(GOMP_parallel_sections_start_real,count); - - /* Obtain @ for GOMP_sections_start */ - GOMP_sections_start_real = - (unsigned(*)(unsigned)) dlsym (RTLD_NEXT, "GOMP_sections_start"); - INC_IF_NOT_NULL(GOMP_sections_start_real,count); - - /* Obtain @ for GOMP_sections_next */ - GOMP_sections_next_real = - (unsigned(*)(void)) dlsym (RTLD_NEXT, "GOMP_sections_next"); - INC_IF_NOT_NULL(GOMP_sections_next_real,count); - - /* Obtain @ for GOMP_sections_end */ - GOMP_sections_end_real = - (void(*)(void)) dlsym (RTLD_NEXT, "GOMP_sections_end"); - INC_IF_NOT_NULL(GOMP_sections_end_real,count); - - /* Obtain @ for GOMP_sections_end_nowait */ - GOMP_sections_end_nowait_real = - (void(*)(void)) dlsym (RTLD_NEXT, "GOMP_sections_end_nowait"); - INC_IF_NOT_NULL(GOMP_sections_end_nowait_real,count); - - /* Obtain @ for GOMP_single_start */ - GOMP_single_start_real = - (unsigned(*)(void)) dlsym (RTLD_NEXT, "GOMP_single_start"); - INC_IF_NOT_NULL(GOMP_single_start_real,count); - - /* Obtain @ for GOMP_taskwait */ - GOMP_taskwait_real = (void(*)(void)) dlsym (RTLD_NEXT, "GOMP_taskwait"); - INC_IF_NOT_NULL(GOMP_taskwait_real,count); - - /**********************/ - /***** OpenMP 4.0 *****/ - /**********************/ - - /* Obtain @ for GOMP_parallel */ - GOMP_parallel_real = - (void(*)(void*,void*,unsigned,unsigned int)) dlsym(RTLD_NEXT, "GOMP_parallel"); - INC_IF_NOT_NULL(GOMP_parallel_real,count); - - /* Obtain @ for GOMP_parallel_loop_static */ - GOMP_parallel_loop_static_real = - (void(*)(void*, void*, unsigned, long, long, long, long, unsigned))dlsym (RTLD_NEXT, "GOMP_parallel_loop_static"); - INC_IF_NOT_NULL(GOMP_parallel_loop_static_real,count); - - /* Obtain @ for GOMP_parallel_loop_dynamic */ - GOMP_parallel_loop_dynamic_real = - (void(*)(void*, void*, unsigned, long, long, long, long, unsigned))dlsym (RTLD_NEXT, "GOMP_parallel_loop_dynamic"); - INC_IF_NOT_NULL(GOMP_parallel_loop_dynamic_real,count); - - /* Obtain @ for GOMP_parallel_loop_guided */ - GOMP_parallel_loop_guided_real = - (void(*)(void*, void*, unsigned, long, long, long, long, unsigned))dlsym (RTLD_NEXT, "GOMP_parallel_loop_guided"); - INC_IF_NOT_NULL(GOMP_parallel_loop_guided_real,count); - - /* Obtain @ for GOMP_parallel_loop_runtime */ - GOMP_parallel_loop_runtime_real = - (void(*)(void*, void*, unsigned, long, long, long, unsigned)) dlsym(RTLD_NEXT, "GOMP_parallel_loop_runtime"); - INC_IF_NOT_NULL(GOMP_parallel_loop_runtime_real,count); - - /* Obtain @ for GOMP_parallel_sections */ - GOMP_parallel_sections_real = - (void(*)(void *, void *, unsigned, unsigned, unsigned)) dlsym(RTLD_NEXT, "GOMP_parallel_sections"); - INC_IF_NOT_NULL(GOMP_parallel_sections_real,count); - - /* Obtain @ for GOMP_taskgroup_start */ - GOMP_taskgroup_start_real = (void(*)(void)) dlsym(RTLD_NEXT, "GOMP_taskgroup_start"); - INC_IF_NOT_NULL(GOMP_taskgroup_start_real,count); - - /* Obtain @ for GOMP_taskgroup_end */ - GOMP_taskgroup_end_real = (void(*)(void)) dlsym(RTLD_NEXT, "GOMP_taskgroup_end"); - INC_IF_NOT_NULL(GOMP_taskgroup_end_real,count); - - /**********************/ - /***** OpenMP 4.5 *****/ - /**********************/ - - /* Obtain @ for GOMP_task */ - GOMP_task_real = - (void(*)(void*,void*,void*,long,long,int,unsigned,...)) dlsym (RTLD_NEXT, "GOMP_task"); - INC_IF_NOT_NULL(GOMP_task_real,count); - - /* Obtain @ for GOMP_taskloop */ - GOMP_taskloop_real = - (void(*)(void*,void*,void*,long,long,unsigned,unsigned long,int,long,long,long)) dlsym (RTLD_NEXT, "GOMP_taskloop"); - INC_IF_NOT_NULL(GOMP_taskloop_real,count); - - /* Obtain @ for GOMP_loop_doacross_static_start */ - GOMP_loop_doacross_static_start_real = (int(*)(unsigned, long *, long, long *, long *)) dlsym (RTLD_NEXT, "GOMP_loop_doacross_static_start"); - INC_IF_NOT_NULL(GOMP_loop_doacross_static_start_real,count); - - /* Obtain @ for GOMP_loop_doacross_dynamic_start */ - GOMP_loop_doacross_dynamic_start_real = (int(*)(unsigned, long *, long, long *, long *)) dlsym (RTLD_NEXT, "GOMP_loop_doacross_dynamic_start"); - INC_IF_NOT_NULL(GOMP_loop_doacross_dynamic_start_real,count); - - /* Obtain @ for GOMP_loop_doacross_guided_start */ - GOMP_loop_doacross_guided_start_real = (int(*)(unsigned, long *, long, long *, long *)) dlsym (RTLD_NEXT, "GOMP_loop_doacross_guided_start"); - INC_IF_NOT_NULL(GOMP_loop_doacross_guided_start_real,count); - - /* Obtain @ for GOMP_loop_doacross_runtime_start */ - GOMP_loop_doacross_runtime_start_real = (int(*)(unsigned, long *, long *, long *)) dlsym (RTLD_NEXT, "GOMP_loop_doacross_runtime_start"); - INC_IF_NOT_NULL(GOMP_loop_doacross_runtime_start_real,count); - - /* Obtain @ for GOMP_doacross_post */ - GOMP_doacross_post_real = (void(*)(long *)) dlsym (RTLD_NEXT, "GOMP_doacross_post"); - INC_IF_NOT_NULL(GOMP_doacross_post_real,count); - - /* Obtain @ for GOMP_doacross_wait */ - GOMP_doacross_wait_real = (void(*)(long, ...)) dlsym (RTLD_NEXT, "GOMP_doacross_wait"); - INC_IF_NOT_NULL(GOMP_doacross_wait_real,count); - - /* Any hook point? */ - return (count > 0); -} + return gnu_libgomp_get_hook_points (rank); +} #endif /* PIC */ -#endif - -/** - * _extrae_gnu_libgomp_init - * - * Initializes the instrumentation module for GNU libgomp. - * - * @param rank The current process ID (not used). - */ -int _extrae_gnu_libgomp_init (int rank) -{ - preallocate_GOMP_helpers(); - - return gnu_libgomp_get_hook_points (rank); -} - - diff --git a/src/tracer/wrappers/OMP/omp-common_c.c b/src/tracer/wrappers/OMP/omp-common_c.c index 8dcedcd9..31026bb3 100644 --- a/src/tracer/wrappers/OMP/omp-common_c.c +++ b/src/tracer/wrappers/OMP/omp-common_c.c @@ -25,6 +25,16 @@ #include "omp-probe.h" // #define DEBUG +#define STRINGIFY(x) #x +#define TOSTRING(x) STRINGIFY(x) + +#if defined (OS_RTEMS) + #define GET_REAL_FUNCTION(f) __real_##f + #define WRAP(f) __wrap_##f +#else + #define GET_REAL_FUNCTION(f) dlsym (RTLD_NEXT, TOSTRING(f)); + #define WRAP(f) f +#endif /* * In case the constructor initialization didn't trigger @@ -41,69 +51,41 @@ omp_common_get_hook_points_c(TASKID); \ } \ } -#if defined (OS_RTEMS) int (*omp_get_thread_num_real)(void) = NULL; void (*omp_set_num_threads_real)(int) = NULL; void (*omp_set_lock_real)(omp_lock_t *) = NULL; void (*omp_unset_lock_real)(omp_lock_t *) = NULL; - +#if defined (OS_RTEMS) extern int __real_omp_get_thread_num (void ) __attribute__((weak)); extern void __real_omp_set_num_threads(int num) __attribute__((weak)); extern void __real_omp_set_lock (omp_lock_t *lock) __attribute__((weak)); extern void __real_omp_unset_lock (omp_lock_t *lock) __attribute__((weak)); - - -#else -#if defined(PIC) -int (*omp_get_thread_num_real)(void) = NULL; -void (*omp_set_num_threads_real)(int) = NULL; -void (*omp_set_lock_real)(omp_lock_t *) = NULL; -void (*omp_unset_lock_real)(omp_lock_t *) = NULL; -#endif /* PIC */ #endif + void omp_common_get_hook_points_c (int rank) { UNREFERENCED_PARAMETER(rank); -#if defined(OS_RTEMS) -/* Obtain @ for omp_get_thread_num_real */ - omp_get_thread_num_real = - (int(*)(void)) __real_omp_get_thread_num; - - /* Obtain @ for omp_set_num_threads */ - omp_set_num_threads_real = - (void(*)(int)) __real_omp_set_num_threads; - - /* Obtain @ for omp_set_lock */ - omp_set_lock_real = - (void(*)(omp_lock_t*)) __real_omp_set_lock; - - /* Obtain @ for omp_unset_lock */ - omp_unset_lock_real = - (void(*)(omp_lock_t*)) __real_omp_unset_lock; - -#else -#if defined(PIC) +#if defined(PIC) || defined (OS_RTEMS) /* Obtain @ for omp_get_thread_num_real */ omp_get_thread_num_real = - (int(*)(void)) dlsym (RTLD_NEXT, "omp_get_thread_num"); + (int(*)(void)) GET_REAL_FUNCTION(omp_get_thread_num); /* Obtain @ for omp_set_num_threads */ omp_set_num_threads_real = - (void(*)(int)) dlsym (RTLD_NEXT, "omp_set_num_threads"); + (void(*)(int)) GET_REAL_FUNCTION(omp_set_num_threads); /* Obtain @ for omp_set_lock */ omp_set_lock_real = - (void(*)(omp_lock_t*)) dlsym (RTLD_NEXT, "omp_set_lock"); + (void(*)(omp_lock_t*)) GET_REAL_FUNCTION(omp_set_lock); /* Obtain @ for omp_unset_lock */ omp_unset_lock_real = - (void(*)(omp_lock_t*)) dlsym (RTLD_NEXT, "omp_unset_lock"); + (void(*)(omp_lock_t*)) GET_REAL_FUNCTION(omp_unset_lock); #endif /* PIC */ -#endif } /******************************************************************************\ @@ -111,163 +93,9 @@ void omp_common_get_hook_points_c (int rank) * C WRAPPERS * * * \******************************************************************************/ -#if defined(OS_RTEMS) - -int __wrap_omp_get_thread_num (void) -{ - static int shown = FALSE; - int res = 0; - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME": omp_get_thread_num starts (real=%p) params=(void)\n", omp_get_thread_num_real); -#endif - - RECHECK_INIT_C(omp_get_thread_num_real); - - if (omp_get_thread_num_real != NULL) - { - res = omp_get_thread_num_real(); - } - else - { - res = 0; - - if (!shown) - { - fprintf (stderr, - PACKAGE_NAME": WARNING! You have ended executing Extrae's omp_get_thread_num weak symbol! " - "That's likely to happen when you load the tracing library for OpenMP, " - "but your application is not compiled/linked against OpenMP.\n" ); - shown = TRUE; - } - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME": THREAD %d: omp_get_thread_num ends\n", res); -#endif - - return res; -} - -void -__wrap_omp_set_num_threads(int num_threads) -{ -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME - ": THREAD %d: omp_set_num_threads starts (real=%p) params=(%d)\n", - THREADID, omp_set_num_threads_real, num_threads); -#endif - - RECHECK_INIT_C(omp_set_num_threads_real); - - int canInstrument = EXTRAE_INITIALIZED() && - omp_set_num_threads_real != NULL; - - if (canInstrument && !Backend_inInstrumentation(THREADID)) - { - /* - * Change number of threads only if in a library not mixing runtimes. - */ - OMP_CLAUSE_NUM_THREADS_CHANGE(num_threads); - - Backend_Enter_Instrumentation(); - Probe_OpenMP_SetNumThreads_Entry(num_threads); - omp_set_num_threads_real(num_threads); - Probe_OpenMP_SetNumThreads_Exit(); - Backend_Leave_Instrumentation(); - } - else if (omp_set_num_threads_real != NULL) - { - omp_set_num_threads_real(num_threads); - } - else - { - fprintf(stderr, PACKAGE_NAME - ": ERROR! omp_set_num_threads is not hooked! Exiting!!\n"); - exit(-1); - } - -#if defined(DEBUG) - fprintf(stderr, PACKAGE_NAME": THREAD %d: omp_set_num_threads ends\n", - THREADID); -#endif -} - -void __wrap_omp_set_lock (omp_lock_t *lock) -{ - void *lock_ptr = (void *)lock; - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME": THREAD %d: omp_set_lock starts (real=%p) params=(%p)\n", THREADID, omp_set_lock_real, lock_ptr); -#endif - - RECHECK_INIT_C(omp_set_lock_real); - - int canInstrument = EXTRAE_INITIALIZED() && - omp_set_lock_real != NULL; - - if (canInstrument && !Backend_inInstrumentation(THREADID)) - { - Backend_Enter_Instrumentation (); - Probe_OpenMP_Named_Lock_Entry(); - omp_set_lock_real (lock_ptr); - Probe_OpenMP_Named_Lock_Exit(lock_ptr); - Backend_Leave_Instrumentation (); - } - else if (omp_set_lock_real != NULL) - { - omp_set_lock_real (lock); - } - else - { - fprintf (stderr, PACKAGE_NAME": ERROR! omp_set_lock is not hooked! Exiting!!\n"); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME": THREAD %d: omp_set_lock ends\n", THREADID); -#endif -} -void __wrap_omp_unset_lock (omp_lock_t *lock) -{ - void *lock_ptr = (void *)lock; - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME": THREAD %d: omp_unset_lock starts (real=%p) params=(%p)\n", THREADID, omp_unset_lock_real, lock_ptr); -#endif - - RECHECK_INIT_C(omp_unset_lock_real); - - int canInstrument = EXTRAE_INITIALIZED() && - omp_unset_lock_real != NULL; - - if (canInstrument && !Backend_inInstrumentation(THREADID)) - { - Backend_Enter_Instrumentation (); - Probe_OpenMP_Named_Unlock_Entry(lock_ptr); - omp_unset_lock_real (lock_ptr); - Probe_OpenMP_Named_Unlock_Exit(); - Backend_Leave_Instrumentation (); - } - else if (omp_unset_lock_real != NULL) - { - omp_unset_lock_real (lock); - } - else - { - fprintf (stderr, PACKAGE_NAME": ERROR! omp_unset_lock is not hooked! Exiting!!\n"); - exit (-1); - } - -#if defined(DEBUG) - fprintf (stderr, PACKAGE_NAME": THREAD %d: omp_unset_lock ends\n", THREADID); -#endif -} -#else -#if defined(PIC) - -int omp_get_thread_num (void) +#if defined(PIC) || defined (OS_RTEMS) +int WRAP(omp_get_thread_num) (void) { static int shown = FALSE; int res = 0; @@ -304,7 +132,7 @@ int omp_get_thread_num (void) } void -omp_set_num_threads(int num_threads) +WRAP(omp_set_num_threads) (int num_threads) { #if defined(DEBUG) fprintf(stderr, PACKAGE_NAME @@ -347,7 +175,7 @@ omp_set_num_threads(int num_threads) #endif } -void omp_set_lock (omp_lock_t *lock) +void WRAP(omp_set_lock) (omp_lock_t *lock) { void *lock_ptr = (void *)lock; @@ -383,7 +211,7 @@ void omp_set_lock (omp_lock_t *lock) #endif } -void omp_unset_lock (omp_lock_t *lock) +void WRAP(omp_unset_lock) (omp_lock_t *lock) { void *lock_ptr = (void *)lock; @@ -420,4 +248,4 @@ void omp_unset_lock (omp_lock_t *lock) } #endif /* PIC */ -#endif + From 9dfd183bc39ee85420e91b6848d0a20d04f9eed9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lau=20Mercadal=20Meli=C3=A0?= Date: Mon, 30 Oct 2023 17:22:43 +0100 Subject: [PATCH 3/3] Addresses PR91 comments Change-Id: Icca5dc77c8bd254a7067efcd32d63a203ee0f488 --- config/openmp.m4 | 23 ++++++++++++++--------- configure.ac | 1 + src/common/utils.c | 13 ++++++------- src/tracer/wrappers/OMP/gnu-libgomp.c | 19 ++++--------------- src/tracer/wrappers/OMP/omp-common_c.c | 2 ++ 5 files changed, 27 insertions(+), 31 deletions(-) diff --git a/config/openmp.m4 b/config/openmp.m4 index 09d1ff04..d15e2e90 100644 --- a/config/openmp.m4 +++ b/config/openmp.m4 @@ -90,15 +90,20 @@ AC_DEFUN([AX_CHECK_OPENMP], AC_DEFUN([AX_HAVE_SYNC_FETCH_AND_ADD], [ AC_MSG_CHECKING([for __sync_fetch_and_add availability]) - AC_TRY_LINK( - [ ], - [ volatile int i; __sync_fetch_and_add(&i,1); ], - [ have_sync_fetch_and_add="yes" ] - ) - - if test "${have_sync_fetch_and_add}" = "yes" -a "${IS_GR740_MACHINE}" = "no" ; then - AC_DEFINE([HAVE__SYNC_FETCH_AND_ADD], 1, [Define if __sync_fetch_and_add is available]) - AC_MSG_RESULT([yes]) + # GR740 has a non-functional __sync_fetch_and_add + if test "${IS_GR740_MACHINE}" = "no"; then + AC_TRY_LINK( + [ ], + [ volatile int i; __sync_fetch_and_add(&i,1); ], + [ have_sync_fetch_and_add="yes" ] + ) + + if test "${have_sync_fetch_and_add}" = "yes"; then + AC_DEFINE([HAVE__SYNC_FETCH_AND_ADD], 1, [Define if __sync_fetch_and_add is available]) + AC_MSG_RESULT([yes]) + else + AC_MSG_RESULT([no]) + fi else AC_MSG_RESULT([no]) fi diff --git a/configure.ac b/configure.ac index 43de1ef1..a254047a 100644 --- a/configure.ac +++ b/configure.ac @@ -472,6 +472,7 @@ AC_CHECK_SIZEOF(ssize_t,${size_t_size}) AC_CHECK_SIZEOF(size_t,${size_t_size}) AC_CHECK_SIZEOF(void*,${voidp_size}) +# GR740 has a non-functional mallinfo structure if test "${IS_GR740_MACHINE}" != "yes" ; then AC_CHECK_MEMBER(struct mallinfo.arena, [AC_DEFINE([HAVE_MALLINFO], [1], [Whether the system supports mallinfo structure])], diff --git a/src/common/utils.c b/src/common/utils.c index 18b9559a..989e166a 100644 --- a/src/common/utils.c +++ b/src/common/utils.c @@ -228,6 +228,12 @@ int __Extrae_Utils_append_from_to_file (const char *source, const char *destinat int __Extrae_Utils_rename_or_copy (char *origen, char *desti) { +#if defined (OS_RTEMS) + /* + * Renaming to an already existing filename using NFS on GR740 caused errors so we delete the destination file first + */ + remove(desti); +#endif if (rename (origen, desti) == -1) { if (errno == EXDEV) @@ -281,13 +287,6 @@ int __Extrae_Utils_rename_or_copy (char *origen, char *desti) /* Remove the files */ unlink (origen); } -#if defined (OS_RTEMS) - else if (errno == EEXIST) - { - if (remove(desti) != -1) - __Extrae_Utils_rename_or_copy (origen, desti); - } -#endif else { perror("rename"); diff --git a/src/tracer/wrappers/OMP/gnu-libgomp.c b/src/tracer/wrappers/OMP/gnu-libgomp.c index 07225966..8340aa62 100644 --- a/src/tracer/wrappers/OMP/gnu-libgomp.c +++ b/src/tracer/wrappers/OMP/gnu-libgomp.c @@ -2839,20 +2839,7 @@ static int gnu_libgomp_get_hook_points (int rank) int count = 0; UNREFERENCED_PARAMETER(rank); -#if defined (OS_RTEMS) -if ((__GOMP_version = getenv("EXTRAE___GOMP_version")) != NULL) { - if ((strcmp(__GOMP_version, GOMP_API_4_5) != 0) && - (strcmp(__GOMP_version, GOMP_API_4_0) != 0) && - (strcmp(__GOMP_version, GOMP_API_3_1) != 0)) { - fprintf(stderr, PACKAGE_NAME": ERROR! Unsupported GOMP version (%s). Valid versions are: 3.1, 4.0 and 4.5. Exiting ...\n", __GOMP_version); - exit (-1); - } - } - else{ - printf("GOMP version not found, please specify the EXTRAE___GOMP_version environment variable"); - } -#else // Detect the OpenMP version supported by the runtime if ((__GOMP_version = getenv("EXTRAE___GOMP_version")) != NULL) { if ((strcmp(__GOMP_version, GOMP_API_4_5) != 0) && @@ -2861,20 +2848,22 @@ if ((__GOMP_version = getenv("EXTRAE___GOMP_version")) != NULL) { fprintf(stderr, PACKAGE_NAME": ERROR! Unsupported GOMP version (%s). Valid versions are: 3.1, 4.0 and 4.5. Exiting ...\n", __GOMP_version); exit (-1); } - } else if (dlsym(RTLD_NEXT, "GOMP_taskloop") != NULL) { + } +#if !defined (OS_RTEMS) + else if (dlsym(RTLD_NEXT, "GOMP_taskloop") != NULL) { __GOMP_version = GOMP_API_4_5; } else if (dlsym(RTLD_NEXT, "GOMP_taskgroup_start") != NULL) { __GOMP_version = GOMP_API_4_0; } else { __GOMP_version = GOMP_API_3_1; } +#endif /* !OS_RTEMS */ if (TASKID == 0) { fprintf (stdout, PACKAGE_NAME": Detected GOMP version is %s\n", __GOMP_version); } -#endif /**********************/ /***** OpenMP 3.1 *****/ diff --git a/src/tracer/wrappers/OMP/omp-common_c.c b/src/tracer/wrappers/OMP/omp-common_c.c index ef0ee59d..583c52f5 100644 --- a/src/tracer/wrappers/OMP/omp-common_c.c +++ b/src/tracer/wrappers/OMP/omp-common_c.c @@ -42,10 +42,12 @@ } \ } +#if defined(PIC) || defined (OS_RTEMS) int (*omp_get_thread_num_real)(void) = NULL; void (*omp_set_num_threads_real)(int) = NULL; void (*omp_set_lock_real)(omp_lock_t *) = NULL; void (*omp_unset_lock_real)(omp_lock_t *) = NULL; +#endif /* PIC */ #if defined (OS_RTEMS) extern int __real_omp_get_thread_num (void ) __attribute__((weak));