| 1 | /* This header file defines standard types and provides
|
|---|
| 2 | * function prototypes used in the OpenMP to CIVLC transformation.
|
|---|
| 3 | */
|
|---|
| 4 |
|
|---|
| 5 | #ifdef __CIVLC_OMP__
|
|---|
| 6 | #else
|
|---|
| 7 | #define __CIVLC_OMP__
|
|---|
| 8 |
|
|---|
| 9 | #include<civlc.h>
|
|---|
| 10 |
|
|---|
| 11 | /* Specifies the sequence of iterations to be assigned to one
|
|---|
| 12 | * thread executing an omp for loop. */
|
|---|
| 13 | typedef struct {
|
|---|
| 14 | int numIters;
|
|---|
| 15 | int collapse;
|
|---|
| 16 | int iters[][];
|
|---|
| 17 | } CIVL_omp_loop_info;
|
|---|
| 18 |
|
|---|
| 19 | /* Specifies the subset of section assigned to one thread executing
|
|---|
| 20 | * an omp sections construct. */
|
|---|
| 21 | typedef struct {
|
|---|
| 22 | int numSections;
|
|---|
| 23 | int sections[];
|
|---|
| 24 | } CIVL_omp_sections_info;
|
|---|
| 25 |
|
|---|
| 26 | /* The global work-sharing state. */
|
|---|
| 27 | typedef struct __omp_gws__ {
|
|---|
| 28 | int nthreads;
|
|---|
| 29 | _Bool isInit[];
|
|---|
| 30 | CIVL_omp_loop_info loops[];
|
|---|
| 31 | CIVL_omp_sections_info sections[];
|
|---|
| 32 | } $omp_gws;
|
|---|
| 33 |
|
|---|
| 34 | /* The local state: a reference to a global object and a thread ID. */
|
|---|
| 35 | typedef struct __omp_ws__ {
|
|---|
| 36 | int tid;
|
|---|
| 37 | $omp_gws gws;
|
|---|
| 38 | } $omp_ws;
|
|---|
| 39 |
|
|---|
| 40 | /* Does a barrier on _barrier and a flush on all shared variables.
|
|---|
| 41 | * After this completes, all local copies will agree with each other
|
|---|
| 42 | * and with the shared copy of the variable, and all state variables
|
|---|
| 43 | * will be -1. */
|
|---|
| 44 | void barrier_and_flush();
|
|---|
| 45 |
|
|---|
| 46 | /* Creates new global work-sharing state object, returning
|
|---|
| 47 | * handle to it. nthreads is the number of threads in
|
|---|
| 48 | * the parallel region. There is one of these per parallel region,
|
|---|
| 49 | * created upon entering the region. */
|
|---|
| 50 | $omp_gws $omp_gws_create($scope scope, int nthreads);
|
|---|
| 51 |
|
|---|
| 52 | /* Deallocates the object that associates with the given
|
|---|
| 53 | * $omp_gws handle. */
|
|---|
| 54 | void $omp_gws_destroy($omp_gws gws);
|
|---|
| 55 |
|
|---|
| 56 | /* Creates a local work-sharing object, which is basically
|
|---|
| 57 | * a pair consisting of a global work-sharing handle and
|
|---|
| 58 | * a thread id. */
|
|---|
| 59 | $omp_ws $omp_ws_create($scope scope, $omp_gws, int tid);
|
|---|
| 60 |
|
|---|
| 61 | /* Deallocates the object that associates with the given
|
|---|
| 62 | * $omp_ws handle. */
|
|---|
| 63 | void $omp_ws_destroy($omp_ws ws);
|
|---|
| 64 |
|
|---|
| 65 | /* for "for" loops only: called when a thread arrives, it
|
|---|
| 66 | * returns the sequence of loop iterations to be performed by
|
|---|
| 67 | * the thread. Parameter location is the ID of the model location
|
|---|
| 68 | * of the top of the loop. It is needed to check that all threads
|
|---|
| 69 | * encounter the same worksharing statements in the same order.
|
|---|
| 70 | * The implementation will need the value start, the initial value of the loop variable;
|
|---|
| 71 | * end is its final value; and inc, the increment (which can be
|
|---|
| 72 | * positive or negative). These values can all be obtained by getting
|
|---|
| 73 | * the loop statement from the location and evaluating the expressions
|
|---|
| 74 | * occurring there.*/
|
|---|
| 75 | CIVL_omp_loop_info $omp_ws_arrive_loop($omp_ws ws, int location);
|
|---|
| 76 |
|
|---|
| 77 | /* for sections: called at arrival, returns the sequence of sections to
|
|---|
| 78 | * be executed by calling thread. The sections are numbered in order,
|
|---|
| 79 | * starting from 0. */
|
|---|
| 80 | CIVL_omp_sections_info $omp_ws_arrive_sections($omp_ws ws, int location);
|
|---|
| 81 |
|
|---|
| 82 | /* for single: called on arrival, returns whether or not to execute
|
|---|
| 83 | * the single code */
|
|---|
| 84 | _Bool $omp_ws_arrive_single($omp_ws ws, int location);
|
|---|
| 85 |
|
|---|
| 86 | /* called when arriving at a barrier. This does not
|
|---|
| 87 | * impose the barrier, you still need to call system function
|
|---|
| 88 | * $barrier... for that. This is needed to ensure all threads
|
|---|
| 89 | * in the team call the same sequence of worksharing and barrier
|
|---|
| 90 | * constructs. */
|
|---|
| 91 | void $omp_ws_arrive_barrier($omp_ws ws, int location);
|
|---|
| 92 |
|
|---|
| 93 | #endif
|
|---|