diff options
author | Andreas Sandberg <Andreas.Sandberg@arm.com> | 2012-11-02 11:32:01 -0500 |
---|---|---|
committer | Andreas Sandberg <Andreas.Sandberg@arm.com> | 2012-11-02 11:32:01 -0500 |
commit | c0ab52799ca4ebd0a51363cfedd0658e6d79b842 (patch) | |
tree | afdf65e4593c64bbc1d5b511aacbaf0fa4b558ad /src/mem/ruby/network | |
parent | 044a6525876efc61838dffa89ac52425d510b754 (diff) | |
download | gem5-c0ab52799ca4ebd0a51363cfedd0658e6d79b842.tar.xz |
sim: Include object header files in SWIG interfaces
When casting objects in the generated SWIG interfaces, SWIG uses
classical C-style casts ( (Foo *)bar; ). In some cases, this can
degenerate into the equivalent of a reinterpret_cast (mainly if only a
forward declaration of the type is available). This usually works for
most compilers, but it is known to break if multiple inheritance is
used anywhere in the object hierarchy.
This patch introduces the cxx_header attribute to Python SimObject
definitions, which should be used to specify a header to include in
the SWIG interface. The header should include the declaration of the
wrapped object. We currently don't enforce header the use of the
header attribute, but a warning will be generated for objects that do
not use it.
Diffstat (limited to 'src/mem/ruby/network')
13 files changed, 22 insertions, 0 deletions
diff --git a/src/mem/ruby/network/BasicLink.py b/src/mem/ruby/network/BasicLink.py index f73f5d977..841208578 100644 --- a/src/mem/ruby/network/BasicLink.py +++ b/src/mem/ruby/network/BasicLink.py @@ -32,6 +32,7 @@ from m5.SimObject import SimObject class BasicLink(SimObject): type = 'BasicLink' + cxx_header = "mem/ruby/network/BasicLink.hh" link_id = Param.Int("ID in relation to other links") latency = Param.Int(1, "latency") # The following banwidth factor does not translate to the same value for @@ -43,12 +44,14 @@ class BasicLink(SimObject): class BasicExtLink(BasicLink): type = 'BasicExtLink' + cxx_header = "mem/ruby/network/BasicLink.hh" ext_node = Param.RubyController("External node") int_node = Param.BasicRouter("ID of internal node") bandwidth_factor = 16 class BasicIntLink(BasicLink): type = 'BasicIntLink' + cxx_header = "mem/ruby/network/BasicLink.hh" node_a = Param.BasicRouter("Router on one end") node_b = Param.BasicRouter("Router on other end") bandwidth_factor = 16 diff --git a/src/mem/ruby/network/BasicRouter.py b/src/mem/ruby/network/BasicRouter.py index 0ff41c33c..0c8e5cb54 100644 --- a/src/mem/ruby/network/BasicRouter.py +++ b/src/mem/ruby/network/BasicRouter.py @@ -32,4 +32,5 @@ from m5.SimObject import SimObject class BasicRouter(SimObject): type = 'BasicRouter' + cxx_header = "mem/ruby/network/BasicRouter.hh" router_id = Param.Int("ID in relation to other routers") diff --git a/src/mem/ruby/network/Network.py b/src/mem/ruby/network/Network.py index 9642b046e..4bc35b30c 100644 --- a/src/mem/ruby/network/Network.py +++ b/src/mem/ruby/network/Network.py @@ -33,6 +33,7 @@ from BasicLink import BasicLink class Topology(SimObject): type = 'Topology' + cxx_header = "mem/ruby/network/Topology.hh" description = Param.String("Not Specified", "the name of the imported topology module") ext_links = VectorParam.BasicExtLink("Links to external nodes") @@ -44,6 +45,7 @@ class Topology(SimObject): class RubyNetwork(SimObject): type = 'RubyNetwork' cxx_class = 'Network' + cxx_header = "mem/ruby/network/Network.hh" abstract = True number_of_virtual_networks = Param.Int(10, ""); topology = Param.Topology(""); diff --git a/src/mem/ruby/network/fault_model/FaultModel.py b/src/mem/ruby/network/fault_model/FaultModel.py index 5117491f2..b1532150b 100644 --- a/src/mem/ruby/network/fault_model/FaultModel.py +++ b/src/mem/ruby/network/fault_model/FaultModel.py @@ -39,6 +39,7 @@ from m5.SimObject import SimObject class FaultModel(SimObject): type = 'FaultModel' cxx_class = 'FaultModel' + cxx_header = "mem/ruby/network/fault_model/FaultModel.hh" baseline_fault_vector_database = VectorParam.Float([ 5, 40, 0.080892, 0.109175, 0.018864, 0.130408, 0.059724, 0.077571, 0.034830, 0.083430, 0.067500, 0.121500, diff --git a/src/mem/ruby/network/garnet/BaseGarnetNetwork.py b/src/mem/ruby/network/garnet/BaseGarnetNetwork.py index 2431db203..0bcb0484d 100644 --- a/src/mem/ruby/network/garnet/BaseGarnetNetwork.py +++ b/src/mem/ruby/network/garnet/BaseGarnetNetwork.py @@ -33,6 +33,7 @@ from Network import RubyNetwork class BaseGarnetNetwork(RubyNetwork): type = 'BaseGarnetNetwork' + cxx_header = "mem/ruby/network/garnet/BaseGarnetNetwork.hh" abstract = True ni_flit_size = Param.Int(16, "network interface flit size in bytes") vcs_per_vnet = Param.Int(4, "virtual channels per virtual network"); diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetLink_d.py b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetLink_d.py index 1fb7e0b7b..e5de4ecaf 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetLink_d.py +++ b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetLink_d.py @@ -35,6 +35,7 @@ from BasicLink import BasicIntLink, BasicExtLink class NetworkLink_d(SimObject): type = 'NetworkLink_d' + cxx_header = "mem/ruby/network/garnet/fixed-pipeline/NetworkLink_d.hh" link_id = Param.Int(Parent.link_id, "link id") link_latency = Param.Int(Parent.latency, "link latency") vcs_per_vnet = Param.Int(Parent.vcs_per_vnet, @@ -46,10 +47,12 @@ class NetworkLink_d(SimObject): class CreditLink_d(NetworkLink_d): type = 'CreditLink_d' + cxx_header = "mem/ruby/network/garnet/fixed-pipeline/CreditLink_d.hh" # Interior fixed pipeline links between routers class GarnetIntLink_d(BasicIntLink): type = 'GarnetIntLink_d' + cxx_header = "mem/ruby/network/garnet/fixed-pipeline/GarnetLink_d.hh" # The detailed fixed pipeline bi-directional link include two main # forward links and two backward flow-control links, one per direction nls = [] @@ -69,6 +72,7 @@ class GarnetIntLink_d(BasicIntLink): # Exterior fixed pipeline links between a router and a controller class GarnetExtLink_d(BasicExtLink): type = 'GarnetExtLink_d' + cxx_header = "mem/ruby/network/garnet/fixed-pipeline/GarnetLink_d.hh" # The detailed fixed pipeline bi-directional link include two main # forward links and two backward flow-control links, one per direction nls = [] diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.py b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.py index a3a00525d..6ebf94e04 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.py +++ b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.py @@ -33,5 +33,6 @@ from BaseGarnetNetwork import BaseGarnetNetwork class GarnetNetwork_d(BaseGarnetNetwork): type = 'GarnetNetwork_d' + cxx_header = "mem/ruby/network/garnet/fixed-pipeline/GarnetNetwork_d.hh" buffers_per_data_vc = Param.Int(4, "buffers per data virtual channel"); buffers_per_ctrl_vc = Param.Int(1, "buffers per ctrl virtual channel"); diff --git a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetRouter_d.py b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetRouter_d.py index b2a01fb46..cd009a807 100644 --- a/src/mem/ruby/network/garnet/fixed-pipeline/GarnetRouter_d.py +++ b/src/mem/ruby/network/garnet/fixed-pipeline/GarnetRouter_d.py @@ -35,6 +35,7 @@ from BasicRouter import BasicRouter class GarnetRouter_d(BasicRouter): type = 'GarnetRouter_d' cxx_class = 'Router_d' + cxx_header = "mem/ruby/network/garnet/fixed-pipeline/Router_d.hh" vcs_per_vnet = Param.Int(Parent.vcs_per_vnet, "virtual channels per virtual network") virt_nets = Param.Int(Parent.number_of_virtual_networks, diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetLink.py b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetLink.py index 591ab4beb..d5b55c1ec 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetLink.py +++ b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetLink.py @@ -35,6 +35,7 @@ from BasicLink import BasicIntLink, BasicExtLink class NetworkLink(SimObject): type = 'NetworkLink' + cxx_header = "mem/ruby/network/garnet/flexible-pipeline/NetworkLink.hh" link_id = Param.Int(Parent.link_id, "link id") link_latency = Param.Int(Parent.latency, "link latency") vcs_per_vnet = Param.Int(Parent.vcs_per_vnet, @@ -47,6 +48,7 @@ class NetworkLink(SimObject): # Interior fixed pipeline links between routers class GarnetIntLink(BasicIntLink): type = 'GarnetIntLink' + cxx_header = "mem/ruby/network/garnet/flexible-pipeline/GarnetLink.hh" # The flexible pipeline bi-directional link only include two main # forward links and no backward flow-control links nls = [] @@ -59,6 +61,7 @@ class GarnetIntLink(BasicIntLink): # Exterior fixed pipeline links between a router and a controller class GarnetExtLink(BasicExtLink): type = 'GarnetExtLink' + cxx_header = "mem/ruby/network/garnet/flexible-pipeline/GarnetLink.hh" # The flexible pipeline bi-directional link only include two main # forward links and no backward flow-control links nls = [] diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.py b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.py index 7ad61a5ce..28f81d732 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.py +++ b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.py @@ -33,6 +33,7 @@ from BaseGarnetNetwork import BaseGarnetNetwork class GarnetNetwork(BaseGarnetNetwork): type = 'GarnetNetwork' + cxx_header = "mem/ruby/network/garnet/flexible-pipeline/GarnetNetwork.hh" buffer_size = Param.Int(0, "default buffer size; 0 indicates infinite buffering"); number_of_pipe_stages = Param.Int(4, "router pipeline stages"); diff --git a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetRouter.py b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetRouter.py index a39348c46..22d8c8670 100644 --- a/src/mem/ruby/network/garnet/flexible-pipeline/GarnetRouter.py +++ b/src/mem/ruby/network/garnet/flexible-pipeline/GarnetRouter.py @@ -35,6 +35,7 @@ from BasicRouter import BasicRouter class GarnetRouter(BasicRouter): type = 'GarnetRouter' cxx_class = 'Router' + cxx_header = "mem/ruby/network/garnet/flexible-pipeline/Router.hh" vcs_per_vnet = Param.Int(Parent.vcs_per_vnet, "virtual channels per virtual network") virt_nets = Param.Int(Parent.number_of_virtual_networks, diff --git a/src/mem/ruby/network/simple/SimpleLink.py b/src/mem/ruby/network/simple/SimpleLink.py index 55b21562e..716a21eec 100644 --- a/src/mem/ruby/network/simple/SimpleLink.py +++ b/src/mem/ruby/network/simple/SimpleLink.py @@ -34,6 +34,8 @@ from BasicLink import BasicIntLink, BasicExtLink class SimpleExtLink(BasicExtLink): type = 'SimpleExtLink' + cxx_header = "mem/ruby/network/simple/SimpleLink.hh" class SimpleIntLink(BasicIntLink): type = 'SimpleIntLink' + cxx_header = "mem/ruby/network/simple/SimpleLink.hh" diff --git a/src/mem/ruby/network/simple/SimpleNetwork.py b/src/mem/ruby/network/simple/SimpleNetwork.py index 0603546ce..217dc20ec 100644 --- a/src/mem/ruby/network/simple/SimpleNetwork.py +++ b/src/mem/ruby/network/simple/SimpleNetwork.py @@ -34,6 +34,7 @@ from BasicRouter import BasicRouter class SimpleNetwork(RubyNetwork): type = 'SimpleNetwork' + cxx_header = "mem/ruby/network/simple/SimpleNetwork.hh" buffer_size = Param.Int(0, "default buffer size; 0 indicates infinite buffering"); endpoint_bandwidth = Param.Int(1000, "bandwidth adjustment factor"); |