ssg-internal.h 2.12 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
#include <stdint.h>
#include <inttypes.h>
11

Shane Snyder's avatar
Shane Snyder committed
12
#include <mercury.h>
Shane Snyder's avatar
Shane Snyder committed
13
#include <mercury_proc_string.h>
Shane Snyder's avatar
Shane Snyder committed
14
#include <abt.h>
Jonathan Jenkins's avatar
Jonathan Jenkins committed
15
#include <margo.h>
16

17
#include "ssg.h"
18 19
#include "uthash.h"

20 21 22 23
#ifdef __cplusplus
extern "C" {
#endif

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

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

41
/* SSG internal dataypes */
42

43
typedef struct ssg_member_state ssg_member_state_t;
Shane Snyder's avatar
Shane Snyder committed
44 45
typedef struct ssg_view ssg_view_t;
typedef struct ssg_group ssg_group_t;
46
typedef struct ssg_instance ssg_instance_t;
47 48 49 50 51 52

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

54
struct ssg_view
55
{
Shane Snyder's avatar
Shane Snyder committed
56
    uint32_t size;
57 58 59
    ssg_member_state_t *member_states;
};

Shane Snyder's avatar
Shane Snyder committed
60 61 62 63 64 65 66 67 68 69 70 71
MERCURY_GEN_PROC(ssg_group_descriptor_t, \
    ((uint64_t) (magic_nr)) \
    ((uint64_t) (name_hash)) \
    ((hg_string_t) (addr_str)));

struct ssg_group_descriptor
{
    uint64_t magic_nr;
    uint64_t name_hash;
    char *addr_str;
};

72
struct ssg_group
Jonathan Jenkins's avatar
Jonathan Jenkins committed
73
{
74
    char *group_name;
Shane Snyder's avatar
Shane Snyder committed
75
    ssg_group_descriptor_t *group_descriptor;
76
    ssg_view_t group_view;
Shane Snyder's avatar
Shane Snyder committed
77
    ssg_member_id_t self_id;
78
    void *fd_ctx; /* failure detector context (currently just SWIM) */
79 80 81 82 83 84 85
    UT_hash_handle hh;
};

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

88 89 90 91 92 93 94 95 96 97 98
/* 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(
Shane Snyder's avatar
Shane Snyder committed
99
    ssg_group_descriptor_t *group_descriptor);
100

101
/* XXX: is this right? can this be a global? */
102
extern ssg_instance_t *ssg_inst; 
103

Shane Snyder's avatar
Shane Snyder committed
104 105 106
#ifdef __cplusplus
}
#endif