source: CIVL/text/include/civlc-omp.cvl@ a9d2603

1.23 2.0 acw/focus-triggers main test-branch
Last change on this file since a9d2603 was d442136, checked in by Stephen Siegel <siegel@…>, 12 years ago

ABC was modified to clean up management of source files, which also modified the interface, so CIVL had to be modified accordingly.
In particular, the constructor for AST now requies the set of source files that went into making that AST.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@1554 fb995dde-84ed-4084-dfe6-e5aef3e2452c

  • Property mode set to 100644
File size: 6.7 KB
Line 
1// IS THIS DEPRECATED?? It does not appear to be used.
2
3
4/* This header file defines standard types and provides
5 * function prototypes used in the OpenMP to CIVLC transformation.
6 */
7
8#ifdef __CIVLC_OMP__
9#else
10#define __CIVLC_OMP__
11
12#include<civlc.h>
13
14/* *********************** Types *********************** */
15
16/* global shared object, used to represent the state of
17 * a shared variable. A handle type.
18 */
19typedef struct OMP_gshared {
20 void * original; // pointer to original variable
21 int size; // size of original variable
22 void * state; // heap allocated state object
23 int state_size; // size of state object
24} * $omp_gshared;
25
26/* local view of the shared object, belonging to a single
27 * thread, with reference to the global object.
28 * A handle type.
29 */
30typedef struct OMP_shared {
31 $omp_gshared;
32 int tid;
33} * $omp_shared;
34
35/* a reference to a shared object or some part of
36 * a shared object. This leaves the struct type
37 * incomplete.
38 */
39typedef struct OMP_ref * $omp_ref;
40
41/* The different kinds of references */
42typedef enum OMP_Ref_kind {
43 IDENTITY,
44 ARRAY_ELEMENT,
45 MEMBER
46} OMP_Ref_kind;
47
48/* A reference to part of a composite structure */
49typedef struct OMP_subref {
50 $omp_ref parent;
51 int index;
52} * $omp_subref;
53
54/* completes the definition of struct OMP_ref */
55struct OMP_ref {
56 enum OMP_Ref_kind kind;
57 union {
58 $omp_gshared var; // for IDENTITY
59 $omp_subref subref; // for ARRAY_ELEMENT and MEMBER
60 } data;
61};
62
63typedef struct OMP_loop_record {
64 $domain loop_domain; // full loop domain
65 $domain subdomain; // subdomain for this thread
66} OMP_loop_record;
67
68typedef struct OMP_work_record {
69 int kind; // loop, barrier, sections, single
70 int location; // location in model of construct
71 _Bool arrived; // has this thread arrived yet?
72 union {
73 OMP_loop_record loop;
74 $domain sections;
75 int singletid;
76 } data;
77} OMP_work_record;
78
79/* global team object, represents a team of threads executing
80 * in a parallel region. A handle type. This is where all the
81 * state needed to correctly execute a parallel region will
82 * be stored. This includes all the shared object data,
83 * and a worksharking queue for every thread.
84 */
85typedef struct OMP_gteam {
86 /* number of threads in team */
87 int nthreads;
88 /* work queues. Length nthreads. For each thread,
89 * a FIFO queue of work records */
90 OMP_work_record work[][];
91 /* number of shared variables */
92 int nshared;
93 /* the shared object data. Length nshared. */
94 $omp_gshared shared[];
95} * $omp_gteam;
96
97typedef struct OMP_team {
98 $omp_gteam gteam;
99 int tid;
100} * $omp_team;
101
102typedef enum OMP_Operator {
103 OMP_SUM,
104 OMP_PRODUCT,
105 OMP_MAX,
106 OMP_MIN
107} $omp_operator;
108
109
110/* *********************** Functions *********************** */
111
112/* creates new global team object, allocating object in heap
113 * in specified scope. Number of threads that will be in the
114 * team is nthreads.
115 */
116$omp_gteam $omp_gteam_create($scope scope, int nthreads);
117
118/* destroys the global team object. All shared objects
119 * associated to the team must have been destroyed before
120 * calling this function.
121 */
122void $omp_gteam_destroy($omp_gteam gteam);
123
124/* creates new local team object for a specific thread. */
125$omp_team $omp_team_create($scope scope, $omp_gteam gteam, int tid);
126
127/* destroys the local team object */
128void $omp_team_destroy($omp_team team);
129
130/* creates new global shared object, associated to the given
131 * global team. A pointer to the shared variable that this
132 * object corresponds to is given. The new object is initialized
133 * by copying the values from the original variable.
134 */
135$omp_gshared $omp_gshared_create($omp_gteam, void *original);
136
137/* destroys the global shared object, copying the content
138 * to the original variable.
139 */
140void $omp_gshared_destroy($omp_gshared gshared);
141
142/* creates a local shared object, returning handle to it */
143$omp_shared $omp_shared_create($omp_team team, $omp_gshared gshared);
144
145/* destroys the local shared object */
146void $omp_shared_destroy($omp_shared shared);
147
148/* creates a reference to the specified shared object */
149$omp_ref $omp_identity_ref($omp_shared shared);
150
151/* creates a reference to an element of a shared array
152 * object. Argument ref is a reference to shared object
153 * of array type.
154 */
155$omp_ref $omp_array_element_ref($omp_ref ref, int index);
156
157/* creates a reference to a member of a structure or
158 * union shared object. Argument ref is a reference to
159 * the shared object of structure or union type.
160 */
161$omp_ref $omp_member_ref($omp_ref ref, int fieldIndex);
162
163/* called by a thread to read a shared object pointed
164 * to by ref. The result of the read is stored in the
165 * memory unit pointed to by result.
166 */
167void $omp_read(void *result, $omp_ref ref);
168
169/* called by a thread to write to the shared object
170 * pointed to by ref. The value to be written is taken
171 * from the memory unit pointed to by value.
172 */
173void $omp_write($omp_ref ref, void *value);
174
175/* Reads the reference, applies the associative operator
176 * specified by op to the read value and the value pointed
177 * to by value, and writes the result back to ref.
178 * This happens in one atomic step. Example: you can
179 * use this to add some value to a shared variable,
180 * using CIVL_SUM for op.
181 */
182void $omp_apply_assoc($omp_ref ref, $omp_operator op,
183 void *value);
184
185/* performs an OpenMP flush operation on the shared object
186 */
187void $omp_flush($omp_shared shared);
188
189/* performs an OpenMP flush operation on all shared
190 * objects. This is the default in OpenMP if no argument
191 * is specified for a flush construct.
192 */
193void $omp_flush_all($omp_team team);
194
195/* performs a barrier only. Note however that usually
196 * (always?) a barrier is accompanied by a flush-all,
197 * so $omp_barrier_and_flush should be used instead.
198 */
199void $omp_barrier($omp_team team);
200
201/* combines a barrier and a flush on all shared objects
202 * owned by the team. Implicit in many OpenMP worksharing
203 * constructs.
204 */
205void $omp_barrier_and_flush($omp_team team);
206
207/* called by a thread when it reaches an omp for loop,
208 * this function returns the subset of the loop domain
209 * specifying the iterations that this thread will execute.
210 * The dimension of the domain returned equals the
211 * dimension of the given domain loop_dom.
212 */
213$domain $omp_arrive_loop($omp_team, $domain loop_dom);
214
215/* called by a thread when it reaches an omp sections
216 * construct, this function returns the subset of the
217 * integers 0..numSections-1 specifying the indexes of
218 * the sections that this thread will execute. The sections
219 * are numbered from 0 in increasing order.
220 */
221$domain(1) $omp_arrive_sections($omp_team, int numSections);
222
223/* called by a thread when it reaches on omp single
224 * construct, returns the thread ID of the thread that
225 * will execute the single construct.
226 */
227int $omp_arrive_single($omp_team team);
228
229#endif
Note: See TracBrowser for help on using the repository browser.