GOMP_CPU_AFFINITY="0 3 1-2 4-15:2" will bind the initial thread to CPU 0, the second to CPU 3, the third to CPU 1, the fourth to CPU 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 of the list.
GOMP_CPU_AFFINITY=0 binds all threads to CPU 0.
There is no GNU OpenMP library routine to determine whether a CPU affinity specification is in effect. As a workaround, language-specific library functions, e.g., getenv in C or GET_ENVIRONMENT_VARIABLE in Fortran, may be used to query the setting of the GOMP_CPU_AFFINITY environment variable. A defined CPU affinity on startup cannot be changed or 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 and OMP_PROC_BIND is unset, or when OMP_PROC_BIND is set to FALSE, the host system will handle the assignment of threads to CPUs.
See also:
http://gcc.gnu.org/onlinedocs/libgomp/GOMP_005fCPU_005fAFFINITY.html#GOMP_005fCPU_005fAFFINITY

本文介绍了GOMP_CPU_AFFINITY环境变量的作用及其配置方式,该变量用于将线程绑定到特定的CPU核心上,以实现更高效的并行处理。文中详细解释了如何设置该变量来指定线程与CPU的对应关系,并说明了其与OMP_PROC_BIND之间的优先级关系。
1173

被折叠的 条评论
为什么被折叠?



