Setting Matlab thread affinity in Linux
Show older comments
Hello, I was wondering if there is a way to set thread affinity in matlab. Basically, I have a mex file with openmp and if I set the number of cores to say, 6, then when I open system manager it shows these threads jumping between cores. I don't need to set threads to specific cores (although this feature would be nice), I just need to make sure once they're assigned a core that they stay there. I tried the following:
!export OMP_PROC_BIND=true
Before running the program but this option doesn't work. Also, I'm using R2011b with ubuntu 11.04 64bit. Thanks.
Accepted Answer
More Answers (1)
Walter Roberson
on 5 Apr 2012
I have no information about that, but I do know that that !export would not work. Instead call
setenv('OMP_PROC_BIND','true');
When you use !export OMP_PROC_BIND=true then you set the environment variable only in the subshell that is created to handle the '!' command, and then that subshell exits leaving MATLAB and further subshells unchanged. Calling setenv() from MATLAB affects all following subshells.
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!