source: CIVL/text/include/civlc-omp.cvh@ c064bf48

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

Improving some comments, fixing old examples, deleted file
in tutorial that was wrongly committed.

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

  • Property mode set to 100644
File size: 6.9 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 <domain.cvh>
7
8/* *********************** Types *********************** */
9
10/* The status of a shared variable (or component of a shared
11 * variable). For each shared variable, there is a "local view",
12 * for each thread, which is a copy of the shared variable in
13 * the thread scope. There is also the shared variable proper.
14 * The local copy may be either empty or full. Flush operations
15 * copy data between the local and shared copies, and modify
16 * the empty/full bit. */
17typedef enum $omp_var_status {
18 EMPTY, // local is empty
19 FULL, // local is occupied, no writes to it have been made
20 MODIFIED // local is occupied, writes have been made to it
21} $omp_var_status;
22
23/* An enumerated type specifying the different kinds of OpenMP
24 * "worksharing" constructs. */
25typedef enum $omp_worksharing_kind {
26 LOOP,
27 BARRIER,
28 SECTIONS,
29 SINGLE
30} $omp_worksharing_kind;
31
32/* An enumerated type used to specify how threads are distributed
33 * among members of a thread team at OpenMP "for" loops. The model
34 * checker can explore all possible partitions (very expensive), or
35 * use just one particular partition, or something inbetween.
36 * */
37typedef enum $omp_loop_policy {
38 ROUND_ROBIN, // deterministic partition by round robin order
39 RANDOM, // a random partition
40 ALL // all possible partitions
41} $omp_loop_policy;
42
43
44/* global shared object, containing a reference to a shared variable.
45 * A handle type. WHY NO *? */
46typedef struct OMP_gshared $omp_gshared;
47
48/* local view of a shared object, belonging to a single
49 * thread, with reference to the global object, and
50 * a local copy and a status of the shared object.
51 * The type of the status variable is obtained from
52 * the type of the original variable by replacing
53 * all leaf nodes in the type tree with "int".
54 * A handle type. */
55typedef struct OMP_shared * $omp_shared;
56
57/* the worksharing information that a thread needs for executing
58 * a worksharing region. It contains the kind of the worksharing
59 * region, the location of the region, the status of the region
60 * and the subdomain (iterations/sections/task assigned to the thread).
61 */
62typedef struct OMP_work_record $omp_work_record;
63
64/* global team object, represents a team of threads executing
65 * in a parallel region. A handle type. This is where all the
66 * state needed to correctly execute a parallel region will
67 * be stored. This includes a global barrier, and a worksharing
68 * queue for every thread. */
69typedef struct OMP_gteam * $omp_gteam;
70
71/*
72 * local object belonging to a single thread and referencing the
73 * global team object. A handle type. It also includes the local
74 * views of all shared data and a local barrier. */
75typedef struct OMP_team * $omp_team;
76
77
78/* *********************** Functions *********************** */
79
80/* creates new global team object, allocating object in heap
81 * in specified scope. Number of threads that will be in the
82 * team is nthreads. */
83$omp_gteam $omp_gteam_create($scope scope, int nthreads);
84
85/* destroys the global team object. All shared objects
86 * associated to the team must have been destroyed before
87 * calling this function. */
88void $omp_gteam_destroy($omp_gteam gteam);
89
90/* creates new local team object for a specific thread. */
91$omp_team $omp_team_create($scope scope, $omp_gteam gteam, int tid);
92
93/* destroys the local team object */
94void $omp_team_destroy($omp_team team);
95
96/* creates new global shared object, associated to the given
97 * global team. A pointer to the shared variable that this
98 * object corresponds to is given. */
99$omp_gshared $omp_gshared_create($omp_gteam gteam, void *original);
100
101/* destroys the global shared object, copying the content
102 * to the original variable. */
103void $omp_gshared_destroy($omp_gshared gshared);
104
105/* creates a local shared object, returning handle to it.
106 * The local copy of the shared object is initialized
107 * by copying the values from the original variable referenced to
108 * by the gshared object. The created shared object is appended
109 * to the shared queue of the $omp_team object. */
110$omp_shared $omp_shared_create($omp_team team,
111 $omp_gshared gshared, void *local, void *status);
112
113/* destroys the local shared object */
114void $omp_shared_destroy($omp_shared shared);
115
116/* called by a thread to read a shared object.
117 * ref is a pointer into the local copy of the shared variable.
118 * The result of the read is stored in the
119 * memory unit pointed to by result.
120 * assumes ref is a pointer to a scalar.
121 */
122void $omp_read($omp_shared shared, void *result, void *ref);
123
124/* called by a thread to write to the shared object.
125 * ref is a pointer into the local copy of the shared variable.
126 * The value to be written is taken
127 * from the memory unit pointed to by value.
128 * assumes ref is a pointer to a scalar.
129 */
130void $omp_write($omp_shared shared, void *ref, void *value);
131
132/* applies the associative operator
133 * specified by op to the local copy and the corresponding shared copy,
134 * and writes the result back to the shared copy.
135 * This happens in one atomic step. Example: you can
136 * use this to add some value to a shared variable,
137 * using CIVL_SUM for op.
138 * assumes local is a pointer to a scalar.
139 */
140void $omp_apply_assoc($omp_shared shared,
141 $operation op,
142 void *local);
143
144/* performs an OpenMP flush operation on the shared object
145 */
146void $omp_flush($omp_shared shared, void *ref);
147
148/* performs an OpenMP flush operation on all shared
149 * objects. This is the default in OpenMP if no argument
150 * is specified for a flush construct. */
151void $omp_flush_all($omp_team team);
152
153/* performs a barrier only. Note however that usually
154 * (always?) a barrier is accompanied by a flush-all,
155 * so $omp_barrier_and_flush should be used instead.
156 */
157void $omp_barrier($omp_team team);
158
159/* combines a barrier and a flush on all shared objects
160 * owned by the team. Implicit in many OpenMP worksharing
161 * constructs. */
162void $omp_barrier_and_flush($omp_team team);
163
164/* called by a thread when it reaches an omp for loop,
165 * this function returns the subset of the loop domain
166 * specifying the iterations that this thread will execute,
167 * according to the given policy. In general, this
168 * function is nondeterministic.
169 * The dimension of the domain returned equals the
170 * dimension of the given domain loop_dom.
171 */
172$domain $omp_arrive_loop($omp_team team, $domain loop_dom,
173 $DecompositionStrategy strategy);
174
175/* called by a thread when it reaches an omp sections
176 * construct, this function returns the subset of the
177 * integers 0..numSections-1 specifying the indexes of
178 * the sections that this thread will execute. The sections
179 * are numbered from 0 in increasing order. */
180$domain(1) $omp_arrive_sections($omp_team team, int numSections);
181
182/* called by a thread when it reaches on omp single
183 * construct, returns the thread ID of the thread that
184 * will execute the single construct. */
185int $omp_arrive_single($omp_team team);
186
187#endif
Note: See TracBrowser for help on using the repository browser.