FrozenGene commented on issue #4747: [ThreadPool] Solve ARM BIG.LITTLE 
heterogeneous multicores
URL: https://github.com/apache/incubator-tvm/pull/4747#issuecomment-576208993
 
 
   > This approach needs to be added as comments in the code explaining how 
this is expected to work. Further I suspect it is TVM_BIND_MASTER_THREAD that 
you refer to above ? What is the role of the TVM master thread ? Is it another 
thread that does compute or is it a "controlling" thread ?
   
   TVM_BIND_MASTER_THREAD is related with `exclude_worker0` , the default value 
of `exclude_worker0` is false. 
https://github.com/apache/incubator-tvm/blob/master/include/tvm/runtime/threading_backend.h#L50.
 As the comment said, if it is false, we will make main thread compute worker0 
and worker0 will not be launched in a new thread. Normally main thread doesn't 
have much to do. If TVM_BIND_MASTER_THREAD env var is set, we will bind the 
main thread be sored_order_[0] or sored_order_[-1] (if we are in the little 
mode)
   
   So previous solution is let us doesn't bind the master thread be one 
specific core. so that our master thread could run any cores. But previous 
solution omit one situation that ARM CPU has BIG.LITTLE, we can not add all 
cpus to CPU SET. It will result in main thread could run big core (even users 
specify tvm run little cores). Also could run little cores (even users specify 
tvm run big cores).
   
   This PR solves this by restrict tvm master thread's cpu set. That is to say: 
if we are in the little mode, we should restrict master thread run only little 
cores. if we are in the big mode, we should restrict master thread run only big 
cores. Note: This could work well on x86 cpu too. Because x86 cpu doesn't have 
BIG.Little. our code implementation will use big_count_ to calculate the cpu 
cores by default. So master thread could run any cores.
   
   I will add comment to explain a bit in code.
   
   > pthread_atfork IIRC originally comes from the posix group from Issue 5 as 
documented here. Checking the other libcs suggest that all other mainstream 
Linux runtimes like glibc, musl and bionic support this and thus are we working 
around a limitation of AliOS here ?
   
   AliOS like some versions of Android, doesn't provide pthread_atfork. 
However, the key to solve this problem is doesn't restrict master thread bind 
to one specific core. So PR's solution could work fine on Linux / Android too. 
pthread_atfork is not a key or must.
   
   

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to