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

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

Shane Snyder's avatar
Shane Snyder committed
9 10 11 12
#ifdef __cplusplus
extern "C" {
#endif

Shane Snyder's avatar
Shane Snyder committed
13 14
#include <stdint.h>
#include <inttypes.h>
15

Shane Snyder's avatar
Shane Snyder committed
16 17
#include <mercury.h>
#include <abt.h>
Jonathan Jenkins's avatar
Jonathan Jenkins committed
18
#include <margo.h>
19

20
#include "ssg.h"
21 22 23
#include "uthash.h"

#define SSG_MAGIC_NR 17321588
Jonathan Jenkins's avatar
Jonathan Jenkins committed
24

25 26
/* debug printing macro for SSG */
/* TODO: direct debug output to file? */
27
/* TODO: how do we debug attachers? */
Shane Snyder's avatar
Shane Snyder committed
28
#ifdef DEBUG
29
#define SSG_DEBUG(__g, __fmt, ...) do { \
Shane Snyder's avatar
Shane Snyder committed
30
    double __now = ABT_get_wtime(); \
31 32
    fprintf(stdout, "%.6lf <%s:%"PRIu64">: " __fmt, __now, \
        __g->group_name, __g->self_id, ## __VA_ARGS__); \
33
    fflush(stdout); \
Shane Snyder's avatar
Shane Snyder committed
34 35
} while(0)
#else
36
#define SSG_DEBUG(__g, __fmt, ...) do { \
Shane Snyder's avatar
Shane Snyder committed
37 38 39
} while(0)
#endif

40
/* SSG internal dataypes */
41

42
typedef struct ssg_group ssg_group_t;
43
typedef struct ssg_view ssg_view_t;
44
typedef struct ssg_member_state ssg_member_state_t;
45
typedef struct ssg_instance ssg_instance_t;
46 47 48 49 50 51

struct ssg_member_state
{
    hg_addr_t addr;
    int is_member;
};
52

53
struct ssg_view
54
{
55
    int size;
56 57 58
    ssg_member_state_t *member_states;
};

59
struct ssg_group
Jonathan Jenkins's avatar
Jonathan Jenkins committed
60
{
61 62 63 64
    char *group_name;
    ssg_group_id_t group_id;
    ssg_member_id_t self_id;
    ssg_view_t group_view;
65
    void *fd_ctx; /* failure detector context (currently just SWIM) */
66 67 68 69 70 71 72
    UT_hash_handle hh;
};

struct ssg_instance
{
    margo_instance_id mid;
    ssg_group_t *group_table;
Jonathan Jenkins's avatar
Jonathan Jenkins committed
73
};
Shane Snyder's avatar
Shane Snyder committed
74

75 76 77 78 79 80 81 82 83 84 85 86 87
/* SSG internal function prototypes */

#define ssg_hashlittle2 hashlittle2
extern void hashlittle2(const void *key, size_t length, uint32_t *pc, uint32_t *pb);

void ssg_register_rpcs(
    void);
hg_return_t ssg_group_lookup(
    ssg_group_t * g,
    const char * const addr_strs[]);
hg_return_t ssg_group_attach_send(
    const char *member_addr_str);

88
/* XXX: is this right? can this be a global? */
89
extern ssg_instance_t *ssg_inst; 
90

Shane Snyder's avatar
Shane Snyder committed
91 92 93
#ifdef __cplusplus
}
#endif