resource-lp.h 2.92 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

Jonathan Jenkins's avatar
Jonathan Jenkins committed
14 15 16 17
#ifdef __cplusplus
extern "C" {
#endif

18
#include <ross.h>
19 20
#include <stdint.h>

21 22 23 24 25
#include "lp-msg.h"
#include "resource.h"
#include "codes-callback.h"
#include "codes-mapping-context.h"

26 27
#define RESOURCE_LP_NM "resource"

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

Jonathan Jenkins's avatar
Jonathan Jenkins committed
34 35

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

/* reads the resource LP configuration */
39
void resource_lp_configure();
40 41 42 43

/* 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.
44 45
 * 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
46 47 48 49
 * sender)
 *
 * block_on_unavail - flag whether to wait to message the requester if
 *                    request cannot be satisfied
50
 * return_tag, return_header - set in the return client event, using the offsets in cb
Jonathan Jenkins's avatar
Jonathan Jenkins committed
51
 */
52
void resource_lp_get(
53
        uint64_t req,
54
        int block_on_unavail,
55 56
        tw_lp *sender,
        struct codes_mctx const * map_ctx,
57 58
        int return_tag,
        msg_header const *return_header,
59
        struct codes_cb_info const *cb);
60
/* no callback for frees thus far */
61 62 63 64
void resource_lp_free(
        uint64_t req,
        tw_lp *sender,
        struct codes_mctx const * map_ctx);
65 66
void resource_lp_reserve(
        uint64_t req,
67
        int block_on_unavail,
68 69
        tw_lp *sender,
        struct codes_mctx const * map_ctx,
70 71
        int return_tag,
        msg_header const *return_header,
72
        struct codes_cb_info const *cb);
73 74 75
void resource_lp_get_reserved(
        uint64_t req,
        resource_token_t tok,
76
        int block_on_unavail,
77 78
        tw_lp *sender,
        struct codes_mctx const * map_ctx,
79 80
        int return_tag,
        msg_header const *return_header,
81
        struct codes_cb_info const *cb);
82 83 84
void resource_lp_free_reserved(
        uint64_t req,
        resource_token_t tok,
85 86
        tw_lp *sender,
        struct codes_mctx const * map_ctx);
87 88 89 90 91 92 93 94 95

/* 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);

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

100 101 102 103 104 105 106 107 108 109
#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
 */