Skip to content

Commit

Permalink
Adds Caliper annotations to module
Browse files Browse the repository at this point in the history
  • Loading branch information
ilumsden committed Jul 28, 2023
1 parent 1773aee commit 5ca0060
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/modules/dyad.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@
#include "utils.h"
#include "dyad_dtl_impl.h"

#if HAVE_CALIPER
#include <caliper/cali.h>
#endif

#define TIME_DIFF(Tstart, Tend) \
((double)(1000000000L * ((Tend).tv_sec - (Tstart).tv_sec) + (Tend).tv_nsec \
- (Tstart).tv_nsec) \
Expand Down Expand Up @@ -62,25 +66,40 @@ static void dyad_mod_fini (void) __attribute__ ((destructor));

void dyad_mod_fini (void)
{
#if HAVE_CALIPER
CALI_MARK_FUNCTION;
#endif
flux_t *h = flux_open (NULL, 0);

if (h != NULL) {
}
#if HAVE_CALIPER
CALI_MARK_FUNCTION_END;
#endif
}

static void freectx (void *arg)
{
#if HAVE_CALIPER
CALI_MARK_FUNCTION;
#endif
dyad_mod_ctx_t *ctx = (dyad_mod_ctx_t *)arg;
flux_msg_handler_delvec (ctx->handlers);
if (ctx->dtl_handle != NULL) {
dyad_dtl_finalize (&(ctx->dtl_handle));
ctx->dtl_handle = NULL;
}
free (ctx);
#if HAVE_CALIPER
CALI_MARK_FUNCTION_END;
#endif
}

static dyad_mod_ctx_t *getctx (flux_t *h)
{
#if HAVE_CALIPER
CALI_MARK_FUNCTION;
#endif
dyad_mod_ctx_t *ctx = (dyad_mod_ctx_t *)flux_aux_get (h, "dyad");

if (!ctx) {
Expand All @@ -103,9 +122,15 @@ static dyad_mod_ctx_t *getctx (flux_t *h)
goto getctx_done;

getctx_error:;
#if HAVE_CALIPER
CALI_MARK_FUNCTION_END;
#endif
return NULL;

getctx_done:
#if HAVE_CALIPER
CALI_MARK_FUNCTION_END;
#endif
return ctx;
}

Expand All @@ -118,6 +143,9 @@ static void dyad_fetch_request_cb (flux_t *h,
const flux_msg_t *msg,
void *arg)
{
#if HAVE_CALIPER
CALI_MARK_FUNCTION;
#endif
FLUX_LOG_INFO (h, "Launched callback for dyad.fetch\n");
dyad_mod_ctx_t *ctx = getctx (h);
ssize_t inlen = 0;
Expand Down Expand Up @@ -218,6 +246,9 @@ static void dyad_fetch_request_cb (flux_t *h,
}
errno = saved_errno;
FLUX_LOG_INFO (h, "Finished dyad.fetch module invocation\n");
#if HAVE_CALIPER
CALI_MARK_FUNCTION_END;
#endif
return;

fetch_error:
Expand All @@ -226,11 +257,17 @@ static void dyad_fetch_request_cb (flux_t *h,
FLUX_LOG_ERR (h, "DYAD_MOD: %s: flux_respond_error", __FUNCTION__);
}
errno = saved_errno;
#if HAVE_CALIPER
CALI_MARK_FUNCTION_END;
#endif
return;
}

static dyad_rc_t dyad_open (flux_t *h, dyad_dtl_mode_t dtl_mode, bool debug)
{
#if HAVE_CALIPER
CALI_MARK_FUNCTION;
#endif
dyad_mod_ctx_t *ctx = getctx (h);
dyad_rc_t rc = 0;
char *e = NULL;
Expand All @@ -243,6 +280,9 @@ static dyad_rc_t dyad_open (flux_t *h, dyad_dtl_mode_t dtl_mode, bool debug)
ctx->debug
);

#if HAVE_CALIPER
CALI_MARK_FUNCTION_END;
#endif
return rc;
}

Expand All @@ -267,6 +307,9 @@ void usage()

DYAD_DLL_EXPORTED int mod_main (flux_t *h, int argc, char **argv)
{
#if HAVE_CALIPER
CALI_MARK_FUNCTION;
#endif
const mode_t m = (S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH | S_ISGID);
dyad_mod_ctx_t *ctx = NULL;
size_t flag_len = 0;
Expand Down Expand Up @@ -334,9 +377,15 @@ DYAD_DLL_EXPORTED int mod_main (flux_t *h, int argc, char **argv)
goto mod_done;

mod_error:;
#if HAVE_CALIPER
CALI_MARK_FUNCTION_END;
#endif
return EXIT_FAILURE;

mod_done:;
#if HAVE_CALIPER
CALI_MARK_FUNCTION_END;
#endif
return EXIT_SUCCESS;
}

Expand Down

0 comments on commit 5ca0060

Please sign in to comment.