[PATCH] D20914: [esan|cfrag] Compute the struct field access variance

Qin Zhao via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 3 09:19:23 PDT 2016


zhaoqin marked 6 inline comments as done.

================
Comment at: lib/esan/cache_frag.cpp:62
@@ +61,3 @@
+
+// We evaluate how much difference between the access counts of the two adjacent
+// struct fields.
----------------
aizatsky wrote:
> Before we move to the weight, let's discuss logarithm base for a while.
> 
> Obviously:
> 
> log(T, V1/V2) = log2(v1/v2) / log2(T)
> 
> So changing T would just change a constant factor for all measurements. Why not statically fix it?
> 
> Maybe just use log2(v1/v2) without base? you could use __builtin_clzll for that.
> 
The major reason is to have a runtime flag for T is that I am not sure what's the right way to evaluate the variation of the struct field counts.
I want the overall score for the variation having a few features:
1. The bigger the difference is, the higher the score should be:
    e.g., { 2^20, 1, 2^20 } should have higher score than { 2^10, 2^8, 2^10, 2^8, 2^10, 2^8, ... }
2. The higher the count value is, the higher the score should be:
    e.g., { 2^20, 2^10 } should have higher score than {2^10, 1}.

It looks like I should not use log to compute at all, which gets rid of the count factor, maybe a simple ratio should work, e.g., V1/V2/Base


================
Comment at: lib/esan/cache_frag.cpp:63
@@ +62,3 @@
+// We evaluate how much difference between the access counts of the two adjacent
+// struct fields.
+// The formula for calculating the difference score is (log(T, V1/V2) - 1) * V1
----------------
aizatsky wrote:
> As for weight, can you please share your thinking why do you need it?
For two pairs of value: (2^20, 2^10), and (2^10, 1), I want to say (2^20, 2^10) worth more attention, and so should have a higher score.
Now use V1/V2/Base, so do not need weight.

================
Comment at: lib/esan/cache_frag.cpp:66
@@ +65,3 @@
+// if V1 is greater than V2.
+// * "- 1":  making the difference score 0 if the two counts are close in value,
+// * "* V2": added weight for how imporant the difference is.
----------------
aizatsky wrote:
> Is there a "-1" now?
I used the while (Ratio > Threshold) to make the score 0, probably not a good idea, make the code look different from the algo. Update it.


================
Comment at: lib/esan/cache_frag.cpp:80
@@ +79,3 @@
+  }
+  while (Ratio > Threshold) {
+    ++Score;
----------------
aizatsky wrote:
> In any case I suggest you extract a simple FastLog function. 
stop using log


http://reviews.llvm.org/D20914





More information about the llvm-commits mailing list