|
The omp_get_num_threads() does not work properly, as well as
similar functions for getting the maximum number of threads etc.
The problem is that omp_get_num_threads() always returns 1,
no matter to what maxNumCompThreads() is set in Matlab.
This was previously reported in this newsgroup:
http://www.mathworks.com/matlabcentral/newsreader/view_thread/157701#416259
The solution given there is to:
>> setenv('OMP_NUM_THREADS','2')
>> maxNumCompThreads(2)
However, this does not work for me in 2008a and 2007b
(x86_64 Linux). The observation by CPU usage is however,
that the loops are parallellized properly.
I would like to use omp_get_num_threads() to default to a
(faster) sequential code when only 1 thread is used.
This is a test listing I used, compiled with Intel C
compiler version 10.
Thanks,
Sebastiaan
#include "mex.h"
#include <omp.h>
void mexFunction(int nlhs, mxArray* plhs[], int nrhs, const
mxArray* prhs[])
{
mexPrintf("Num threads %d.\n", omp_get_num_threads());
}
|