resource-lp.h 2.82 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
/*
 * Copyright (C) 2014 University of Chicago.
 * See COPYRIGHT notice in top-level directory.
 *
*/

/* this header defines the user-facing functionality needed to interact with a
 * resource LP. All of the LP-specific implementation details are in the
 * corresponding C file */

#ifndef RESOURCE_LP_H
#define RESOURCE_LP_H

14
#include <ross.h>
15 16
#include <stdint.h>

17 18 19 20 21
#include "lp-msg.h"
#include "resource.h"
#include "codes-callback.h"
#include "codes-mapping-context.h"

22
#define RESOURCE_MAX_CALLBACK_PAYLOAD 64
23

24 25
#define RESOURCE_LP_NM "resource"

26 27 28 29
typedef struct {
    int ret;
    /* in the case of a reserve, need to return the token */
    resource_token_t tok;
30
} resource_return;
31

Jonathan Jenkins's avatar
Jonathan Jenkins committed
32 33

/* registers the resource LP with CODES/ROSS */
34
void resource_lp_init();
Jonathan Jenkins's avatar
Jonathan Jenkins committed
35 36

/* reads the resource LP configuration */
37
void resource_lp_configure();
38 39 40 41

/* Wrappers for the underlying resource structure.
 * Implicitly maps the given LPID to it's group and repetition, then messages
 * the resource LP with the request.
42 43
 * The following functions expect the sending LP to put its magic and callback
 * event type into the header parameter (lpid not necessary, it's grabbed from
Jonathan Jenkins's avatar
Jonathan Jenkins committed
44 45 46 47
 * sender)
 *
 * block_on_unavail - flag whether to wait to message the requester if
 *                    request cannot be satisfied
48
 * tag, h - set in the return client event, using the offsets in cb
Jonathan Jenkins's avatar
Jonathan Jenkins committed
49
 */
50
void resource_lp_get(
51
        uint64_t req,
52
        int block_on_unavail,
53 54 55 56 57
        tw_lp *sender,
        struct codes_mctx const * map_ctx,
        int tag,
        msg_header const *h,
        struct codes_cb_info const *cb);
58
/* no callback for frees thus far */
59 60 61 62
void resource_lp_free(
        uint64_t req,
        tw_lp *sender,
        struct codes_mctx const * map_ctx);
63 64
void resource_lp_reserve(
        uint64_t req,
65
        int block_on_unavail,
66 67 68 69 70
        tw_lp *sender,
        struct codes_mctx const * map_ctx,
        int tag,
        msg_header const *h,
        struct codes_cb_info const *cb);
71 72 73
void resource_lp_get_reserved(
        uint64_t req,
        resource_token_t tok,
74
        int block_on_unavail,
75 76 77 78 79
        tw_lp *sender,
        struct codes_mctx const * map_ctx,
        int tag,
        msg_header const *h,
        struct codes_cb_info const *cb);
80 81 82
void resource_lp_free_reserved(
        uint64_t req,
        resource_token_t tok,
83 84
        tw_lp *sender,
        struct codes_mctx const * map_ctx);
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103

/* rc functions - thankfully, they only use codes-local-latency, so no need 
 * to pass in any arguments */
void resource_lp_get_rc(tw_lp *sender);
void resource_lp_free_rc(tw_lp *sender);
void resource_lp_reserve_rc(tw_lp *sender);
void resource_lp_get_reserved_rc(tw_lp *sender);
void resource_lp_free_reserved_rc(tw_lp *sender);

#endif /* end of include guard: RESOURCE_LP_H */

/*
 * Local variables:
 *  c-indent-level: 4
 *  c-basic-offset: 4
 * End:
 *
 * vim: ts=8 sts=4 sw=4 expandtab
 */