Thread Subject: omp_get_num_threads() (again)

Subject: omp_get_num_threads() (again)

From: Sebastiaan

Date: 29 May, 2008 13:48:02

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:25
omp Sebastiaan 29 May, 2008 09:50:25
mex Sebastiaan 29 May, 2008 09:50:25
rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com