bake-rpc.h 5.3 KB
Newer Older
Philip Carns's avatar
Philip Carns committed
1 2 3 4 5 6
/*
 * (C) 2015 The University of Chicago
 * 
 * See COPYRIGHT in top-level directory.
 */

7 8
#ifndef __BAKE_RPC
#define __BAKE_RPC
Philip Carns's avatar
Philip Carns committed
9

10
#include <uuid/uuid.h>
Philip Carns's avatar
Philip Carns committed
11
#include <margo.h>
12
#include <mercury_proc_string.h>
13
#include <bake.h>
Philip Carns's avatar
Philip Carns committed
14

15
/* encoders for BAKE-specific types */
16
static inline hg_return_t hg_proc_bake_uuid_t(hg_proc_t proc, bake_uuid_t *bti);
17
static inline hg_return_t hg_proc_bake_region_id_t(hg_proc_t proc, bake_region_id_t *rid);
Philip Carns's avatar
Philip Carns committed
18

19 20 21 22 23
/* BAKE shutdown */
DECLARE_MARGO_RPC_HANDLER(bake_shutdown_ult)

/* BAKE create */
MERCURY_GEN_PROC(bake_create_in_t,
24
    ((bake_uuid_t)(pool_id))\
25
    ((uint64_t)(region_size)))
26
MERCURY_GEN_PROC(bake_create_out_t,
27
    ((int32_t)(ret))\
28 29
    ((bake_region_id_t)(rid)))
DECLARE_MARGO_RPC_HANDLER(bake_create_ult)
30

31 32
/* BAKE write */
MERCURY_GEN_PROC(bake_write_in_t,
33
    ((bake_uuid_t)(pool_id))\
34
    ((bake_region_id_t)(rid))\
Philip Carns's avatar
Philip Carns committed
35
    ((uint64_t)(region_offset))\
36 37 38 39
    ((hg_bulk_t)(bulk_handle))\
    ((uint64_t)(bulk_offset))\
    ((uint64_t)(bulk_size))\
    ((hg_string_t)(remote_addr_str)))
40
MERCURY_GEN_PROC(bake_write_out_t,
Philip Carns's avatar
Philip Carns committed
41
    ((int32_t)(ret)))
42
DECLARE_MARGO_RPC_HANDLER(bake_write_ult)
43

44
/* BAKE eager write */
Philip Carns's avatar
Philip Carns committed
45 46
typedef struct 
{
47
    bake_uuid_t pool_id;
48
    bake_region_id_t rid;
Philip Carns's avatar
Philip Carns committed
49 50 51
    uint64_t region_offset;
    uint32_t size;
    char * buffer;
52 53 54
} bake_eager_write_in_t;
static inline hg_return_t hg_proc_bake_eager_write_in_t(hg_proc_t proc, void *v_out_p);
MERCURY_GEN_PROC(bake_eager_write_out_t,
Philip Carns's avatar
Philip Carns committed
55
    ((int32_t)(ret)))
56
DECLARE_MARGO_RPC_HANDLER(bake_eager_write_ult)
Philip Carns's avatar
Philip Carns committed
57

58 59
/* BAKE persist */
MERCURY_GEN_PROC(bake_persist_in_t,
60
    ((bake_uuid_t)(pool_id))\
61 62
    ((bake_region_id_t)(rid)))
MERCURY_GEN_PROC(bake_persist_out_t,
Philip Carns's avatar
Philip Carns committed
63
    ((int32_t)(ret)))
64
DECLARE_MARGO_RPC_HANDLER(bake_persist_ult)
Philip Carns's avatar
Philip Carns committed
65

66 67
/* BAKE create/write/persist */
MERCURY_GEN_PROC(bake_create_write_persist_in_t,
68
    ((bake_uuid_t)(pool_id))\
69 70 71 72 73 74 75 76 77 78 79
    ((uint64_t)(region_size))\
    ((uint64_t)(region_offset))\
    ((hg_bulk_t)(bulk_handle))\
    ((uint64_t)(bulk_offset))\
    ((uint64_t)(bulk_size))\
    ((hg_string_t)(remote_addr_str)))
MERCURY_GEN_PROC(bake_create_write_persist_out_t,
    ((int32_t)(ret))\
    ((bake_region_id_t)(rid)))
DECLARE_MARGO_RPC_HANDLER(bake_create_write_persist_ult)

80 81
/* BAKE get size */
MERCURY_GEN_PROC(bake_get_size_in_t,
82
    ((bake_uuid_t)(pool_id))\
83 84
    ((bake_region_id_t)(rid)))
MERCURY_GEN_PROC(bake_get_size_out_t,
85 86
    ((int32_t)(ret))\
    ((uint64_t)(size)))
87
DECLARE_MARGO_RPC_HANDLER(bake_get_size_ult)
88

89 90
/* BAKE read */
MERCURY_GEN_PROC(bake_read_in_t,
91
    ((bake_uuid_t)(pool_id))\
92
    ((bake_region_id_t)(rid))\
93
    ((uint64_t)(region_offset))\
94 95 96 97
    ((hg_bulk_t)(bulk_handle))\
    ((uint64_t)(bulk_offset))\
    ((uint64_t)(bulk_size))\
    ((hg_string_t)(remote_addr_str)))
98
MERCURY_GEN_PROC(bake_read_out_t,
99
    ((int32_t)(ret)))
100
DECLARE_MARGO_RPC_HANDLER(bake_read_ult)
101

102 103
/* BAKE eager read */
MERCURY_GEN_PROC(bake_eager_read_in_t,
104
    ((bake_uuid_t)(pool_id))\
105
    ((bake_region_id_t)(rid))\
Philip Carns's avatar
Philip Carns committed
106 107 108 109 110 111 112
    ((uint64_t)(region_offset))\
    ((uint32_t)(size)))
typedef struct 
{
    int32_t ret;
    uint32_t size;
    char * buffer;
113 114 115
} bake_eager_read_out_t;
static inline hg_return_t hg_proc_bake_eager_read_out_t(hg_proc_t proc, void *v_out_p);
DECLARE_MARGO_RPC_HANDLER(bake_eager_read_ult)
Philip Carns's avatar
Philip Carns committed
116

117 118
/* BAKE probe */
MERCURY_GEN_PROC(bake_probe_out_t,
119
    ((int32_t)(ret))\
120
    ((bake_uuid_t)(pool_id)))
121
DECLARE_MARGO_RPC_HANDLER(bake_probe_ult)
122

123 124
/* BAKE noop */
DECLARE_MARGO_RPC_HANDLER(bake_noop_ult)
Philip Carns's avatar
Philip Carns committed
125

Philip Carns's avatar
Philip Carns committed
126

127
static inline hg_return_t hg_proc_bake_region_id_t(hg_proc_t proc, bake_region_id_t *rid)
128 129
{
    /* TODO: update later depending on final region_id_t type */
Philip Carns's avatar
Philip Carns committed
130
    /* TODO: need separate encoders for different backend types */
131 132 133
    int i;
    hg_return_t ret;

Philip Carns's avatar
Philip Carns committed
134
    hg_proc_hg_uint32_t(proc, &rid->type);
135
    for(i=0; i<BAKE_REGION_ID_DATA_SIZE; i++)
136 137 138 139 140 141 142 143
    {
        ret = hg_proc_hg_uint8_t(proc, (uint8_t*)&rid->data[i]);
        if(ret != HG_SUCCESS)
            return(ret);
    }
    return(HG_SUCCESS);
}

144
static inline hg_return_t hg_proc_bake_uuid_t(hg_proc_t proc, bake_uuid_t *pool_id)
145
{
146
    /* TODO: make this portable */
147
    return(hg_proc_memcpy(proc, pool_id, sizeof(*pool_id)));
148 149
}

150
static inline hg_return_t hg_proc_bake_eager_write_in_t(hg_proc_t proc, void *v_out_p)
Philip Carns's avatar
Philip Carns committed
151
{
Philip Carns's avatar
Philip Carns committed
152
    /* TODO: error checking */
153
    bake_eager_write_in_t *in = v_out_p;
154
    void *buf = NULL;
Philip Carns's avatar
Philip Carns committed
155

156
    hg_proc_bake_uuid_t(proc, &in->pool_id);
157
    hg_proc_bake_region_id_t(proc, &in->rid);
Philip Carns's avatar
Philip Carns committed
158 159
    hg_proc_uint64_t(proc, &in->region_offset);
    hg_proc_uint32_t(proc, &in->size);
160 161 162 163 164 165 166 167 168
    if(in->size)
    {
        buf = hg_proc_save_ptr(proc, in->size);
        if(hg_proc_get_op(proc) == HG_ENCODE)
            memcpy(buf, in->buffer, in->size);
        if(hg_proc_get_op(proc) == HG_DECODE)
            in->buffer = buf;
        hg_proc_restore_ptr(proc, buf, in->size);
    }
Philip Carns's avatar
Philip Carns committed
169

Philip Carns's avatar
Philip Carns committed
170 171 172
    return(HG_SUCCESS);
}

Philip Carns's avatar
Philip Carns committed
173

174
static inline hg_return_t hg_proc_bake_eager_read_out_t(hg_proc_t proc, void *v_out_p)
Philip Carns's avatar
Philip Carns committed
175 176
{
    /* TODO: error checking */
177
    bake_eager_read_out_t *out = v_out_p;
178
    void *buf = NULL;
Philip Carns's avatar
Philip Carns committed
179 180 181

    hg_proc_int32_t(proc, &out->ret);
    hg_proc_uint32_t(proc, &out->size);
182 183 184 185 186 187 188 189 190
    if(out->size)
    {
        buf = hg_proc_save_ptr(proc, out->size);
        if(hg_proc_get_op(proc) == HG_ENCODE)
            memcpy(buf, out->buffer, out->size);
        if(hg_proc_get_op(proc) == HG_DECODE)
            out->buffer = buf;
        hg_proc_restore_ptr(proc, buf, out->size);
    }
Philip Carns's avatar
Philip Carns committed
191 192 193 194

    return(HG_SUCCESS);
}

195
#endif /* __BAKE_RPC */