Network.hh (6284:a63d1dc4c820) Network.hh (6285:ce086eca1ede)
1
2/*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

--- 35 unchanged lines hidden (view full) ---

44 * */
45
46#ifndef NETWORK_H
47#define NETWORK_H
48
49#include "mem/ruby/common/Global.hh"
50#include "mem/ruby/system/NodeID.hh"
51#include "mem/protocol/MessageSizeType.hh"
1
2/*
3 * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are
8 * met: redistributions of source code must retain the above copyright

--- 35 unchanged lines hidden (view full) ---

44 * */
45
46#ifndef NETWORK_H
47#define NETWORK_H
48
49#include "mem/ruby/common/Global.hh"
50#include "mem/ruby/system/NodeID.hh"
51#include "mem/protocol/MessageSizeType.hh"
52#include "mem/ruby/system/System.hh"
53#include "mem/ruby/config/RubyConfig.hh"
52
53class NetDest;
54class MessageBuffer;
55class Throttle;
54
55class NetDest;
56class MessageBuffer;
57class Throttle;
58class Topology;
56
57class Network {
58public:
59 // Constructors
59
60class Network {
61public:
62 // Constructors
60 Network() {}
63 Network(const string & name);
64 virtual void init(const vector<string> & argv);
61
62 // Destructor
63 virtual ~Network() {}
64
65 // Public Methods
65
66 // Destructor
67 virtual ~Network() {}
68
69 // Public Methods
70 int getBufferSize() { return m_buffer_size; }
71 int getNumberOfVirtualNetworks() { return m_virtual_networks; }
72 int getEndpointBandwidth() { return m_endpoint_bandwidth; }
73 bool getAdaptiveRouting() {return m_adaptive_routing; }
74 int getLinkLatency() { return m_link_latency; }
66
75
67 static Network* createNetwork(int nodes);
68
69 // returns the queue requested for the given component
70 virtual MessageBuffer* getToNetQueue(NodeID id, bool ordered, int netNumber) = 0;
71 virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int netNumber) = 0;
72 virtual const Vector<Throttle*>* getThrottles(NodeID id) const { return NULL; }
73
74 virtual int getNumNodes() {return 1;}
75
76 virtual void makeOutLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) = 0;
77 virtual void makeInLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration) = 0;
78 virtual void makeInternalLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) = 0;
79
80 virtual void reset() = 0;
81
82 virtual void printStats(ostream& out) const = 0;
83 virtual void clearStats() = 0;
84 virtual void printConfig(ostream& out) const = 0;
85 virtual void print(ostream& out) const = 0;
86
76 // returns the queue requested for the given component
77 virtual MessageBuffer* getToNetQueue(NodeID id, bool ordered, int netNumber) = 0;
78 virtual MessageBuffer* getFromNetQueue(NodeID id, bool ordered, int netNumber) = 0;
79 virtual const Vector<Throttle*>* getThrottles(NodeID id) const { return NULL; }
80
81 virtual int getNumNodes() {return 1;}
82
83 virtual void makeOutLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) = 0;
84 virtual void makeInLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int bw_multiplier, bool isReconfiguration) = 0;
85 virtual void makeInternalLink(SwitchID src, NodeID dest, const NetDest& routing_table_entry, int link_latency, int link_weight, int bw_multiplier, bool isReconfiguration) = 0;
86
87 virtual void reset() = 0;
88
89 virtual void printStats(ostream& out) const = 0;
90 virtual void clearStats() = 0;
91 virtual void printConfig(ostream& out) const = 0;
92 virtual void print(ostream& out) const = 0;
93
87private:
94protected:
88
89 // Private Methods
90 // Private copy constructor and assignment operator
91 Network(const Network& obj);
92 Network& operator=(const Network& obj);
93
94 // Data Members (m_ prefix)
95
96 // Private Methods
97 // Private copy constructor and assignment operator
98 Network(const Network& obj);
99 Network& operator=(const Network& obj);
100
101 // Data Members (m_ prefix)
102protected:
103 const string m_name;
104 int m_nodes;
105 int m_virtual_networks;
106 int m_buffer_size;
107 int m_endpoint_bandwidth;
108 Topology* m_topology_ptr;
109 bool m_adaptive_routing;
110 int m_link_latency;
95};
96
97// Output operator declaration
98ostream& operator<<(ostream& out, const Network& obj);
99
100// ******************* Definitions *******************
101
102// Output operator definition
103extern inline
104ostream& operator<<(ostream& out, const Network& obj)
105{
106 obj.print(out);
107 out << flush;
108 return out;
109}
110
111// Code to map network message size types to an integer number of bytes
112const int CONTROL_MESSAGE_SIZE = 8;
111};
112
113// Output operator declaration
114ostream& operator<<(ostream& out, const Network& obj);
115
116// ******************* Definitions *******************
117
118// Output operator definition
119extern inline
120ostream& operator<<(ostream& out, const Network& obj)
121{
122 obj.print(out);
123 out << flush;
124 return out;
125}
126
127// Code to map network message size types to an integer number of bytes
128const int CONTROL_MESSAGE_SIZE = 8;
113const int DATA_MESSAGE_SIZE = (64+8);
129const int DATA_MESSAGE_SIZE = (RubySystem::getBlockSizeBytes()+8);
114
115extern inline
116int MessageSizeType_to_int(MessageSizeType size_type)
117{
118 switch(size_type) {
119 case MessageSizeType_Undefined:
120 ERROR_MSG("Can't convert Undefined MessageSizeType to integer");
121 break;

--- 27 unchanged lines hidden ---
130
131extern inline
132int MessageSizeType_to_int(MessageSizeType size_type)
133{
134 switch(size_type) {
135 case MessageSizeType_Undefined:
136 ERROR_MSG("Can't convert Undefined MessageSizeType to integer");
137 break;

--- 27 unchanged lines hidden ---