Search code examples
openmpintelicc

warning #3180: unrecognized OpenMP #pragma


I am having a really hard time in implementing openMP code on my mac machine on Terminal with icc compiler. I find the following error! Please do help me with the correction of error.

The following code is pasted as follows. IT NEVER WORK FOR openMP for, reduce either. The pragma is just not recognising. Appreciate yourself trying the code to help.

#include <stdio.h>
#include <omp.h>
int main()
{
#pragma omp parallel for
  {
    for(int i=0;i<3;i++)
      {
        printf("Hello");
      }
  }
  return 0;
}

Solution

  • To add to my comment, the correct version of the code is

    #include <stdio.h>
    #include <omp.h>
    int main()
    {
    #pragma omp parallel for
        for(int i=0;i<3;i++)
          {
            printf("Hello");
          }
      return 0;
    }
    

    The proper compiler command line is icc -fopenmp ... -o bla.exe bla.c (assuming that the file is named bla.c). Please replace ... with the other command line options that you will need for your code to compile.

    UPDATE: The proper compiler command line for the new OpenMP compilers from Intel is to use -fiopenmp (needs -fopenmp-targets=spir64 for GPUs).