RubySlicc_ComponentMapping.hh (6862:3d308cbd1657) RubySlicc_ComponentMapping.hh (6926:775342cda4db)
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
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/*
31 * $Id$
32 */
33
34#ifndef COMPONENTMAPPINGFNS_H
35#define COMPONENTMAPPINGFNS_H
36
37#include "mem/ruby/common/Global.hh"
38#include "mem/ruby/system/NodeID.hh"
39#include "mem/ruby/system/MachineID.hh"
40#include "mem/ruby/common/Address.hh"
41#include "mem/ruby/common/Set.hh"
42#include "mem/ruby/common/NetDest.hh"
43#include "mem/protocol/GenericMachineType.hh"
44#include "mem/ruby/system/DirectoryMemory.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
9 * notice, this list of conditions and the following disclaimer;
10 * redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution;
13 * neither the name of the copyright holders nor the names of its
14 * contributors may be used to endorse or promote products derived from
15 * this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
18 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
19 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
20 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
21 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
22 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
23 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 */
29
30/*
31 * $Id$
32 */
33
34#ifndef COMPONENTMAPPINGFNS_H
35#define COMPONENTMAPPINGFNS_H
36
37#include "mem/ruby/common/Global.hh"
38#include "mem/ruby/system/NodeID.hh"
39#include "mem/ruby/system/MachineID.hh"
40#include "mem/ruby/common/Address.hh"
41#include "mem/ruby/common/Set.hh"
42#include "mem/ruby/common/NetDest.hh"
43#include "mem/protocol/GenericMachineType.hh"
44#include "mem/ruby/system/DirectoryMemory.hh"
45#include "mem/protocol/MachineType.hh"
45
46#ifdef MACHINETYPE_L1Cache
47#define MACHINETYPE_L1CACHE_ENUM MachineType_L1Cache
48#else
49#define MACHINETYPE_L1CACHE_ENUM MachineType_NUM
50#endif
51
52#ifdef MACHINETYPE_L2Cache
53#define MACHINETYPE_L2CACHE_ENUM MachineType_L2Cache
54#else
55#define MACHINETYPE_L2CACHE_ENUM MachineType_NUM
56#endif
57
58#ifdef MACHINETYPE_L3Cache
59#define MACHINETYPE_L3CACHE_ENUM MachineType_L3Cache
60#else
61#define MACHINETYPE_L3CACHE_ENUM MachineType_NUM
62#endif
63
64#ifdef MACHINETYPE_DMA
65#define MACHINETYPE_DMA_ENUM MachineType_DMA
66#else
67#define MACHINETYPE_DMA_ENUM MachineType_NUM
68#endif
69
46
47#ifdef MACHINETYPE_L1Cache
48#define MACHINETYPE_L1CACHE_ENUM MachineType_L1Cache
49#else
50#define MACHINETYPE_L1CACHE_ENUM MachineType_NUM
51#endif
52
53#ifdef MACHINETYPE_L2Cache
54#define MACHINETYPE_L2CACHE_ENUM MachineType_L2Cache
55#else
56#define MACHINETYPE_L2CACHE_ENUM MachineType_NUM
57#endif
58
59#ifdef MACHINETYPE_L3Cache
60#define MACHINETYPE_L3CACHE_ENUM MachineType_L3Cache
61#else
62#define MACHINETYPE_L3CACHE_ENUM MachineType_NUM
63#endif
64
65#ifdef MACHINETYPE_DMA
66#define MACHINETYPE_DMA_ENUM MachineType_DMA
67#else
68#define MACHINETYPE_DMA_ENUM MachineType_NUM
69#endif
70
70// used to determine the number of acks to wait for
71int getNumberOfLastLevelCaches();
72
73// used to determine the home directory
74// returns a value between 0 and total_directories_within_the_system
75inline
76NodeID map_Address_to_DirectoryNode(const Address& addr)
77{
78 return DirectoryMemory::mapAddressToDirectoryVersion(addr);
79}
80
81// used to determine the home directory
82// returns a value between 0 and total_directories_within_the_system
83inline
84MachineID map_Address_to_Directory(const Address &addr)
85{
86 MachineID mach = {MachineType_Directory, map_Address_to_DirectoryNode(addr)};
87 return mach;
88}
89
90inline
91MachineID map_Address_to_DMA(const Address & addr)
92{
93 MachineID dma = {MACHINETYPE_DMA_ENUM, 0};
94 return dma;
95}
96
97inline
98NetDest broadcast(MachineType type)
99{
100 NetDest dest;
101 for (int i=0; i<MachineType_base_count(type); i++) {
102 MachineID mach = {type, i};
103 dest.add(mach);
104 }
105 return dest;
106}
107
108inline
109MachineID mapAddressToRange(const Address & addr, MachineType type, int low_bit, int num_bits)
110{
111 MachineID mach = {type, 0};
112 if (num_bits == 0)
113 return mach;
114 mach.num = addr.bitSelect(low_bit, low_bit+num_bits-1);
115 return mach;
116}
117
118extern inline NodeID machineIDToNodeID(MachineID machID)
119{
120 return machID.num;
121}
122
123extern inline MachineType machineIDToMachineType(MachineID machID)
124{
125 return machID.type;
126}
127
128extern inline NodeID L1CacheMachIDToProcessorNum(MachineID machID)
129{
130 assert(machID.type == MachineType_L1Cache);
131 return machID.num;
132}
133
134extern inline MachineID getL1MachineID(NodeID L1RubyNode)
135{
136 MachineID mach = {MACHINETYPE_L1CACHE_ENUM, L1RubyNode};
137 return mach;
138}
139
140extern inline GenericMachineType ConvertMachToGenericMach(MachineType machType) {
141 if (machType == MACHINETYPE_L1CACHE_ENUM) {
142 return GenericMachineType_L1Cache;
143 } else if (machType == MACHINETYPE_L2CACHE_ENUM) {
144 return GenericMachineType_L2Cache;
145 } else if (machType == MACHINETYPE_L3CACHE_ENUM) {
146 return GenericMachineType_L3Cache;
147 } else if (machType == MachineType_Directory) {
148 return GenericMachineType_Directory;
149 } else {
150 ERROR_MSG("cannot convert to a GenericMachineType");
151 return GenericMachineType_NULL;
152 }
153}
154
71// used to determine the home directory
72// returns a value between 0 and total_directories_within_the_system
73inline
74NodeID map_Address_to_DirectoryNode(const Address& addr)
75{
76 return DirectoryMemory::mapAddressToDirectoryVersion(addr);
77}
78
79// used to determine the home directory
80// returns a value between 0 and total_directories_within_the_system
81inline
82MachineID map_Address_to_Directory(const Address &addr)
83{
84 MachineID mach = {MachineType_Directory, map_Address_to_DirectoryNode(addr)};
85 return mach;
86}
87
88inline
89MachineID map_Address_to_DMA(const Address & addr)
90{
91 MachineID dma = {MACHINETYPE_DMA_ENUM, 0};
92 return dma;
93}
94
95inline
96NetDest broadcast(MachineType type)
97{
98 NetDest dest;
99 for (int i=0; i<MachineType_base_count(type); i++) {
100 MachineID mach = {type, i};
101 dest.add(mach);
102 }
103 return dest;
104}
105
106inline
107MachineID mapAddressToRange(const Address & addr, MachineType type, int low_bit, int num_bits)
108{
109 MachineID mach = {type, 0};
110 if (num_bits == 0)
111 return mach;
112 mach.num = addr.bitSelect(low_bit, low_bit+num_bits-1);
113 return mach;
114}
115
116extern inline NodeID machineIDToNodeID(MachineID machID)
117{
118 return machID.num;
119}
120
121extern inline MachineType machineIDToMachineType(MachineID machID)
122{
123 return machID.type;
124}
125
126extern inline NodeID L1CacheMachIDToProcessorNum(MachineID machID)
127{
128 assert(machID.type == MachineType_L1Cache);
129 return machID.num;
130}
131
132extern inline MachineID getL1MachineID(NodeID L1RubyNode)
133{
134 MachineID mach = {MACHINETYPE_L1CACHE_ENUM, L1RubyNode};
135 return mach;
136}
137
138extern inline GenericMachineType ConvertMachToGenericMach(MachineType machType) {
139 if (machType == MACHINETYPE_L1CACHE_ENUM) {
140 return GenericMachineType_L1Cache;
141 } else if (machType == MACHINETYPE_L2CACHE_ENUM) {
142 return GenericMachineType_L2Cache;
143 } else if (machType == MACHINETYPE_L3CACHE_ENUM) {
144 return GenericMachineType_L3Cache;
145 } else if (machType == MachineType_Directory) {
146 return GenericMachineType_Directory;
147 } else {
148 ERROR_MSG("cannot convert to a GenericMachineType");
149 return GenericMachineType_NULL;
150 }
151}
152
153extern inline int machineCount(MachineType machType) {
154 return MachineType_base_count(machType);
155}
155
156#endif // COMPONENTMAPPINGFNS_H
156
157#endif // COMPONENTMAPPINGFNS_H