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

1.23 2.0 main test-branch
Last change on this file since 09d949f was 887a6423, checked in by Stephen Siegel <siegel@…>, 12 years ago

Fixed bugs in omp header files support libraries and impl.

git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@1562 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 created shared object is appended
98 * to the shared queue of the $omp_team object. */
99$omp_shared $omp_shared_create($omp_team team,
100 $omp_gshared gshared, void *local, void *status);
101
102/* destroys the local shared object */
103void $omp_shared_destroy($omp_shared shared);
104
105/* called by a thread to read a shared object.
106 * ref is a pointer into the local copy of the shared variable.
107 * The result of the read is stored in the
108 * memory unit pointed to by result.
109 * assumes ref is a pointer to a scalar.
110 */
111void $omp_read($omp_shared shared, void *result, void *ref);
112
113/* called by a thread to write to the shared object.
114 * ref is a pointer into the local copy of the shared variable.
115 * The value to be written is taken
116 * from the memory unit pointed to by value.
117 * assumes ref is a pointer to a scalar.
118 */
119void $omp_write($omp_shared shared, void *ref, void *value);
120
121/* applies the associative operator
122 * specified by op to the local copy and the corresponding shared copy,
123 * and writes the result back to the shared copy.
124 * This happens in one atomic step. Example: you can
125 * use this to add some value to a shared variable,
126 * using CIVL_SUM for op.
127 * assumes local is a pointer to a scalar.
128 */
129void $omp_apply_assoc($omp_shared shared,
130 $operation op,
131 void *local);
132
133/* performs an OpenMP flush operation on the shared object
134 */
135void $omp_flush($omp_shared shared, void *ref);
136
137/* performs an OpenMP flush operation on all shared
138 * objects. This is the default in OpenMP if no argument
139 * is specified for a flush construct. */
140void $omp_flush_all($omp_team team);
141
142/* performs a barrier only. Note however that usually
143 * (always?) a barrier is accompanied by a flush-all,
144 * so $omp_barrier_and_flush should be used instead.
145 */
146void $omp_barrier($omp_team team);
147
148/* combines a barrier and a flush on all shared objects
149 * owned by the team. Implicit in many OpenMP worksharing
150 * constructs. */
151void $omp_barrier_and_flush($omp_team team);
152
153/* called by a thread when it reaches an omp for loop,
154 * this function returns the subset of the loop domain
155 * specifying the iterations that this thread will execute,
156 * according to the given policy. In general, this
157 * function is nondeterministic.
158 * The dimension of the domain returned equals the
159 * dimension of the given domain loop_dom.
160 */
161$domain $omp_arrive_loop($omp_team team, $domain loop_dom,
162 $domain_strategy strategy);
163
164/* called by a thread when it reaches an omp sections
165 * construct, this function returns the subset of the
166 * integers 0..numSections-1 specifying the indexes of
167 * the sections that this thread will execute. The sections
168 * are numbered from 0 in increasing order. */
169$domain(1) $omp_arrive_sections($omp_team team, int numSections);
170
171/* called by a thread when it reaches on omp single
172 * construct, returns the thread ID of the thread that
173 * will execute the single construct. */
174int $omp_arrive_single($omp_team team);
175
176#endif
Note: See TracBrowser for help on using the repository browser.