固定特定的线程到特定的CPU

https://gcc.gnu.org/onlinedocs/libgomp/GOMP_005fCPU_005fAFFINITY.html



Description:
Binds threads to specific CPUs. The variable should contain a space-separatedor comma-separated list of CPUs. This list may contain different kinds ofentries: either single CPU numbers in any order, a range of CPUs (M-N)or a range with some stride (M-N:S). CPU numbers are zero based. For example, GOMP_CPU_AFFINITY="0 3 1-2 4-15:2" will bind the initial threadto CPU 0, the second to CPU 3, the third to CPU 1, the fourth toCPU 2, the fifth to CPU 4, the sixth through tenth to CPUs 6, 8, 10, 12,and 14 respectively and then start assigning back from the beginning ofthe list. GOMP_CPU_AFFINITY=0 binds all threads to CPU 0.

There is no libgomp library routine to determine whether a CPU affinityspecification is in effect. As a workaround, language-specific libraryfunctions, e.g., getenv in C or GET_ENVIRONMENT_VARIABLE inFortran, may be used to query the setting of the GOMP_CPU_AFFINITYenvironment variable. A defined CPU affinity on startup cannot be changedor disabled during the runtime of the application.

If both GOMP_CPU_AFFINITY and OMP_PROC_BIND are set,OMP_PROC_BIND has a higher precedence. If neither has been set andOMP_PROC_BIND is unset, or when OMP_PROC_BIND is set toFALSE, the host system will handle the assignment of threads to CPUs.

See also:
OMP_PLACES, OMP_PROC_BIND

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值