swim-fd-internal.h 2.59 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 61 62 63 64 65 66
    ABT_pool swim_pool;
    /* swim protocol ULT handle */
    ABT_thread prot_thread;
    /* SWIM protocol parameters */
    double prot_period_len;
    int prot_susp_timeout;
    int prot_subgroup_sz;
67 68
    /* current membership state */
    void *suspect_list;
Shane Snyder's avatar
Shane Snyder committed
69
#if 0
70
    void *recent_update_list;
71
#endif
Shane Snyder's avatar
Shane Snyder committed
72 73
    /* XXX */
    int shutdown_flag;
74 75
};

Shane Snyder's avatar
Shane Snyder committed
76
typedef struct swim_member_update
77
{
Shane Snyder's avatar
Shane Snyder committed
78
    swim_member_id_t id;
79 80
    swim_member_status_t status;
    swim_member_inc_nr_t inc_nr;
Shane Snyder's avatar
Shane Snyder committed
81
} swim_member_update_t;
82

Shane Snyder's avatar
Shane Snyder committed
83
/* SWIM ping function prototypes */
84
void swim_register_ping_rpcs(
85
    swim_context_t * swim_ctx);
86
void swim_dping_send_ult(
87
    void * t_arg);
88
void swim_iping_send_ult(
89
    void * t_arg);
90

Shane Snyder's avatar
Shane Snyder committed
91
#if 0
Shane Snyder's avatar
Shane Snyder committed
92 93
/* SWIM membership update function prototypes */
void swim_retrieve_membership_updates(
94 95
    ssg_group_t * g,
    swim_member_update_t * updates,
Shane Snyder's avatar
Shane Snyder committed
96 97
    int update_count);
void swim_apply_membership_updates(
98 99
    ssg_group_t * g,
    swim_member_update_t * updates,
Shane Snyder's avatar
Shane Snyder committed
100
    int update_count);
101
#endif
Shane Snyder's avatar
Shane Snyder committed
102

103 104 105
#ifdef __cplusplus
}
#endif