Clean up some unused atomic routines.
AtomicTest was the only use of sk_atomic_add(). AtomicInc64 bench was the only use of sk_atomic_inc(int64_t*). BUG=skia: GOLD_TRYBOT_URL= https://gold.skia.org/search?issue=2183473005 CQ_INCLUDE_TRYBOTS=master.client.skia:Test-Ubuntu-GCC-GCE-CPU-AVX2-x86_64-Release-TSAN-Trybot,Test-Ubuntu-GCC-Golo-GPU-GT610-x86_64-Release-TSAN-Trybot Review-Url: https://codereview.chromium.org/2183473005
This commit is contained in:
parent
735109c248
commit
570c868b38
@ -38,30 +38,6 @@ private:
|
||||
typedef Benchmark INHERITED;
|
||||
};
|
||||
|
||||
class AtomicInc64 : public Benchmark {
|
||||
public:
|
||||
AtomicInc64() : fX(0) {}
|
||||
|
||||
bool isSuitableFor(Backend backend) override {
|
||||
return backend == kNonRendering_Backend;
|
||||
}
|
||||
|
||||
protected:
|
||||
const char* onGetName() override {
|
||||
return "atomic_inc_64";
|
||||
}
|
||||
|
||||
void onDraw(int loops, SkCanvas*) override {
|
||||
for (int i = 0; i < loops; ++i) {
|
||||
sk_atomic_inc(&fX);
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
int64_t fX;
|
||||
typedef Benchmark INHERITED;
|
||||
};
|
||||
|
||||
class RefCntBench_Stack : public Benchmark {
|
||||
public:
|
||||
bool isSuitableFor(Backend backend) override {
|
||||
@ -238,7 +214,6 @@ private:
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
DEF_BENCH( return new AtomicInc32(); )
|
||||
DEF_BENCH( return new AtomicInc64(); )
|
||||
|
||||
DEF_BENCH( return new RefCntBench_Stack(); )
|
||||
DEF_BENCH( return new RefCntBench_Heap(); )
|
||||
|
@ -155,8 +155,5 @@ T sk_atomic_exchange(T* ptr, T val, sk_memory_order mo) {
|
||||
|
||||
inline int32_t sk_atomic_inc(int32_t* ptr) { return sk_atomic_fetch_add(ptr, +1); }
|
||||
inline int32_t sk_atomic_dec(int32_t* ptr) { return sk_atomic_fetch_add(ptr, -1); }
|
||||
inline int32_t sk_atomic_add(int32_t* ptr, int32_t v) { return sk_atomic_fetch_add(ptr, v); }
|
||||
|
||||
inline int64_t sk_atomic_inc(int64_t* ptr) { return sk_atomic_fetch_add<int64_t>(ptr, +1); }
|
||||
|
||||
#endif//SkAtomics_DEFINED
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright 2012 Google Inc.
|
||||
*
|
||||
* Use of this source code is governed by a BSD-style license that can be
|
||||
* found in the LICENSE file.
|
||||
*/
|
||||
|
||||
#include "SkAtomics.h"
|
||||
#include "SkThreadUtils.h"
|
||||
#include "SkTypes.h"
|
||||
#include "Test.h"
|
||||
|
||||
struct AddInfo {
|
||||
int32_t valueToAdd;
|
||||
int timesToAdd;
|
||||
};
|
||||
|
||||
static int32_t base = 0;
|
||||
|
||||
static AddInfo gAdds[] = {
|
||||
{ 3, 100 },
|
||||
{ 2, 200 },
|
||||
{ 7, 150 },
|
||||
};
|
||||
|
||||
static void addABunchOfTimes(void* data) {
|
||||
AddInfo* addInfo = static_cast<AddInfo*>(data);
|
||||
for (int i = 0; i < addInfo->timesToAdd; i++) {
|
||||
sk_atomic_add(&base, addInfo->valueToAdd);
|
||||
}
|
||||
}
|
||||
|
||||
DEF_TEST(Atomic, reporter) {
|
||||
int32_t total = base;
|
||||
SkThread* threads[SK_ARRAY_COUNT(gAdds)];
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gAdds); i++) {
|
||||
total += gAdds[i].valueToAdd * gAdds[i].timesToAdd;
|
||||
}
|
||||
// Start the threads
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gAdds); i++) {
|
||||
threads[i] = new SkThread(addABunchOfTimes, &gAdds[i]);
|
||||
threads[i]->start();
|
||||
}
|
||||
|
||||
// Now end the threads
|
||||
for (size_t i = 0; i < SK_ARRAY_COUNT(gAdds); i++) {
|
||||
threads[i]->join();
|
||||
delete threads[i];
|
||||
}
|
||||
REPORTER_ASSERT(reporter, total == base);
|
||||
// Ensure that the returned value from sk_atomic_add is correct.
|
||||
int32_t valueToModify = 3;
|
||||
const int32_t originalValue = valueToModify;
|
||||
REPORTER_ASSERT(reporter, originalValue == sk_atomic_add(&valueToModify, 7));
|
||||
|
||||
{
|
||||
SkAtomic<int> v {0};
|
||||
REPORTER_ASSERT(reporter, 0 == v.load());
|
||||
v = 10;
|
||||
REPORTER_ASSERT(reporter, 10 == v.load());
|
||||
int q = v;
|
||||
REPORTER_ASSERT(reporter, 10 == q);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user