bake-bulk-rpc.h 3.15 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 17
/* 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
18 19
DECLARE_MARGO_RPC_HANDLER(bake_bulk_shutdown_ult)

20 21 22 23 24 25 26 27 28
/* 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)

29 30 31 32 33 34 35 36
/* 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)))
37
DECLARE_MARGO_RPC_HANDLER(bake_bulk_write_ult)
38

39 40 41 42 43 44 45 46
/* 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)

47 48 49 50 51 52 53 54 55
/* 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)

56 57 58 59 60 61 62 63 64 65
/* 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)

66 67 68 69 70 71
/* 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
72 73 74
/* noop */
DECLARE_MARGO_RPC_HANDLER(bake_bulk_noop_ult)

75 76 77 78 79 80 81 82
/* 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;
};
83 84


85 86 87
/* 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...
 */
88 89 90
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
91
    /* TODO: need separate encoders for different backend types */
92 93 94
    int i;
    hg_return_t ret;

Philip Carns's avatar
Philip Carns committed
95 96
    hg_proc_hg_uint32_t(proc, &rid->type);
    for(i=0; i<BAKE_BULK_REGION_ID_DATA_SIZE; i++)
97 98 99 100 101 102 103 104 105 106
    {
        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)
{
107 108
    /* TODO: make this portable; just raw encoding for now */
    return(hg_proc_raw(proc, bti->id, sizeof(bti->id)));
109 110 111
}

#endif /* __BAKE_BULK_RPC */