summaryrefslogtreecommitdiff
path: root/src/python
AgeCommit message (Collapse)Author
2019-12-18python: fix "fatal" usage in fdthelperAdrian Herrera
"fatal" was not correctly imported in the fdthelper module, which caused a crash when reporting errors. Change-Id: I7ee9dcde1f0288e11e56dba67ead4aa2d6d67e02 Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23753 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-12-12python: Convert terminal escape sequences to strings.Gabe Black
In python 3, the curses escape sequences are bytes objects and not strings, making them unsuitable to concatenate to strings which are being print()-ed. This uses the decode() method to turn them from bytes objects into string objects, assuming they represent UTF-8. In python 2, bytes objects and strings are treated interchangeably, and so this isn't necessary. Change-Id: Ifc5d788e1c62751090a350d3a064e89f434559e8 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23265 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-11-27base, python: Allow dirname selection for the interpreterGiacomo Travaglini
This is the second step towards being able to run dynamically linked applications when the guest ISA != than host ISA. Once the guest interpreter is loaded to memory, we are able to redirect shared object loads through the redirectPath interface. How do we load the guest interpreter? The elf file is for example asking for the /lib/ld-linux-aarch64.so interpreter. That would point to a valid dynamic linker/loader if guest ISA == host ISA, but if we are running on X86 we should point to the guest (aarch64 in the example) toolchain wherever it is installed. This patch is adding the --interp-dir option to point to the parent folder of the guest /lib in the host fs. Change-Id: Id27b97c060008d2e847776a49323d45c8809a27f Signed-off-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/23066 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-11-20base,tests: Expanded GTests for addr_range.hhBrandon Potter
These tests assume the "end address" is not included in the range. This exposed some bugs in addr_range.hh which have been fixed. Where appropriate code comments in addr_range.hh have been extended to improve understanding of the class's behavior. Hard-coded AddrRange values in the project have been updated to take into account that end address is now exclusive. The python params.py interface has been updated to conform to this new standard. Change-Id: Idd1e75d5771d198c4b8142b28de0f3a6e9007a52 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/22427 Maintainer: Bobby R. Bruce <bbruce@ucdavis.edu> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-09-30misc: Added line wrapping functionality for Sim-Object descBobby R. Bruce
Descriptions were previously printed on one line, unless explicitly broken when writing the description of the Sim-Object. In this commit, line wrapping is enabled when printing these descriptions. Developers, when writing the Sim-Object descriptions, may now over multiple lines with triple double-quotes and still have the description output correctly when viewing the Sim-Objects within the CLI. E.g.: X86System previously had the following load_addr_mask component which was output as: load_addr_mask default: 18446744073709551615 desc: Address to mask loading binaries with, if 0, system \ auto-calculates the mask to be the most restrictive, otherwise it obeys a \ custom mask. This was defined by the developer via: load_addr_mask = Param.UInt64(0xffffffffffffffff, "Address to mask loading binaries with, if 0, system " "auto-calculates the mask to be the most restrictive, " "otherwise it obeys a custom mask.") This is now displayed as: load_addr_mask default: 18446744073709551615 desc: Address to mask loading binaries with, if 0, system auto-calculates the mask to be the most restrictive, otherwise it obeys a custom mask. JiraID: Gem5-57 Built: Linux (GCC) Tested: Ran quick tests for X86, ARM, and RISC-V Change-Id: If012304e50af60f6ba10c1fa2b44da8bac1c09cf Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21179 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
2019-09-26stats: Add a preDumpStats() callback to Stats::GroupAndreas Sandberg
Some objects need to know that we are about to dump stats to perform prepare statistics. This is currently done by registering a callback with the stat system. Expose this callback as a virtual method in Stats::Group to make this pattern more convenient. Change-Id: I5aa475b7d04c288e45f5f413ab7a1907b971dae5 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21139 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
2019-09-26stats: Don't output index in vectors of length 1Andreas Sandberg
New-world stats didn't implement the old gem5 quirk where the index of an element in a vector of size 1 is ignored. This affects the object path when printed in a stat file. Implement the same quirk as the original code to make sure names of old- and new-world stats are compatible. Change-Id: I12696d40baaed2d0bb1ef061e87c3b1d0f4bb4b1 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21163 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
2019-09-19python: Don't try to bind a stat group to the NULL simobject.Gabe Black
That is a SimObject like object which is used when a SimObject parameter is purposefully left empty, vs. being accidentally left empty through a typo or accidental ommission. It doesn't have a getCCObject method, and attempting to use it anyway causes gem5 to crash. Change-Id: Ie86321fbdbcc41cf88b7009184423acd7b64484b Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/21059 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-09-10stats: Ignore non-Group objects in stat hierarchyChun-Chen TK Hsu
Some objects, such as SystemC modules, are not a subclass of Stat::Group. Calling the addStatGroup function on them causes errors. This changes ignores those objects that are not Stat::Group in the stat hierarchy. Signed-off-by: Chun-Chen TK Hsu <chunchenhsu@google.com> Change-Id: I9b62419417b7af7331461fbfaf15e45a4ee2b35f Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20680 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Jason Lowe-Power <jason@lowepower.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-09-07python: Make the dot writer handle unconnected Port vector elements.Gabe Black
Change-Id: I5234013716cdcce5fc39e239dc3d92cd1f2b7799 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20699 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Gabe Black <gabeblack@google.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-09-02stats: Add support for listing available formatsAndreas Sandberg
Add a command line option to list available stat formats and their documentation. Change-Id: I7f5f2272d9b0176639f59f2efedb9cab2f7da5b9 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19670 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-08-29stats: Add beta support for HDF5 stat dumpsAndreas Sandberg
This changeset add support for stat dumps in the HDF5 file format. HDF5 is a binary data format that represents data in a file-system-like balanced tree. It has native support for N-dimensional arrays and binary data (e.g., frame buffers). It has the following benefits over traditional text stat files: * Efficient storage of time series (multiple stat dumps) * Fast lookup of stats * Plenty of existing tooling (e.g., Python libraries and graphical viewers) * File format can be used to store frame buffers together with normal stats. Drawbacks: * Large startup cost (single stat dump larger than text equivalent) * Stat dumps are slower than text Known limitations: * Distributions and histograms aren't supported. HDF5 stat output can be enabled using the 'h5' URL scheme when overriding the stat file name on gem5's command line. The following parameters are supported: * chunking (unsigned): Number of time steps to pre-allocate (default: 10) * desc (bool): Output stat descriptions (default: True) * formulas (bool): Output derived stats (default: True) Example gem5 command line: ./build/ARM/gem5.opt \ --stats-file="h5://stats.h5?desc=False;formulas=False" \ configs/example/fs.py Example Python stat consumer that computes IPC: import h5py f = h5py.File('stats.h5', 'r') group = f['/system/cpu'] for i, c in zip(group['committedInsts'], group['numCycles']): print i, c, i / c Change-Id: I351c6cbff2fb7bef9012f47876ba227ed288975b Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/8121 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Ciro Santilli <ciro.santilli@arm.com>
2019-08-29stats: Add support for partial stat dumpsAndreas Sandberg
Add support for partial stat dumps by passing an optional 'root' keyword argument to m5.stats.dump(). Specifying root slightly changes the semantics of the dump command. For legacy reasons, gem5 only allows one stat dump per tick. This is likely a limitation introduced as a hack to prevent automatic dumping at the end of simulation from interfering with explicit dumping from a simulation script. This restriction does not apply when specifying a root. However, these stat dumps will still prevent an additional stat dump in the same tick with an unspecified root. N.B.: This new API /only/ works for new-style stats that have an explicit hierarchy. Legacy stats will not be dumped if a root is specified. Change-Id: Idc8ff448b9f70a796427b4a5231e7371485130b4 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19369 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-08-29stats: Add support for hierarchical statsAndreas Sandberg
This change makes the stat system aware of the hierarchical nature of stats. The aim is to achieve the following goals: * Make the SimObject hierarchy explicit in the stat system (i.e., get rid of name() + ".foo"). This makes stat naming less fragile and makes it possible to implement hierarchical formats like XML/HDF5/JSON in a clean way. * Make it more convenient to split stats into a separate struct/class that can be bound to a SimObject. This makes the namespace cleaner and makes stat accesses a bit more obvious. * Make it possible to build groups of stats in C++ that can be used in subcomponents in a SimObject (similar to what we do for checkpoint sections). This makes it easier to structure large components. * Enable partial stat dumps. Some of our internal users have been asking for this since a full stat dump can be large. * Enable better stat access from Python. This changeset implements solves the first three points by introducing a class (Stats::Group) that owns statistics belonging to the same object. SimObjects inherit from Stats::Group since they typically have statistics. New-style statistics need to be associated with a parent group at instantiation time. Instantiation typically sets the name and the description, other parameters need to be set by overriding Group::regStats() just like with legacy stats. Simple objects with scalar stats can typically avoid implementing regStats() altogether since the stat name and description are both specified in the constructor. For convenience reasons, statistics groups can be merged into other groups. This means that a SimObject can create a stat struct that inherits from Stats::Group and merge it into the parent group (SimObject). This can make the code cleaner since statistics tracking gets grouped into a single object. Stat visitors have a new API to expose the group structure. The Output::beginGroup(name) method is called at the beginning of a group and the Output::endGroup() method is called when all stats, and sub-groups, have been visited. Flat formats (e.g., the text format) typically need to maintain a stack to track the full path to a stat. Legacy, flat, statistics are still supported after applying this change. These stats don't belong to any group and stat visitors will not see a Output::beginGroup(name) call before their corresponding Output::visit() methods are called. Change-Id: I9025d61dfadeabcc8ecf30813ab2060def455648 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19368 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
2019-08-12python: FdtState using interrupt-cellsGiacomo Travaglini
Change-Id: I37813748f518b442d2b53c2bc4f381edb2e26146 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/20050 Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-06-19python: Add support for exporting static class methods from c++Nikos Nikoleris
This change adds support for exporting static methods in a c++ SimObject from the coressponsing python wrapper class. This will allow us to define and use c++ methods without the need to instantiate an object of the corresponding class. Change-Id: Iaf24c1aa6f20feb5c91241f46ec8db005a6a0c0c Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19168 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
2019-06-18misc: dot_writer fixupTiago Muck
In large configs the tooltip may be greater then the maximum line size graphviz supports when parsing the dot file (typically 16k). Adding '/' causes graphviz to break the string in multiple lines while parsing and works around this limitation. Change-Id: I16a0030127de4165080de97f5213309eed9fdeca Signed-off-by: Tiago Mück <tiago.muck@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19208 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-06-17python: Fix AddrRange legacy ParamValue wrapperNikos Nikoleris
This change fixes a bug that would manifest if a user would instantiate an AddrRange ParamValue using the kwargs 'intlvBits' and 'intlvHighBit' without specifying the optional 'xorHighBit'. Change-Id: I2091c432234df9cf907d52af6ba7f0cadd8c37a8 Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19248 Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-06-10python: Fix cxx_ini_parse for ScopedEnumNikos Nikoleris
Change-Id: I69534bbbc16b2d24a65fa1dee4926f213c3618ef Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19152 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-06-10python: Add binding for the new AddrRange c++ constructorNikos Nikoleris
Change-Id: I5b3fb59a11d8587a753759310dd3b2748ac13a0b Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19132 Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-06-10base: Extend AddrRange to support more flexible addressingNikos Nikoleris
Previously an AddrRange could express interleaving using a number of consecutive bits and in additional optionally a second number of consecutive bits. The two sets of consecutive bits would be xored and matched against a value to determine if an address is in the AddrRange. For example: sel[0] = a[8] ^ a[12] sel[1] = a[9] ^ a[13] where sel == intlvMatch This change extends AddrRange to allow more flexible interleavings with an abritary number of set of bits which do not need be consecutive. For example: sel[0] = a[8] ^ a[11] ^ a[13] sel[1] = a[15] ^ a[17] ^ a[19] where sel == intlvMatch Change-Id: I42220a6d5011a31f0560535762a25bfc823c3ebb Signed-off-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/19130 Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br>
2019-05-20misc: Added dot_writer for Ruby's network topologyTiago Muck
Change-Id: Ic71ca7bc2eb4174d70afa368bc9cc987f3df89e9 Signed-off-by: Tiago Muck <tiago.muck@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17548 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-04-28mem: Minimize the use of MemObject.Gabe Black
MemObject doesn't provide anything beyond its base ClockedObject any more, so this change removes it from most inheritance hierarchies. Occasionally MemObject is replaced with SimObject when I was fairly confident that the extra functionality of ClockedObject wasn't needed. Change-Id: Ic014ab61e56402e62548e8c831eb16e26523fdce Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18289 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com> Maintainer: Gabe Black <gabeblack@google.com>
2019-04-27python: Get rid of the VectorPort constructor.Gabe Black
The only thing it was doing beyond calling the parent Port __init__ was to set isVec, and nobody actually looks at that value later. Change-Id: I567cb583e6f02a6c18504b9bb20dd13b3c934822 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18175 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
2019-04-27python: Replace the Master/Slave Ports with Request/Response ports.Gabe Black
These are a little more descriptive and a little less potentially offensive. Change-Id: I84c30f783f0a4c242cb4f54ab272b6fdf1e9eec7 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18174 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Anthony Gutierrez <anthony.gutierrez@amd.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com>
2019-04-24python: Generalize the Port.splice function.Gabe Black
Now that the MASTER and SLAVE roles aren't special, the splice function needs to be able to handle arbitrarily role-d peers. Change-Id: I22a28b7cdcb93f7f370730b7e38b0e6d3500a6a0 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18170 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
2019-04-24python: Generalize the dot_writer to handle non Master/Slave roles.Gabe Black
Change-Id: I6d93c28e754c0cacacdd5e8885c45bc861135e94 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18169 Maintainer: Gabe Black <gabeblack@google.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-04-24python: Make Port roles a more generic concept.Gabe Black
A recent change got rid of the strict Master => Slave port relationship which used to be checked in python and instead left the checking up to C++. One major downside to this approach is that it was no longer obvious in the configuration what was supposed to be connected to what, and it still left the arbitrary and misleading MasterPort and SlavePort types in the Ethernet devices which could now connect with each other symmetrically but couldn't actually connect to an arbitrary MasterPort/SlavePort. This change exposes the base Port and VectorPort types, and makes them accept a "role" parameter in __init__ which used to be set directly by their subclasses. This role can be any string, and will be used later to check for compatiblity and to give a hint as to what can be connected to what in the SimObject definitions. To make the checks work with arbitrary compatible pairs, the base Port type now has a class method called compat() which accepts a pair of roles which will become mutually compatible, ie any port with the first role will be allowed to connect to any port with the second role, and vice versa. To be self compatible, the same role should be passed in for both parameters. To maintain compatibility, the MasterPort and SlavePort types are retained, but now they're nothing special and could have been set up in any arbitrary SimObject .py file. The same is true for MasterVectorPort and SlaveVectorPort. Also, since we can no longer assume that all edges in the dot graph of the config should start with a port with the MASTER role and end with a port with the SLAVE role, Ports now track an is_source property which says whether the arrow head should be surpressed at that end of the edge representing the connection. Change-Id: Ifcc6faab05e437ad87cd21f0ba613b09cf21c321 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18168 Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Gabe Black <gabeblack@google.com>
2019-04-23python: fix tracing after Python 3 refactorCiro Santilli
gem5.opt --debug-flags ExecAll was failing with: ImportError: No module named defines on Python 2. Change-Id: I06959d6e0ccb7c661c7c749af3392632dac779f3 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/18108 Maintainer: Andreas Sandberg <andreas.sandberg@arm.com> Tested-by: kokoro <noreply+kokoro@google.com>
2019-03-26base,python: Fix to allow multiple --debug-ignore values.Isaac Sánchez Barrera
When adding multiple SimObjects to --debug-ignore, either separating the values with a colon or adding multiple --debug-ignore flags, the previous code only ignored the last SimObject in the list. This changeset adds and uses new `ObjectMatch::add` and `Logger::addIgnore` methods to make the functionality of the flag consistent with its description. Change-Id: Ib6967a48611ea59a211f81af2a970c4de429b1be Signed-off-by: Isaac Sánchez Barrera <isaac.sanchez@bsc.es> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17488 Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
2019-03-19arch, cpu, dev, gpu, mem, sim, python: start using getPort.Gabe Black
Replace the getMasterPort, getSlavePort, and getEthPort functions with getPort, and remove extraneous mechanisms that are no longer necessary. Change-Id: Iab7e3c02d2f3a0cf33e7e824e18c28646b5bc318 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17040 Reviewed-by: Daniel Carvalho <odanrc@yahoo.com.br> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
2019-03-19python: Switch to the new getPort mechanism to connect ports.Gabe Black
This retrieves ports using the getPort method, and connects them using the bind method on the ports themselves. Any smarts as far as what type of peers are allowed to connect or how they connect is left up to the individual bind methods. Change-Id: Ic640d1fce8af1bed411116e5830edc4a8a0f9d66 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17039 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
2019-03-19sim: Add a getPort function to SimObject.Gabe Black
This will retrieve a Port object from a given SimObject (which might not be a MemObject) no matter what flavor of Port it is. Change-Id: I636b85e9d4929a05a769e165849106bcb5f3e9c1 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17037 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
2019-03-18python: Change || to && for MessageBuffers in connectPorts.Gabe Black
The connectPorts function currently checks if *either* of the peers in a port connection are a MessageBuffer, and if so will ignore the connection. This CL changes that || into a && so that *both* of the peers need to be a Ruby types (either a MessageBuffer or Network) for the connection to be ignored. That makes it easier to contain that abnormal behavior to those types instead of having it apply even when other types of port owners are involved. Unfortunately the number of interesting Ruby types is unbounded, but these are the types with ports as of today. This mechanism will hopefully be replacedall together so this should be a temporary issue. Change-Id: I140498770e5d37eb2abd3d99261d47e111f1c8ab Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17031 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Jason Lowe-Power <jason@lowepower.com>
2019-03-18python: Improve how templated SimObject classes are handled.Gabe Black
When setting up a SimObject's Param structure, gem5 will autogenerate a header file which attempts to declare the SimObject's C++ type. It has had at least some level of sophistication there where it would pull off the namespaces ahead of the class name and handle them properly, but it didn't know how to handle templates. This change improves that handling in two ways. First, it adds a new magical SimObject attribute called 'cxx_template_params' which is used to specify what the template parameters are as a list. For instance, if your SimObject was a template which took an integer constant as its first parameter and a type as its second, this attribute could look like the following: cxx_template_params = [ 'int FOO', 'class Bar' ] Importantly, if there are any default values for these template parameters, they should *not* be included here, they should be specified where the class is later defined. The second new mechanism is to add an internal CxxClass in the SimObject.cxx_param_decl method. This class accepts the class signature in the cxx_class attribute and the cxx_template_params and does two things. First, it strips off namespaces like in the old implementation. Second, it extracts and processes any template arguments attached to the class. If these are constants (as determined by the contents of cxx_template_params), then they are stored verbatim. If they're types, then they're recursively expanded into a CxxClass and stored that way. Note that these are the *values* of the template arguments, where as cxx_template_params lists the *types* and *names* of those arguments. In our earlier example, if cxx_class was: cxx_class = 'CoolClasses::ClassName<12, Fruit::Apple>' Then CxxClass would extract the namespace 'CoolClasses', the class name 'ClassName', the argument '12', and the argument 'Fruit::Apple'. That second argument would be expanded into a CxxClass with the namespace 'Fruit' and the class name 'Apple'. Importantly here, because there were no default arguments given in cxx_template_params, all "hidden" arguments which would fall through to their defaults need to be fully specified in cxx_class. The CxxClass has a method called declare() which uses the information extracted earlier to output all of the "stuff" necessary for declaring the given class, including opening any containing namespaces and putting template<...> ahead of the actual class declaration with the template parameters specified. If any of the template arguments are themselves CxxClass instances, then they'll be recursively declared immediately before the current class is. An alternative solution to this problem might be to include the header file which actually defines the cxx_class type to avoid having to come up with a declaration. Unfortunately this doesn't work since it can set up include loops where the SimObject C++ header file includes the param header to get access to the Param type, but that includes the C++ header to get access to the SimObject type. This also makes it harder for SimObjects to refer to each other, since they rely on the declaration in the params header files when declaring a member pointer to that type in their own Param structures. Change-Id: I68cfc36ddff6d789eb4cdef5178c4619ac2cc8b1 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17228 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Gabe Black <gabeblack@google.com>
2019-03-15python: Simplify connectPorts() around EtherObject/EtherDevice.Gabe Black
EtherDevice now inherits EtherObject and shares the same getEthPort virtual function, so there's no need to treat them separately any more. Change-Id: Ia6c147fd97fece4a281c296521a7b095f793d32e Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17030 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
2019-03-14python: Teach cxxMethod how to set return_value_policy.Gabe Black
This is passed through to the underlying call to PyBindMethod. Change-Id: Ib46c55664ba0707464bb84e137a0fad817aea1bb Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17034 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
2019-03-14python: Teach PyBindMethod how to set return_value_policy.Gabe Black
Change-Id: Ia208e43672672556b36f905e8f71dce44b978d22 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17033 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
2019-03-14python: Fix unknown params and proxy multiplicationDaniel R. Carvalho
One of the recent changes made params not visible anymore: NameError: global name 'params' is not defined This is fixed by adding the proper import statement. However, the second error makes the multiplication values be assigned to other proxies (that are not even used on the multiplication). A workaround is added to prevent this from happening by extending "*=". Change-Id: I3ad276a456efff62058672d16caac2b3ad1b326b Signed-off-by: Daniel R. Carvalho <odanrc@yahoo.com.br> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/17048 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Maintainer: Andreas Sandberg <andreas.sandberg@arm.com>
2019-03-01python: Fix issue when Self proxy resolves to a another proxyAndreas Sandberg
The problem occurs when a proxy is being resolved to another proxy that hasn't been resolved yet. The problematic case that was triggering this issues in the VGIC. It was caused by parameters looking a bit like this: gic = Param.GicV2(Parent.any) some_param = Param.Int(Self.gic.some_param) When 'some_param' was resolved, it found the 'gic' parameter in Self. However, that parameter hadn't been resolved yet, so the existing code was setting the proxy evaluation context to the unresolved Parent.any proxy without first unproxying it. It seems like this bug depends on the graph traversal order and I have so far only seen it when compiling gem5 with Python 3. Change-Id: Iea12cc138765e70bfd6bb776b1efa012364db066 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/16004 Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
2019-02-26scons: Marshal Python sources using the same Python as gem5Andreas Sandberg
We currently use the Python version used by scons to marshal Python code. This doesn't work when building gem5 with Python 3 support since scons typically runs in Python 2.7. Add a custom marshal helper that links with the same library as gem5 to generate byte code that is guaranteed to work in gem5's Python interpreter. Change-Id: I665b0f2078726d4c055d74a3e668a580fc613b59 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/16422 Reviewed-by: Gabe Black <gabeblack@google.com>
2019-02-25systemc: Add m5.systemc and m5.tlm python modules.Gabe Black
These will be how systemc and tlm APIs which are not attached to SimObjects will be exposed. This avoids having to artificially attach them to wrapping SimObjects for instance, which is a bit awkward and non-obvious. The python code which attaches the systemc and tlm modules to the m5 modules lives in src/python/m5/__init__.py, but the modules themselves live in src/systemc/python to keep all the systemc code grouped together. It might be a little confusing to have a small part of the glue that adds those modules in a separate place (__init__.py), but that is, as far as I can tell, unavoidable, and it's better in my opinion to keep the systemc code grouped together than to put it alongside the other python code and __init__.py. Change-Id: Iecb218daec5e15772152b5ad22b51f43b86c3d4b Reviewed-on: https://gem5-review.googlesource.com/c/16563 Reviewed-by: Andreas Sandberg <andreas.sandberg@arm.com> Maintainer: Gabe Black <gabeblack@google.com>
2019-02-25python: Stop using basestring to test for stringsAndreas Sandberg
The base class basestring doesn't exist in Python 3. Use string_types from six instead. Change-Id: I7e84903fb7dd4a0af7ae4e9f4ec2e54338f212bb Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/15998 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Juha Jäykkä <juha.jaykka@arm.com>
2019-02-25python: Add Python 3 workarounds for longAndreas Sandberg
Python 3 doesn't have a separate long type. Make long an alias for int where needed to maintain compatibility. Change-Id: I4c0861302bc3a2fa5226b3041803ef975d29b2fd Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/15988 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>
2019-02-25python: Fix params/proxy import loopAndreas Sandberg
There is a circular dependency between params and proxy at import time. This causes issues for Python 3. Add the imports to the specific methods with the dependencies to make the import happen when the method is executed instead. Change-Id: I770112fd3c07c395459e204976942bda3dc7236f Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/15993 Reviewed-by: Giacomo Travaglini <giacomo.travaglini@arm.com> Reviewed-by: Juha Jäykkä <juha.jaykka@arm.com>
2019-02-23python: Enforce absolute imports for Python 3 compatibilityAndreas Sandberg
Change-Id: Ia88d7fd472f7aed9b97df81468211384981bf6c6 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/15983 Reviewed-by: Gabe Black <gabeblack@google.com> Maintainer: Gabe Black <gabeblack@google.com>
2019-02-22python: Add fallbacks for packages that have been renamedAndreas Sandberg
Python 3 has restructured some packages. Specifically, __builtin__ has been renamed to builtins and urlparse has been included in urllib. Change-Id: I81f8f3942471db1043006a36abbad6e5a49e0a43 Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/15994 Reviewed-by: Juha Jäykkä <juha.jaykka@arm.com>
2019-02-22python: Fix param -> int conversion issuesAndreas Sandberg
Python 3 doesn't convert params to integers automatically in range(). Add __index__ to CheckedInt to enable implicit conversions again. Add explicit conversions where necessary. Change-Id: I2de6c9906d3bb7616f12ada6728b9e4b1928511c Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/16000 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com> Maintainer: Jason Lowe-Power <jason@lowepower.com>
2019-02-22python: Make iterator handling Python 3 compatibleAndreas Sandberg
Many functions that used to return lists (e.g., dict.items()) now return iterators and their iterator counterparts (e.g., dict.iteritems()) have been removed. Switch calls to the Python 2.7 iterator methods to use the Python 3 equivalent and add explicit list conversions where necessary. Change-Id: I0c18114955af8f4932d81fb689a0adb939dafaba Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/15992 Reviewed-by: Juha Jäykkä <juha.jaykka@arm.com> Reviewed-by: Jason Lowe-Power <jason@lowepower.com>
2019-02-22python: Add missing operators to NumericParamValueAndreas Sandberg
Add missing operators to NumericParamValue and ensure that they are able to work on the underlying value if the right hand side is a param. Change-Id: I2bd86662aee9891bbd89aed7ebe20b827b5528bd Signed-off-by: Andreas Sandberg <andreas.sandberg@arm.com> Reviewed-on: https://gem5-review.googlesource.com/c/16001 Reviewed-by: Nikos Nikoleris <nikos.nikoleris@arm.com>