swim-fd-internal.h 2.48 KB
Newer Older
1
/*
Shane Snyder's avatar
Shane Snyder committed
2 3
 * Copyright (c) 2016 UChicago Argonne, LLC
 *
4 5 6
 * See COPYRIGHT in top-level directory.
 */

Shane Snyder's avatar
Shane Snyder committed
7
#pragma once
8

9 10 11
#include <abt.h>
#include <margo.h>

12
#include "swim-fd.h"
Shane Snyder's avatar
Shane Snyder committed
13
#include "utlist.h"
14

15 16 17 18
#ifdef __cplusplus
extern "C" {
#endif

19
/* SWIM protocol parameter defaults */
20 21 22 23 24 25 26
#define SWIM_DEF_PROTOCOL_PERIOD_LEN    2000.0  /* milliseconds */
#define SWIM_DEF_SUSPECT_TIMEOUT        5       /* protocol period lengths */
#define SWIM_DEF_SUBGROUP_SIZE          2
#define SWIM_MAX_SUBGROUP_SIZE          5
#define SWIM_MAX_PIGGYBACK_ENTRIES      8
#define SWIM_MAX_PIGGYBACK_TX_COUNT     50

27 28 29 30
/* debug printing macro for SSG */
#ifdef DEBUG
#define SWIM_DEBUG(__swim_ctx, __fmt, ...) do { \
    double __now = ABT_get_wtime(); \
31
    fprintf(stdout, "[%.6lf] %20"PRIu64": SWIM " __fmt, __now, \
32 33 34 35 36 37 38 39
        __swim_ctx->self_id, ## __VA_ARGS__); \
    fflush(stdout); \
} while(0)
#else
#define SWIM_DEBUG(__swim_ctx, __fmt, ...) do { \
} while(0)
#endif

40 41 42
/* internal swim context implementation */
struct swim_context
{
43 44 45
    margo_instance_id mid;
    /* void pointer to user group data */
    void *group_data;
46
    /* group management callbacks */
Shane Snyder's avatar
Shane Snyder committed
47
    swim_group_mgmt_callbacks_t swim_callbacks;
48 49 50 51 52
    /* SWIM protocol parameters */
    double prot_period_len;
    int prot_susp_timeout;
    int prot_subgroup_sz;
    /* SWIM protocol internal state */
53 54
    swim_member_id_t self_id;
    swim_member_inc_nr_t self_inc_nr;
Shane Snyder's avatar
Shane Snyder committed
55 56 57
    swim_member_id_t dping_target_id;
    swim_member_inc_nr_t dping_target_inc_nr;
    hg_addr_t dping_target_addr;
58
    double dping_timeout;
Shane Snyder's avatar
Shane Snyder committed
59 60 61 62
    swim_member_id_t iping_target_ids[SWIM_MAX_SUBGROUP_SIZE];
    hg_addr_t iping_target_addrs[SWIM_MAX_SUBGROUP_SIZE];
    int iping_target_ndx;
    int ping_target_acked;
63 64 65
    void *suspect_list;
    void *recent_update_list;
    int shutdown_flag;
66
    /* argobots pool for launching SWIM threads */
67
    ABT_pool swim_pool;
68 69
    /* mutex for modifying SWIM group state */
    ABT_mutex swim_mutex;
70 71 72 73
    /* swim protocol ULT handle */
    ABT_thread prot_thread;
};

Shane Snyder's avatar
Shane Snyder committed
74
/* SWIM ping function prototypes */
75
void swim_register_ping_rpcs(
76
    swim_context_t * swim_ctx);
77
void swim_dping_send_ult(
78
    void * t_arg);
79
void swim_iping_send_ult(
80
    void * t_arg);
81

Shane Snyder's avatar
Shane Snyder committed
82 83
/* SWIM membership update function prototypes */
void swim_retrieve_membership_updates(
84 85 86
    swim_context_t *swim_ctx,
    swim_member_update_t *updates,
    hg_size_t *update_count);
Shane Snyder's avatar
Shane Snyder committed
87
void swim_apply_membership_updates(
88 89 90
    swim_context_t *swim_ctx,
    swim_member_update_t *updates,
    hg_size_t update_count);
Shane Snyder's avatar
Shane Snyder committed
91

92 93 94
#ifdef __cplusplus
}
#endif