Compiling OpenMP Code to C Code

Is there a way by which I can compile the code with the OpenMP code in C (with the part of OpenMP translated to regular C) so that I can know what code is generated by OpenMP. I am using gcc 4.4 compiler.

+7
source share
2 answers

At least http://www2.cs.uh.edu/~openuh/ OpenUH (even listed at http://openmp.org/wp/openmp-compilers/ ), which may

fix optimized C or Fortran 77 code that can be compiled by the native compiler on other platforms.

Also there is: http://www.cs.uoi.gr/~ompi/ OMPi:

The OMPi compiler takes C source code from OpenMP #pragmas and creates the converted multi-threaded C code, ready to be compiled using its own system compiler.

and OdinMP:

OdinMP / CCp was written in Java for mobility reasons and accepts a C program with OpenMP directives and creates a C program for POSIX streams.

I have to say that converting openmp code to Plain C is almost impossible; because the old plain of C does not have thread support, and I think that the translators of the source to the OpenMP source do not yet know C11. The OpenMP program can be translated either into C with POSIX streams, or into C with some runtime libraries (for example, libgomp). For example, OpenUH has its own library, which itself uses pthreads.

+3
source

Like other commentators, gcc does not translate OpenMP directives to regular C.

But if you want to get an idea of ​​what gcc does with your directives, you can compile -fdump-tree-optimized . This will create an intermediate view of the program that is at least C-like.

There are several steps that you can reset (check the man page for gcc), in the OpenMP- optimized directives, the GOMP runtime library calls have been replaced. Looking at this view, you can talk about what is happening.

+6
source

All Articles