c++ - How control which numa node executes my program -


i have server 4 numa nodes each having 8 cores hyper threading. have 64 logical cpus.

i have programs producing data , other programs consuming data. these programs written in c++ (11). want start number of producers , number of consumers programs.

to maximize performance control program instances execute. in other words consumer-program should on same numa node corresponding producer.

in end need control core program running on.

i'm using c++ (11).

how can control way programs distributed?

edit: maybe should add server running linux. solution linux great solution supporting both linux , windows better.

this code should make thread run on specific core or subset of cores -- core 17 , 18 in example;

cpu_set_t cpuset; cpu_zero(&cpuset); cpu_set(17, &cpuset); cpu_set(18, &cpuset); if (pthread_setaffinity_np(thread[0], sizeof(cpu_set_t), &cpuset) != 0)     throw error"failed set affinity thread");   

you can allow thread have affinity multiple number of cores, can setup mask core on same cpu allowable, or tinker allowable set maximum l2/l3 cache performance.

you can write own logic around sniplet allowing remaining threads on other cores.

this still works in in case have multiple processes want control, instead of multiple threads, need either determine core allocation ahead of time, or create external service each program can ask set of core allowable.


Popular posts from this blog