huajsj commented on a change in pull request #9802:
URL: https://github.com/apache/tvm/pull/9802#discussion_r815082009
##########
File path: src/runtime/thread_pool.cc
##########
@@ -373,13 +375,28 @@
TVM_REGISTER_GLOBAL("runtime.config_threadpool").set_body([](TVMArgs args, TVMRe
threading::ThreadGroup::AffinityMode mode =
static_cast<threading::ThreadGroup::AffinityMode>(static_cast<int>(args[0]));
int nthreads = args[1];
- ThreadPool::ThreadLocal()->UpdateWorkerConfiguration(mode, nthreads);
+ std::vector<unsigned int> cpus;
+ int max_concurrency = 0;
+ if (args.num_args == 3) {
+ Array<String> cpu_array = args[2];
+ for (auto cpu : cpu_array) {
+ cpus.push_back(std::stoi(cpu));
Review comment:
Sorry for the misunderstanding. following are the answer
> What you want to do is to restrict tvm thread run on specific cpu core ids?
Yes, restrict the worker thread running on specific cpu core or cpu core
groups
> how to handle Python's API interface?
the supported use case like following
`config_threadpool('-1', 2, ['1', '2', '3'])`
>And how to handle the specific core ids is greater than the 2nd
argument(i.e. how many threads to lauch).
In existing logic, the second parameter is not used to determine how many
worker threads to launch, it is used as
a default value about how many task in a parallel running should be used
when task number not get set.
and the final value of task number is the minimize of 'max_cocurrency' and
this value .
The thread launched number determine by 'max_concurrency', in our solution
,this value will be the cpu id list size.
Under this solution, for example when cpu list is ['2', '8', '9'], nthreads
is 2, exclude_worker0 is true(default) following will happen.
1. mode is 'kSpecifyOneCorePerThread',
1.1. 3 worker thread get launched , cpu affinity like following
T1 (2-9)
T2 (8)
T3 (9)
1.2 when run the task
task1 --> T1
task2 --> T2
2. mode is 'kSpecifyThreadShareAllCore',
2.1 3 worker thread get launched , cpu affinity like following
T1 (2-9)
T2 (2-9)
T3 (2-9)
2.2 when run the task
task1 --> T1
task2 --> T2
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]