aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests
diff options
context:
space:
mode:
authorGravatar mtklein <mtklein@google.com>2014-09-03 14:17:48 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-09-03 14:17:48 -0700
commit2460bbdfbb1d55ef307c3189c661e65de1a7affb (patch)
tree62342a335023875d1482447bea9e29e8a0ba22fb /tests
parent9c7207b5dc71dc5a96a2eb107d401133333d5b6f (diff)
Revert of SkThreadPool ~~> SkTaskGroup (patchset #4 id:60001 of https://codereview.chromium.org/531653002/)
Reason for revert: Leaks, leaks, leaks. Original issue's description: > SkThreadPool ~~> SkTaskGroup > > SkTaskGroup is like SkThreadPool except the threads stay in > one global pool. Each SkTaskGroup itself is tiny (4 bytes) > and its wait() method applies only to tasks add()ed to that > instance, not the whole thread pool. > > This means we don't need to bring up new thread pools when > tests themselves want to use multithreading (e.g. pathops, > quilt). We just create a new SkTaskGroup and wait for that > to complete. This should be more efficient, and allow us > to expand where we use threads to really latency sensitive > places. E.g. we can probably now use these in nanobench > for CPU .skp rendering. > > Now that all threads are sharing the same pool, I think we > can remove most of the custom mechanism pathops tests use > to control threading. They'll just ride on the global pool > with all other tests now. > > This (temporarily?) removes the GPU multithreading feature > from DM, which we don't use. > > On my desktop, DM runs a little faster (57s -> 55s) in > Debug, and a lot faster in Release (36s -> 24s). The bots > show speedups of similar proportions, cutting more than a > minute off the N4/Release and Win7/Debug runtimes. > > BUG=skia: > > Committed: https://skia.googlesource.com/skia/+/9c7207b5dc71dc5a96a2eb107d401133333d5b6f R=caryclark@google.com, bsalomon@google.com, bungeman@google.com, reed@google.com, mtklein@chromium.org TBR=bsalomon@google.com, bungeman@google.com, caryclark@google.com, mtklein@chromium.org, reed@google.com NOTREECHECKS=true NOTRY=true BUG=skia: Author: mtklein@google.com Review URL: https://codereview.chromium.org/533393002
Diffstat (limited to 'tests')
-rw-r--r--tests/OnceTest.cpp10
-rw-r--r--tests/PathOpsExtendedTest.cpp5
-rw-r--r--tests/PathOpsExtendedTest.h2
-rw-r--r--tests/PathOpsOpCubicThreadedTest.cpp4
-rwxr-xr-xtests/PathOpsOpLoopThreadedTest.cpp6
-rw-r--r--tests/PathOpsOpRectThreadedTest.cpp4
-rw-r--r--tests/PathOpsQuadLineIntersectionThreadedTest.cpp4
-rwxr-xr-xtests/PathOpsSimplifyDegenerateThreadedTest.cpp4
-rw-r--r--tests/PathOpsSimplifyQuadThreadedTest.cpp4
-rwxr-xr-xtests/PathOpsSimplifyQuadralateralsThreadedTest.cpp4
-rw-r--r--tests/PathOpsSimplifyRectThreadedTest.cpp4
-rwxr-xr-xtests/PathOpsSimplifyTrianglesThreadedTest.cpp4
-rwxr-xr-xtests/PathOpsSkpClipTest.cpp44
-rw-r--r--tests/PathOpsThreadedCommon.cpp6
-rw-r--r--tests/PathOpsThreadedCommon.h6
-rw-r--r--tests/PathOpsTightBoundsTest.cpp8
-rw-r--r--tests/SkpSkGrTest.cpp15
-rw-r--r--tests/Test.cpp4
-rw-r--r--tests/Test.h1
-rw-r--r--tests/skia_test.cpp10
20 files changed, 88 insertions, 61 deletions
diff --git a/tests/OnceTest.cpp b/tests/OnceTest.cpp
index 192abaaee3..389d257b73 100644
--- a/tests/OnceTest.cpp
+++ b/tests/OnceTest.cpp
@@ -6,7 +6,7 @@
*/
#include "SkOnce.h"
-#include "SkTaskGroup.h"
+#include "SkThreadPool.h"
#include "Test.h"
static void add_five(int* x) {
@@ -42,7 +42,7 @@ public:
};
DEF_TEST(SkOnce_Multithreaded, r) {
- const int kTasks = 16;
+ const int kTasks = 16, kThreads = 4;
// Make a bunch of tasks that will race to be the first to add six to x.
Racer racers[kTasks];
@@ -54,11 +54,11 @@ DEF_TEST(SkOnce_Multithreaded, r) {
}
// Let them race.
- SkTaskGroup tg;
+ SkThreadPool pool(kThreads);
for (int i = 0; i < kTasks; i++) {
- tg.add(&racers[i]);
+ pool.add(&racers[i]);
}
- tg.wait();
+ pool.wait();
// Only one should have done the +=.
REPORTER_ASSERT(r, 6 == x);
diff --git a/tests/PathOpsExtendedTest.cpp b/tests/PathOpsExtendedTest.cpp
index f90b9fec69..05d00045b9 100644
--- a/tests/PathOpsExtendedTest.cpp
+++ b/tests/PathOpsExtendedTest.cpp
@@ -14,8 +14,8 @@
#include "SkPaint.h"
#include "SkRTConf.h"
#include "SkStream.h"
-#include "SkTaskGroup.h"
#include "SkThread.h"
+#include "SkThreadPool.h"
#ifdef SK_BUILD_FOR_MAC
#include <sys/sysctl.h>
@@ -542,7 +542,7 @@ bool testThreadedPathOp(skiatest::Reporter* reporter, const SkPath& a, const SkP
SK_DECLARE_STATIC_MUTEX(gMutex);
-void initializeTests(skiatest::Reporter* reporter, const char* test) {
+int initializeTests(skiatest::Reporter* reporter, const char* test) {
#if 0 // doesn't work yet
SK_CONF_SET("images.jpeg.suppressDecoderWarnings", true);
SK_CONF_SET("images.png.suppressDecoderWarnings", true);
@@ -566,6 +566,7 @@ void initializeTests(skiatest::Reporter* reporter, const char* test) {
}
}
}
+ return reporter->allowThreaded() ? SkThreadPool::kThreadPerCore : 1;
}
void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType pathFillType) {
diff --git a/tests/PathOpsExtendedTest.h b/tests/PathOpsExtendedTest.h
index a854410139..5f3413c572 100644
--- a/tests/PathOpsExtendedTest.h
+++ b/tests/PathOpsExtendedTest.h
@@ -36,7 +36,7 @@ extern bool testSimplify(SkPath& path, bool useXor, SkPath& out, PathOpsThreadSt
const char* pathStr);
extern bool testSimplify(skiatest::Reporter* reporter, const SkPath& path, const char* filename);
-void initializeTests(skiatest::Reporter* reporter, const char* testName);
+int initializeTests(skiatest::Reporter* reporter, const char* testName);
void outputProgress(char* ramStr, const char* pathStr, SkPath::FillType );
void outputProgress(char* ramStr, const char* pathStr, SkPathOp op);
diff --git a/tests/PathOpsOpCubicThreadedTest.cpp b/tests/PathOpsOpCubicThreadedTest.cpp
index 751ccc5f1b..889ade0487 100644
--- a/tests/PathOpsOpCubicThreadedTest.cpp
+++ b/tests/PathOpsOpCubicThreadedTest.cpp
@@ -67,8 +67,8 @@ static void testOpCubicsMain(PathOpsThreadState* data) {
}
DEF_TEST(PathOpsOpCubicsThreaded, reporter) {
- initializeTests(reporter, "cubicOp");
- PathOpsThreadedTestRunner testRunner(reporter);
+ int threadCount = initializeTests(reporter, "cubicOp");
+ PathOpsThreadedTestRunner testRunner(reporter, threadCount);
for (int a = 0; a < 6; ++a) { // outermost
for (int b = a + 1; b < 7; ++b) {
for (int c = 0 ; c < 6; ++c) {
diff --git a/tests/PathOpsOpLoopThreadedTest.cpp b/tests/PathOpsOpLoopThreadedTest.cpp
index 3f316d1fe9..71efff3edc 100755
--- a/tests/PathOpsOpLoopThreadedTest.cpp
+++ b/tests/PathOpsOpLoopThreadedTest.cpp
@@ -62,8 +62,8 @@ static void testOpLoopsMain(PathOpsThreadState* data) {
}
DEF_TEST(PathOpsOpLoopsThreaded, reporter) {
- initializeTests(reporter, "cubicOp");
- PathOpsThreadedTestRunner testRunner(reporter);
+ int threadCount = initializeTests(reporter, "cubicOp");
+ PathOpsThreadedTestRunner testRunner(reporter, threadCount);
for (int a = 0; a < 6; ++a) { // outermost
for (int b = a + 1; b < 7; ++b) {
for (int c = 0 ; c < 6; ++c) {
@@ -81,7 +81,7 @@ finish:
}
DEF_TEST(PathOpsOpLoops, reporter) {
- initializeTests(reporter, "cubicOp");
+ (void) initializeTests(reporter, "cubicOp");
PathOpsThreadState state;
state.fReporter = reporter;
SkBitmap bitmap;
diff --git a/tests/PathOpsOpRectThreadedTest.cpp b/tests/PathOpsOpRectThreadedTest.cpp
index 1b6e4e86b9..3d07d74bb0 100644
--- a/tests/PathOpsOpRectThreadedTest.cpp
+++ b/tests/PathOpsOpRectThreadedTest.cpp
@@ -74,8 +74,8 @@ static void testPathOpsRectsMain(PathOpsThreadState* data)
}
DEF_TEST(PathOpsRectsThreaded, reporter) {
- initializeTests(reporter, "testOp");
- PathOpsThreadedTestRunner testRunner(reporter);
+ int threadCount = initializeTests(reporter, "testOp");
+ PathOpsThreadedTestRunner testRunner(reporter, threadCount);
for (int a = 0; a < 6; ++a) { // outermost
for (int b = a + 1; b < 7; ++b) {
for (int c = 0 ; c < 6; ++c) {
diff --git a/tests/PathOpsQuadLineIntersectionThreadedTest.cpp b/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
index 7e33b7b374..fd7581fa58 100644
--- a/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
+++ b/tests/PathOpsQuadLineIntersectionThreadedTest.cpp
@@ -111,8 +111,8 @@ static void testQuadLineIntersectMain(PathOpsThreadState* data)
}
DEF_TEST(PathOpsQuadLineIntersectionThreaded, reporter) {
- initializeTests(reporter, "testQuadLineIntersect");
- PathOpsThreadedTestRunner testRunner(reporter);
+ int threadCount = initializeTests(reporter, "testQuadLineIntersect");
+ PathOpsThreadedTestRunner testRunner(reporter, threadCount);
for (int a = 0; a < 16; ++a) {
for (int b = 0 ; b < 16; ++b) {
for (int c = 0 ; c < 16; ++c) {
diff --git a/tests/PathOpsSimplifyDegenerateThreadedTest.cpp b/tests/PathOpsSimplifyDegenerateThreadedTest.cpp
index 8e8c58bf44..5cd3c35d8a 100755
--- a/tests/PathOpsSimplifyDegenerateThreadedTest.cpp
+++ b/tests/PathOpsSimplifyDegenerateThreadedTest.cpp
@@ -68,8 +68,8 @@ static void testSimplifyDegeneratesMain(PathOpsThreadState* data) {
}
DEF_TEST(PathOpsSimplifyDegeneratesThreaded, reporter) {
- initializeTests(reporter, "testDegenerates");
- PathOpsThreadedTestRunner testRunner(reporter);
+ int threadCount = initializeTests(reporter, "testDegenerates");
+ PathOpsThreadedTestRunner testRunner(reporter, threadCount);
for (int a = 0; a < 16; ++a) {
int ax = a & 0x03;
int ay = a >> 2;
diff --git a/tests/PathOpsSimplifyQuadThreadedTest.cpp b/tests/PathOpsSimplifyQuadThreadedTest.cpp
index 3c92cca217..dbbec3e3e6 100644
--- a/tests/PathOpsSimplifyQuadThreadedTest.cpp
+++ b/tests/PathOpsSimplifyQuadThreadedTest.cpp
@@ -74,8 +74,8 @@ static void testSimplifyQuadsMain(PathOpsThreadState* data)
}
DEF_TEST(PathOpsSimplifyQuadsThreaded, reporter) {
- initializeTests(reporter, "testQuads");
- PathOpsThreadedTestRunner testRunner(reporter);
+ int threadCount = initializeTests(reporter, "testQuads");
+ PathOpsThreadedTestRunner testRunner(reporter, threadCount);
int a = 0;
for (; a < 16; ++a) {
for (int b = a ; b < 16; ++b) {
diff --git a/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp b/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp
index f8e9a6e3dc..afa9200389 100755
--- a/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp
+++ b/tests/PathOpsSimplifyQuadralateralsThreadedTest.cpp
@@ -76,8 +76,8 @@ static void testSimplifyQuadralateralsMain(PathOpsThreadState* data)
}
DEF_TEST(PathOpsSimplifyQuadralateralsThreaded, reporter) {
- initializeTests(reporter, "testQuadralaterals");
- PathOpsThreadedTestRunner testRunner(reporter);
+ int threadCount = initializeTests(reporter, "testQuadralaterals");
+ PathOpsThreadedTestRunner testRunner(reporter, threadCount);
for (int a = 0; a < 16; ++a) {
for (int b = a ; b < 16; ++b) {
for (int c = b ; c < 16; ++c) {
diff --git a/tests/PathOpsSimplifyRectThreadedTest.cpp b/tests/PathOpsSimplifyRectThreadedTest.cpp
index 52a78ece84..9e6a5eaf03 100644
--- a/tests/PathOpsSimplifyRectThreadedTest.cpp
+++ b/tests/PathOpsSimplifyRectThreadedTest.cpp
@@ -187,8 +187,8 @@ static void testSimplify4x4RectsMain(PathOpsThreadState* data)
}
DEF_TEST(PathOpsSimplifyRectsThreaded, reporter) {
- initializeTests(reporter, "testLine");
- PathOpsThreadedTestRunner testRunner(reporter);
+ int threadCount = initializeTests(reporter, "testLine");
+ PathOpsThreadedTestRunner testRunner(reporter, threadCount);
for (int a = 0; a < 8; ++a) { // outermost
for (int b = a ; b < 8; ++b) {
for (int c = b ; c < 8; ++c) {
diff --git a/tests/PathOpsSimplifyTrianglesThreadedTest.cpp b/tests/PathOpsSimplifyTrianglesThreadedTest.cpp
index ee0ca2bcaa..b5d6508846 100755
--- a/tests/PathOpsSimplifyTrianglesThreadedTest.cpp
+++ b/tests/PathOpsSimplifyTrianglesThreadedTest.cpp
@@ -73,8 +73,8 @@ static void testSimplifyTrianglesMain(PathOpsThreadState* data) {
}
DEF_TEST(PathOpsSimplifyTrianglesThreaded, reporter) {
- initializeTests(reporter, "testTriangles");
- PathOpsThreadedTestRunner testRunner(reporter);
+ int threadCount = initializeTests(reporter, "testTriangles");
+ PathOpsThreadedTestRunner testRunner(reporter, threadCount);
for (int a = 0; a < 15; ++a) {
int ax = a & 0x03;
int ay = a >> 2;
diff --git a/tests/PathOpsSkpClipTest.cpp b/tests/PathOpsSkpClipTest.cpp
index 0769141685..cdc3c1fcd9 100755
--- a/tests/PathOpsSkpClipTest.cpp
+++ b/tests/PathOpsSkpClipTest.cpp
@@ -20,8 +20,8 @@
#include "SkString.h"
#include "SkTArray.h"
#include "SkTDArray.h"
-#include "SkTaskGroup.h"
#include "SkTemplates.h"
+#include "SkThreadPool.h"
#include "SkTime.h"
__SK_FORCE_IMAGE_DECODER_LINKING;
@@ -90,14 +90,14 @@ static SkString get_in_path(int dirNo, const char* filename) {
}
if (filename) {
path.appendf("%s%s", PATH_SLASH, filename);
- if (!sk_exists(path.c_str())) {
+ if (!sk_exists(path.c_str())) {
SkDebugf("could not read %s\n", path.c_str());
return SkString();
}
}
return path;
}
-
+
static void make_recursive_dir(const SkString& path) {
if (sk_exists(path.c_str())) {
return;
@@ -129,7 +129,7 @@ static SkString get_out_path(int dirNo, const char* dirName) {
make_recursive_dir(path);
return path;
}
-
+
static SkString get_sum_path(const char* dirName) {
SkString path;
SkASSERT(dirName);
@@ -166,12 +166,12 @@ struct TestResult {
fTestStep = kCompareBits;
fScale = 1;
}
-
+
void init(int dirNo, const SkString& filename) {
fDirNo = dirNo;
strcpy(fFilename, filename.c_str());
fTestStep = kCompareBits;
- fScale = 1;
+ fScale = 1;
}
SkString status() {
@@ -204,7 +204,7 @@ struct TestResult {
}
void testOne();
-
+
char fFilename[kMaxLength];
TestStep fTestStep;
int fDirNo;
@@ -245,8 +245,13 @@ struct TestState {
};
struct TestRunner {
+ TestRunner(int threadCount)
+ : fNumThreads(threadCount) {
+ }
+
~TestRunner();
void render();
+ int fNumThreads;
SkTDArray<class TestRunnable*> fRunnables;
};
@@ -295,9 +300,9 @@ TestRunner::~TestRunner() {
}
void TestRunner::render() {
- SkTaskGroup tg;
+ SkThreadPool pool(fNumThreads);
for (int index = 0; index < fRunnables.count(); ++ index) {
- tg.add(fRunnables[index]);
+ pool.add(fRunnables[index]);
}
}
@@ -526,12 +531,18 @@ DEFINE_string2(dir, d, NULL, "range of directories (e.g., 1-100)");
DEFINE_string2(skp, s, NULL, "skp to test");
DEFINE_bool2(single, z, false, "run tests on a single thread internally.");
DEFINE_int32(testIndex, 0, "override local test index (PathOpsSkpClipOneOff only).");
+DEFINE_int32(threads, SkThreadPool::kThreadPerCore,
+ "Run threadsafe tests on a threadpool with this many threads.");
DEFINE_bool2(verbose, v, false, "enable verbose output.");
static bool verbose() {
return FLAGS_verbose;
}
+static int getThreadCount() {
+ return FLAGS_single ? 1 : FLAGS_threads;
+}
+
class Dirs {
public:
Dirs() {
@@ -605,7 +616,7 @@ public:
}
return NULL;
}
-
+
void set(const SkCommandLineFlags::StringArray& names) {
fNames = &names;
}
@@ -615,7 +626,7 @@ private:
const SkCommandLineFlags::StringArray* fNames;
} gNames;
-static bool buildTestDir(int dirNo, int firstDirNo,
+static bool buildTestDir(int dirNo, int firstDirNo,
SkTDArray<TestResult>* tests, SkTDArray<SortByName*>* sorted) {
SkString dirName = get_out_path(dirNo, outStatusDir);
if (!dirName.size()) {
@@ -781,7 +792,8 @@ static void encodeFound(TestState& state) {
}
}
}
- TestRunner testRunner;
+ int threadCount = getThreadCount();
+ TestRunner testRunner(threadCount);
for (int index = 0; index < state.fPixelWorst.count(); ++index) {
const TestResult& result = state.fPixelWorst[index];
SkString filename(result.fFilename);
@@ -853,7 +865,8 @@ static void testSkpClipMain(TestState* data) {
DEF_TEST(PathOpsSkpClipThreaded) {
gDirs.setDefault();
initTest();
- TestRunner testRunner;
+ int threadCount = getThreadCount();
+ TestRunner testRunner(threadCount);
int dirNo;
gDirs.reset();
while ((dirNo = gDirs.next()) > 0) {
@@ -876,7 +889,7 @@ DEF_TEST(PathOpsSkpClipThreaded) {
}
encodeFound(state);
}
-
+
static bool buildTests(SkTDArray<TestResult>* tests, SkTDArray<SortByName*>* sorted) {
int firstDirNo = gDirs.first();
int dirNo;
@@ -899,7 +912,8 @@ DEF_TEST(PathOpsSkpClipUberThreaded) {
if (!buildTests(tests.get(), sorted.get())) {
return;
}
- TestRunner testRunner;
+ int threadCount = getThreadCount();
+ TestRunner testRunner(threadCount);
int dirNo;
gDirs.reset();
while ((dirNo = gDirs.next()) > 0) {
diff --git a/tests/PathOpsThreadedCommon.cpp b/tests/PathOpsThreadedCommon.cpp
index 0adde915e0..ac4cd6ba62 100644
--- a/tests/PathOpsThreadedCommon.cpp
+++ b/tests/PathOpsThreadedCommon.cpp
@@ -7,7 +7,7 @@
#include "PathOpsExtendedTest.h"
#include "PathOpsThreadedCommon.h"
-#include "SkTaskGroup.h"
+#include "SkThreadPool.h"
PathOpsThreadedTestRunner::~PathOpsThreadedTestRunner() {
for (int index = 0; index < fRunnables.count(); index++) {
@@ -16,8 +16,8 @@ PathOpsThreadedTestRunner::~PathOpsThreadedTestRunner() {
}
void PathOpsThreadedTestRunner::render() {
- SkTaskGroup tg;
+ SkThreadPool pool(fNumThreads);
for (int index = 0; index < fRunnables.count(); ++ index) {
- tg.add(fRunnables[index]);
+ pool.add(fRunnables[index]);
}
}
diff --git a/tests/PathOpsThreadedCommon.h b/tests/PathOpsThreadedCommon.h
index 124921e389..a638cd2fdf 100644
--- a/tests/PathOpsThreadedCommon.h
+++ b/tests/PathOpsThreadedCommon.h
@@ -33,13 +33,17 @@ struct PathOpsThreadState {
class PathOpsThreadedTestRunner {
public:
- PathOpsThreadedTestRunner(skiatest::Reporter* reporter) : fReporter(reporter) {}
+ PathOpsThreadedTestRunner(skiatest::Reporter* reporter, int threadCount)
+ : fNumThreads(threadCount)
+ , fReporter(reporter) {
+ }
~PathOpsThreadedTestRunner();
void render();
public:
+ int fNumThreads;
SkTDArray<PathOpsThreadedRunnable*> fRunnables;
skiatest::Reporter* fReporter;
};
diff --git a/tests/PathOpsTightBoundsTest.cpp b/tests/PathOpsTightBoundsTest.cpp
index cea37520b1..09f962296f 100644
--- a/tests/PathOpsTightBoundsTest.cpp
+++ b/tests/PathOpsTightBoundsTest.cpp
@@ -35,8 +35,8 @@ static void testTightBoundsLines(PathOpsThreadState* data) {
}
DEF_TEST(PathOpsTightBoundsLines, reporter) {
- initializeTests(reporter, "tightBoundsLines");
- PathOpsThreadedTestRunner testRunner(reporter);
+ int threadCount = initializeTests(reporter, "tightBoundsLines");
+ PathOpsThreadedTestRunner testRunner(reporter, threadCount);
int outerCount = reporter->allowExtendedTest() ? 100 : 1;
for (int index = 0; index < outerCount; ++index) {
for (int idx2 = 0; idx2 < 10; ++idx2) {
@@ -110,8 +110,8 @@ static void testTightBoundsQuads(PathOpsThreadState* data) {
}
DEF_TEST(PathOpsTightBoundsQuads, reporter) {
- initializeTests(reporter, "tightBoundsQuads");
- PathOpsThreadedTestRunner testRunner(reporter);
+ int threadCount = initializeTests(reporter, "tightBoundsQuads");
+ PathOpsThreadedTestRunner testRunner(reporter, threadCount);
int outerCount = reporter->allowExtendedTest() ? 100 : 1;
for (int index = 0; index < outerCount; ++index) {
for (int idx2 = 0; idx2 < 10; ++idx2) {
diff --git a/tests/SkpSkGrTest.cpp b/tests/SkpSkGrTest.cpp
index c882654650..c1883a9890 100644
--- a/tests/SkpSkGrTest.cpp
+++ b/tests/SkpSkGrTest.cpp
@@ -23,7 +23,7 @@
#include "SkString.h"
#include "SkTArray.h"
#include "SkTDArray.h"
-#include "SkTaskGroup.h"
+#include "SkThreadPool.h"
#include "SkTime.h"
#include "Test.h"
@@ -125,12 +125,14 @@ struct SkpSkGrThreadState {
};
struct SkpSkGrThreadedTestRunner {
- SkpSkGrThreadedTestRunner(skiatest::Reporter* reporter)
- : fReporter(reporter) {
+ SkpSkGrThreadedTestRunner(skiatest::Reporter* reporter, int threadCount)
+ : fNumThreads(threadCount)
+ , fReporter(reporter) {
}
~SkpSkGrThreadedTestRunner();
void render();
+ int fNumThreads;
SkTDArray<SkpSkGrThreadedRunnable*> fRunnables;
skiatest::Reporter* fReporter;
};
@@ -162,9 +164,9 @@ SkpSkGrThreadedTestRunner::~SkpSkGrThreadedTestRunner() {
}
void SkpSkGrThreadedTestRunner::render() {
- SkTaskGroup tg;
+ SkThreadPool pool(fNumThreads);
for (int index = 0; index < fRunnables.count(); ++ index) {
- tg.add(fRunnables[index]);
+ pool.add(fRunnables[index]);
}
}
@@ -674,7 +676,8 @@ DEF_TEST(SkpSkGrThreaded, reporter) {
if (!initTest()) {
return;
}
- SkpSkGrThreadedTestRunner testRunner(reporter);
+ int threadCount = reporter->allowThreaded() ? 3 : 1;
+ SkpSkGrThreadedTestRunner testRunner(reporter, threadCount);
for (int dirIndex = 1; dirIndex <= 100; ++dirIndex) {
SkString pictDir = make_in_dir_name(dirIndex);
if (pictDir.size() == 0) {
diff --git a/tests/Test.cpp b/tests/Test.cpp
index d0147e1e4a..20afd45561 100644
--- a/tests/Test.cpp
+++ b/tests/Test.cpp
@@ -75,6 +75,10 @@ protected:
return fReporter->allowExtendedTest();
}
+ virtual bool allowThreaded() const SK_OVERRIDE {
+ return fReporter->allowThreaded();
+ }
+
virtual void bumpTestCount() SK_OVERRIDE {
fReporter->bumpTestCount();
}
diff --git a/tests/Test.h b/tests/Test.h
index 6c85b32bce..72b0bee126 100644
--- a/tests/Test.h
+++ b/tests/Test.h
@@ -32,6 +32,7 @@ namespace skiatest {
void endTest(Test*);
virtual bool allowExtendedTest() const { return false; }
+ virtual bool allowThreaded() const { return false; }
virtual bool verbose() const { return false; }
virtual void bumpTestCount() { sk_atomic_inc(&fTestCount); }
diff --git a/tests/skia_test.cpp b/tests/skia_test.cpp
index a73b6bae53..97ac29b0fd 100644
--- a/tests/skia_test.cpp
+++ b/tests/skia_test.cpp
@@ -12,8 +12,8 @@
#include "SkGraphics.h"
#include "SkOSFile.h"
#include "SkTArray.h"
-#include "SkTaskGroup.h"
#include "SkTemplates.h"
+#include "SkThreadPool.h"
#include "SkTime.h"
#include "Test.h"
@@ -54,6 +54,7 @@ public:
explicit DebugfReporter(int total) : fDone(0), fTotal(total) {}
virtual bool allowExtendedTest() const SK_OVERRIDE { return FLAGS_extendedTest; }
+ virtual bool allowThreaded() const SK_OVERRIDE { return !FLAGS_single; }
virtual bool verbose() const SK_OVERRIDE { return FLAGS_veryVerbose; }
protected:
@@ -174,8 +175,7 @@ int test_main() {
int32_t failCount = 0;
int skipCount = 0;
- SkTaskGroup::SetThreadCount(FLAGS_threads);
- SkTaskGroup cpuTests;
+ SkThreadPool threadpool(FLAGS_threads);
SkTArray<Test*> gpuTests; // Always passes ownership to an SkTestRunnable
DebugfReporter reporter(toRun);
@@ -186,7 +186,7 @@ int test_main() {
} else if (test->isGPUTest()) {
gpuTests.push_back() = test.detach();
} else {
- cpuTests.add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCount)));
+ threadpool.add(SkNEW_ARGS(SkTestRunnable, (test.detach(), &failCount)));
}
}
@@ -204,7 +204,7 @@ int test_main() {
}
// Block until threaded tests finish.
- cpuTests.wait();
+ threadpool.wait();
if (FLAGS_verbose) {
SkDebugf("\nFinished %d tests, %d failures, %d skipped. (%d internal tests)",