1/* 2 * Copyright (c) 2003-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 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; --- 14 unchanged lines hidden (view full) --- 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. 27 * 28 * Authors: Nathan Binkert 29 */ 30 |
31#include "pybind11/pybind11.h" 32 |
33#include <iomanip> 34#include <iostream> 35#include <string> 36 37#include "base/cprintf.hh" 38#include "base/misc.hh" 39#include "base/statistics.hh" 40#include "base/types.hh" 41#include "sim/core.hh" |
42#include "sim/init.hh" |
43#include "sim/stat_control.hh" 44 |
45namespace py = pybind11; 46 |
47// override the default main() code for this unittest 48const char *m5MainCommands[] = { 49 "import m5.stattestmain", 50 "m5.stattestmain.main()", 51 0 // sentinel is required 52}; 53 54using namespace std; 55using namespace Stats; 56 57double testfunc(); 58struct StatTest; 59StatTest & __stattest(); |
60 61 62double 63testfunc() 64{ 65 return 9.8; 66} 67 --- 53 unchanged lines hidden (view full) --- 121StatTest & 122__stattest() 123{ 124 static StatTest st; 125 return st; 126} 127 128void |
129StatTest::init() 130{ 131 EventQueue *q = getEventQueue(0); 132 curEventQueue(q); 133 134 cprintf("sizeof(Scalar) = %d\n", sizeof(Scalar)); 135 cprintf("sizeof(Vector) = %d\n", sizeof(Vector)); 136 cprintf("sizeof(Distribution) = %d\n", sizeof(Distribution)); --- 529 unchanged lines hidden (view full) --- 666 } 667 668 s19[0] = 1; 669 s19[1] = 100000; 670 s20[0] = 100000; 671 s20[1] = 1; 672 673} |
674 675static void 676stattest_init_pybind(py::module &m_internal) 677{ 678 py::module m = m_internal.def_submodule("stattest"); 679 680 m 681 .def("stattest_init", []() { __stattest().init(); }) 682 .def("stattest_run", []() { __stattest().run(); }) 683 ; 684} 685 686static EmbeddedPyBind embed_("stattest", stattest_init_pybind); |