Search code examples
clangopenmpdirectivepragma

What will #pragma directives of OpenMP be expanded to in Clang and Open64?


I have been just playing around with Clang and Open64 and used the OpenMP library. I am somehow new to these three! I was wondering if anyone could help me on finding what will the #pragma directives expand to. What I know is that a #pragma directive in the C file will be expanded to a some lines of codes. I was hoping if someone could tell me where should I look for to find it. I know for sure that Clang and Open64 compilers have output for assembly and their different intermediate representations. But since that is not useful, I want to know the exact codes that are expanded when encountering a directive.

Let me rephrase my question.

I know that an OpenMP #pragma directive is expanded into some lines of codes (or maybe I am wrong). I was hoping if someone could tell me where should I look for it in the sources of compiler or sources of OpenMP?

Let me give you an example. Consider this piece of code:

#pragma omp parallel
{
    printf("Hello world! %d", omp_get_thread_num());
}

As far as I know, it will be converted to something like this (or something more complex):

f1();
{
    printf("Hello world! %d", omp_get_thread_num());
}
f2();

I want to know what are the f1() and f2() methods.

If I am wrong tell me. And if you know where should I look for in the code, let me know about that.

Thanks.


Solution

  • A short replication of the answer, since @AlanWik asked for it.

    OpenMP is not a source to source translator, so there is no translated source code to look at. All of the conversions occur on the compiler data structures, so you need to look at those, or at the assembler output.