resource-lp.h 2.68 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 29
typedef struct {
    int ret;
    /* in the case of a reserve, need to return the token */
    resource_token_t tok;
} resource_callback;

void resource_lp_init();
30
void resource_lp_configure();
31 32 33 34

/* 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.
35 36 37
 * 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
 * sender) */
38 39 40
void resource_lp_get(
        msg_header *header,
        uint64_t req, 
41
        int block_on_unavail,
42 43 44
        int msg_size, 
        int msg_header_offset,
        int msg_callback_offset,
45 46 47
        int msg_callback_misc_size,
        int msg_callback_misc_offset,
        void *msg_callback_misc_data,
48 49
        tw_lp *sender);
/* no callback for frees thus far */
50
void resource_lp_free(uint64_t req, tw_lp *sender);
51 52 53
void resource_lp_reserve(
        msg_header *header, 
        uint64_t req,
54
        int block_on_unavail,
55 56 57
        int msg_size,
        int msg_header_offset,
        int msg_callback_offset,
58 59 60
        int msg_callback_misc_size,
        int msg_callback_misc_offset,
        void *msg_callback_misc_data,
61 62 63 64 65
        tw_lp *sender);
void resource_lp_get_reserved(
        msg_header *header,
        uint64_t req,
        resource_token_t tok,
66
        int block_on_unavail,
67 68 69
        int msg_size, 
        int msg_header_offset,
        int msg_callback_offset,
70 71 72
        int msg_callback_misc_size,
        int msg_callback_misc_offset,
        void *msg_callback_misc_data,
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
        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
 */