OSDN Git Service

* bug fix
authorfche <fche>
Thu, 27 Sep 2001 20:23:50 +0000 (20:23 +0000)
committerfche <fche>
Thu, 27 Sep 2001 20:23:50 +0000 (20:23 +0000)
2001-09-27  Frank Ch. Eigler  <fche@redhat.com>

* cache.cxx (emit_report): Remove extra blank line.
(set_hash_mask, set_hash_shift): Exchange names to match functionality.
* cacheutil.cxx (cache ctor): Compute good default hash_params.

sid/component/cache/ChangeLog
sid/component/cache/cache.cxx
sid/component/cache/cacheutil.cxx

index c77c70e..1cc083c 100644 (file)
@@ -1,3 +1,9 @@
+2001-09-27  Frank Ch. Eigler  <fche@redhat.com>
+
+       * cache.cxx (emit_report): Remove extra blank line.
+       (set_hash_mask, set_hash_shift): Exchange names to match functionality.
+       * cacheutil.cxx (cache ctor): Compute good default hash_params.
+
 2001-09-26  Frank Ch. Eigler  <fche@redhat.com>
 
        * cacheutil.cxx (hash_fn): Detect index overflow.  Complain loudly.
index 13fc2d2..2785ff5 100644 (file)
@@ -398,7 +398,7 @@ cache_component::unlock_line (host_int_4 addr)
 void
 cache_component::emit_report (host_int_4 ignore)
 {
-  cout << report_heading << endl << endl
+  cout << report_heading << endl
        << "reads:        " << make_attribute (stats.reads) << endl
        << "read hits:    " << read_hit_rate () << endl
        << "writes:       " << make_attribute (stats.writes) << endl
@@ -420,7 +420,7 @@ cache_component::get_hash_shift ()
 }
 
 sid::component::status
-cache_component::set_hash_mask (const string& value)
+cache_component::set_hash_shift (const string& value)
 {
   unsigned shift;
 
@@ -435,7 +435,7 @@ cache_component::set_hash_mask (const string& value)
 }
 
 sid::component::status
-cache_component::set_hash_shift (const string& value)
+cache_component::set_hash_mask (const string& value)
 {
   sid::host_int_4 mask;
 
index 6528abd..ec6a1fb 100644 (file)
@@ -275,9 +275,10 @@ cache::cache (unsigned cache_size, unsigned line_size, unsigned assoc,
   
   num_non_tag_bits = log2 (line_size);
 
-  // suitable defaults
-  hash_params.mask = 0x3fe0;
-  hash_params.shift = 5;
+  // Pick a default hash function: the next few bits above the intra-line address bits
+  unsigned cache_set_bits = log2 (sets.size());
+  hash_params.mask = ((1U << cache_set_bits) - 1) << num_non_tag_bits;
+  hash_params.shift = num_non_tag_bits;
 }
 
 cache::~cache ()