> On Oct. 7, 2016, 7:15 a.m., Jason Lowe-Power wrote:
> > configs/ruby/Ruby.py, line 50
> > <http://reviews.gem5.org/r/3647/diff/1/?file=58365#file58365line50>
> >
> > I think I'm missing something, but isn't the network directory and the
> > topologies directory both in configs/? Why are these addToPath calls
> > different?
>
> Andreas Hansson wrote:
> Excellent question. I think the topology line is acually both wrong and
> unnecessary.
>
> I really must confess the current behaviuor of addToPath is a bit of a
> mystery (what is it really relative to), and it turns out it is relative to
> the run.py script in the test folder.
>
> Jason Lowe-Power wrote:
> Thanks for the info. I agree about addToPath :).
>
> Tony Gutierrez wrote:
> You're right, according to the comment near the definition of addToPath()
> it seems things are relative to whichever run script you're using.
> Unfortunately the relative path of configs is not the same for all run
> scripts. E.g., using apu_se.py by hand still doesn't work, even with this
> patch, and I have to manually add the paths back to apu_se.py for things to
> work.
>
> Andreas Hansson wrote:
> Any suggestions for how to solve it?
>
> Can this patch go in as is? If not, what should I add to it?
>
> Tony Gutierrez wrote:
> I would suggest we make addToPath() behave more intuitively by having it
> use the callers path, as opposed to whichever script initiated the python
> interpreter - in our case the run scripts. This way the configs can truly use
> paths relative to their own, which is not only more intuitive, but solves the
> problem of the configs essentially needing to know the path relative to the
> run scripts, which as previously pointed out may vary. The following worked
> for apu_se.py paths:
>
> diff --git a/configs/ruby/Ruby.py b/configs/ruby/Ruby.py
> --- a/configs/ruby/Ruby.py
> +++ b/configs/ruby/Ruby.py
> @@ -46,8 +46,8 @@
> from m5.util import addToPath, fatal
>
> import MemConfig
> -addToPath('../configs/topologies')
> -addToPath('../configs/network')
> +addToPath('../topologies')
> +addToPath('../network')
>
> import Network
>
> diff --git a/src/python/m5/util/__init__.py
> b/src/python/m5/util/__init__.py
> --- a/src/python/m5/util/__init__.py
> +++ b/src/python/m5/util/__init__.py
> @@ -81,8 +81,10 @@
>
> # if it's a relative path and we know what directory the current
> # python script is in, make the path relative to that directory.
> - if not os.path.isabs(path) and sys.path[0]:
> - path = os.path.join(sys.path[0], path)
> + frame = sys._current_frames().values()[0]
> + caller_path = os.path.dirname(frame.f_back.f_globals['__file__'])
> + if not os.path.isabs(path) and caller_path:
> + path = os.path.join(caller_path, path)
> path = os.path.realpath(path)
> # sys.path[0] should always refer to the current script's directory,
> # so place the new dir right after that.
>
> Then you'd need to go for all callers of addToPath() to specify paths
> relative to their own, and not run.py.
Sorry, the diff in the above got messed up somehow. Should be:
diff --git a/configs/ruby/Ruby.py b/configs/ruby/Ruby.py
--- a/configs/ruby/Ruby.py
+++ b/configs/ruby/Ruby.py
@@ -46,8 +46,8 @@
from m5.util import addToPath, fatal
import MemConfig
-addToPath('../configs/topologies')
-addToPath('../configs/network')
+addToPath('../topologies')
+addToPath('../network')
import Network
diff --git a/src/python/m5/util/__init__.py b/src/python/m5/util/__init__.py
--- a/src/python/m5/util/__init__.py
+++ b/src/python/m5/util/__init__.py
@@ -81,8 +81,10 @@
# if it's a relative path and we know what directory the current
# python script is in, make the path relative to that directory.
- if not os.path.isabs(path) and sys.path[0]:
- path = os.path.join(sys.path[0], path)
+ frame = sys._current_frames().values()[0]
+ caller_path = os.path.dirname(frame.f_back.f_globals['__file__'])
+ if not os.path.isabs(path) and caller_path:
+ path = os.path.join(caller_path, path)
path = os.path.realpath(path)
# sys.path[0] should always refer to the current script's directory,
# so place the new dir right after that.
- Tony
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
http://reviews.gem5.org/r/3647/#review8780
-----------------------------------------------------------
On Oct. 7, 2016, 10:29 a.m., Andreas Hansson wrote:
>
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> http://reviews.gem5.org/r/3647/
> -----------------------------------------------------------
>
> (Updated Oct. 7, 2016, 10:29 a.m.)
>
>
> Review request for Default.
>
>
> Repository: gem5
>
>
> Description
> -------
>
> Changeset 11668:8816ebf0a103
> ---------------------------
> ruby: Fix broken regressions
>
> This patch moves the addition of network options into the Ruby module
> to avoid the regressions all having to add it explicitly. The example
> scripts are also updated, and the messy path-deducing variations in
> the scripts are unified.
>
>
> Diffs
> -----
>
> tests/configs/gpu-randomtest-ruby.py ebf2acd02fc5
> tests/configs/gpu-ruby.py ebf2acd02fc5
> tests/configs/memtest-ruby.py ebf2acd02fc5
> tests/configs/o3-timing-mp-ruby.py ebf2acd02fc5
> tests/configs/o3-timing-ruby.py ebf2acd02fc5
> tests/configs/pc-simple-timing-ruby.py ebf2acd02fc5
> tests/configs/rubytest-ruby.py ebf2acd02fc5
> tests/configs/simple-atomic-mp-ruby.py ebf2acd02fc5
> tests/configs/simple-timing-mp-ruby.py ebf2acd02fc5
> tests/configs/simple-timing-ruby.py ebf2acd02fc5
> configs/example/apu_se.py ebf2acd02fc5
> configs/example/fs.py ebf2acd02fc5
> configs/example/garnet_synth_traffic.py ebf2acd02fc5
> configs/example/ruby_direct_test.py ebf2acd02fc5
> configs/example/ruby_gpu_random_test.py ebf2acd02fc5
> configs/example/ruby_mem_test.py ebf2acd02fc5
> configs/example/ruby_random_test.py ebf2acd02fc5
> configs/example/se.py ebf2acd02fc5
> configs/ruby/Ruby.py ebf2acd02fc5
>
> Diff: http://reviews.gem5.org/r/3647/diff/
>
>
> Testing
> -------
>
>
> Thanks,
>
> Andreas Hansson
>
>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev