2 * Copyright (c) 2003-2005 The Regents of The University of Michigan
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
7 * met: redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer;
9 * redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution;
12 * neither the name of the copyright holders nor the names of its
13 * contributors may be used to endorse or promote products derived from
14 * this software without specific prior written permission.
16 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Authors: Nathan Binkert
35 #include "base/cprintf.hh"
36 #include "base/misc.hh"
37 #include "base/statistics.hh"
38 #include "base/types.hh"
39 #include "sim/core.hh"
40 #include "sim/stat_control.hh"
42 // override the default main() code for this unittest
43 const char *m5MainCommands
[] = {
44 "import m5.stattestmain",
45 "m5.stattestmain.main()",
46 0 // sentinel is required
50 using namespace Stats
;
60 double operator()() { return 9.7; }
77 VectorDistribution s13
;
78 VectorStandardDeviation s14
;
79 VectorAverageDeviation s15
;
133 cprintf("sizeof(Scalar) = %d\n", sizeof(Scalar
));
134 cprintf("sizeof(Vector) = %d\n", sizeof(Vector
));
135 cprintf("sizeof(Distribution) = %d\n", sizeof(Distribution
));
139 .desc("this is statistic 1")
144 .desc("this is statistic 2")
150 .desc("this is statistic 3")
156 .desc("this is statistic 4")
163 .desc("this is statistic 5")
175 .desc("this is statistic 6")
182 .desc("this is statistic 7")
191 .desc("this is statistic 8")
199 .desc("this is statistic 9")
206 .desc("this is statistic 10")
213 .desc("this is statistic 12")
219 .desc("this is statistic 13")
225 .desc("this is statistic 14")
231 .desc("this is statistic 15")
237 .desc("this is statistic 16")
248 .desc("this is stat 17")
255 .desc("this is stat 18")
261 .desc("this is histogram 1")
267 .desc("this is histogram 2")
273 .desc("this is histogram 3")
279 .desc("this is histogram 4")
285 .desc("this is histogram 5")
291 .desc("this is histogram 6")
297 .desc("this is histogram 7")
303 .desc("this is histogram 8")
309 .desc("this is histogram 9")
315 .desc("this is histogram 10")
321 .desc("this is histogram 11")
327 .desc("this is histogram 12")
332 .name("SparseHistogram1")
333 .desc("this is sparse histogram 1")
338 .desc("this is formula 1")
344 .desc("this is formula 2")
351 .desc("this is formula 3")
362 .desc("this is formula 4")
368 .desc("this is statistic 19 for vector op testing")
369 .flags(total
| nozero
| nonan
)
374 .desc("this is statistic 20 for vector op testing")
375 .flags(total
| nozero
| nonan
)
379 .name("vector_op_test_formula")
380 .desc("The total stat should equal 1")
381 .flags(total
|nozero
|nonan
)
385 f2
= (-s1
) / (-s2
) * (-s3
+ ULL(100) + s4
);
387 f4
+= constant(10.0);
421 s10
.sample(1000000000);
422 curTick(curTick() + ULL(1000000));
497 curTick(curTick() + ULL(1000000));
499 curTick(curTick() + ULL(1000000));
501 curTick(curTick() + ULL(1000000));
503 curTick(curTick() + ULL(1000000));
505 curTick(curTick() + ULL(1000000));
512 curTick(curTick() + ULL(1000000));
514 curTick(curTick() + ULL(1000000));
516 curTick(curTick() + ULL(1000000));
518 curTick(curTick() + ULL(1000000));
521 curTick(curTick() + ULL(1000000));
523 curTick(curTick() + ULL(1000000));
525 curTick(curTick() + ULL(1000000));
527 curTick(curTick() + ULL(1000000));
533 curTick(curTick() + ULL(1000000));
540 curTick(curTick() + ULL(1000000));
549 curTick(curTick() + 9);
624 curTick(curTick() + 9);
633 for (int i
= 0; i
< 100; i
++) {
638 for (int i
= -100; i
< 100; i
++) {
643 for (int i
= -100; i
< 1000; i
++) {
648 for (int i
= 100; i
>= -1000; i
--) {
653 for (int i
= 0; i
<= 1023; i
++) {
658 for (int i
= -1024; i
<= 1023; i
++) {
663 for (int i
= 0; i
< 1000; i
++) {
664 sh1
.sample(random() % 10000);