The following program compiles and runs fine when I compile without
OpenMP (OMP) support.

With OMP support, it fails to compile with error:

    omp-test.c:7:18: error omp.h: No such file or directory

I have ports and sources installed, but the header cannot be found on
the system:

    $ find / -name omp.h 2>/dev/null
    $

The <omp.h> include is guarded on _OPENMP, so the compiler is clearly
defining the preprocessor macro.

The compiler responds to -fopenmp option, so the compiler clearly
declares support for OMP. Trying to compile with, say, -ffoobar,
results in a error.

I've tried installing openmp and omp through the package tool, but
they result in "Can't find openmp" and "Can't find omp" respectively.

**********

The system is:

    $ uname -a
    OpenBSD openbsd 5.7 GENERIC#825 amd64

**********

I think this falls into the "Repeatable problems that are not specific
to your hardware/software layout" class
(http://www.openbsd.org/report.html).

I see others have asked about it. Unfortunately, answer like "why
would you want to use OMP given the state of threads" does not help
solve the missing header problem
(http://openbsd-archive.7691.n7.nabble.com/OpenMP-with-gcc4-td58791.html).

A related problem is there are no man pages for OMP, so I can't even
read about it....

**********

Here is the program.

/* Without OMP: gcc -O0 omp-test.c -o omp-test.exe */
/* With OMP:    gcc -O0 -fopenmp omp-test.c -o omp-test.exe -lgomp */

#include <stdio.h>

#ifdef _OPENMP
# include <omp.h>
#endif

int main(int argc, char* argv[])
{
    int a = 3, b = 5;
    if(argc >= 2) a = atoi(argv[1]);
    if(argc >= 3) b = atoi(argv[2]);

    #pragma omp parallel sections
    {
        #pragma omp section
            a *= a;
        #pragma omp section
            b *= b;
    }

    printf("Sum of squares: %d\n", a+b);
    return 0;
}

Reply via email to