This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 169981 - OpenMP option does not work
Summary: OpenMP option does not work
Status: RESOLVED WORKSFORME
Alias: None
Product: cnd
Classification: Unclassified
Component: Project (show other bugs)
Version: 7.3.1
Hardware: Sun Linux
: P2 blocker (vote)
Assignee: Thomas Preisler
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2009-08-06 13:13 UTC by nnnnnk
Modified: 2013-09-26 12:16 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description nnnnnk 2009-08-06 13:13:30 UTC
Sun Studio 12.1.
It seems that "OpenMP" parameter for "Multithreading Level" does not work.
Comment 1 Thomas Preisler 2009-08-06 13:24:40 UTC
What do you mean by 'does not work'? Does the project not set the option, or does the compiler not like the option the project sets, or does the compiler do 
something wrong?
Comment 2 nnnnnk 2009-08-06 13:54:08 UTC
The reason is that default threads number for parallelization is 1.

So you have to add function call like 
omp_set_num_threads(4);

Also it's possible to set OMP_NUM_THREADS and OMP_DYNAMIC environment variables.
Comment 3 Leonid Lenyashin 2009-08-06 15:37:05 UTC
It is better to use OMP_DYNAMIC rather than anything else. Shouldn't we just add this variable to all "Runs" by default?
Comment 4 Alexander Pepin 2010-04-03 19:09:43 UTC
do we need this to be fixed for OSS?
Comment 5 Leonid Lenyashin 2010-04-22 17:33:24 UTC
Yes. We need it. Upgrading to P2.
Comment 6 Thomas Preisler 2010-04-26 22:43:19 UTC
Trying to figure out what the best way to solve this issue is.....
Comment 7 Thomas Preisler 2010-04-28 22:50:01 UTC
OK, here is how I decided to fix it:

1) On Solaris and Linux OMP_NUM_THREADS=2 is added to all run and debug sessions, unless OMP_NUM_THREADS is already set in user's environment or in the Run|Environment project properties.

2) Added the following hint  to the Multithreading Level property in the compiler project properties:
Note for OpenMP on Solaris and Linux: unless already defined, the IDE will set the maximum number of threads the program can create to 2 via the environment variable OMP_NUM_THREADS. Go to the Run|Environment property in the project properties and set OMP_NUM_THREADS to the number of your choice if you want to change this.

So, if user is using a managed project, he will see the hint (which is displayed in the same panel right below the properties) and understand the IDE changes the environment so his app will run multithreaded and understand how he can control this.

I chose the number of threads to 2 because it will probably be the new default in the next compiler generation. We are considering setting the number to the actual number of available cores, but need an API to retrieve this number.
Comment 8 Quality Engineering 2010-05-01 05:17:29 UTC
Integrated into 'main-golden', will be available in build *201005010200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/
User: 
Log:
Comment 9 SATISH510 2013-09-26 09:57:04 UTC
omp_set_num_threads() command not working in NetBeans....
How can we set the OMP_NUM_THREADS in NetBeans
Comment 10 Alexander Simon 2013-09-26 12:16:00 UTC
(In reply to SATISH510 from comment #9)
> omp_set_num_threads() command not working in NetBeans....
> How can we set the OMP_NUM_THREADS in NetBeans
Please file separate bug.