libgomp: Implementing PARALLEL construct
1
1 9.10 Implementing PARALLEL construct
1 ====================================
1
1 #pragma omp parallel
1 {
1 body;
1 }
1
1 becomes
1
1 void subfunction (void *data)
1 {
1 use data;
1 body;
1 }
1
1 setup data;
1 GOMP_parallel_start (subfunction, &data, num_threads);
1 subfunction (&data);
1 GOMP_parallel_end ();
1
1 void GOMP_parallel_start (void (*fn)(void *), void *data, unsigned num_threads)
1
1 The FN argument is the subfunction to be run in parallel.
1
1 The DATA argument is a pointer to a structure used to communicate
1 data in and out of the subfunction, as discussed above with respect to
1 FIRSTPRIVATE et al.
1
1 The NUM_THREADS argument is 1 if an IF clause is present and false,
1 or the value of the NUM_THREADS clause, if present, or 0.
1
1 The function needs to create the appropriate number of threads and/or
1 launch them from the dock. It needs to create the team structure and
1 assign team ids.
1
1 void GOMP_parallel_end (void)
1
1 Tears down the team and returns us to the previous
1 'omp_in_parallel()' state.
1