You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tvm.apache.org by GitBox <gi...@apache.org> on 2022/10/21 00:50:47 UTC
[GitHub] [tvm] Wanger-SJTU commented on a diff in pull request #13158: [Bugfix][Runtime] Fix sched_setaffinity in Android
Wanger-SJTU commented on code in PR #13158:
URL: https://github.com/apache/tvm/pull/13158#discussion_r1001252288
##########
src/runtime/threading_backend.cc:
##########
@@ -167,7 +169,9 @@ class ThreadGroup::Impl {
CPU_SET(id, &cpuset);
}
#if defined(__ANDROID__)
- sched_setaffinity(thread, sizeof(cpu_set_t), &cpuset);
+ if (sched_setaffinity(pthread_gettid_np(thread), sizeof(cpu_set_t), &cpuset) != 0) {
Review Comment:
If on older versions than Android21+, there could be compile error with no func found. In this case, could be record the tid
like
```cpp
std::mutex m;
std::map<std::thread::id, pid_t> threads;
void add_tid_mapping()
{
std::lock_guard<std::mutex> l(m);
threads[std::this_thread::get_id()] = syscall(SYS_gettid);
}
void wrap(void (*f)())
{
add_tid_mapping();
f();
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@tvm.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org