local-storage-model.h 3.22 KB
Newer Older
1 2 3 4 5 6 7 8 9
/*
 * Copyright (C) 2013 University of Chicago.
 * See COPYRIGHT notice in top-level directory.
 *
 */

#ifndef __LS_MODEL__
#define __LS_MODEL__

Jonathan Jenkins's avatar
Jonathan Jenkins committed
10 11 12 13
#ifdef __cplusplus
extern "C" {
#endif

14 15
#include <ross.h>

16 17 18
#include "codes-callback.h"
#include "codes-mapping-context.h"

19 20
#define LSM_NAME "lsm"

21 22 23 24 25
/* HACK: problems arise when some LP sends multiple messages as part of an
 * event and expects FCFS ordering. One could simply set a higher delay in
 * delay, but that is hacky as well (and relies on knowing bounds on internal
 * codes_local_latency bounds. Hence, expose explicit start-sequence and
 * stop-sequence markers */
26
extern int lsm_in_sequence;
27 28
extern tw_stime lsm_msg_offset;
#define LSM_START_SEQ() do {\
29
    lsm_in_sequence = 1; \
30 31 32
    lsm_msg_offset = 0.0; \
} while (0)
#define LSM_END_SEQ() do {\
33
    lsm_in_sequence = 0;\
34 35
} while (0)

36 37 38 39 40 41 42 43 44 45 46 47
/*
 * lsm_event_t
 *   - events supported by the local storage model
 */
typedef enum lsm_event_e
{
    LSM_WRITE_REQUEST = 1,
    LSM_READ_REQUEST = 2,
    LSM_WRITE_COMPLETION = 3,
    LSM_READ_COMPLETION = 4
} lsm_event_t;

48 49 50 51 52 53 54
/*
 * return type for lsm events (in the codes-callback sense)
 */
typedef struct {
    int rc;
} lsm_return_t;

55 56 57 58
/*
 * Prototypes
 */

59
/* given LP sender, find the LSM device LP in the same group */ 
60
tw_lpid lsm_find_local_device(
61
        struct codes_mctx const * map_ctx,
62
        tw_lpid sender_gid);
63

64
/*
65
 * lsm_io_event
66 67 68
 *   - creates a new event that is targeted for the corresponding
 *     LSM LP.
 *   - this event will allow wrapping the callers completion event
69 70
 *   - lp_io_category: string name to identify the traffic category for use in
 *     lp-io
71 72 73 74 75 76
 *   - gid_offset: relative offset of the LSM LP to the originating LP
 *   - io_object: id of byte stream the caller will modify
 *   - io_offset: offset into byte stream
 *   - io_size_bytes: size in bytes of IO request
 *   - io_type: read or write request
 */
77 78 79

void lsm_io_event(
        const char * lp_io_category,
80 81 82 83 84
        uint64_t io_object,
        int64_t  io_offset,
        uint64_t io_size_bytes,
        int      io_type,
        tw_stime delay,
85 86 87 88 89
        tw_lp *sender,
        struct codes_mctx const * map_ctx,
        int return_tag,
        msg_header const * return_header,
        struct codes_cb_info const * cb);
90

91
void lsm_io_event_rc(tw_lp *sender);
92 93 94 95 96 97

/* get the priority count for the LSM scheduler.
 * returns 0 if priorities aren't being used, -1 if no LSMs were configured,
 * and >0 otherwise.
 * This should not be called before lsm_configure */
int lsm_get_num_priorities(
98 99
        struct codes_mctx const * map_ctx,
        tw_lpid sender_id);
100 101 102 103 104 105 106 107 108

/* set a request priority for the following lsm_event_*.
 * - tw_error will be called if the priority ends up being out-of-bounds
 *   (won't able to tell until the lsm_event call b/c annotations)
 * - not setting a priority (or setting a negative priority) is equivalent to
 *   setting the message to the lowest priority
 */
void lsm_set_event_priority(int prio);

109
/* registers the storage model LP with CODES/ROSS */
110
void lsm_register(void);
111

112 113
/* configures the LSM model(s) */
void lsm_configure(void);
114 115 116

#define LSM_DEBUG 0

Jonathan Jenkins's avatar
Jonathan Jenkins committed
117 118 119 120
#ifdef __cplusplus
}
#endif

121 122 123 124 125 126 127 128 129 130
#endif

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