Commit e374abf8 by Pariksheet Pinjari Committed by Tianqi Chen

Bug fix for Android platforms (https://github.com/dmlc/tvm/pull/971) (#986)

parent f11f6b4e
......@@ -355,6 +355,7 @@ class ThreadPool {
// bind worker threads to disjoint cores
void SetThreadAffinity() {
#if defined(__ANDROID__)
#ifndef CPU_SET
#define CPU_SETSIZE 1024
#define __NCPUBITS (8 * sizeof (uint64_t))
typedef struct {
......@@ -366,14 +367,19 @@ class ThreadPool {
#define CPU_ZERO(cpusetp) \
memset((cpusetp), 0, sizeof(cpu_set_t))
#endif
#endif
for (int i=0; i < num_workers_; ++i) {
#if defined(__linux__) || defined(__ANDROID__)
cpu_set_t cpuset;
CPU_ZERO(&cpuset);
CPU_SET(i, &cpuset);
#if defined(__ANDROID__)
sched_setaffinity(threads_[i].native_handle(), sizeof(cpu_set_t), &cpuset);
#else
pthread_setaffinity_np(threads_[i].native_handle(),
sizeof(cpu_set_t), &cpuset);
#endif
#endif
}
}
// Number of workers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment