Using threadprivate directive

General OpenMP discussion

Using threadprivate directive

Postby sqrt2010 » Fri Sep 21, 2012 4:42 pm

Hi,

An OpenMP implementation in Visual Studio 2010 has a serious bug that does not allow to have external variables as threadprivate. The the following code would not compile:

file.c

-----

#include <omp.h>

/* Declaration of external variable. */

extern int My_Var;

#pragma omp threadprivate (My_Var)

void MyFunc(void) { My_Var = 1;}

---------

The error message is:

error C3053:
'My_Var' : 'threadprivate' is only valid for global or static data tems.

Clearly the compiler is confused about linkage attribute of the variable.

It is most common to refer global variables in multiple files. So this problem makes threadprivate directive unusable in any realistic program.

I wonder if there are tricks to handle this bug. Unfortunately in my case this problem prevents me to use OMP completely.

Thank you,



Alex
sqrt2010
 
Posts: 1
Joined: Fri Sep 21, 2012 3:35 am

Re: Using threadprivate directive

Postby MarkB » Tue Sep 25, 2012 2:16 am

Hi Alex,

I see you got a workaround over on stackoverflow http://stackoverflow.com/questions/1256 ... ual-studio

As far as I know, the Visual Studio implementation of OpenMP is not under active development and has not progressed beyond OpenMP 2.0. You might want to consider using a different compiler, if at all possible.

Mark.
MarkB
 
Posts: 481
Joined: Thu Jan 08, 2009 10:12 am
Location: EPCC, University of Edinburgh


Return to Using OpenMP

Who is online

Users browsing this forum: No registered users and 8 guests