Thread Subject: omp_get_num_threads() (again)

Subject: omp_get_num_threads() (again)

From: Sebastiaan

Date: 29 May, 2008 13:49:01

Message: 1 of 1

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());
}

Tags for this Thread

Everyone's Tags:

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Tag Activity for This Thread
Tag Applied By Date/Time
openmp Sebastiaan 29 May, 2008 09:50:26
omp Sebastiaan 29 May, 2008 09:50:26
mex Sebastiaan 29 May, 2008 09:50:26
rssFeed for this Thread

Contact us at files@mathworks.com