Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.

OpenMP on Ubuntu 11.04

booby
Beginner
523 Views
#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?
0 Kudos
3 Replies
jimdempseyatthecove
Honored Contributor III
523 Views
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




0 Kudos
neokenny
Beginner
523 Views
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.
0 Kudos
Om_S_Intel
Employee
523 Views

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.

0 Kudos
Reply