3 # Copyright (c) 2014 ARM Limited
6 # The license below extends only to copyright in the software and shall
7 # not be construed as granting a license to any other intellectual
8 # property including but not limited to intellectual property relating
9 # to a hardware implementation of the functionality of the software
10 # licensed hereunder. You may use the software subject to the license
11 # terms below provided that you ensure that this notice is replicated
12 # unmodified and in its entirety in all distributions of the software,
13 # modified or unmodified, in source code or in binary form.
15 # Redistribution and use in source and binary forms, with or without
16 # modification, are permitted provided that the following conditions are
17 # met: redistributions of source code must retain the above copyright
18 # notice, this list of conditions and the following disclaimer;
19 # redistributions in binary form must reproduce the above copyright
20 # notice, this list of conditions and the following disclaimer in the
21 # documentation and/or other materials provided with the distribution;
22 # neither the name of the copyright holders nor the names of its
23 # contributors may be used to endorse or promote products derived from
24 # this software without specific prior written permission.
26 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
27 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
28 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
29 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
30 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
31 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
32 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
33 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
34 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
35 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
36 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
38 # Authors: Andreas Hansson
42 from mpl_toolkits
.mplot3d
import Axes3D
43 from matplotlib
import cm
44 from matplotlib
.ticker
import LinearLocator
, FormatStrFormatter
45 import matplotlib
.pyplot
as plt
48 print "Failed to import matplotlib and numpy"
54 # Determine the parameters of the sweep from the simout output, and
55 # then parse the stats and plot the 3D surface corresponding to the
56 # different combinations of parallel banks, and stride size, as
57 # generated by the config/dram/sweep.py script
60 if len(sys
.argv
) != 2:
61 print "Usage: ", sys
.argv
[0], " <simout directory>"
65 stats
= open(sys
.argv
[1] + '/stats.txt', 'r')
67 print "Failed to open ", sys
.argv
[1] + '/stats.txt', " for reading"
71 simout
= open(sys
.argv
[1] + '/simout', 'r')
73 print "Failed to open ", sys
.argv
[1] + '/simout', " for reading"
76 # Get the burst size, number of banks and the maximum stride from
77 # the simulation output
81 match
= re
.match("DRAM sweep with "
82 "burst: (\d+), banks: (\d+), max stride: (\d+)", line
)
84 burst_size
= int(match
.groups(0)[0])
85 banks
= int(match
.groups(0)[1])
86 max_size
= int(match
.groups(0)[2])
92 print "Failed to establish sweep details, ensure simout is up-to-date"
96 # Collect the bus utilisation as our Z-axis, we do this in a 2D
97 # grid corresponding to each iteration over the various stride
103 # Now parse the stats
105 match
= re
.match(".*busUtil\s+(\d+\.\d+)\s+#.*", line
)
107 bus_util
= float(match
.groups(0)[0])
110 # If we have completed a sweep over the stride sizes,
112 if i
== max_size
/ burst_size
:
119 # We should have a 2D grid with as many columns as banks
121 print "Unexpected number of data points in stats output"
125 ax
= fig
.gca(projection
='3d')
126 X
= np
.arange(burst_size
, max_size
+ 1, burst_size
)
127 Y
= np
.arange(1, banks
+ 1, 1)
128 X
, Y
= np
.meshgrid(X
, Y
)
130 # the values in the util are banks major, so we see groups for each
131 # stride size in order
134 surf
= ax
.plot_surface(X
, Y
, Z
, rstride
=1, cstride
=1, cmap
=cm
.coolwarm
,
135 linewidth
=0, antialiased
=False)
137 # Change the tick frequency to 64
138 start
, end
= ax
.get_xlim()
139 ax
.xaxis
.set_ticks(np
.arange(start
, end
+ 1, 64))
141 ax
.set_xlabel('Bytes per activate')
142 ax
.set_ylabel('Banks')
143 ax
.set_zlabel('Efficiency (%)')
146 fig
.colorbar(surf
, shrink
=0.5, pad
=.1, aspect
=10)
150 if __name__
== "__main__":