From b3255eaedb322e9c85913dc9a09ac12ff87fa288 Mon Sep 17 00:00:00 2001 From: Phil Carns Date: Fri, 28 Jun 2024 10:20:50 -0400 Subject: [PATCH 1/6] switch to in-tree wrappers for bedrock query - c++ code provided by Matthieu Dorier --- configure.ac | 12 ------------ src/Makefile.subdir | 4 +++- src/quintain-benchmark.c | 2 +- 3 files changed, 4 insertions(+), 14 deletions(-) diff --git a/configure.ac b/configure.ac index 4cae103..6891f26 100755 --- a/configure.ac +++ b/configure.ac @@ -85,18 +85,6 @@ LIBS="$BEDROCK_LIBS $LIBS" CPPFLAGS="$BEDROCK_CFLAGS $CPPFLAGS" CFLAGS="$BEDROCK_CFLAGS $CFLAGS" -# see if bedrock has a C API for retrieving configuration -AC_MSG_CHECKING(for bedrock_service_query_config in Bedrock) -AC_TRY_COMPILE([ -#include -], [ -char* foo = bedrock_service_query_config(NULL, ""); -], -AC_MSG_RESULT(yes), -AC_MSG_RESULT(no) -AC_MSG_ERROR([This version of Bedrock does not support bedrock_service_query_config]) -) - PKG_CHECK_MODULES([SSG], [ssg >= 0.5],[], [AC_MSG_ERROR([Could not find working SSG installationi v0.5 or higher])]) LIBS="$SSG_LIBS $LIBS" diff --git a/src/Makefile.subdir b/src/Makefile.subdir index ca35873..d0a83f0 100644 --- a/src/Makefile.subdir +++ b/src/Makefile.subdir @@ -2,7 +2,9 @@ src_libquintain_bedrock_la_SOURCES += src/quintain-bedrock-module.c src_libquintain_bedrock_la_LIBADD = src/libquintain-server.la src/libquintain-client.la src_libquintain_client_la_SOURCES += src/quintain-client.c \ - src/quintain-rpc.h + src/quintain-rpc.h \ + src/bedrock-c-wrapper.cpp \ + bedrock-c-wrapper.h src_libquintain_server_la_SOURCES += src/quintain-server.c \ src/quintain-rpc.h diff --git a/src/quintain-benchmark.c b/src/quintain-benchmark.c index 1825b73..1bcf3b6 100644 --- a/src/quintain-benchmark.c +++ b/src/quintain-benchmark.c @@ -24,9 +24,9 @@ #include #include #include -#include #include "quintain-macros.h" +#include "bedrock-c-wrapper.h" /* record up to 32 million (power of 2) samples. This will take 256 MiB of RAM * per rank */ From 0e55c2275293ed68efe25989d2fdffd56fcc7b03 Mon Sep 17 00:00:00 2001 From: Phil Carns Date: Fri, 28 Jun 2024 10:44:53 -0400 Subject: [PATCH 2/6] use quintain library on server side too --- src/Makefile.subdir | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Makefile.subdir b/src/Makefile.subdir index d0a83f0..9e7b871 100644 --- a/src/Makefile.subdir +++ b/src/Makefile.subdir @@ -1,5 +1,5 @@ src_libquintain_bedrock_la_SOURCES += src/quintain-bedrock-module.c -src_libquintain_bedrock_la_LIBADD = src/libquintain-server.la src/libquintain-client.la +src_libquintain_bedrock_la_LIBADD = src/libquintain-server.la src/libquintain-client.la -lbedrock-client src_libquintain_client_la_SOURCES += src/quintain-client.c \ src/quintain-rpc.h \ @@ -7,7 +7,9 @@ src_libquintain_client_la_SOURCES += src/quintain-client.c \ bedrock-c-wrapper.h src_libquintain_server_la_SOURCES += src/quintain-server.c \ - src/quintain-rpc.h + src/quintain-rpc.h \ + src/bedrock-c-wrapper.cpp \ + bedrock-c-wrapper.h dist_bin_SCRIPTS += src/quintain-benchmark-parse.sh From 57f9058783f0c80437af62afd853ab6208e32725 Mon Sep 17 00:00:00 2001 From: Phil Carns Date: Fri, 28 Jun 2024 10:49:57 -0400 Subject: [PATCH 3/6] more notes in README.md --- README.md | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/README.md b/README.md index d106dae..f076338 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,10 @@ mochi-quintain is a microservice (i.e., a Mochi provider) that responds to parameterized RPCs to generate synthetic concurrent server load. +NOTE: As of June 2024, Quintain requires that bedrock be built with SSG +support (`+ssg` in Spack). In the future it will be updated to support +Flock. + ## Provider The provider portion of mochi-quintain can be started with bedrock. @@ -21,3 +25,20 @@ Or none at all: The primary client is an MPI program that generates a workload for the provider and measures it's performance. +## Example executioa by hand + +Note that this example assumes that you are running from within the build +tree and thus need to set an explicit library path for bedrock to be able to +find the provider libraries for quintain. + +In one terminal (for a server): +``` +export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/home/carns/working/src/mochi/mochi-quintain/build/src/.libs" + +bedrock --jx9 -c ~/working/src/mochi/mochi-quintain/tests/mochi-quintain-provider.jx9 --jx9-context "num_rpc_xstreams=5" na+sm:// +``` + +In another terminal (for a client): +``` +src/quintain-benchmark -g quintain.ssg -j ../tests/quintain-benchmark-example.json -o foo +``` From 7a11fa160517b71357705543c3f722455fd8dbf8 Mon Sep 17 00:00:00 2001 From: Phil Carns Date: Fri, 12 Jul 2024 07:27:07 -0400 Subject: [PATCH 4/6] add missing wrapper files --- src/bedrock-c-wrapper.cpp | 48 +++++++++++++++++++++++++++++++++++++++ src/bedrock-c-wrapper.h | 33 +++++++++++++++++++++++++++ 2 files changed, 81 insertions(+) create mode 100644 src/bedrock-c-wrapper.cpp create mode 100644 src/bedrock-c-wrapper.h diff --git a/src/bedrock-c-wrapper.cpp b/src/bedrock-c-wrapper.cpp new file mode 100644 index 0000000..fdf910b --- /dev/null +++ b/src/bedrock-c-wrapper.cpp @@ -0,0 +1,48 @@ +#include "bedrock-c-wrapper.h" +#include +#include + +struct bedrock_client { + bedrock::Client inner; +}; + +struct bedrock_service { + bedrock::ServiceHandle inner; +}; + +extern "C" int bedrock_client_init(margo_instance_id mid, + bedrock_client_t* client) +{ + *client = new bedrock_client{bedrock::Client{mid}}; + return BEDROCK_SUCCESS; +} + +extern "C" int bedrock_client_finalize(bedrock_client_t client) +{ + delete client; + return BEDROCK_SUCCESS; +} + +extern "C" int bedrock_service_handle_create(bedrock_client_t client, + const char* address, + uint16_t provider_id, + bedrock_service_t* sh) +{ + *sh = new bedrock_service{ + client->inner.makeServiceHandle(address, provider_id)}; + return BEDROCK_SUCCESS; +} + +extern "C" int bedrock_service_handle_destroy(bedrock_service_t sh) +{ + delete sh; + return BEDROCK_SUCCESS; +} + +extern "C" char* bedrock_service_query_config(bedrock_service_t sh, + const char* script) +{ + std::string config; + sh->inner.queryConfig(script, &config); + return strdup(config.c_str()); +} diff --git a/src/bedrock-c-wrapper.h b/src/bedrock-c-wrapper.h new file mode 100644 index 0000000..f6ad9df --- /dev/null +++ b/src/bedrock-c-wrapper.h @@ -0,0 +1,33 @@ +#ifndef BEDROCK_C_WRAPPER +#define BEDROCK_C_WRAPPER + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +#define BEDROCK_SUCCESS 0 + +typedef struct bedrock_client* bedrock_client_t; +typedef struct bedrock_service* bedrock_service_t; + +int bedrock_client_init(margo_instance_id mid, bedrock_client_t* client); + +int bedrock_client_finalize(bedrock_client_t client); + +int bedrock_service_handle_create(bedrock_client_t, + const char* address, + uint16_t provider_id, + bedrock_service_t* sh); + +int bedrock_service_handle_destroy(bedrock_service_t sh); + +char* bedrock_service_query_config(bedrock_service_t sh, const char* script); + +#ifdef __cplusplus +} +#endif + +#endif From 4393448eeca5ebd5003076ee40cafc8152937e97 Mon Sep 17 00:00:00 2001 From: Phil Carns Date: Fri, 12 Jul 2024 07:37:24 -0400 Subject: [PATCH 5/6] switch zlib autoconf test to pkgconfig --- configure.ac | 6 +++++- m4/check_zlib.m4 | 26 -------------------------- 2 files changed, 5 insertions(+), 27 deletions(-) delete mode 100644 m4/check_zlib.m4 diff --git a/configure.ac b/configure.ac index 6891f26..57a8a9a 100755 --- a/configure.ac +++ b/configure.ac @@ -92,7 +92,11 @@ CPPFLAGS="$SSG_CFLAGS $CPPFLAGS" CFLAGS="$SSG_CFLAGS $CFLAGS" # need zlib output file -CHECK_ZLIB +PKG_CHECK_MODULES([ZLIB], [zlib],[], + [AC_MSG_ERROR([Could not find working zlib installation!])]) +LIBS="$ZLIB_LIBS $LIBS" +CPPFLAGS="$ZLIB_CFLAGS $CPPFLAGS" +CFLAGS="$ZLIB_CFLAGS $CFLAGS" # optional mpi; this will cause the benchmark program to be built as well, # in addition to the provider piece diff --git a/m4/check_zlib.m4 b/m4/check_zlib.m4 deleted file mode 100644 index 568dcd9..0000000 --- a/m4/check_zlib.m4 +++ /dev/null @@ -1,26 +0,0 @@ -AC_DEFUN([CHECK_ZLIB], -[ - -AC_ARG_WITH(zlib, -[ --with-zlib=DIR root directory path of zlib installation [defaults to - /usr/local or /usr if not found in /usr/local] - --without-zlib to disable zlib usage completely], -[if test "$withval" != no ; then - if test -d "$withval" - then - ZLIB_HOME="$withval" - LDFLAGS="$LDFLAGS -L${ZLIB_HOME}/lib" - CPPFLAGS="$CPPFLAGS -I${ZLIB_HOME}/include" - __DARSHAN_ZLIB_LINK_FLAGS="-L${ZLIB_HOME}/lib" - __DARSHAN_ZLIB_INCLUDE_FLAGS="-I${ZLIB_HOME}/include" - else - AC_MSG_WARN([Sorry, $withval does not exist, checking usual places]) - fi -else - AC_MSG_ERROR(zlib is required) -fi]) - -AC_CHECK_HEADER(zlib.h, [],[AC_MSG_ERROR(zlib.h not found)]) -AC_CHECK_LIB(z, inflateEnd, [],[AC_MSG_ERROR(libz not found)]) - -]) From a542633b1581e52c89d37c4a5de63ecdd197ca66 Mon Sep 17 00:00:00 2001 From: Phil Carns Date: Fri, 12 Jul 2024 16:25:16 -0400 Subject: [PATCH 6/6] bug fix - correctly handle bulk tranfers using pool sets --- src/quintain-server.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/quintain-server.c b/src/quintain-server.c index 9163096..c277f9c 100644 --- a/src/quintain-server.c +++ b/src/quintain-server.c @@ -242,7 +242,12 @@ static void qtn_work_ult(hg_handle_t handle) finish: margo_respond(handle, &out); margo_free_input(handle, &in); - if (bulk_handle != HG_BULK_NULL) margo_bulk_free(bulk_handle); + if (bulk_handle != HG_BULK_NULL) { + if (in.flags & QTN_WORK_USE_SERVER_POOLSET) + margo_bulk_poolset_release(provider->poolset, bulk_handle); + else + margo_bulk_free(bulk_handle); + } if (bulk_buffer != NULL) free(bulk_buffer); if (out.resp_buffer) free(out.resp_buffer); margo_destroy(handle);