From 689f6d1b02f788ecd2a44ff4ca010acc38d14954 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 8 Mar 2005 22:07:26 -0500 Subject: [PATCH 1/7] Split the string importer from the rest of the mpy parsing and importing stuff to avoid some confusion. sim/pyconfig/SConscript: Split the string importer from the rest of the importer code. The importer.py code can be embedded like m5config.py sim/pyconfig/m5config.py: import what we need from importer --HG-- extra : convert_revision : 9d57f43381b55e717b5b10adfb8f0a522280ac57 --- sim/pyconfig/SConscript | 6 +++--- sim/pyconfig/m5config.py | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/sim/pyconfig/SConscript b/sim/pyconfig/SConscript index 9154d3b99..c8671b50f 100644 --- a/sim/pyconfig/SConscript +++ b/sim/pyconfig/SConscript @@ -170,7 +170,7 @@ EmbedMap %(name)s("%(fname)s", /* namespace */ } ''' -embedded_py_files = ['m5config.py', '../../util/pbs/jobfile.py'] +embedded_py_files = ['m5config.py', 'importer.py', '../../util/pbs/jobfile.py'] objpath = os.path.join(env['SRCDIR'], 'objects') for root, dirs, files in os.walk(objpath, topdown=True): for i,dir in enumerate(dirs): @@ -184,7 +184,7 @@ for root, dirs, files in os.walk(objpath, topdown=True): embedded_py_files.append(os.path.join(root, f)) embedfile_hh = os.path.join(env['SRCDIR'], 'base/embedfile.hh') -env.Depends('embedded_py.cc', embedfile_hh) env.Command('embedded_py.py', embedded_py_files, MakeEmbeddedPyFile) -env.Command('embedded_py.cc', ['importer.py', 'embedded_py.py'], +env.Depends('embedded_py.cc', embedfile_hh) +env.Command('embedded_py.cc', ['string_importer.py', 'embedded_py.py'], MakePythonCFile) diff --git a/sim/pyconfig/m5config.py b/sim/pyconfig/m5config.py index 7b1719dfa..f7bc90061 100644 --- a/sim/pyconfig/m5config.py +++ b/sim/pyconfig/m5config.py @@ -26,6 +26,9 @@ from __future__ import generators import os, re, sys, types, inspect + +from importer import AddToPath, LoadMpyFile + noDot = False try: import pydot From d191b14ff71f8b7af2098a29c2914d7332acd9be Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Tue, 8 Mar 2005 23:06:54 -0500 Subject: [PATCH 2/7] Pass all scons defined pre-processor macro variables to the python configuration stuff as environment variables. sim/pyconfig/SConscript: generate a python file that updates the env dict with all variables in the CPPDEFINES so the python code can use those variables in configuration scripts. --HG-- extra : convert_revision : 50b0719b044f7adc87ce6ae1571d156ca0c5644c --- sim/pyconfig/SConscript | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/sim/pyconfig/SConscript b/sim/pyconfig/SConscript index c8671b50f..95785d372 100644 --- a/sim/pyconfig/SConscript +++ b/sim/pyconfig/SConscript @@ -144,6 +144,28 @@ def MakeEmbeddedPyFile(target, source, env): for pyfile, path, name, ext, filename in files: WriteEmbeddedPyFile(target, pyfile, path, name, ext, filename) +def MakeDefinesPyFile(target, source, env): + target = file(str(target[0]), 'w') + + defines = env['CPPDEFINES'] + if isinstance(defines, list): + for var in defines: + if isinstance(var, tuple): + key,val = var + else: + key,val = var,'True' + + if not isinstance(key, basestring): + panic("invalid type for define: %s" % type(key)) + + print >>target, "env['%s'] = '%s'" % (key, val) + + elif isinstance(defines, dict): + for key,val in defines.iteritems(): + print >>target, "env['%s'] = '%s'" % (key, val) + else: + panic("invalid type for defines: %s" % type(defines)) + CFileCounter = 0 def MakePythonCFile(target, source, env): global CFileCounter @@ -184,7 +206,9 @@ for root, dirs, files in os.walk(objpath, topdown=True): embedded_py_files.append(os.path.join(root, f)) embedfile_hh = os.path.join(env['SRCDIR'], 'base/embedfile.hh') +env.Command('defines.py', None, MakeDefinesPyFile) env.Command('embedded_py.py', embedded_py_files, MakeEmbeddedPyFile) env.Depends('embedded_py.cc', embedfile_hh) -env.Command('embedded_py.cc', ['string_importer.py', 'embedded_py.py'], +env.Command('embedded_py.cc', + ['string_importer.py', 'defines.py', 'embedded_py.py'], MakePythonCFile) From 4b69debac6ce72fe46a8d8b5284c740e338f06f6 Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Wed, 9 Mar 2005 00:17:09 -0500 Subject: [PATCH 3/7] Fix a couple of bugs introduced (or tickled) by the .ini sorting change. sim/pyconfig/m5config.py: Don't sort child nodes, as this can change timing in memory system. (Really ought to be fixed in memory system, but we'll just take the sort back out for now to avoid intoducing gratuitous changes.) --HG-- extra : convert_revision : 07e950c25911443cbc7a84435969ca596fb04348 --- sim/pyconfig/m5config.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/sim/pyconfig/m5config.py b/sim/pyconfig/m5config.py index 17a0d8f42..330d7e878 100644 --- a/sim/pyconfig/m5config.py +++ b/sim/pyconfig/m5config.py @@ -697,8 +697,12 @@ class Node(object): if self.children: # instantiate children in same order they were added for # backward compatibility (else we can end up with cpu1 - # before cpu0). - self.children.sort(lambda x,y: cmp(x.name, y.name)) + # before cpu0). Changing ordering can also influence timing + # in the current memory system, as caches get added to a bus + # in different orders which affects their priority in the + # case of simulataneous requests. We should uncomment the + # following line once we take care of that issue. + # self.children.sort(lambda x,y: cmp(x.name, y.name)) children = [ c.name for c in self.children if not c.paramcontext] print 'children =', ' '.join(children) From de540a4aeebb512d663daa1342593ddc3cf76e3b Mon Sep 17 00:00:00 2001 From: Steve Reinhardt Date: Wed, 9 Mar 2005 00:22:42 -0500 Subject: [PATCH 4/7] Fix tracediff to work with new parameter and output directory structure. util/tracediff: Fix to work with new parameter and output directory structure. --HG-- extra : convert_revision : 421ed14fa02df7c9e95eb93f4d36b9ff046f1e39 --- util/tracediff | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/util/tracediff b/util/tracediff index 402abbe55..87210f1ed 100755 --- a/util/tracediff +++ b/util/tracediff @@ -51,12 +51,15 @@ $sim2 = shift; # be given to both invocations $simargs = '"' . join('" "', @ARGV) . '"'; -# Redirect config output to cout so that gets diffed too (in case -# that's the source of the problem). -$simargs .= " --root:config_output_file=cout"; +# Run individual invocations in separate dirs so output and intermediate +# files (particularly config.py and config.ini) don't conflict. +$dir1 = "tracediff-$$-1"; +$dir2 = "tracediff-$$-2"; +mkdir($dir1) or die "Can't create dir $dir1\n"; +mkdir($dir2) or die "Can't create dir $dir2\n"; -$cmd1 = "$sim1 $simargs --stats:text_file=tracediff-$$-1.stats 2>&1 |"; -$cmd2 = "$sim2 $simargs --stats:text_file=tracediff-$$-2.stats 2>&1 |"; +$cmd1 = "$sim1 $simargs -d $dir1 2>&1 |"; +$cmd2 = "$sim2 $simargs -d $dir2 2>&1 |"; # This only works if you have rundiff in your path. I just edit it # with an explicit path if necessary. From 21946f071026d3b3c4122ef41d755f883e22e668 Mon Sep 17 00:00:00 2001 From: Lisa Hsu Date: Wed, 9 Mar 2005 11:04:19 -0500 Subject: [PATCH 5/7] fix typo in the fixed etherlink serialization. dev/etherlink.cc: fix type in serialization. --HG-- extra : convert_revision : 87f47db14b90f414fef9a0db869da4d7ef72216a --- dev/etherlink.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dev/etherlink.cc b/dev/etherlink.cc index 94293815d..81cdbc20f 100644 --- a/dev/etherlink.cc +++ b/dev/etherlink.cc @@ -178,7 +178,7 @@ EtherLink::Link::serialize(const string &base, ostream &os) packet->serialize(base + ".packet", os); bool event_scheduled = doneEvent.scheduled(); - paramOut(os, base + ".event_scheuled", event_scheduled); + paramOut(os, base + ".event_scheduled", event_scheduled); if (event_scheduled) { Tick event_time = doneEvent.when(); paramOut(os, base + ".event_time", event_time); From 4a3ad218e1a41a9fa655471b999e2540e4e78448 Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 9 Mar 2005 14:39:35 -0500 Subject: [PATCH 6/7] We should import m5config *after* we do the CPPDEFINES stuff, otherwise m5config and the object descriptions cannot take advantage of them. sim/pyconfig/SConscript: We should import m5config *after* we do the CPPDEFINES stuff, otherwise m5config and the object descriptions cannot take advantage of them. This means that we can't use the env dict alias. We should instead use os.environ. --HG-- extra : convert_revision : 392f99a3c15cfba74a5cde79a709ecfad3820e63 --- sim/pyconfig/SConscript | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sim/pyconfig/SConscript b/sim/pyconfig/SConscript index 95785d372..2799ef64f 100644 --- a/sim/pyconfig/SConscript +++ b/sim/pyconfig/SConscript @@ -147,6 +147,7 @@ def MakeEmbeddedPyFile(target, source, env): def MakeDefinesPyFile(target, source, env): target = file(str(target[0]), 'w') + print >>target, "import os" defines = env['CPPDEFINES'] if isinstance(defines, list): for var in defines: @@ -158,11 +159,11 @@ def MakeDefinesPyFile(target, source, env): if not isinstance(key, basestring): panic("invalid type for define: %s" % type(key)) - print >>target, "env['%s'] = '%s'" % (key, val) + print >>target, "os.environ['%s'] = '%s'" % (key, val) elif isinstance(defines, dict): for key,val in defines.iteritems(): - print >>target, "env['%s'] = '%s'" % (key, val) + print >>target, "os.environ['%s'] = '%s'" % (key, val) else: panic("invalid type for defines: %s" % type(defines)) From 7d91bda6bfba1bd0cf49ff7ff20373b5d44df87a Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Wed, 9 Mar 2005 14:42:30 -0500 Subject: [PATCH 7/7] Add support for using the variables that m5 was compiled with for determining which parameters belong to a class. This allows us to remove the disable flag since it is not the correct model for variable checking anyway. objects/BaseCPU.mpy: Use the FULL_SYSTEM environment variable to enable or disable parameters. sim/pyconfig/m5config.py: remove the disable flag since it is not the correct model for variable checking. --HG-- extra : convert_revision : a8ccb78ba16d23006225df282a09187d32557608 --- objects/BaseCPU.mpy | 28 +++++++--------------------- sim/pyconfig/m5config.py | 35 ++++++----------------------------- 2 files changed, 13 insertions(+), 50 deletions(-) diff --git a/objects/BaseCPU.mpy b/objects/BaseCPU.mpy index f6e6ff96c..484fcccd6 100644 --- a/objects/BaseCPU.mpy +++ b/objects/BaseCPU.mpy @@ -4,11 +4,13 @@ simobj BaseCPU(SimObject): icache = Param.BaseMem(NULL, "L1 instruction cache object") dcache = Param.BaseMem(NULL, "L1 data cache object") - dtb = Param.AlphaDTB("Data TLB") - itb = Param.AlphaITB("Instruction TLB") - mem = Param.FunctionalMemory("memory") - system = Param.BaseSystem(Super, "system object") - workload = VectorParam.Process("processes to run") + if Bool._convert(env.get('FULL_SYSTEM', 'False')): + dtb = Param.AlphaDTB("Data TLB") + itb = Param.AlphaITB("Instruction TLB") + mem = Param.FunctionalMemory("memory") + system = Param.BaseSystem(Super, "system object") + else: + workload = VectorParam.Process("processes to run") max_insts_all_threads = Param.Counter(0, "terminate when all threads have reached this inst count") @@ -21,19 +23,3 @@ simobj BaseCPU(SimObject): defer_registration = Param.Bool(False, "defer registration with system (for sampling)") - - def check(self): - has_workload = self._hasvalue('workload') - has_dtb = self._hasvalue('dtb') - has_itb = self._hasvalue('itb') - has_mem = self._hasvalue('mem') - has_system = self._hasvalue('system') - - if has_workload: - self.dtb.disable = True - self.itb.disable = True - self.mem.disable = True - self.system.disable = True - - if has_dtb or has_itb or has_mem or has_system: - self.workload.disable = True diff --git a/sim/pyconfig/m5config.py b/sim/pyconfig/m5config.py index b5617c8ae..e6201b3ad 100644 --- a/sim/pyconfig/m5config.py +++ b/sim/pyconfig/m5config.py @@ -246,7 +246,6 @@ class MetaConfigNode(type): cls._params = {} cls._values = {} cls._enums = {} - cls._disable = {} cls._bases = [c for c in cls.__mro__ if isConfigNode(c)] cls._anon_subclass_counter = 0 @@ -382,15 +381,6 @@ class MetaConfigNode(type): def _setvalue(cls, name, value): cls._values[name] = value - def _getdisable(cls, name): - for c in cls._bases: - if c._disable.has_key(name): - return c._disable[name] - return False - - def _setdisable(cls, name, value): - cls._disable[name] = value - def __getattr__(cls, attr): if cls._isvalue(attr): return Value(cls, attr) @@ -465,9 +455,6 @@ class MetaConfigNode(type): cls.check() for key,value in cls._getvalues().iteritems(): - if cls._getdisable(key): - continue - if isConfigNode(value): cls.add_child(instance, key, value) if issequence(value): @@ -477,15 +464,11 @@ class MetaConfigNode(type): for pname,param in cls._getparams().iteritems(): try: - if cls._getdisable(pname): - continue - - try: - value = cls._getvalue(pname) - except: - print 'Error getting %s' % pname - raise + value = cls._getvalue(pname) + except: + panic('Error getting %s' % pname) + try: if isConfigNode(value): value = instance.child_objects[value] elif issequence(value): @@ -814,16 +797,10 @@ class Value(object): return self.obj._getvalue(self.attr) def __setattr__(self, attr, value): - if attr == 'disable': - self.obj._setdisable(self.attr, value) - else: - setattr(self._getattr(), attr, value) + setattr(self._getattr(), attr, value) def __getattr__(self, attr): - if attr == 'disable': - return self.obj._getdisable(self.attr) - else: - return getattr(self._getattr(), attr) + return getattr(self._getattr(), attr) def __getitem__(self, index): return self._getattr().__getitem__(index)