changeset e76348cb11de in /z/repo/m5
details: http://repo.m5sim.org/m5?cmd=changeset;node=e76348cb11de
description:
ruby: configuration supports multiple runs in same session
These changes allow to run Ruby-gems multiple times from the same
ruby-lang script with different configurations
diffstat:
6 files changed, 52 insertions(+), 30 deletions(-)
src/mem/ruby/config/MI_example-homogeneous.rb | 14 +++++-----
src/mem/ruby/config/MI_example.rb | 4 ++
src/mem/ruby/config/MOESI_CMP_directory.rb | 11 --------
src/mem/ruby/config/TwoLevel_SplitL1UnifiedL2.rb | 30 +++++++++++-----------
src/mem/ruby/config/cfg.rb | 13 +++++++++
src/mem/ruby/config/util.rb | 10 +++++++
diffs (206 lines):
diff -r e983bc0f31a0 -r e76348cb11de
src/mem/ruby/config/MI_example-homogeneous.rb
--- a/src/mem/ruby/config/MI_example-homogeneous.rb Wed Aug 05 14:17:23
2009 -0500
+++ b/src/mem/ruby/config/MI_example-homogeneous.rb Wed Aug 05 14:20:32
2009 -0500
@@ -8,15 +8,17 @@
require "cfg.rb"
+RubySystem.reset
+
# default values
num_cores = 2
-L1_CACHE_SIZE_KB = 32
-L1_CACHE_ASSOC = 8
-L1_CACHE_LATENCY = 1
+l1_cache_size_kb = 32
+l1_cache_assoc = 8
+l1_cache_latency = 1
num_memories = 2
memory_size_mb = 1024
-NUM_DMA = 1
+num_dma = 1
protocol = "MI_example"
# check for overrides
@@ -46,7 +48,7 @@
require protocol+".rb"
num_cores.times { |n|
- cache = SetAssociativeCache.new("l1u_"+n.to_s, L1_CACHE_SIZE_KB,
L1_CACHE_LATENCY, L1_CACHE_ASSOC, "PSEUDO_LRU")
+ cache = SetAssociativeCache.new("l1u_"+n.to_s, l1_cache_size_kb,
l1_cache_latency, l1_cache_assoc, "PSEUDO_LRU")
sequencer = Sequencer.new("Sequencer_"+n.to_s, cache, cache)
iface_ports << sequencer
net_ports << MI_example_CacheController.new("L1CacheController_"+n.to_s,
@@ -61,7 +63,7 @@
"Directory",
directory, memory_control)
}
-NUM_DMA.times { |n|
+num_dma.times { |n|
dma_sequencer = DMASequencer.new("DMASequencer_"+n.to_s)
iface_ports << dma_sequencer
net_ports << MI_example_DMAController.new("DMAController_"+n.to_s, "DMA",
dma_sequencer)
diff -r e983bc0f31a0 -r e76348cb11de src/mem/ruby/config/MI_example.rb
--- a/src/mem/ruby/config/MI_example.rb Wed Aug 05 14:17:23 2009 -0500
+++ b/src/mem/ruby/config/MI_example.rb Wed Aug 05 14:20:32 2009 -0500
@@ -1,3 +1,5 @@
+
+require "util.rb"
class MI_example_CacheController < L1CacheController
attr :cache
@@ -21,6 +23,8 @@
def argv()
vec = super()
vec += " directory_latency "+directory_latency.to_s
+ vec += " dma_select_low_bit "+log_int(RubySystem.block_size_bytes).to_s
+ vec += " dma_select_num_bits "+log_int(NetPort.totalOfType("DMA")).to_s
end
end
diff -r e983bc0f31a0 -r e76348cb11de src/mem/ruby/config/MOESI_CMP_directory.rb
--- a/src/mem/ruby/config/MOESI_CMP_directory.rb Wed Aug 05 14:17:23
2009 -0500
+++ b/src/mem/ruby/config/MOESI_CMP_directory.rb Wed Aug 05 14:20:32
2009 -0500
@@ -1,15 +1,6 @@
require "cfg.rb"
-
-def log_int(n)
- assert(n.is_a?(Fixnum), "log_int takes a number for an argument")
- counter = 0
- while n >= 2 do
- counter += 1
- n = n >> 1
- end
- return counter
-end
+require "util.rb"
class MOESI_CMP_directory_L1CacheController < L1CacheController
diff -r e983bc0f31a0 -r e76348cb11de
src/mem/ruby/config/TwoLevel_SplitL1UnifiedL2.rb
--- a/src/mem/ruby/config/TwoLevel_SplitL1UnifiedL2.rb Wed Aug 05 14:17:23
2009 -0500
+++ b/src/mem/ruby/config/TwoLevel_SplitL1UnifiedL2.rb Wed Aug 05 14:20:32
2009 -0500
@@ -7,22 +7,24 @@
require "cfg.rb"
+RubySystem.reset
+
# default values
num_cores = 2
-L1_ICACHE_SIZE_KB = 32
-L1_ICACHE_ASSOC = 8
-L1_ICACHE_LATENCY = 1
-L1_DCACHE_SIZE_KB = 32
-L1_DCACHE_ASSOC = 8
-L1_DCACHE_LATENCY = 1
-L2_CACHE_SIZE_KB = 2048 # total size (sum of all banks)
-L2_CACHE_ASSOC = 16
-L2_CACHE_LATENCY = 12
+l1_icache_size_kb = 32
+l1_icache_assoc = 8
+l1_icache_latency = 1
+l1_dcache_size_kb = 32
+l1_dcache_assoc = 8
+l1_dcache_latency = 1
+l2_cache_size_kb = 2048 # total size (sum of all banks)
+l2_cache_assoc = 16
+l2_cache_latency = 12
num_l2_banks = num_cores
num_memories = 1
memory_size_mb = 1024
-NUM_DMA = 1
+num_dma = 1
protocol = "MOESI_CMP_directory"
@@ -52,8 +54,8 @@
require protocol+".rb"
num_cores.times { |n|
- icache = SetAssociativeCache.new("l1i_"+n.to_s, L1_ICACHE_SIZE_KB,
L1_ICACHE_LATENCY, L1_ICACHE_ASSOC, "PSEUDO_LRU")
- dcache = SetAssociativeCache.new("l1d_"+n.to_s, L1_DCACHE_SIZE_KB,
L1_DCACHE_LATENCY, L1_DCACHE_ASSOC, "PSEUDO_LRU")
+ icache = SetAssociativeCache.new("l1i_"+n.to_s, l1_icache_size_kb,
l1_icache_latency, l1_icache_assoc, "PSEUDO_LRU")
+ dcache = SetAssociativeCache.new("l1d_"+n.to_s, l1_dcache_size_kb,
l1_dcache_latency, l1_dcache_assoc, "PSEUDO_LRU")
sequencer = Sequencer.new("Sequencer_"+n.to_s, icache, dcache)
iface_ports << sequencer
if protocol == "MOESI_CMP_directory"
@@ -65,7 +67,7 @@
end
}
num_l2_banks.times { |n|
- cache = SetAssociativeCache.new("l2u_"+n.to_s,
L2_CACHE_SIZE_KB/num_l2_banks, L2_CACHE_LATENCY, L2_CACHE_ASSOC, "PSEUDO_LRU")
+ cache = SetAssociativeCache.new("l2u_"+n.to_s,
l2_cache_size_kb/num_l2_banks, l2_cache_latency, l2_cache_assoc, "PSEUDO_LRU")
if protocol == "MOESI_CMP_directory"
net_ports <<
MOESI_CMP_directory_L2CacheController.new("L2CacheController_"+n.to_s,
"L2Cache",
@@ -82,7 +84,7 @@
memory_control)
end
}
-NUM_DMA.times { |n|
+num_dma.times { |n|
dma_sequencer = DMASequencer.new("DMASequencer_"+n.to_s)
iface_ports << dma_sequencer
if protocol == "MOESI_CMP_directory"
diff -r e983bc0f31a0 -r e76348cb11de src/mem/ruby/config/cfg.rb
--- a/src/mem/ruby/config/cfg.rb Wed Aug 05 14:17:23 2009 -0500
+++ b/src/mem/ruby/config/cfg.rb Wed Aug 05 14:20:32 2009 -0500
@@ -150,6 +150,9 @@
def cppClassName
"NetPort"
end
+ def self.totalOfType(mach_type)
+ return @@type_cnt[mach_type]
+ end
end
class MemoryVector < LibRubyObject
@@ -190,6 +193,7 @@
class RubySystem
@@params = Hash.new
+ @@defaults = Hash.new
@@network = nil
def self.init(iface_ports, network)
@@ -197,6 +201,14 @@
@@network = network
end
+ def self.reset()
+ @@iface_ports = nil
+ @@network = nil
+ @@params.each { |param_name, param|
+ param = @@defaults[param_name]
+ }
+ end
+
def self.default_param(param_name, type, default)
if default.is_a?(FalseClass) || default.is_a?(TrueClass)
assert type.is_a?(Boolean), "default value of param \"#{param_name}\"
must be either true or false"
@@ -204,6 +216,7 @@
assert default.is_a?(type), "default value of param \"#{param_name}\"
does not match type #{type}"
end
@@params[param_name] = default
+ @@defaults[param_name] = default
method_name = (param_name.to_s).to_sym
instance_eval <<-EOS
def #{method_name.to_s}
diff -r e983bc0f31a0 -r e76348cb11de src/mem/ruby/config/util.rb
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/mem/ruby/config/util.rb Wed Aug 05 14:20:32 2009 -0500
@@ -0,0 +1,10 @@
+
+def log_int(n)
+ assert(n.is_a?(Fixnum), "log_int takes a number for an argument")
+ counter = 0
+ while n >= 2 do
+ counter += 1
+ n = n >> 1
+ end
+ return counter
+end
_______________________________________________
m5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/m5-dev