From c2dbfc1d6ca677f9b6fb8eaa60e4003a903e26bd Mon Sep 17 00:00:00 2001 From: Andreas Hansson Date: Mon, 9 Jan 2012 18:08:20 -0600 Subject: MAC: Make gem5 compile and run on MacOSX 10.7.2 Adaptations to make gem5 compile and run on OSX 10.7.2, with a stock gcc 4.2.1 and the remaining dependencies from macports, i.e. python 2.7,.2 swig 2.0.4, mercurial 2.0. The changes include an adaptation of the SConstruct to handle non-library linker flags, and Darwin-specific code to find the memory usage of gem5. A number of Ruby files relied on ambigious uint (without the 32 suffix) which caused compilation errors. --- src/base/hostinfo.cc | 32 +++++++++++++++++++++++++++++++- src/base/hostinfo.hh | 8 ++++++-- 2 files changed, 37 insertions(+), 3 deletions(-) (limited to 'src/base') diff --git a/src/base/hostinfo.cc b/src/base/hostinfo.cc index 5ff34e603..857ccfa7f 100644 --- a/src/base/hostinfo.cc +++ b/src/base/hostinfo.cc @@ -30,6 +30,12 @@ #include +#ifdef __APPLE__ +#include +#include +#include +#endif + #include #include #include @@ -82,7 +88,31 @@ procInfo(const char *filename, const char *target) } if (fp) - fclose(fp); + fclose(fp); return 0; } + +uint64_t +memUsage() +{ +// For the Mach-based Darwin kernel, use the task_info of the self task +#ifdef __APPLE__ + struct task_basic_info t_info; + mach_msg_type_number_t t_info_count = TASK_BASIC_INFO_COUNT; + + if (KERN_SUCCESS != task_info(mach_task_self(), + TASK_BASIC_INFO, (task_info_t)&t_info, + &t_info_count)) { + return 0; + } + + // Mimic Darwin's implementation of top and subtract + // SHARED_REGION_SIZE from the tasks virtual size to account for the + // shared memory submap that is incorporated into every process. + return (t_info.virtual_size - SHARED_REGION_SIZE) / 1024; +#else + // Linux implementation + return procInfo("/proc/self/status", "VmSize:"); +#endif +} diff --git a/src/base/hostinfo.hh b/src/base/hostinfo.hh index ac7d40f13..d9a30481a 100644 --- a/src/base/hostinfo.hh +++ b/src/base/hostinfo.hh @@ -39,7 +39,11 @@ std::string &hostname(); uint64_t procInfo(const char *filename, const char *target); -inline uint64_t memUsage() -{ return procInfo("/proc/self/status", "VmSize:"); } +/** + * Determine the simulator process' total virtual memory usage. + * + * @return virtual memory usage in kilobytes + */ +uint64_t memUsage(); #endif // __HOSTINFO_HH__ -- cgit v1.2.3 From 3f9e352de4e1ac34e1f0b83c3f66af2175b524f4 Mon Sep 17 00:00:00 2001 From: Dam Sunwoo Date: Mon, 9 Jan 2012 18:08:20 -0600 Subject: Base: Fixed shift amount in genrand() to work with large numbers The previous version didn't work correctly with max integer values (2^31-1 for 32-bit, 2^63-1 for 64bit version), causing "shift" to become -1. For smaller numbers, it wouldn't have caused functional errors, but would have resulted in more than necessary loops in the while loop. Special-cased cases when (max + 1 == 0) to prevent the ceilLog2 functions from failing. --- src/base/random.cc | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/base') diff --git a/src/base/random.cc b/src/base/random.cc index 457b0c98b..cffeddec9 100644 --- a/src/base/random.cc +++ b/src/base/random.cc @@ -29,6 +29,7 @@ * Ali Saidi */ +#include #include "base/fenv.hh" #include "base/intmath.hh" #include "base/misc.hh" @@ -67,7 +68,10 @@ Random::genrand(uint32_t max) { if (max == 0) return 0; - int log = ceilLog2(max) + 1; + if (max == std::numeric_limits::max()) + return genrand(); + + int log = ceilLog2(max + 1); int shift = (sizeof(uint32_t) * 8 - log); uint32_t random; @@ -83,7 +87,10 @@ Random::genrand(uint64_t max) { if (max == 0) return 0; - int log = ceilLog2(max) + 1; + if (max == std::numeric_limits::max()) + return genrand(); + + int log = ceilLog2(max + 1); int shift = (sizeof(uint64_t) * 8 - log); uint64_t random; -- cgit v1.2.3 From 51aa7e4a0392d5e8f98bd7a4d09f4026dd21bd0a Mon Sep 17 00:00:00 2001 From: Prakash Ramrakhyani Date: Mon, 9 Jan 2012 18:08:20 -0600 Subject: sim: Enable sampling of run-time for code-sections marked using pseudo insts. This patch adds a mechanism to collect run time samples for specific portions of a benchmark, using work_begin and work_end pseudo instructions.It also enhances the histogram stat to report geometric mean. --- src/base/statistics.hh | 5 +++++ src/base/stats/info.hh | 1 + src/base/stats/text.cc | 6 ++++++ 3 files changed, 12 insertions(+) (limited to 'src/base') diff --git a/src/base/statistics.hh b/src/base/statistics.hh index d98c79414..1f8a59326 100644 --- a/src/base/statistics.hh +++ b/src/base/statistics.hh @@ -1477,6 +1477,8 @@ class HistStor /** The current sum. */ Counter sum; + /** The sum of logarithm of each sample, used to compute geometric mean. */ + Counter logs; /** The sum of squares. */ Counter squares; /** The number of samples. */ @@ -1528,6 +1530,7 @@ class HistStor sum += val * number; squares += val * val * number; + logs += log(val) * number; samples += number; } @@ -1567,6 +1570,7 @@ class HistStor data.cvec[i] = cvec[i]; data.sum = sum; + data.logs = logs; data.squares = squares; data.samples = samples; } @@ -1589,6 +1593,7 @@ class HistStor sum = Counter(); squares = Counter(); samples = Counter(); + logs = Counter(); } }; diff --git a/src/base/stats/info.hh b/src/base/stats/info.hh index 2c5b44a38..98e811747 100644 --- a/src/base/stats/info.hh +++ b/src/base/stats/info.hh @@ -183,6 +183,7 @@ struct DistData VCounter cvec; Counter sum; Counter squares; + Counter logs; Counter samples; }; diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc index 683ba7fe4..4cf98ca9e 100644 --- a/src/base/stats/text.cc +++ b/src/base/stats/text.cc @@ -367,6 +367,12 @@ DistPrint::operator()(ostream &stream) const print.value = data.samples ? data.sum / data.samples : NAN; print(stream); + if (data.type == Hist) { + print.name = base + "gmean"; + print.value = data.samples ? exp(data.logs / data.samples) : NAN; + print(stream); + } + Result stdev = NAN; if (data.samples) stdev = sqrt((data.samples * data.squares - data.sum * data.sum) / -- cgit v1.2.3 From bda1125e882eaf8c127ebdae0d847bf2148832ad Mon Sep 17 00:00:00 2001 From: Dam Sunwoo Date: Mon, 9 Jan 2012 18:08:20 -0600 Subject: stats: fix Vector2d to display stats correctly when y_subname is not specified. Vector2d stats with no y_subname were not displayed as the VectorPrint subname was not initialized correctly to reflect the empty field. --- src/base/stats/text.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src/base') diff --git a/src/base/stats/text.cc b/src/base/stats/text.cc index 4cf98ca9e..8fb49dc59 100644 --- a/src/base/stats/text.cc +++ b/src/base/stats/text.cc @@ -513,7 +513,14 @@ Text::visit(const Vector2dInfo &info) bool havesub = false; VectorPrint print; - print.subnames = info.y_subnames; + if (!info.y_subnames.empty()) { + for (off_type i = 0; i < info.y; ++i) { + if (!info.y_subnames[i].empty()) { + print.subnames = info.y_subnames; + } + break; + } + } print.flags = info.flags; print.separatorString = info.separatorString; print.descriptions = descriptions; -- cgit v1.2.3