16145Snate@binkert.org/* 26145Snate@binkert.org * Copyright (c) 1999-2008 Mark D. Hill and David A. Wood 36145Snate@binkert.org * All rights reserved. 46145Snate@binkert.org * 56145Snate@binkert.org * Redistribution and use in source and binary forms, with or without 66145Snate@binkert.org * modification, are permitted provided that the following conditions are 76145Snate@binkert.org * met: redistributions of source code must retain the above copyright 86145Snate@binkert.org * notice, this list of conditions and the following disclaimer; 96145Snate@binkert.org * redistributions in binary form must reproduce the above copyright 106145Snate@binkert.org * notice, this list of conditions and the following disclaimer in the 116145Snate@binkert.org * documentation and/or other materials provided with the distribution; 126145Snate@binkert.org * neither the name of the copyright holders nor the names of its 136145Snate@binkert.org * contributors may be used to endorse or promote products derived from 146145Snate@binkert.org * this software without specific prior written permission. 156145Snate@binkert.org * 166145Snate@binkert.org * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 176145Snate@binkert.org * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 186145Snate@binkert.org * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 196145Snate@binkert.org * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 206145Snate@binkert.org * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 216145Snate@binkert.org * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 226145Snate@binkert.org * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 236145Snate@binkert.org * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 246145Snate@binkert.org * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 256145Snate@binkert.org * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 266145Snate@binkert.org * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 276145Snate@binkert.org */ 286145Snate@binkert.org 297039Snate@binkert.org#ifndef __MEM_RUBY_COMMON_NETDEST_HH__ 307039Snate@binkert.org#define __MEM_RUBY_COMMON_NETDEST_HH__ 316145Snate@binkert.org 327055Snate@binkert.org#include <iostream> 337454Snate@binkert.org#include <vector> 347055Snate@binkert.org 357055Snate@binkert.org#include "mem/ruby/common/Set.hh" 3610301Snilay@cs.wisc.edu#include "mem/ruby/common/MachineID.hh" 376145Snate@binkert.org 3811085Snilay@cs.wisc.edu// NetDest specifies the network destination of a Message 397039Snate@binkert.orgclass NetDest 407039Snate@binkert.org{ 417039Snate@binkert.org public: 427039Snate@binkert.org // Constructors 437039Snate@binkert.org // creates and empty set 447039Snate@binkert.org NetDest(); 457039Snate@binkert.org explicit NetDest(int bit_size); 466145Snate@binkert.org 477039Snate@binkert.org NetDest& operator=(const Set& obj); 486145Snate@binkert.org 497039Snate@binkert.org ~NetDest() 508054Sksewell@umich.edu { } 516145Snate@binkert.org 527039Snate@binkert.org void add(MachineID newElement); 537039Snate@binkert.org void addNetDest(const NetDest& netDest); 547039Snate@binkert.org void setNetDest(MachineType machine, const Set& set); 557039Snate@binkert.org void remove(MachineID oldElement); 567039Snate@binkert.org void removeNetDest(const NetDest& netDest); 577039Snate@binkert.org void clear(); 587039Snate@binkert.org void broadcast(); 597039Snate@binkert.org void broadcast(MachineType machine); 607039Snate@binkert.org int count() const; 6110004Snilay@cs.wisc.edu bool isEqual(const NetDest& netDest) const; 626145Snate@binkert.org 637039Snate@binkert.org // return the logical OR of this netDest and orNetDest 647039Snate@binkert.org NetDest OR(const NetDest& orNetDest) const; 656145Snate@binkert.org 667039Snate@binkert.org // return the logical AND of this netDest and andNetDest 677039Snate@binkert.org NetDest AND(const NetDest& andNetDest) const; 686145Snate@binkert.org 697039Snate@binkert.org // Returns true if the intersection of the two netDests is non-empty 707039Snate@binkert.org bool intersectionIsNotEmpty(const NetDest& other_netDest) const; 716145Snate@binkert.org 727039Snate@binkert.org // Returns true if the intersection of the two netDests is empty 737039Snate@binkert.org bool intersectionIsEmpty(const NetDest& other_netDest) const; 746145Snate@binkert.org 757039Snate@binkert.org bool isSuperset(const NetDest& test) const; 767039Snate@binkert.org bool isSubset(const NetDest& test) const { return test.isSuperset(*this); } 777039Snate@binkert.org bool isElement(MachineID element) const; 787039Snate@binkert.org bool isBroadcast() const; 797039Snate@binkert.org bool isEmpty() const; 806145Snate@binkert.org 817039Snate@binkert.org // For Princeton Network 827454Snate@binkert.org std::vector<NodeID> getAllDest(); 836145Snate@binkert.org 847039Snate@binkert.org MachineID smallestElement() const; 857039Snate@binkert.org MachineID smallestElement(MachineType machine) const; 866145Snate@binkert.org 877454Snate@binkert.org void resize(); 887039Snate@binkert.org int getSize() const { return m_bits.size(); } 896145Snate@binkert.org 907039Snate@binkert.org // get element for a index 917039Snate@binkert.org NodeID elementAt(MachineID index); 926145Snate@binkert.org 937055Snate@binkert.org void print(std::ostream& out) const; 946145Snate@binkert.org 957039Snate@binkert.org private: 967039Snate@binkert.org // returns a value >= MachineType_base_level("this machine") 977039Snate@binkert.org // and < MachineType_base_level("next highest machine") 987039Snate@binkert.org int 997039Snate@binkert.org vecIndex(MachineID m) const 1007039Snate@binkert.org { 1017039Snate@binkert.org int vec_index = MachineType_base_level(m.type); 1027039Snate@binkert.org assert(vec_index < m_bits.size()); 1037039Snate@binkert.org return vec_index; 1047039Snate@binkert.org } 1056145Snate@binkert.org 10610086Snilay@cs.wisc.edu NodeID bitIndex(NodeID index) const { return index; } 1076145Snate@binkert.org 1087454Snate@binkert.org std::vector<Set> m_bits; // a vector of bit vectors - i.e. Sets 1096145Snate@binkert.org}; 1106145Snate@binkert.org 1117055Snate@binkert.orginline std::ostream& 1127055Snate@binkert.orgoperator<<(std::ostream& out, const NetDest& obj) 1136145Snate@binkert.org{ 1147039Snate@binkert.org obj.print(out); 1157055Snate@binkert.org out << std::flush; 1167039Snate@binkert.org return out; 1176145Snate@binkert.org} 1186145Snate@binkert.org 1197039Snate@binkert.org#endif // __MEM_RUBY_COMMON_NETDEST_HH__ 120