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

/* This is the base model-net LP that all events pass through before
 * performing any topology-specific work. Packet scheduling, dealing with
 * packet loss (potentially), etc. happens here. 
 * Additionally includes wrapper event "send" function that all 
 * events for underlying models must go through */

#ifndef MODEL_NET_LP_H  
#define MODEL_NET_LP_H

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

20
#include <ross.h>
21
#include "codes/lp-msg.h"
22 23
#include "model-net.h"
#include "model-net-sched.h"
24
#include "net/dragonfly.h"
25
#include "net/dragonfly-custom.h"
26
#include "net/slimfly.h"
27
#include "net/fattree.h"
28 29
#include "net/loggp.h"
#include "net/simplenet-upd.h"
30
#include "net/simplep2p.h"
31
#include "net/torus.h"
32
#include "net/express-mesh.h"
33 34 35

extern int model_net_base_magic;

36 37 38 39 40 41
// register the networks with ROSS, given the array of flags, one for each
// network type
void model_net_base_register(int *do_config_nets);
// configure the base LP type, setting up general parameters
void model_net_base_configure();

Jonathan Jenkins's avatar
Jonathan Jenkins committed
42 43 44
/// The remaining functions/data structures are only of interest to model-net
/// model developers

45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
// Construct a model-net-specific event, analagous to a tw_event_new and
// codes_event_new. The difference here is that we return pointers to 
// both the message data (to be cast into the appropriate type) and the
// pointer to the end of the event struct.
// 
// This function is expected to be called within each specific model-net
// method - strange and disturbing things will happen otherwise
tw_event * model_net_method_event_new(
        tw_lpid dest_gid,
        tw_stime offset_ts,
        tw_lp *sender,
        int net_id,
        void **msg_data,
        void **extra_data);

60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
// Construct a model-net-specific event, similar to model_net_method_event_new.
// The primary differences are:
// - the event gets sent to final_dest_lp and put on it's receiver queue
// - no message initialization is needed - that's the job of the
//   model_net_method_recv_msg_event functions
//
// NOTE: this is largely a constructor of a model_net_request
void model_net_method_send_msg_recv_event(
        tw_lpid final_dest_lp,
        tw_lpid dest_mn_lp, // which model-net lp is going to handle message
        tw_lpid src_lp, // the "actual" source (as opposed to the model net lp)
        uint64_t msg_size, // the size of this message
        int is_pull,
        uint64_t pull_size, // the size of the message to pull if is_pull==1
        int remote_event_size,
        const mn_sched_params *sched_params,
        const char * category,
        int net_id,
        void * msg,
79
        tw_stime offset,
80
        tw_lp *sender);
Jonathan Jenkins's avatar
Jonathan Jenkins committed
81 82
// just need to reverse an RNG for the time being
void model_net_method_send_msg_recv_event_rc(tw_lp *sender);
83

84 85 86 87 88 89 90 91
// Issue an event from the underlying model (e.g., simplenet, loggp) to tell the
// scheduler when next to issue a packet event. As different models update their
// notion of "idleness" separately, this is necessary. DANGER: Failure to call
// this function appropriately will cause the scheduler to hang or cause other
// weird behavior.
//
// This function is expected to be called within each specific model-net
// method - strange and disturbing things will happen otherwise
92 93
void model_net_method_idle_event(tw_stime offset_ts, int is_recv_queue,
        tw_lp * lp);
Nikhil's avatar
Nikhil committed
94 95
void model_net_method_idle_event2(tw_stime offset_ts, int is_recv_queue,
        int queue_offset, tw_lp * lp);
96

97 98 99 100 101 102 103 104 105 106 107 108 109
// Get a ptr to past the message struct area, where the self/remote events
// are located, given the type of network.
// NOTE: this should ONLY be called on model-net implementations, nowhere else
void * model_net_method_get_edata(int net_id, void * msg);

/// The following functions/data structures should not need to be used by
/// model developers - they are just provided so other internal components can
/// use them

enum model_net_base_event_type {
    MN_BASE_NEW_MSG,
    // schedule next packet
    MN_BASE_SCHED_NEXT,
110 111
    // gather a sample from the underlying model
    MN_BASE_SAMPLE,
112 113 114 115 116 117
    // message goes directly down to topology-specific event handler
    MN_BASE_PASS
};

typedef struct model_net_base_msg {
    // no need for event type - in wrap message
118 119
    model_net_request req;
    int is_from_remote;
Nikhil's avatar
Nikhil committed
120 121
    int isQueueReq;
    tw_stime save_ts;
122 123 124
    // parameters to pass to new messages (via model_net_set_msg_params)
    // TODO: make this a union for multiple types of parameters
    mn_sched_params sched_params;
125
    model_net_sched_rc rc; // rc for scheduling events
126 127 128
} model_net_base_msg;

typedef struct model_net_wrap_msg {
129
    msg_header h;
130
    union {
131 132
        model_net_base_msg      m_base;  // base lp
        terminal_message        m_dfly;  // dragonfly
133
        terminal_custom_message        m_custom_dfly;  // dragonfly-custom
134 135
        slim_terminal_message   m_slim;  // slimfly
	fattree_message		m_fat;   // fattree
136 137 138 139
        loggp_message           m_loggp; // loggp
        sn_message              m_snet;  // simplenet
        sp_message              m_sp2p;  // simplep2p
        nodes_message           m_torus; // torus
140
        em_message              m_em; // express-mesh
141 142 143 144
        // add new ones here
    } msg;
} model_net_wrap_msg;

Jonathan Jenkins's avatar
Jonathan Jenkins committed
145 146 147 148
#ifdef __cplusplus
}
#endif

149 150 151 152 153 154 155 156 157 158
#endif /* end of include guard: MODEL_NET_LP_H */

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