From 9b1e2db811f86d9911bacaad475d1fec70c4aecd Mon Sep 17 00:00:00 2001 From: Nathan Binkert Date: Sat, 19 Feb 2005 11:46:41 -0500 Subject: Clean up CPU stuff and make it use params structs cpu/base_cpu.cc: cpu/base_cpu.hh: Convert the CPU stuff to use a params struct cpu/memtest/memtest.cc: The memory tester is really not a cpu, so don't derive from BaseCPU since it just makes things a pain in the butt. Keep track of max loads in the memtest class now that the base class doesn't do it for us. Don't have any default parameters. cpu/memtest/memtest.hh: The memory tester is really not a cpu, so don't derive from BaseCPU since it just makes things a pain in the butt. Keep track of max loads in the memtest class now that the base class doesn't do it for us. cpu/simple_cpu/simple_cpu.cc: Convert to use a params struct. remove default parameters cpu/simple_cpu/simple_cpu.hh: convert to use a params struct cpu/trace/opt_cpu.cc: cpu/trace/opt_cpu.hh: cpu/trace/trace_cpu.cc: cpu/trace/trace_cpu.hh: this isn't really a cpu. don't derive from BaseCPU objects/MemTest.mpy: we only need one max_loads parameter sim/main.cc: Don't check for the number of CPUs since we may be doing something else going on. If we don't have anything to simulate, the simulator will exit anyway. --HG-- extra : convert_revision : 2195a34a9ec90b5414324054ceb3bab643540dd5 --- cpu/memtest/memtest.cc | 49 +++++++++++++++++++++---------------------------- cpu/memtest/memtest.hh | 17 +++++++++-------- 2 files changed, 30 insertions(+), 36 deletions(-) (limited to 'cpu/memtest') diff --git a/cpu/memtest/memtest.cc b/cpu/memtest/memtest.cc index e967c79da..14b119880 100644 --- a/cpu/memtest/memtest.cc +++ b/cpu/memtest/memtest.cc @@ -36,6 +36,7 @@ #include "base/misc.hh" #include "base/statistics.hh" +#include "cpu/exec_context.hh" #include "cpu/memtest/memtest.hh" #include "mem/cache/base_cache.hh" #include "mem/functional_mem/main_memory.hh" @@ -59,10 +60,8 @@ MemTest::MemTest(const string &name, unsigned _percentSourceUnaligned, unsigned _percentDestUnaligned, Addr _traceAddr, - Counter max_loads_any_thread, - Counter max_loads_all_threads) - : BaseCPU(name, 1, true, 0, 0, max_loads_any_thread, - max_loads_all_threads), + Counter _max_loads) + : SimObject(name), tickEvent(this), cacheInterface(_cache_interface), mainMem(main_mem), @@ -74,12 +73,13 @@ MemTest::MemTest(const string &name, progressInterval(_progressInterval), nextProgressMessage(_progressInterval), percentSourceUnaligned(_percentSourceUnaligned), - percentDestUnaligned(percentDestUnaligned) + percentDestUnaligned(percentDestUnaligned), + maxLoads(_max_loads) { vector cmd; cmd.push_back("/bin/ls"); vector null_vec; - xc = new ExecContext(this ,0,mainMem,0); + xc = new ExecContext(NULL, 0, mainMem, 0); blockSize = cacheInterface->getBlockSize(); blockAddrMask = blockSize - 1; @@ -160,7 +160,8 @@ MemTest::completeRequest(MemReqPtr &req, uint8_t *data) nextProgressMessage += progressInterval; } - comLoadEventQueue[0]->serviceEvents(numReads); + if (numReads >= maxLoads) + SimExit(curTick, "Maximum number of loads reached!"); break; case Write: @@ -402,8 +403,7 @@ BEGIN_DECLARE_SIM_OBJECT_PARAMS(MemTest) Param percent_source_unaligned; Param percent_dest_unaligned; Param trace_addr; - Param max_loads_any_thread; - Param max_loads_all_threads; + Param max_loads; END_DECLARE_SIM_OBJECT_PARAMS(MemTest) @@ -413,23 +413,17 @@ BEGIN_INIT_SIM_OBJECT_PARAMS(MemTest) INIT_PARAM(cache, "L1 cache"), INIT_PARAM(main_mem, "hierarchical memory"), INIT_PARAM(check_mem, "check memory"), - INIT_PARAM_DFLT(memory_size, "memory size", 65536), - INIT_PARAM_DFLT(percent_reads, "target read percentage", 65), - INIT_PARAM_DFLT(percent_copies, "target copy percentage", 0), - INIT_PARAM_DFLT(percent_uncacheable, "target uncacheable percentage", 10), - INIT_PARAM_DFLT(progress_interval, - "progress report interval (in accesses)", 1000000), - INIT_PARAM_DFLT(percent_source_unaligned, "percent of copy source address " - "that are unaligned", 50), - INIT_PARAM_DFLT(percent_dest_unaligned, "percent of copy dest address " - "that are unaligned", 50), - INIT_PARAM_DFLT(trace_addr, "address to trace", 0), - INIT_PARAM_DFLT(max_loads_any_thread, - "terminate when any thread reaches this load count", - 0), - INIT_PARAM_DFLT(max_loads_all_threads, - "terminate when all threads have reached this load count", - 0) + INIT_PARAM(memory_size, "memory size"), + INIT_PARAM(percent_reads, "target read percentage"), + INIT_PARAM(percent_copies, "target copy percentage"), + INIT_PARAM(percent_uncacheable, "target uncacheable percentage"), + INIT_PARAM(progress_interval, "progress report interval (in accesses)"), + INIT_PARAM(percent_source_unaligned, + "percent of copy source address that are unaligned"), + INIT_PARAM(percent_dest_unaligned, + "percent of copy dest address that are unaligned"), + INIT_PARAM(trace_addr, "address to trace"), + INIT_PARAM(max_loads, "terminate when we have reached this load count") END_INIT_SIM_OBJECT_PARAMS(MemTest) @@ -440,8 +434,7 @@ CREATE_SIM_OBJECT(MemTest) check_mem, memory_size, percent_reads, percent_copies, percent_uncacheable, progress_interval, percent_source_unaligned, percent_dest_unaligned, - trace_addr, max_loads_any_thread, - max_loads_all_threads); + trace_addr, max_loads); } REGISTER_SIM_OBJECT("MemTest", MemTest) diff --git a/cpu/memtest/memtest.hh b/cpu/memtest/memtest.hh index 43b17a713..45b2d24e8 100644 --- a/cpu/memtest/memtest.hh +++ b/cpu/memtest/memtest.hh @@ -26,20 +26,21 @@ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef __MEMTEST_HH__ -#define __MEMTEST_HH__ +#ifndef __CPU_MEMTEST_MEMTEST_HH__ +#define __CPU_MEMTEST_MEMTEST_HH__ #include #include "base/statistics.hh" -#include "cpu/base_cpu.hh" -#include "cpu/exec_context.hh" #include "mem/functional_mem/functional_memory.hh" #include "mem/mem_interface.hh" +#include "sim/eventq.hh" +#include "sim/sim_exit.hh" #include "sim/sim_object.hh" #include "sim/stats.hh" -class MemTest : public BaseCPU +class ExecContext; +class MemTest : public SimObject { public: @@ -55,8 +56,7 @@ class MemTest : public BaseCPU unsigned _percentSourceUnaligned, unsigned _percentDestUnaligned, Addr _traceAddr, - Counter max_loads_any_thread, - Counter max_loads_all_threads); + Counter _max_loads); // register statistics virtual void regStats(); @@ -116,6 +116,7 @@ class MemTest : public BaseCPU Tick noResponseCycles; uint64_t numReads; + uint64_t maxLoads; Stats::Scalar<> numReadsStat; Stats::Scalar<> numWritesStat; Stats::Scalar<> numCopiesStat; @@ -146,7 +147,7 @@ class MemCompleteEvent : public Event virtual const char *description(); }; -#endif // __MEMTEST_HH__ +#endif // __CPU_MEMTEST_MEMTEST_HH__ -- cgit v1.2.3