From 314c4b9e411a3dcd27875a751ce36e794d7675d3 Mon Sep 17 00:00:00 2001 From: Phil Carns Date: Mon, 16 Dec 2024 12:39:49 -0500 Subject: [PATCH 1/2] autoconf test for hpctoolkit --- configure.ac | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/configure.ac b/configure.ac index c89ce80..5c58574 100755 --- a/configure.ac +++ b/configure.ac @@ -98,6 +98,25 @@ LIBS="$ZLIB_LIBS $LIBS" CPPFLAGS="$ZLIB_CFLAGS $CPPFLAGS" CFLAGS="$ZLIB_CFLAGS $CFLAGS" +AC_ARG_WITH([hpctoolkit], +[AS_HELP_STRING([--with-hpctoolkit], + [enable explicit support for HPCToolkit profiling control])], +[], +[with_hpctoolkit=no]) + +# if hpctoolkit support not disabled, check for header and library +if test x$with_hpctoolkit != xno; then + # guess that hpctoolkit might be in the spack env. Otherwise the user + # needs to set LDFLAGS appropriately at configure time + LIBS="-L$SPACK_ENV/.spack-env/view/lib/hpctoolkit $LIBS" + AC_CHECK_HEADER([hpctoolkit.h], + [AC_CHECK_LIB(hpctoolkit, hpctoolkit_sampling_start, + [AC_DEFINE(HAVE_HPCTOOLKIT, 1, [HPCToolkit support enabled]) + LIBS="-lhpctoolkit $LIBS"], + [AC_MSG_ERROR(Cannot find required hpctoolkit_sampling_start() in libhpctoolkit)])], + [AC_MSG_ERROR(Cannot find hpctoolkit headers)]) +fi + # optional mpi; this will cause the benchmark program to be built as well, # in addition to the provider piece AC_MSG_CHECKING([If MPI programs can be compiled]) From bca857f59a0c7f4c9adced4d6e78c19a94f8bc0f Mon Sep 17 00:00:00 2001 From: Phil Carns Date: Mon, 16 Dec 2024 13:24:38 -0500 Subject: [PATCH 2/2] explicit start of hpctoolkit sampling --- src/quintain-server.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/quintain-server.c b/src/quintain-server.c index 1875077..70a02ce 100644 --- a/src/quintain-server.c +++ b/src/quintain-server.c @@ -18,6 +18,10 @@ #include #include +#ifdef HAVE_HPCTOOLKIT + #include +#endif + #include "quintain-rpc.h" #include "quintain-macros.h" @@ -172,6 +176,10 @@ int quintain_provider_deregister(quintain_provider_t provider) return QTN_SUCCESS; } +#ifdef HAVE_HPCTOOLKIT +static int hpctoolkit_started = 0; +#endif + static void qtn_work_ult(hg_handle_t handle) { margo_instance_id mid = MARGO_INSTANCE_NULL; @@ -186,6 +194,13 @@ static void qtn_work_ult(hg_handle_t handle) memset(&out, 0, sizeof(out)); +#ifdef HAVE_HPCTOOLKIT + if (!hpctoolkit_started) { + hpctoolkit_sampling_start(); + hpctoolkit_started = 1; + } +#endif + mid = margo_hg_handle_get_instance(handle); assert(mid); info = margo_get_info(handle);