How I can have a better understanding of the workflow for some directive in GCC?

86 views Asked by At

I'm currently working on a project and I need a better understanding of the GCC workflow of a GOMP directive and I'd like to bring up some changes to the source code too. Is there a best practice to do so? Shall I re-compile the entire GCC to do so?

I've already searched how to build my GCC but it feels excessive to do so just to change some changes.

1

There are 1 answers

1
Joseph Tate On

If you look at the openmp documentation here, it seems like GOMP uses makefiles and pragmas to feed information to the gcc compiler and annotates the way it behaves, rather than actually rewriting the source code for GCC. I'm not an expert tho so forgive me if I'm off... Here's an example I saw:

#include <std.io>
#include <omp.h>

int main (void) {
    omp_set_nested(1);
    omp_set_dynamic(0);
    #pragma omp parallel
    {
        //should print whatever OMP_NUM_THREADS was set to.
        printf ("Inner: num_thds=%d\n", omp_get_num_threads());
    }
    #pragma omp barrier
    return 0;
}

Are you trying to use GOMP for offloading threads to another device? Or do you just want to run multithreading locally? What specifically are you trying to use GOMP for?

Here is another helpful resource I found... Using OpenMP with C