aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--BUILD.public2
-rw-r--r--cmake/CMakeLists.txt5
-rw-r--r--gyp/utils.gyp11
-rw-r--r--gyp/utils.gypi3
-rw-r--r--src/utils/SkThreadUtils.h7
-rw-r--r--src/utils/SkThreadUtils_pthread_linux.cpp46
-rw-r--r--src/utils/SkThreadUtils_pthread_mach.cpp30
-rw-r--r--src/utils/SkThreadUtils_pthread_other.cpp12
-rw-r--r--src/utils/SkThreadUtils_win.cpp40
-rw-r--r--tests/AtomicTest.cpp8
-rw-r--r--tests/RefCntTest.cpp8
11 files changed, 5 insertions, 167 deletions
diff --git a/BUILD.public b/BUILD.public
index d806214f0e..322310acef 100644
--- a/BUILD.public
+++ b/BUILD.public
@@ -31,8 +31,6 @@ SRCS = glob(
"src/ports/**/*",
"src/utils/android/**/*",
"src/utils/mac/**/*",
- "src/utils/SkThreadUtils_pthread_mach.cpp", # Mac-only. Move to ports?
- "src/utils/SkThreadUtils_pthread_other.cpp", # Non-Mac-non-Linux. Move to ports?
"src/utils/SkThreadUtils_win.cpp", # Windows-only. Move to ports?
"src/utils/win/**/*",
"src/views/sdl/*",
diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index ab6952f1e4..55539d02d6 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -47,8 +47,6 @@ remove_srcs (../src/ports/SkFontHost_fontconfig.cpp
../src/ports/SkFontConfigInterface_direct.cpp)
# Alternative font managers.
remove_srcs (../src/ports/SkFontMgr_custom*.cpp)
-# Not actually used by Skia.
-remove_srcs (../src/utils/SkThreadUtils_pthread_*.cpp)
# Skia sure ships a lot of code no one uses.
remove_srcs (../src/animator/* ../src/*nacl* ../src/svg/* ../src/views/* ../src/xml/*)
@@ -66,8 +64,7 @@ if (NOT UNIX)
../src/ports/SkOSFile_posix.cpp
../src/ports/SkTLS_pthread.cpp
../src/ports/SkTime_Unix.cpp
- ../src/utils/SkThreadUtils_pthread.cpp
- ../src/utils/SkThreadUtils_pthread_other.cpp)
+ ../src/utils/SkThreadUtils_pthread.cpp)
endif()
if (APPLE OR NOT UNIX)
remove_srcs(../src/gpu/gl/glx/*
diff --git a/gyp/utils.gyp b/gyp/utils.gyp
index e677b2a089..9e78c528f0 100644
--- a/gyp/utils.gyp
+++ b/gyp/utils.gyp
@@ -51,9 +51,6 @@
'../include/utils/mac',
],
},
- 'sources!': [
- '../src/utils/SkThreadUtils_pthread_other.cpp',
- ],
},{ #else if 'skia_os != "mac"'
'include_dirs!': [
'../include/utils/mac',
@@ -61,20 +58,13 @@
'sources!': [
'../include/utils/mac/SkCGUtils.h',
'../src/utils/mac/SkCreateCGImageRef.cpp',
- '../src/utils/SkThreadUtils_pthread_mach.cpp',
],
}],
[ 'skia_os in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]', {
- 'sources!': [
- '../src/utils/SkThreadUtils_pthread_other.cpp',
- ],
},{ #else if 'skia_os not in ["linux", "freebsd", "openbsd", "solaris", "chromeos"]'
'include_dirs!': [
'../include/utils/unix',
],
- 'sources!': [
- '../src/utils/SkThreadUtils_pthread_linux.cpp',
- ],
}],
[ 'skia_os == "win"', {
'direct_dependent_settings': {
@@ -85,7 +75,6 @@
'sources!': [
'../src/utils/SkThreadUtils_pthread.cpp',
'../src/utils/SkThreadUtils_pthread.h',
- '../src/utils/SkThreadUtils_pthread_other.cpp',
],
},{ #else if 'skia_os != "win"'
'include_dirs!': [
diff --git a/gyp/utils.gypi b/gyp/utils.gypi
index 089e3fc3a8..4359805a2e 100644
--- a/gyp/utils.gypi
+++ b/gyp/utils.gypi
@@ -96,9 +96,6 @@
'<(skia_src_path)/utils/SkThreadUtils.h',
'<(skia_src_path)/utils/SkThreadUtils_pthread.cpp',
'<(skia_src_path)/utils/SkThreadUtils_pthread.h',
- '<(skia_src_path)/utils/SkThreadUtils_pthread_linux.cpp',
- '<(skia_src_path)/utils/SkThreadUtils_pthread_mach.cpp',
- '<(skia_src_path)/utils/SkThreadUtils_pthread_other.cpp',
'<(skia_src_path)/utils/SkThreadUtils_win.cpp',
'<(skia_src_path)/utils/SkThreadUtils_win.h',
'<(skia_src_path)/utils/SkTFitsIn.h',
diff --git a/src/utils/SkThreadUtils.h b/src/utils/SkThreadUtils.h
index e89bc6d09b..d9fc99d397 100644
--- a/src/utils/SkThreadUtils.h
+++ b/src/utils/SkThreadUtils.h
@@ -32,13 +32,6 @@ public:
*/
void join();
- /**
- * SkThreads with an affinity for the same processor will attempt to run cache
- * locally with each other. SkThreads with an affinity for different processors
- * will attempt to run on different cores. Returns false if the request failed.
- */
- bool setProcessorAffinity(unsigned int processor);
-
private:
void* fData;
};
diff --git a/src/utils/SkThreadUtils_pthread_linux.cpp b/src/utils/SkThreadUtils_pthread_linux.cpp
deleted file mode 100644
index 4a03cb8276..0000000000
--- a/src/utils/SkThreadUtils_pthread_linux.cpp
+++ /dev/null
@@ -1,46 +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.
- */
-
-#ifndef _GNU_SOURCE
-#define _GNU_SOURCE //for pthread_setaffinity_np
-#endif
-
-#include "SkThreadUtils.h"
-#include "SkThreadUtils_pthread.h"
-
-#include <pthread.h>
-
-static int nth_set_cpu(unsigned int n, cpu_set_t* cpuSet) {
- n %= CPU_COUNT(cpuSet);
- for (unsigned int setCpusSeen = 0, currentCpu = 0; true; ++currentCpu) {
- if (CPU_ISSET(currentCpu, cpuSet)) {
- ++setCpusSeen;
- if (setCpusSeen > n) {
- return currentCpu;
- }
- }
- }
-}
-
-bool SkThread::setProcessorAffinity(unsigned int processor) {
- SkThread_PThreadData* pthreadData = static_cast<SkThread_PThreadData*>(fData);
- if (!pthreadData->fValidPThread) {
- return false;
- }
-
- cpu_set_t parentCpuset;
- if (0 != pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &parentCpuset)) {
- return false;
- }
-
- cpu_set_t cpuset;
- CPU_ZERO(&cpuset);
- CPU_SET(nth_set_cpu(processor, &parentCpuset), &cpuset);
- return 0 == pthread_setaffinity_np(pthreadData->fPThread,
- sizeof(cpu_set_t),
- &cpuset);
-}
diff --git a/src/utils/SkThreadUtils_pthread_mach.cpp b/src/utils/SkThreadUtils_pthread_mach.cpp
deleted file mode 100644
index 0f6e263906..0000000000
--- a/src/utils/SkThreadUtils_pthread_mach.cpp
+++ /dev/null
@@ -1,30 +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 "SkThreadUtils.h"
-#include "SkThreadUtils_pthread.h"
-
-#include <mach/mach.h>
-#include <mach/thread_policy.h>
-#include <pthread.h>
-
-bool SkThread::setProcessorAffinity(unsigned int processor) {
- SkThread_PThreadData* pthreadData = static_cast<SkThread_PThreadData*>(fData);
- if (!pthreadData->fValidPThread) {
- return false;
- }
-
- mach_port_t tid = pthread_mach_thread_np(pthreadData->fPThread);
-
- thread_affinity_policy_data_t policy;
- policy.affinity_tag = processor;
-
- return 0 == thread_policy_set(tid,
- THREAD_AFFINITY_POLICY,
- (thread_policy_t) &policy,
- THREAD_AFFINITY_POLICY_COUNT);
-}
diff --git a/src/utils/SkThreadUtils_pthread_other.cpp b/src/utils/SkThreadUtils_pthread_other.cpp
deleted file mode 100644
index a3973f1d72..0000000000
--- a/src/utils/SkThreadUtils_pthread_other.cpp
+++ /dev/null
@@ -1,12 +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 "SkThreadUtils.h"
-
-bool SkThread::setProcessorAffinity(unsigned int processor) {
- return false;
-}
diff --git a/src/utils/SkThreadUtils_win.cpp b/src/utils/SkThreadUtils_win.cpp
index a5efb939f3..07cceee142 100644
--- a/src/utils/SkThreadUtils_win.cpp
+++ b/src/utils/SkThreadUtils_win.cpp
@@ -53,7 +53,7 @@ SkThread::SkThread(entryPointProc entryPoint, void* data) {
0, // use default stack size
thread_start, // thread function name (proxy)
winData, // argument to thread function (proxy args)
- CREATE_SUSPENDED, // create suspended so affinity can be set
+ CREATE_SUSPENDED, // we used to set processor affinity, which needed this
&winData->fThreadId); // returns the thread identifier
}
@@ -96,41 +96,3 @@ void SkThread::join() {
WaitForSingleObject(winData->fHandle, INFINITE);
}
-
-static unsigned int num_bits_set(DWORD_PTR mask) {
- unsigned int count;
- for (count = 0; mask; ++count) {
- mask &= mask - 1;
- }
- return count;
-}
-
-static unsigned int nth_set_bit(unsigned int n, DWORD_PTR mask) {
- n %= num_bits_set(mask);
- for (unsigned int setBitsSeen = 0, currentBit = 0; true; ++currentBit) {
- if (mask & (static_cast<DWORD_PTR>(1) << currentBit)) {
- ++setBitsSeen;
- if (setBitsSeen > n) {
- return currentBit;
- }
- }
- }
-}
-
-bool SkThread::setProcessorAffinity(unsigned int processor) {
- SkThread_WinData* winData = static_cast<SkThread_WinData*>(fData);
- if (nullptr == winData->fHandle) {
- return false;
- }
-
- DWORD_PTR processAffinityMask;
- DWORD_PTR systemAffinityMask;
- if (0 == GetProcessAffinityMask(GetCurrentProcess(),
- &processAffinityMask,
- &systemAffinityMask)) {
- return false;
- }
-
- DWORD_PTR threadAffinityMask = 1 << nth_set_bit(processor, processAffinityMask);
- return 0 != SetThreadAffinityMask(winData->fHandle, threadAffinityMask);
-}
diff --git a/tests/AtomicTest.cpp b/tests/AtomicTest.cpp
index e9db3f093d..530fba79d5 100644
--- a/tests/AtomicTest.cpp
+++ b/tests/AtomicTest.cpp
@@ -13,15 +13,14 @@
struct AddInfo {
int32_t valueToAdd;
int timesToAdd;
- unsigned int processorAffinity;
};
static int32_t base = 0;
static AddInfo gAdds[] = {
- { 3, 100, 23 },
- { 2, 200, 2 },
- { 7, 150, 17 },
+ { 3, 100 },
+ { 2, 200 },
+ { 7, 150 },
};
static void addABunchOfTimes(void* data) {
@@ -40,7 +39,6 @@ DEF_TEST(Atomic, reporter) {
// Start the threads
for (size_t i = 0; i < SK_ARRAY_COUNT(gAdds); i++) {
threads[i] = new SkThread(addABunchOfTimes, &gAdds[i]);
- threads[i]->setProcessorAffinity(gAdds[i].processorAffinity);
threads[i]->start();
}
diff --git a/tests/RefCntTest.cpp b/tests/RefCntTest.cpp
index b73618d9f3..6a1e0dc2fe 100644
--- a/tests/RefCntTest.cpp
+++ b/tests/RefCntTest.cpp
@@ -25,9 +25,6 @@ static void test_refCnt(skiatest::Reporter* reporter) {
SkThread thing1(bounce_ref, ref);
SkThread thing2(bounce_ref, ref);
- thing1.setProcessorAffinity(0);
- thing2.setProcessorAffinity(23);
-
SkASSERT(thing1.start());
SkASSERT(thing2.start());
@@ -63,11 +60,6 @@ static void test_weakRefCnt(skiatest::Reporter* reporter) {
SkThread thing3(bounce_weak_ref, ref);
SkThread thing4(bounce_weak_weak_ref, ref);
- thing1.setProcessorAffinity(0);
- thing2.setProcessorAffinity(23);
- thing3.setProcessorAffinity(2);
- thing4.setProcessorAffinity(17);
-
SkASSERT(thing1.start());
SkASSERT(thing2.start());
SkASSERT(thing3.start());