downstream_api.h 1.49 KB
Newer Older
1 2 3 4 5 6 7
/* Filename: downstream_api.h
 *
 * Includes required headers, functions and parameters used by NRM downstream 
 * interface
 *
 */

8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
#ifndef NRM_H
#define NRM_H 1

#include<time.h>

/* min time in nsec between messages: necessary for rate-limiting progress
 * report. For now, 10ms is the threashold. */
#define NRM_RATELIMIT_THRESHOLD (10000000LL)

struct nrm_context {
    void *context;
    void *socket;
    char *container_uuid;
    char *app_uuid;
    struct timespec time;
    unsigned long acc;
};

#define NRM_DEFAULT_URI "ipc:///tmp/nrm-downstream-in"
#define NRM_ENV_URI "ARGO_NRM_DOWNSTREAM_IN_URI"

#define NRM_START_FORMAT "{\"type\":\"application\", \"event\":\"start\", \"container\": \"%s\", \"uuid\": \"%s\", \"progress\": true, \"threads\": null}"
#define NRM_PROGRESS_FORMAT "{\"type\":\"application\", \"event\":\"progress\", \"payload\": \"%lu\", \"uuid\": \"%s\"}"
31
#define NRM_POWER_POLICY_FORMAT "{\"type\":\"application\", \"event\":\"power_policy\", \"cpu\": \"%d\", \"startcompute\": \"%lf\", \"endcompute\": \"%lf\", \"startbarrier\": \"%lf\", \"endbarrier\": \"%lf\", \"uuid\": \"%s\"}"
32 33 34 35 36 37
#define NRM_EXIT_FORMAT "{\"type\":\"application\", \"event\":\"exit\", \"uuid\": \"%s\"}"

int nrm_init(struct nrm_context *, const char *);
int nrm_fini(struct nrm_context *);

int nrm_send_progress(struct nrm_context *, unsigned long);
38 39 40
int nrm_invoke_power_policy(struct nrm_context *ctxt, int cpu, double 
        startCompute, double endCompute, double startBarrier, double 
        endBarrier);
41 42

#endif