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

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

Reorganizing omp library structure in more rational way.

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

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