bake-bulk-rpc.h 4.98 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_BULK_RPC
#define __BAKE_BULK_RPC
Philip Carns's avatar
Philip Carns committed
9 10

#include <margo.h>
11
#include <bake-bulk.h>
Philip Carns's avatar
Philip Carns committed
12

13 14 15 16
/* encoders for bake-specific types */
static inline hg_return_t hg_proc_bake_target_id_t(hg_proc_t proc, bake_target_id_t *bti);
static inline hg_return_t hg_proc_bake_bulk_region_id_t(hg_proc_t proc, bake_bulk_region_id_t *rid);
/* shutdown */
Philip Carns's avatar
Philip Carns committed
17 18
DECLARE_MARGO_RPC_HANDLER(bake_bulk_shutdown_ult)

19 20 21 22 23 24 25 26 27
/* bulk create */
MERCURY_GEN_PROC(bake_bulk_create_in_t,
    ((bake_target_id_t)(bti))\
    ((uint64_t)(region_size)))
MERCURY_GEN_PROC(bake_bulk_create_out_t,
    ((int32_t)(ret))\
    ((bake_bulk_region_id_t)(rid)))
DECLARE_MARGO_RPC_HANDLER(bake_bulk_create_ult)

28 29 30 31 32 33 34 35
/* bulk write */
MERCURY_GEN_PROC(bake_bulk_write_in_t,
    ((bake_target_id_t)(bti))\
    ((bake_bulk_region_id_t)(rid))\
    ((uint64_t)(region_offset))\
    ((hg_bulk_t)(bulk_handle)))
MERCURY_GEN_PROC(bake_bulk_write_out_t,
    ((int32_t)(ret)))
36
DECLARE_MARGO_RPC_HANDLER(bake_bulk_write_ult)
37

38 39 40 41 42 43 44 45 46
/* bulk eager write */
typedef struct 
{
    bake_target_id_t bti;
    bake_bulk_region_id_t rid;
    uint64_t region_offset;
    uint32_t size;
    char * buffer;
} bake_bulk_eager_write_in_t;
Philip Carns's avatar
Philip Carns committed
47
static inline hg_return_t hg_proc_bake_bulk_eager_write_in_t(hg_proc_t proc, void *v_out_p);
48 49 50 51 52
MERCURY_GEN_PROC(bake_bulk_eager_write_out_t,
    ((int32_t)(ret)))
DECLARE_MARGO_RPC_HANDLER(bake_bulk_eager_write_ult)


53 54 55 56 57 58 59 60
/* bulk persist */
MERCURY_GEN_PROC(bake_bulk_persist_in_t,
    ((bake_target_id_t)(bti))\
    ((bake_bulk_region_id_t)(rid)))
MERCURY_GEN_PROC(bake_bulk_persist_out_t,
    ((int32_t)(ret)))
DECLARE_MARGO_RPC_HANDLER(bake_bulk_persist_ult)

61 62 63 64 65 66 67 68 69
/* bulk get size */
MERCURY_GEN_PROC(bake_bulk_get_size_in_t,
    ((bake_target_id_t)(bti))\
    ((bake_bulk_region_id_t)(rid)))
MERCURY_GEN_PROC(bake_bulk_get_size_out_t,
    ((int32_t)(ret))\
    ((uint64_t)(size)))
DECLARE_MARGO_RPC_HANDLER(bake_bulk_get_size_ult)

70 71 72 73 74 75 76 77 78 79
/* bulk read */
MERCURY_GEN_PROC(bake_bulk_read_in_t,
    ((bake_target_id_t)(bti))\
    ((bake_bulk_region_id_t)(rid))\
    ((uint64_t)(region_offset))\
    ((hg_bulk_t)(bulk_handle)))
MERCURY_GEN_PROC(bake_bulk_read_out_t,
    ((int32_t)(ret)))
DECLARE_MARGO_RPC_HANDLER(bake_bulk_read_ult)

Philip Carns's avatar
Philip Carns committed
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94
/* bulk eager read */
MERCURY_GEN_PROC(bake_bulk_eager_read_in_t,
    ((bake_target_id_t)(bti))\
    ((bake_bulk_region_id_t)(rid))\
    ((uint64_t)(region_offset))\
    ((uint32_t)(size)))
typedef struct 
{
    int32_t ret;
    uint32_t size;
    char * buffer;
} bake_bulk_eager_read_out_t;
static inline hg_return_t hg_proc_bake_bulk_eager_read_out_t(hg_proc_t proc, void *v_out_p);
DECLARE_MARGO_RPC_HANDLER(bake_bulk_eager_read_ult)

95 96 97 98 99 100
/* bulk probe */
MERCURY_GEN_PROC(bake_bulk_probe_out_t,
    ((int32_t)(ret))\
    ((bake_target_id_t)(bti)))
DECLARE_MARGO_RPC_HANDLER(bake_bulk_probe_ult)

Philip Carns's avatar
Philip Carns committed
101 102 103
/* noop */
DECLARE_MARGO_RPC_HANDLER(bake_bulk_noop_ult)

104 105 106 107 108 109 110 111
/* TODO: this should be somewhere else, just putting in this header for
 * convenience right now.  The type should only be visible to the server
 * daemon and the rpc handlers.
 */
struct bake_bulk_root
{
    bake_target_id_t target_id;
};
112 113


114 115 116
/* TODO: where should the encoder defs live?  Not in bake-bulk-rpc.c because 
 * we don't really need the rpc handlers to be linked into clients...
 */
117 118 119
static inline hg_return_t hg_proc_bake_bulk_region_id_t(hg_proc_t proc, bake_bulk_region_id_t *rid)
{
    /* TODO: update later depending on final region_id_t type */
Philip Carns's avatar
Philip Carns committed
120
    /* TODO: need separate encoders for different backend types */
121 122 123
    int i;
    hg_return_t ret;

Philip Carns's avatar
Philip Carns committed
124 125
    hg_proc_hg_uint32_t(proc, &rid->type);
    for(i=0; i<BAKE_BULK_REGION_ID_DATA_SIZE; i++)
126 127 128 129 130 131 132 133 134 135
    {
        ret = hg_proc_hg_uint8_t(proc, (uint8_t*)&rid->data[i]);
        if(ret != HG_SUCCESS)
            return(ret);
    }
    return(HG_SUCCESS);
}

static inline hg_return_t hg_proc_bake_target_id_t(hg_proc_t proc, bake_target_id_t *bti)
{
136 137
    /* TODO: make this portable; just raw encoding for now */
    return(hg_proc_raw(proc, bti->id, sizeof(bti->id)));
138 139
}

Philip Carns's avatar
Philip Carns committed
140
static inline hg_return_t hg_proc_bake_bulk_eager_write_in_t(hg_proc_t proc, void *v_out_p)
141
{
142
    /* TODO: error checking */
Philip Carns's avatar
Philip Carns committed
143
    bake_bulk_eager_write_in_t *in = v_out_p;
144 145 146 147 148

    hg_proc_bake_target_id_t(proc, &in->bti);
    hg_proc_bake_bulk_region_id_t(proc, &in->rid);
    hg_proc_uint64_t(proc, &in->region_offset);
    hg_proc_uint32_t(proc, &in->size);
149
    if(hg_proc_get_op(proc) == HG_DECODE)
Philip Carns's avatar
Philip Carns committed
150
        hg_proc_memcpy_decode_in_place(proc, (void**)(&in->buffer), in->size);
151 152
    else
        hg_proc_memcpy(proc, in->buffer, in->size);
153

154 155 156
    return(HG_SUCCESS);
}

Philip Carns's avatar
Philip Carns committed
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172

static inline hg_return_t hg_proc_bake_bulk_eager_read_out_t(hg_proc_t proc, void *v_out_p)
{
    /* TODO: error checking */
    bake_bulk_eager_read_out_t *out = v_out_p;

    hg_proc_int32_t(proc, &out->ret);
    hg_proc_uint32_t(proc, &out->size);
    if(hg_proc_get_op(proc) == HG_DECODE)
        hg_proc_memcpy_decode_in_place(proc, (void**)(&out->buffer), out->size);
    else
        hg_proc_memcpy(proc, out->buffer, out->size);

    return(HG_SUCCESS);
}

173
#endif /* __BAKE_BULK_RPC */