diff options
author | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-30 15:09:44 +0000 |
---|---|---|
committer | commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2014-05-30 15:09:44 +0000 |
commit | 3dd6368232dd975f2d48f5d7b4c17fc011840a8a (patch) | |
tree | f1fb1dac2e6b2b462629f97119b09223c72a7207 | |
parent | 9a558d495dfe305a52946cdf97e8883190e0bbcc (diff) |
Revert of TSAN caught us racing in ScalarBench.cpp (https://codereview.chromium.org/305033002/)
Reason for revert:
windows doesn't like it
Original issue's description:
> TSAN caught us racing in ScalarBench.cpp
>
> http://108.170.220.102:10117/builders/Test-Ubuntu13-ShuttleA-HD2000-x86_64-Debug-TSAN/builds/914/steps/RunDM/logs/stdio
>
> BUG=skia:
>
> Committed: http://code.google.com/p/skia/source/detail?r=14992
R=reed@google.com, mtklein@chromium.org
TBR=mtklein@chromium.org, reed@google.com
NOTREECHECKS=true
NOTRY=true
BUG=skia:
Author: mtklein@google.com
Review URL: https://codereview.chromium.org/308883003
git-svn-id: http://skia.googlecode.com/svn/trunk@14994 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | bench/ScalarBench.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/bench/ScalarBench.cpp b/bench/ScalarBench.cpp index a023704fcd..54ee0fcd19 100644 --- a/bench/ScalarBench.cpp +++ b/bench/ScalarBench.cpp @@ -41,6 +41,18 @@ private: 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 @@ public: 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 @@ public: 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; |