arch-gcn3: make read2st64_b32 write proper registers
[gem5.git] / ext / mcpat / cachearray.h
1 /*****************************************************************************
2 * McPAT
3 * SOFTWARE LICENSE AGREEMENT
4 * Copyright (c) 2010-2013 Advanced Micro Devices, Inc.
5 * All Rights Reserved
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met: redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer;
11 * redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution;
14 * neither the name of the copyright holders nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
17
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * Authors: Joel Hestness
31 * Yasuko Eckert
32 *
33 ***************************************************************************/
34
35 #ifndef CACHEARRAY_H_
36 #define CACHEARRAY_H_
37
38 #include <iostream>
39 #include <string>
40
41 #include "basic_components.h"
42 #include "cacti_interface.h"
43 #include "component.h"
44 #include "const.h"
45 #include "parameter.h"
46
47 class CacheArray : public McPATComponent {
48 public:
49 static double area_efficiency_threshold;
50
51 // These are used for the CACTI interface.
52 static int ed;
53 static int delay_wt;
54 static int cycle_time_wt;
55 static int area_wt;
56 static int dynamic_power_wt;
57 static int leakage_power_wt;
58 static int delay_dev;
59 static int cycle_time_dev;
60 static int area_dev;
61 static int dynamic_power_dev;
62 static int leakage_power_dev;
63 static int cycle_time_dev_threshold;
64
65 InputParameter l_ip;
66 enum Device_ty device_ty;
67 bool opt_local;
68 enum Core_type core_ty;
69 bool is_default;
70 uca_org_t local_result;
71
72 // These are only used for static bank tag (SBT) directory type.
73 double sbt_dir_overhead;
74 // Set this to contain SBT peak power stats
75 statsDef sbt_tdp_stats;
76 // Set this to contain SBT runtime power stats
77 statsDef sbt_rtp_stats;
78
79 CacheArray(XMLNode* _xml_data, const InputParameter *configure_interface,
80 string _name, enum Device_ty device_ty_, double _clockRate = 0.0f,
81 bool opt_local_ = true,
82 enum Core_type core_ty_ = Inorder, bool _is_default = true);
83 void computeArea();
84 void computeEnergy();
85 void compute_base_power();
86 void setSBTDirOverhead(double overhead) { sbt_dir_overhead = overhead; }
87 ~CacheArray();
88
89 private:
90 double computeSBTDynEnergy(statsDef *sbt_stats_ptr);
91 };
92
93 extern inline
94 double CacheArray::computeSBTDynEnergy(statsDef *sbt_stats_p) {
95 if (sbt_dir_overhead == 0) {
96 return 0;
97 }
98
99 // Write miss on dynamic home node will generate a replacement write on
100 // whole cache block
101 double dynamic =
102 sbt_stats_p->readAc.hit *
103 (local_result.data_array2->power.readOp.dynamic * sbt_dir_overhead +
104 local_result.tag_array2->power.readOp.dynamic) +
105 sbt_stats_p->readAc.miss *
106 local_result.tag_array2->power.readOp.dynamic +
107 sbt_stats_p->writeAc.miss *
108 local_result.tag_array2->power.readOp.dynamic +
109 sbt_stats_p->writeAc.hit *
110 (local_result.data_array2->power.writeOp.dynamic * sbt_dir_overhead +
111 local_result.tag_array2->power.readOp.dynamic+
112 sbt_stats_p->writeAc.miss *
113 local_result.power.writeOp.dynamic);
114 return dynamic;
115 }
116
117 #endif /* CACHEARRAY_H_ */