resource-lp.h 3.46 KB
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
/*
 * 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

#include "ross.h"
#include "codes/lp-msg.h"
#include "codes/resource.h"
#include <stdint.h>

19
#define RESOURCE_MAX_CALLBACK_PAYLOAD 64
20

21
22
#define RESOURCE_LP_NM "resource"

23
24
25
26
27
28
typedef struct {
    int ret;
    /* in the case of a reserve, need to return the token */
    resource_token_t tok;
} resource_callback;

Jonathan Jenkins's avatar
Jonathan Jenkins committed
29
30

/* registers the resource LP with CODES/ROSS */
31
void resource_lp_init();
Jonathan Jenkins's avatar
Jonathan Jenkins committed
32
33

/* reads the resource LP configuration */
34
void resource_lp_configure();
35
36
37
38

/* 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.
39
40
 * 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 * sender)
 *
 * block_on_unavail - flag whether to wait to message the requester if
 *                    request cannot be satisfied
 * msg_size - size of the requester event structure
 * msg_header_offset - offset in the requester event to place the resource's 
 *                     msg_header
 * msg_callback_offset - offset in the requester event struct to place the
 *                       resource-provided resource_callback data
 * msg_callback_misc_size - size of requester-provided callback data
 * msg_callback_misc_offset - offset in the requester event struct to place the
 *                            requester-provided callback data
 * msg_callback_misc_data - requester-provided callback data
 *
 */
56
57
58
void resource_lp_get(
        msg_header *header,
        uint64_t req, 
59
        int block_on_unavail,
60
61
62
        int msg_size, 
        int msg_header_offset,
        int msg_callback_offset,
63
64
65
        int msg_callback_misc_size,
        int msg_callback_misc_offset,
        void *msg_callback_misc_data,
66
67
        tw_lp *sender);
/* no callback for frees thus far */
68
void resource_lp_free(uint64_t req, tw_lp *sender);
69
70
71
void resource_lp_reserve(
        msg_header *header, 
        uint64_t req,
72
        int block_on_unavail,
73
74
75
        int msg_size,
        int msg_header_offset,
        int msg_callback_offset,
76
77
78
        int msg_callback_misc_size,
        int msg_callback_misc_offset,
        void *msg_callback_misc_data,
79
80
81
82
83
        tw_lp *sender);
void resource_lp_get_reserved(
        msg_header *header,
        uint64_t req,
        resource_token_t tok,
84
        int block_on_unavail,
85
86
87
        int msg_size, 
        int msg_header_offset,
        int msg_callback_offset,
88
89
90
        int msg_callback_misc_size,
        int msg_callback_misc_offset,
        void *msg_callback_misc_data,
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
        tw_lp *sender);
void resource_lp_free_reserved(
        uint64_t req,
        resource_token_t tok,
        tw_lp *sender);

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