torus.h 2.87 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
#ifndef INC_torus_h
#define INC_torus_h

#include <ross.h>
#include <assert.h>

#include "codes/codes_mapping.h"
#include "codes/codes.h"
#include "codes/model-net.h"
#include "codes/model-net-method.h"

#define CHUNK_SIZE 32
#define DEBUG 1
#define MEAN_INTERVAL 100
#define CATEGORY_NAME_MAX 16
#define MAX_NAME_LENGTH 256
#define TRACE -1 

// Total number of nodes in torus, calculate in main
int N_nodes = 1;
double link_bandwidth;
int buffer_size;
int num_vc;
int n_dims;
int * dim_length;
int * factor;
int * half_length;

char grp_name[MAX_NAME_LENGTH], type_name[MAX_NAME_LENGTH];
int grp_id, lp_type_id, rep_id, offset;

typedef enum nodes_event_t nodes_event_t;
typedef struct nodes_state nodes_state;
typedef struct nodes_message nodes_message;

/* Issues a torus packet event call */
static void torus_packet_event(
		       char* category,
		       tw_lpid final_dest_lp,
		       int packet_size,
		       int remote_event_size,
		       const void* remote_event,
		       int self_event_size,
		       const void* self_event,
		       tw_lp *sender,
		       int is_last_pckt);

static void torus_packet_event_rc(tw_lp *sender);
static void torus_setup(const void* net_params);
static int torus_get_msg_sz(void);
static const tw_lptype* torus_get_lp_type(void);
52
static void torus_report_stats(void);
53 54 55 56 57 58 59 60 61 62

/* data structure for torus statistics */
struct model_net_method torus_method =
{
   .method_name = "torus",
   .mn_setup = torus_setup,
   .model_net_method_packet_event = torus_packet_event,
   .model_net_method_packet_event_rc = torus_packet_event_rc,
   .mn_get_lp_type = torus_get_lp_type,
   .mn_get_msg_sz = torus_get_msg_sz,
63
   .mn_report_stats = torus_report_stats,
64 65 66 67 68 69 70 71 72 73 74 75 76 77 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 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
};

enum nodes_event_t
{
  GENERATE = 1,
  ARRIVAL, 
  SEND,
  CREDIT,
};

struct nodes_state
{
  unsigned long long packet_counter;            
  tw_stime** next_link_available_time; 
  tw_stime** next_credit_available_time;
  tw_stime** next_flit_generate_time;
  int** buffer;
  int* dim_position;
  int* neighbour_minus_lpID;
  int* neighbour_plus_lpID;
  int source_dim;
  int direction;
};

struct nodes_message
{
  char category[CATEGORY_NAME_MAX];
  tw_stime travel_start_time;
  tw_stime saved_available_time;

  unsigned long long packet_ID;
  nodes_event_t	 type;

  int saved_src_dim;
  int saved_src_dir;

  int* dest;

  tw_lpid final_dest_gid;
  tw_lpid dest_lp;
  tw_lpid sender_lp;

  int my_N_hop;
  int source_dim;
  int source_direction;
  int next_stop;
  int packet_size;
  short chunk_id;

  // for codes local and remote events
  int local_event_size_bytes;
  int remote_event_size_bytes;
};

tw_stime         average_travel_time = 0;
tw_stime         total_time = 0;
tw_stime         max_latency = 0;

float head_delay=0.0;
float credit_delay = 0.0;

Philip Carns's avatar
Philip Carns committed
125 126
static long long       N_finished_packets = 0;
static long long       total_hops = 0;
127 128 129 130 131 132
// run time arguments
int num_packets;
int num_chunks;
int packet_offset = 0;

#endif