- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
#include
#include
using namespace std;
int main(void){
int a[100];
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i=0;i<100;i++)
{
a=i*i;
}
system("pwd");
return 0;
}
This code works if it is compiled without -openmp.
But when it is compiled with -openmp, the program stops at the end of the code.
This happened when I upgraded from Ubuntu 10.10 to 11.04.
This problem didn't occur on Ubuntu 10.10.
Also, if I use g++ with -fopenmp, the program works.
The compiler version is 12.0.4.
I don't know if this is due to the compiler or OS.
Does someone have the same problem?
Is there a way to solve this issue?
#include
using namespace std;
int main(void){
int a[100];
#ifdef _OPENMP
#pragma omp parallel for
#endif
for (int i=0;i<100;i++)
{
a=i*i;
}
system("pwd");
return 0;
}
This code works if it is compiled without -openmp.
But when it is compiled with -openmp, the program stops at the end of the code.
This happened when I upgraded from Ubuntu 10.10 to 11.04.
This problem didn't occur on Ubuntu 10.10.
Also, if I use g++ with -fopenmp, the program works.
The compiler version is 12.0.4.
I don't know if this is due to the compiler or OS.
Does someone have the same problem?
Is there a way to solve this issue?
Link Copied
3 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
When -fopenmp is not used
#pragma omp parallel for
is an ignored #pragma
Therefor you do not require the conditional#ifdef _OPENMP around #pragma omp parallel for
If after removing the #ifdef _OPENMP and #endif (leaving #pragma omp parallel for) and the program does not run properly then check to make sure you are linking in the appropriate libraries.
Jim Dempsey
#pragma omp parallel for
is an ignored #pragma
Therefor you do not require the conditional#ifdef _OPENMP around #pragma omp parallel for
If after removing the #ifdef _OPENMP and #endif (leaving #pragma omp parallel for) and the program does not run properly then check to make sure you are linking in the appropriate libraries.
Jim Dempsey
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes you're right the openmp is double checked once explicitlely bi the ifdef and once implicitely by the pragma.
But you're mssing the point. Booby reported a Intel Compiler bug (flag -openmp). You're talking about gcc (flag -fopenmp). He's talking about the system() call, which let's the application hang. You're talking about the "appropriate libraries."
I noticed the same bug yesterday - which led me to this thread, so I can confirm it. It occurs on Ubuntu 11.04 and icc 11.1.069 and 12.0.
We never encountered this bug before - even though this is a common use-case here, so I'd say its a Ubuntu 11.04 specific problem.
But you're mssing the point. Booby reported a Intel Compiler bug (flag -openmp). You're talking about gcc (flag -fopenmp). He's talking about the system() call, which let's the application hang. You're talking about the "appropriate libraries."
I noticed the same bug yesterday - which led me to this thread, so I can confirm it. It occurs on Ubuntu 11.04 and icc 11.1.069 and 12.0.
We never encountered this bug before - even though this is a common use-case here, so I'd say its a Ubuntu 11.04 specific problem.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can compiler and run it in FC11.
$ icc -D_OPENMP -openmp tstcase.cpp
$ icc -V
Intel C Intel 64 Compiler XE for applications running on Intel 64, Version 12.0.1.107 Build 20101116
Copyright (C) 1985-2010 Intel Corporation. All rights reserved.

Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page