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
;
130 EventQueue
*q
= getEventQueue(0);
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")
259 .functor([]() { return 0; })
261 .desc("this is stat 19")
267 .desc("this is histogram 1")
273 .desc("this is histogram 2")
279 .desc("this is histogram 3")
285 .desc("this is histogram 4")
291 .desc("this is histogram 5")
297 .desc("this is histogram 6")
303 .desc("this is histogram 7")
309 .desc("this is histogram 8")
315 .desc("this is histogram 9")
321 .desc("this is histogram 10")
327 .desc("this is histogram 11")
333 .desc("this is histogram 12")
338 .name("SparseHistogram1")
339 .desc("this is sparse histogram 1")
344 .desc("this is formula 1")
350 .desc("this is formula 2")
357 .desc("this is formula 3")
368 .desc("this is formula 4")
374 .desc("this is statistic 20 for vector op testing")
375 .flags(total
| nozero
| nonan
)
380 .desc("this is statistic 21 for vector op testing")
381 .flags(total
| nozero
| nonan
)
385 .name("vector_op_test_formula")
386 .desc("The total stat should equal 1")
387 .flags(total
|nozero
|nonan
)
391 f2
= (-s1
) / (-s2
) * (-s3
+ ULL(100) + s4
);
393 f4
+= constant(10.0);
427 s10
.sample(1000000000);
428 curEventQueue()->setCurTick(curTick() + ULL(1000000));
503 curEventQueue()->setCurTick(curTick() + ULL(1000000));
505 curEventQueue()->setCurTick(curTick() + ULL(1000000));
507 curEventQueue()->setCurTick(curTick() + ULL(1000000));
509 curEventQueue()->setCurTick(curTick() + ULL(1000000));
511 curEventQueue()->setCurTick(curTick() + ULL(1000000));
518 curEventQueue()->setCurTick(curTick() + ULL(1000000));
520 curEventQueue()->setCurTick(curTick() + ULL(1000000));
522 curEventQueue()->setCurTick(curTick() + ULL(1000000));
524 curEventQueue()->setCurTick(curTick() + ULL(1000000));
527 curEventQueue()->setCurTick(curTick() + ULL(1000000));
529 curEventQueue()->setCurTick(curTick() + ULL(1000000));
531 curEventQueue()->setCurTick(curTick() + ULL(1000000));
533 curEventQueue()->setCurTick(curTick() + ULL(1000000));
539 curEventQueue()->setCurTick(curTick() + ULL(1000000));
546 curEventQueue()->setCurTick(curTick() + ULL(1000000));
555 curEventQueue()->setCurTick(curTick() + 9);
630 curEventQueue()->setCurTick(curTick() + 9);
639 for (int i
= 0; i
< 100; i
++) {
644 for (int i
= -100; i
< 100; i
++) {
649 for (int i
= -100; i
< 1000; i
++) {
654 for (int i
= 100; i
>= -1000; i
--) {
659 for (int i
= 0; i
<= 1023; i
++) {
664 for (int i
= -1024; i
<= 1023; i
++) {
669 for (int i
= 0; i
< 1000; i
++) {
670 sh1
.sample(random() % 10000);
681 stattest_init_pybind(py::module
&m_internal
)
683 py::module m
= m_internal
.def_submodule("stattest");
686 .def("stattest_init", []() { __stattest().init(); })
687 .def("stattest_run", []() { __stattest().run(); })
691 static EmbeddedPyBind
embed_("stattest", stattest_init_pybind
);