ssg.h 2.43 KB
Newer Older
Jonathan Jenkins's avatar
Jonathan Jenkins committed
1
2
3
4
5
6
7
8
/*
 * Copyright (c) 2016 UChicago Argonne, LLC
 *
 * See COPYRIGHT in top-level directory.
 */

#pragma once

Jonathan Jenkins's avatar
Jonathan Jenkins committed
9
// "simple static group" interface
Jonathan Jenkins's avatar
Jonathan Jenkins committed
10
11
12
13
14
15
16
17
18
//
// Contains trivial wireup and connection management functionality, with a
// model of a static (at startup) member list.

#ifdef __cplusplus
extern "C" {
#endif

#include <mercury.h>
Shane Snyder's avatar
Shane Snyder committed
19
20
21
22
23
#include <margo.h>

#ifdef HAVE_MPI
#include <mpi.h>
#endif
Jonathan Jenkins's avatar
Jonathan Jenkins committed
24

Jonathan Jenkins's avatar
Jonathan Jenkins committed
25
// using pointer so that we can use proc (proc has to allocate in this case)
Jonathan Jenkins's avatar
Jonathan Jenkins committed
26
27
28
29
30
31
typedef struct ssg *ssg_t;

// some defines
// null pointer shim
#define SSG_NULL ((ssg_t)NULL)

32
33
34
35
36
37
38
39
40
typedef enum ssg_member_status
{
    SSG_MEMBER_UNKNOWN = 0,
    SSG_MEMBER_ALIVE,
    SSG_MEMBER_SUSPECT,
    SSG_MEMBER_DEAD
} ssg_member_status_t;

/// group member initialization
Jonathan Jenkins's avatar
Jonathan Jenkins committed
41

42
43
// config file based - load up the given config file containing a set of hostnames
ssg_t ssg_init_config(margo_instance_id mid, const char * fname);
Jonathan Jenkins's avatar
Jonathan Jenkins committed
44

Shane Snyder's avatar
Shane Snyder committed
45
46
47
48
#ifdef HAVE_MPI
// mpi based (no config file) - all participants (defined by the input
// communicator) do a global address exchange
// in this case, the caller has already initialized HG with its address
49
ssg_t ssg_init_mpi(margo_instance_id mid, MPI_Comm comm);
Shane Snyder's avatar
Shane Snyder committed
50
51
#endif

Jonathan Jenkins's avatar
Jonathan Jenkins committed
52
53
/// finalization

54
// teardown all state associated with the given ssg group
Jonathan Jenkins's avatar
Jonathan Jenkins committed
55
56
57
58
void ssg_finalize(ssg_t s);

/// accessors

59
60
// get my rank in the group
int ssg_get_group_rank(const ssg_t s);
Jonathan Jenkins's avatar
Jonathan Jenkins committed
61

62
63
// get the size of the group
int ssg_get_group_size(const ssg_t s);
Jonathan Jenkins's avatar
Jonathan Jenkins committed
64

65
// get the HG address for the group member at the given rank
Jonathan Jenkins's avatar
Jonathan Jenkins committed
66
hg_addr_t ssg_get_addr(const ssg_t s, int rank);
Jonathan Jenkins's avatar
Jonathan Jenkins committed
67
68
69
70
71
72

// get the string hostname for the group member at the given rank
const char * ssg_get_addr_str(const ssg_t s, int rank);

/// mercury support

73
#if 0
Jonathan Jenkins's avatar
Jonathan Jenkins committed
74
75
76
// group serialization mechanism
hg_return_t hg_proc_ssg_t(hg_proc_t proc, ssg_t *s);

77
78
79
80
81
82
83
/// utility functions

// dump address list to the given file
// returns -1 on error, corresponding to the return code of open/write/close,
// and sets errno
int ssg_dump(const ssg_t s, const char *fname);

Shane Snyder's avatar
Shane Snyder committed
84
85
86
87
88
89
90
91
92
// set up barrier data structures. Separate call to resolve the margo -> barrier
// race condition - call this before kicking off the progress loop with margo
void ssg_register_barrier(ssg_t s, hg_class_t *hgcl);

// perform a naive N-1 barrier using margo.
// requires ssg_set_margo_id to have been called.
// NOTE: rank must be set on all ranks prior to calling this. I.e. should init
// the rank prior to starting up margo
hg_return_t ssg_barrier_margo(ssg_t s);
93
#endif
Shane Snyder's avatar
Shane Snyder committed
94

Jonathan Jenkins's avatar
Jonathan Jenkins committed
95
96
97
#ifdef __cplusplus
}
#endif