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.
29 #include "pybind11/pybind11.h"
35 #include "base/cprintf.hh"
36 #include "base/logging.hh"
37 #include "base/statistics.hh"
38 #include "base/types.hh"
39 #include "sim/core.hh"
40 #include "sim/init.hh"
41 #include "sim/stat_control.hh"
43 namespace py
= pybind11
;
45 // override the default main() code for this unittest
46 const char *m5MainCommands
[] = {
47 "import m5.stattestmain",
48 "m5.stattestmain.main()",
49 0 // sentinel is required
53 using namespace Stats
;
57 StatTest
& __stattest();
68 double operator()() { return 9.7; }
85 VectorDistribution s13
;
86 VectorStandardDeviation s14
;
87 VectorAverageDeviation s15
;
129 EventQueue
*q
= getEventQueue(0);
132 cprintf("sizeof(Scalar) = %d\n", sizeof(Scalar
));
133 cprintf("sizeof(Vector) = %d\n", sizeof(Vector
));
134 cprintf("sizeof(Distribution) = %d\n", sizeof(Distribution
));
138 .desc("this is statistic 1")
143 .desc("this is statistic 2")
149 .desc("this is statistic 3")
155 .desc("this is statistic 4")
162 .desc("this is statistic 5")
174 .desc("this is statistic 6")
181 .desc("this is statistic 7")
190 .desc("this is statistic 8")
198 .desc("this is statistic 9")
205 .desc("this is statistic 10")
212 .desc("this is statistic 12")
218 .desc("this is statistic 13")
224 .desc("this is statistic 14")
230 .desc("this is statistic 15")
236 .desc("this is statistic 16")
247 .desc("this is stat 17")
254 .desc("this is stat 18")
260 .desc("this is histogram 1")
266 .desc("this is histogram 2")
272 .desc("this is histogram 3")
278 .desc("this is histogram 4")
284 .desc("this is histogram 5")
290 .desc("this is histogram 6")
296 .desc("this is histogram 7")
302 .desc("this is histogram 8")
308 .desc("this is histogram 9")
314 .desc("this is histogram 10")
320 .desc("this is histogram 11")
326 .desc("this is histogram 12")
331 .name("SparseHistogram1")
332 .desc("this is sparse histogram 1")
337 .desc("this is formula 1")
343 .desc("this is formula 2")
350 .desc("this is formula 3")
361 .desc("this is formula 4")
367 .desc("this is statistic 19 for vector op testing")
368 .flags(total
| nozero
| nonan
)
373 .desc("this is statistic 20 for vector op testing")
374 .flags(total
| nozero
| nonan
)
378 .name("vector_op_test_formula")
379 .desc("The total stat should equal 1")
380 .flags(total
|nozero
|nonan
)
384 f2
= (-s1
) / (-s2
) * (-s3
+ ULL(100) + s4
);
386 f4
+= constant(10.0);
420 s10
.sample(1000000000);
421 curEventQueue()->setCurTick(curTick() + ULL(1000000));
496 curEventQueue()->setCurTick(curTick() + ULL(1000000));
498 curEventQueue()->setCurTick(curTick() + ULL(1000000));
500 curEventQueue()->setCurTick(curTick() + ULL(1000000));
502 curEventQueue()->setCurTick(curTick() + ULL(1000000));
504 curEventQueue()->setCurTick(curTick() + ULL(1000000));
511 curEventQueue()->setCurTick(curTick() + ULL(1000000));
513 curEventQueue()->setCurTick(curTick() + ULL(1000000));
515 curEventQueue()->setCurTick(curTick() + ULL(1000000));
517 curEventQueue()->setCurTick(curTick() + ULL(1000000));
520 curEventQueue()->setCurTick(curTick() + ULL(1000000));
522 curEventQueue()->setCurTick(curTick() + ULL(1000000));
524 curEventQueue()->setCurTick(curTick() + ULL(1000000));
526 curEventQueue()->setCurTick(curTick() + ULL(1000000));
532 curEventQueue()->setCurTick(curTick() + ULL(1000000));
539 curEventQueue()->setCurTick(curTick() + ULL(1000000));
548 curEventQueue()->setCurTick(curTick() + 9);
623 curEventQueue()->setCurTick(curTick() + 9);
632 for (int i
= 0; i
< 100; i
++) {
637 for (int i
= -100; i
< 100; i
++) {
642 for (int i
= -100; i
< 1000; i
++) {
647 for (int i
= 100; i
>= -1000; i
--) {
652 for (int i
= 0; i
<= 1023; i
++) {
657 for (int i
= -1024; i
<= 1023; i
++) {
662 for (int i
= 0; i
< 1000; i
++) {
663 sh1
.sample(random() % 10000);
674 stattest_init_pybind(py::module
&m_internal
)
676 py::module m
= m_internal
.def_submodule("stattest");
679 .def("stattest_init", []() { __stattest().init(); })
680 .def("stattest_run", []() { __stattest().run(); })
684 static EmbeddedPyBind
embed_("stattest", stattest_init_pybind
);