You are viewing a plain text version of this content. The canonical link for it is here.
Posted to discuss-archive@tvm.apache.org by popojames via Apache TVM Discuss <no...@discuss.tvm.ai> on 2021/10/23 22:18:13 UTC

[Apache TVM Discuss] [Questions] Setting the CPU affinity and number of cores locally without RPC Remote


Hello,

This is a continuing discussion from [Use all cores in a big.LITTLE architecture](https://discuss.tvm.apache.org/t/use-all-cores-in-a-big-little-architecture/8474/6):

I am wondering how can we adjust CPU affinity and the numbers of the thread **locally** without using "remote setting".

Now I was able to set the numbers of the thread through RPC.remtoe as the previous discussion shows (command as shown below).

[quote="FrozenGene, post:5, topic:8474"]
```
config_threadpool = remote.get_function('runtime.config_threadpool')
# affinity_mode: kBig = 1, kLittle = -1. kDefault = 0. pass 1 or -1 to control the cores
config_threadpool(affinity_mode, num_threads)
```
[/quote]
![image|499x132](upload://aU8dBFtLwvKmum9dL6qJinG0vdP.png) 


However, I am still wondering can we set it locally without RPC Remote like the following figure shows? According to https://discuss.tvm.apache.org/t/can-tvm-split-work-into-different-layers-and-assign-layers-into-different-cores/11161/10?u=popojames, it seems it is possible to do so. 

![image|354x108](upload://7FafocynhTfwzAiSAFiRTsJaYlJ.png) 


Does anyone have any idea about this question?
Thanks :)

cc @FrozenGene  @hjiang





---
[Visit Topic](https://discuss.tvm.apache.org/t/setting-the-cpu-affinity-and-number-of-cores-locally-without-rpc-remote/11306/1) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/32a65e14e3ffb130762cb17d057eeafac13e92201ff9d16d68364eaedb9c39d7).

[Apache TVM Discuss] [Questions] Setting the CPU affinity and number of cores locally without RPC Remote

Posted by popojames via Apache TVM Discuss <no...@discuss.tvm.ai>.

This problem is fixed by myslef. 
I was able to set it locally without RPC Remote.

![image|354x108](upload://7FafocynhTfwzAiSAFiRTsJaYlJ.png) 

What I did is very similar with the aforementioned setting: hooks c++ into python
[quote="popojames, post:3, topic:11306"]
I tried to create a function in “module” (python/runtime/module.py) that hooks c++ into python so that I can directly use

> module.module.get_global_function(‘runtime.config_threadpool’)
[/quote]

In my **python/runtime/module.py**, I add "conf_set" function inside,
![image|421x299](upload://5U28DTqf16stVmjaKrEePaqez5h.png)

to set the configuration, I can direct use this command just like we did in remote.get_function
>     config_threadpool = module.module.config_set(remote.get_function('runtime.config_threadpool')





---
[Visit Topic](https://discuss.tvm.apache.org/t/setting-the-cpu-affinity-and-number-of-cores-locally-without-rpc-remote/11306/4) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/f141ac5dc840c482d50f470d9f3da5b2d532c7ee96d5c5a5b873f21a7bc118ee).

[Apache TVM Discuss] [Questions] Setting the CPU affinity and number of cores locally without RPC Remote

Posted by popojames via Apache TVM Discuss <no...@discuss.tvm.ai>.



According to this post:
[quote="FrozenGene, post:5, topic:8474"]
I assume you have got ‘remote’ handle correctly. Then we could get the func:

```
config_threadpool = remote.get_function('runtime.config_threadpool')
# affinity_mode: kBig = 1, kLittle = -1. kDefault = 0. pass 1 or -1 to control the cores
config_threadpool(affinity_mode, num_threads)
```
[/quote]

I tried to create a function in "module" (python/runtime/module.py) that hooks c++ into python so that I can directly use 

> module.module.get_global_function('runtime.config_threadpool')

, which is very similar to what we did in remote.get_function('runtime.config_threadpool')


remote is "RPsession(object)" with "get_function" which use "get_global_function" that can get global function. Therefore, I put **get_global_function** into **python/runtime/module.py**

![image|478x339](upload://3lskz0fuRFAnJtRJIDLyis945Pi.png) 

And  **python/runtime/module.py** will use ""get_global_func"" from **tvm/_ffi/_ctypes/packed_func.py**
![image|570x217](upload://zw9SsYYuidP85MDlz1HJlM2Tc4n.png)


May I ask are the above steps the correct way to follow to enable such setting?





---
[Visit Topic](https://discuss.tvm.apache.org/t/setting-the-cpu-affinity-and-number-of-cores-locally-without-rpc-remote/11306/3) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/1317f6dfdd441a78946027e612cfc6c1b1397d19c7c4b8648e30f2df0c84ede5).

[Apache TVM Discuss] [Questions] Setting the CPU affinity and number of cores locally without RPC Remote

Posted by popojames via Apache TVM Discuss <no...@discuss.tvm.ai>.

To be more precise on this question, I am working on Hikey 970 with 4 little cores (core id: 0123) and 4 big cores (core id:4567). I am working on splitting the entire relay graph into graphs and running it in pipeline format.

I know that with the following command, I can control the CPU number of threads **locally.**
>     export TVM_BIND_THREADS=1 (enable CPU affinity)
>     export TVM_NUM_THREADS= N (N=1~4  control Number of CPU you wanna use)

However, I have two questions on this problem:

1. This command only allows me to use 1/2/3/4 big cores only and it seems that the default setting doesn't allow users to use the small cores. Even if I set TVM_NUM_THREADS larger than 4, it still uses 4 big cores only. Is it possible to use small cores, or big and small cores (e.g. 3 big 4 small)?

2. Moreover, this command would set all of the benchmarks using assign cores. Since I split the original graph into subgraphs, what I would like to have is actually **assigning specific subgraphs to use specific cores** (something like subgraph 0 -> 2 big cores, subgraph 1 -> 2 big cores, subgraph 2 -> 4 small cores) instead of changing the entire setting globally.

@hjiang may I ask is it possible to share some of your implementations even though it's still under development?





---
[Visit Topic](https://discuss.tvm.apache.org/t/setting-the-cpu-affinity-and-number-of-cores-locally-without-rpc-remote/11306/2) to respond.

You are receiving this because you enabled mailing list mode.

To unsubscribe from these emails, [click here](https://discuss.tvm.apache.org/email/unsubscribe/df6080c5cf22df9b044823702fe9fdb7116587297e41300ba085184042c1e297).