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

#include <ross.h>
17 18
#include "model-net.h"
#include "model-net-sched.h"
19 20 21 22 23 24 25 26
#include "net/dragonfly.h"
#include "net/loggp.h"
#include "net/simplenet-upd.h"
#include "net/simplewan.h"
#include "net/torus.h"

extern int model_net_base_magic;

27 28 29 30 31 32
// 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();

33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
// 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);

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

// init method
58
void model_net_base_init(int *do_config_nets);
59 60 61 62 63 64 65 66 67 68 69 70 71 72 73

enum model_net_base_event_type {
    MN_BASE_NEW_MSG,
    // schedule next packet
    MN_BASE_SCHED_NEXT,
    // 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
    union {
        model_net_request req;
        struct {} sched; // needs nothing at the moment
    } u;
74 75 76
    // 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;
77
    model_net_sched_rc rc; // rc for scheduling events
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
} model_net_base_msg;

typedef struct model_net_wrap_msg {
    enum model_net_base_event_type event_type;
    int magic;
    union {
        model_net_base_msg m_base;  // base lp
        terminal_message   m_dfly;  // dragonfly
        loggp_message      m_loggp; // loggp
        sn_message         m_snet;  // simplenet
        sw_message         m_swan;  // simplewan
        nodes_message      m_torus; // torus
        // add new ones here
    } msg;
} model_net_wrap_msg;

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