swim-fd-internal.h 2.52 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 31 32 33 34 35 36 37 38 39
/* debug printing macro for SSG */
#ifdef DEBUG
#define SWIM_DEBUG(__swim_ctx, __fmt, ...) do { \
    double __now = ABT_get_wtime(); \
    fprintf(stdout, "%.6lf <%020"PRIu64">: SWIM: " __fmt, __now, \
        __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;
Shane Snyder's avatar
Shane Snyder committed
46 47
    /* XXX group mgmt callbacks */
    swim_group_mgmt_callbacks_t swim_callbacks;
48 49 50
    /* XXX other state */
    swim_member_id_t self_id;
    swim_member_inc_nr_t self_inc_nr;
Shane Snyder's avatar
Shane Snyder committed
51 52 53
    swim_member_id_t dping_target_id;
    swim_member_inc_nr_t dping_target_inc_nr;
    hg_addr_t dping_target_addr;
54
    double dping_timeout;
Shane Snyder's avatar
Shane Snyder committed
55 56 57 58
    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;
59
    /* argobots pool for launching SWIM threads */
60
    ABT_pool swim_pool;
61 62
    /* mutex for modifying SWIM group state */
    ABT_mutex swim_mutex;
63 64 65 66 67 68
    /* swim protocol ULT handle */
    ABT_thread prot_thread;
    /* SWIM protocol parameters */
    double prot_period_len;
    int prot_susp_timeout;
    int prot_subgroup_sz;
69 70 71
    /* current membership state */
    void *suspect_list;
    void *recent_update_list;
Shane Snyder's avatar
Shane Snyder committed
72 73
    /* XXX */
    int shutdown_flag;
74 75
};

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

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

94 95 96
#ifdef __cplusplus
}
#endif