source: CIVL/include/headers/civl-omp.cvh@ 1aaefd4

main test-branch
Last change on this file since 1aaefd4 was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago

Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.

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

  • Property mode set to 100644
File size: 9.7 KB
Line 
1// civlc-omp.cvh: header file for CIVL-C support functions for OpenMP.
2
3#ifndef _CIVLC_OMP_
4#define _CIVLC_OMP_
5
6#include <civlc.cvh>
7#include <op.h>
8#include <domain.cvh>
9#pragma CIVL ACSL
10/** Important notes:
11 * 1. none of those variables that comprise a shared object should ever
12 * be accessed directly. All access must happen through $omp_read/write,
13 * including the local views, status, and shared view.
14 */
15
16/* *********************** Types *********************** */
17
18/* The status of a shared variable (or component of a shared
19 * variable). For each shared variable, there is a "local view",
20 * for each thread, which is a copy of the shared variable in
21 * the thread scope. There is also the shared variable proper.
22 * The local copy may be either empty or full. Flush operations
23 * copy data between the local and shared copies, and modify
24 * the empty/full bit. */
25typedef enum $omp_var_status {
26 EMPTY, // local is empty
27 FULL, // local is occupied, no writes to it have been made
28 MODIFIED // local is occupied, writes have been made to it
29} $omp_var_status;
30
31/* An enumerated type specifying the different kinds of OpenMP
32 * "worksharing" constructs. */
33typedef enum $omp_worksharing_kind {
34 LOOP,
35 BARRIER,
36 SECTIONS,
37 SINGLE
38} $omp_worksharing_kind;
39
40
41
42/* global shared object, containing a reference to a shared variable.
43 * A handle type. */
44typedef struct OMP_gshared * $omp_gshared;
45
46/* local view of a shared object, belonging to a single
47 * thread, with reference to the global object, and
48 * a local copy and a status of the shared object.
49 * The type of the status variable is obtained from
50 * the type of the original variable by replacing
51 * all leaf nodes in the type tree with "int".
52 * A handle type. */
53typedef struct OMP_shared * $omp_shared;
54
55/* the worksharing information that a thread needs for executing
56 * a worksharing region. It contains the kind of the worksharing
57 * region, the location of the region, the status of the region
58 * and the subdomain (iterations/sections/task assigned to the thread).
59 */
60typedef struct OMP_work_record $omp_work_record;
61
62/* global team object, represents a team of threads executing
63 * in a parallel region. A handle type. This is where all the
64 * state needed to correctly execute a parallel region will
65 * be stored. This includes a global barrier, and a worksharing
66 * queue for every thread. */
67typedef struct OMP_gteam * $omp_gteam;
68
69/*
70 * local object belonging to a single thread and referencing the
71 * global team object. A handle type. It also includes the local
72 * views of all shared data and a local barrier. */
73typedef struct OMP_team * $omp_team;
74
75/*
76 * semaphore struct used for helping control the execution of
77 * CIVL-C code transformed from OpenMP programs.
78 * It includes an integer value 'value' as its only field,
79 * which is used for P/V operations. */
80
81/* A helper struct used by CIVL for synchronizing the execution
82 * of multiple threads required by an OpenMP program.
83 * It has an 'int' field named as 'value', which is used for
84 * determining the actual sync behaviors: block/unblock */
85typedef struct OMP_HELPER_SIGNAL $omp_helper_signal;
86
87/* *********************** Functions *********************** */
88
89/* creates new global team object, allocating object in heap
90 * in specified scope. Number of threads that will be in the
91 * team is nthreads. */
92/*@ depends_on \nothing; */
93$atomic_f $omp_gteam $omp_gteam_create($scope scope, int nthreads);
94
95/* destroys the global team object. All shared objects
96 * associated to the team must have been destroyed before
97 * calling this function. */
98/*@ depends_on \access(gteam); */
99$atomic_f void $omp_gteam_destroy($omp_gteam gteam);
100
101/* creates new local team object for a specific thread. */
102/*@ depends_on \access(gteam); */
103$atomic_f $omp_team $omp_team_create($scope scope, $omp_gteam gteam, int tid);
104
105/* destroys the local team object */
106/*@ depends_on \access(team); */
107$atomic_f void $omp_team_destroy($omp_team team);
108
109/* creates new global shared object, associated to the given
110 * global team. A pointer to the shared variable that this
111 * object corresponds to is given. */
112/*@ depends_on \access(gteam, original); */
113$atomic_f $omp_gshared $omp_gshared_create($omp_gteam gteam, void *original);
114
115/* destroys the global shared object, copying the content
116 * to the original variable. */
117/*@ depends_on \access(gshared); */
118$atomic_f void $omp_gshared_destroy($omp_gshared gshared);
119
120/* creates a local shared object, returning handle to it.
121 * The local copy of the shared object is initialized
122 * by copying the values from the original variable referenced to
123 * by the gshared object. The status variable is initialized to FULL.
124 * The created shared object is appended
125 * to the shared queue of the $omp_team object. */
126/*@ depends_on \access(team, gshared, local, status); */
127$atomic_f $omp_shared $omp_shared_create($omp_team team,
128 $omp_gshared gshared, void *local, void *status);
129
130/* destroys the local shared object */
131/*@ depends_on \access(shared); */
132$atomic_f void $omp_shared_destroy($omp_shared shared);
133
134/* called by a thread to read a shared object.
135 * ref is a pointer into the local copy of the shared variable.
136 * The result of the read is stored in the
137 * memory unit pointed to by result.
138 * assumes ref is a pointer to a scalar.
139 */
140void $omp_read($omp_shared shared, void *result, void *ref);
141
142/* called by a thread to write to the shared object.
143 * ref is a pointer into the local copy of the shared variable.
144 * The value to be written is taken
145 * from the memory unit pointed to by value.
146 * assumes ref is a pointer to a scalar.
147 */
148void $omp_write($omp_shared shared, void *ref, void *value);
149
150/* applies the associative operator
151 * specified by op to the local copy and the corresponding shared copy,
152 * and writes the result back to the shared copy.
153 * This happens in one atomic step. Example: you can
154 * use this to add some value to a shared variable,
155 * using CIVL_SUM for op.
156 * assumes local is a pointer to a scalar.
157 */
158$atomic_f void $omp_apply_assoc($omp_shared shared,
159 $operation op,
160 void *local);
161
162/* applies the operation indicated by the given 'op' to combine
163 * all referenced local copy values and the original reduction
164 * item value.
165 */
166$atomic_f void $omp_reduction_combine(
167 $operation op, void *reduction_final, void *reduction_local);
168
169/* performs an OpenMP flush operation on the shared object
170 */
171void $omp_flush($omp_shared shared, void *ref);
172
173/* performs an OpenMP flush operation on all shared
174 * objects. This is the default in OpenMP if no argument
175 * is specified for a flush construct. */
176void $omp_flush_all($omp_team team);
177
178/* performs a barrier only. Note however that usually
179 * (always?) a barrier is accompanied by a flush-all,
180 * so $omp_barrier_and_flush should be used instead.
181 */
182void $omp_barrier($omp_team team);
183
184/* called by a thread when it reaches an omp for loop,
185 * this function returns the subset of the loop domain
186 * specifying the iterations that this thread will execute,
187 * according to the given policy. In general, this
188 * function is nondeterministic.
189 * The dimension of the domain returned equals the
190 * dimension of the given domain loop_dom.
191 */
192$domain $omp_arrive_loop($omp_team team, int location, $domain loop_dom,
193 $domain_strategy strategy);
194
195/* called by a thread when it reaches an omp sections
196 * construct, this function returns the subset of the
197 * integers 0..numSections-1 specifying the indexes of
198 * the sections that this thread will execute. The sections
199 * are numbered from 0 in increasing order. */
200$domain(1) $omp_arrive_sections($omp_team team, int location, int numSections);
201
202/* called by a thread when it reaches on omp single
203 * construct, returns the thread ID of the thread that
204 * will execute the single construct. */
205int $omp_arrive_single($omp_team team, int location);
206
207/* called by a thread when a openMP synchronization point
208 * is encountered and then this function will check and report
209 * any possible occurrence of data race as assertion violations
210 * iff there is a non-empty intersection between checked $mem pairs */
211$atomic_f void $check_data_race($omp_team team);
212
213/* OMP Helper Signal Instance Creation
214 * creates and returns an initialized '$omp_helper_signal' instance
215 * with a given initial integer value 'initValue' */
216$atomic_f $omp_helper_signal $omp_helper_signal_create(
217 int initValue);
218
219/* OMP Helper Signal Wait Operation:
220 * The caller process will wait (or be blocked) until the associated
221 * $omp_helper_signal instance 'signal' value (signal->value) is set
222 * as the same value being equal to 'waitValue' by calling
223 * '$omp_helper_signal_send' with the same $omp_helper_signal instance */
224$atomic_f void $omp_helper_signal_wait(
225 $omp_helper_signal *signal, int waitValue);
226
227/* OMP Helper Signal Send Operation:
228 * The caller process will set the given 'signal' value to be 'sendValue'.
229 * This operation can be regarded as sending a 'signal' to those threads,
230 * who are waiting for a specific integer value so that they can continue
231 * executing statements following the call of '$omp_helper_signal_wait'. */
232$atomic_f void $omp_helper_signal_send(
233 $omp_helper_signal *signal, int sendValue);
234
235/* called by a thread to update its current read and write sets
236 * with ones peeked from the current read/write set stack.
237 * NOTE: both stacks are assumed to be non-empty. */
238$atomic_f void $read_and_write_sets_pop($omp_team team);
239
240$atomic_f void $read_and_write_sets_push($omp_team team);
241
242$atomic_f void $omp_atomic_execution_lock_acquire(
243 $omp_team team, $omp_helper_signal *lock);
244
245$atomic_f void $omp_atomic_execution_lock_release(
246 $omp_team team, $omp_helper_signal *lock);
247
248$atomic_f void $omp_loop_operation($omp_team team);
249
250$atomic_f void $omp_thread_termination($omp_team team);
251
252#endif
Note: See TracBrowser for help on using the repository browser.