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
;
54 StatTest
& __stattest();
67 double operator()() { return 9.7; }
84 VectorDistribution s13
;
85 VectorStandardDeviation s14
;
86 VectorAverageDeviation s15
;
140 EventQueue
*q
= getEventQueue(0);
143 cprintf("sizeof(Scalar) = %d\n", sizeof(Scalar
));
144 cprintf("sizeof(Vector) = %d\n", sizeof(Vector
));
145 cprintf("sizeof(Distribution) = %d\n", sizeof(Distribution
));
149 .desc("this is statistic 1")
154 .desc("this is statistic 2")
160 .desc("this is statistic 3")
166 .desc("this is statistic 4")
173 .desc("this is statistic 5")
185 .desc("this is statistic 6")
192 .desc("this is statistic 7")
201 .desc("this is statistic 8")
209 .desc("this is statistic 9")
216 .desc("this is statistic 10")
223 .desc("this is statistic 12")
229 .desc("this is statistic 13")
235 .desc("this is statistic 14")
241 .desc("this is statistic 15")
247 .desc("this is statistic 16")
258 .desc("this is stat 17")
265 .desc("this is stat 18")
271 .desc("this is histogram 1")
277 .desc("this is histogram 2")
283 .desc("this is histogram 3")
289 .desc("this is histogram 4")
295 .desc("this is histogram 5")
301 .desc("this is histogram 6")
307 .desc("this is histogram 7")
313 .desc("this is histogram 8")
319 .desc("this is histogram 9")
325 .desc("this is histogram 10")
331 .desc("this is histogram 11")
337 .desc("this is histogram 12")
342 .name("SparseHistogram1")
343 .desc("this is sparse histogram 1")
348 .desc("this is formula 1")
354 .desc("this is formula 2")
361 .desc("this is formula 3")
372 .desc("this is formula 4")
378 .desc("this is statistic 19 for vector op testing")
379 .flags(total
| nozero
| nonan
)
384 .desc("this is statistic 20 for vector op testing")
385 .flags(total
| nozero
| nonan
)
389 .name("vector_op_test_formula")
390 .desc("The total stat should equal 1")
391 .flags(total
|nozero
|nonan
)
395 f2
= (-s1
) / (-s2
) * (-s3
+ ULL(100) + s4
);
397 f4
+= constant(10.0);
431 s10
.sample(1000000000);
432 curEventQueue()->setCurTick(curTick() + ULL(1000000));
507 curEventQueue()->setCurTick(curTick() + ULL(1000000));
509 curEventQueue()->setCurTick(curTick() + ULL(1000000));
511 curEventQueue()->setCurTick(curTick() + ULL(1000000));
513 curEventQueue()->setCurTick(curTick() + ULL(1000000));
515 curEventQueue()->setCurTick(curTick() + ULL(1000000));
522 curEventQueue()->setCurTick(curTick() + ULL(1000000));
524 curEventQueue()->setCurTick(curTick() + ULL(1000000));
526 curEventQueue()->setCurTick(curTick() + ULL(1000000));
528 curEventQueue()->setCurTick(curTick() + ULL(1000000));
531 curEventQueue()->setCurTick(curTick() + ULL(1000000));
533 curEventQueue()->setCurTick(curTick() + ULL(1000000));
535 curEventQueue()->setCurTick(curTick() + ULL(1000000));
537 curEventQueue()->setCurTick(curTick() + ULL(1000000));
543 curEventQueue()->setCurTick(curTick() + ULL(1000000));
550 curEventQueue()->setCurTick(curTick() + ULL(1000000));
559 curEventQueue()->setCurTick(curTick() + 9);
634 curEventQueue()->setCurTick(curTick() + 9);
643 for (int i
= 0; i
< 100; i
++) {
648 for (int i
= -100; i
< 100; i
++) {
653 for (int i
= -100; i
< 1000; i
++) {
658 for (int i
= 100; i
>= -1000; i
--) {
663 for (int i
= 0; i
<= 1023; i
++) {
668 for (int i
= -1024; i
<= 1023; i
++) {
673 for (int i
= 0; i
< 1000; i
++) {
674 sh1
.sample(random() % 10000);