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

1.23 2.0 acw/focus-triggers main test-branch
Last change on this file since a7911c8 was 584355b, checked in by Manchun Zheng <zmanchun@…>, 12 years ago

implemented system function $leaf_node_ptr() of pointer.cvh; fixed bugs in civlc-omp.cvl for $omp_shared_create() that broke $omp_read and $omp_write.

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

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