Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(809)

Unified Diff: bench/ScalarBench.cpp

Issue 308883003: Revert of TSAN caught us racing in ScalarBench.cpp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: bench/ScalarBench.cpp
diff --git a/bench/ScalarBench.cpp b/bench/ScalarBench.cpp
index a023704fcd132d7bbbdd042ab9d0db43dbb218f7..54ee0fcd195967a73bd532b2bf9b08872fc9b76d 100644
--- a/bench/ScalarBench.cpp
+++ b/bench/ScalarBench.cpp
@@ -41,6 +41,18 @@
typedef SkBenchmark INHERITED;
};
+// we want to stop the compiler from eliminating code that it thinks is a no-op
+// so we have a non-static global we increment, hoping that will convince the
+// compiler to execute everything
+int gScalarBench_NonStaticGlobal;
+
+#define always_do(pred) \
+ do { \
+ if (pred) { \
+ ++gScalarBench_NonStaticGlobal; \
+ } \
+ } while (0)
+
// having unknown values in our arrays can throw off the timing a lot, perhaps
// handling NaN values is a lot slower. Anyway, this guy is just meant to put
// reasonable values in our arrays.
@@ -59,10 +71,8 @@
protected:
virtual int mulLoopCount() const { return 4; }
virtual void performTest() {
- // xoring into a volatile prevents the compiler from optimizing these checks away.
- volatile bool junk = false;
- junk ^= (fArray[6] != 0.0f || fArray[7] != 0.0f || fArray[8] != 1.0f);
- junk ^= (fArray[2] != 0.0f || fArray[5] != 0.0f);
+ always_do(fArray[6] != 0.0f || fArray[7] != 0.0f || fArray[8] != 1.0f);
+ always_do(fArray[2] != 0.0f || fArray[5] != 0.0f);
}
private:
float fArray[9];
@@ -78,13 +88,11 @@
protected:
virtual int mulLoopCount() const { return 4; }
virtual void performTest() {
- // xoring into a volatile prevents the compiler from optimizing these checks away.
- volatile bool junk = false;
- junk ^= (SkScalarAs2sCompliment(fArray[6]) |
- SkScalarAs2sCompliment(fArray[7]) |
- (SkScalarAs2sCompliment(fArray[8]) - kPersp1Int));
- junk ^= (SkScalarAs2sCompliment(fArray[2]) |
- SkScalarAs2sCompliment(fArray[5]));
+ always_do(SkScalarAs2sCompliment(fArray[6]) |
+ SkScalarAs2sCompliment(fArray[7]) |
+ (SkScalarAs2sCompliment(fArray[8]) - kPersp1Int));
+ always_do(SkScalarAs2sCompliment(fArray[2]) |
+ SkScalarAs2sCompliment(fArray[5]));
}
private:
static const int32_t kPersp1Int = 0x3f800000;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698