annotate libcilkrts/runtime/global_state.h @ 143:76e1cf5455ef

add cbc_gc test
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Sun, 23 Dec 2018 19:24:05 +0900
parents 04ced10e8804
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 /* global_state.h -*-C++-*-
kono
parents:
diff changeset
2 *
kono
parents:
diff changeset
3 *************************************************************************
kono
parents:
diff changeset
4 *
kono
parents:
diff changeset
5 * Copyright (C) 2009-2016, Intel Corporation
kono
parents:
diff changeset
6 * All rights reserved.
kono
parents:
diff changeset
7 *
kono
parents:
diff changeset
8 * Redistribution and use in source and binary forms, with or without
kono
parents:
diff changeset
9 * modification, are permitted provided that the following conditions
kono
parents:
diff changeset
10 * are met:
kono
parents:
diff changeset
11 *
kono
parents:
diff changeset
12 * * Redistributions of source code must retain the above copyright
kono
parents:
diff changeset
13 * notice, this list of conditions and the following disclaimer.
kono
parents:
diff changeset
14 * * Redistributions in binary form must reproduce the above copyright
kono
parents:
diff changeset
15 * notice, this list of conditions and the following disclaimer in
kono
parents:
diff changeset
16 * the documentation and/or other materials provided with the
kono
parents:
diff changeset
17 * distribution.
kono
parents:
diff changeset
18 * * Neither the name of Intel Corporation nor the names of its
kono
parents:
diff changeset
19 * contributors may be used to endorse or promote products derived
kono
parents:
diff changeset
20 * from this software without specific prior written permission.
kono
parents:
diff changeset
21 *
kono
parents:
diff changeset
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
kono
parents:
diff changeset
23 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
kono
parents:
diff changeset
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
kono
parents:
diff changeset
25 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
kono
parents:
diff changeset
26 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
kono
parents:
diff changeset
27 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
kono
parents:
diff changeset
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
kono
parents:
diff changeset
29 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
kono
parents:
diff changeset
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
kono
parents:
diff changeset
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
kono
parents:
diff changeset
32 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
kono
parents:
diff changeset
33 * POSSIBILITY OF SUCH DAMAGE.
kono
parents:
diff changeset
34 *
kono
parents:
diff changeset
35 * *********************************************************************
kono
parents:
diff changeset
36 *
kono
parents:
diff changeset
37 * PLEASE NOTE: This file is a downstream copy of a file mainitained in
kono
parents:
diff changeset
38 * a repository at cilkplus.org. Changes made to this file that are not
kono
parents:
diff changeset
39 * submitted through the contribution process detailed at
kono
parents:
diff changeset
40 * http://www.cilkplus.org/submit-cilk-contribution will be lost the next
kono
parents:
diff changeset
41 * time that a new version is released. Changes only submitted to the
kono
parents:
diff changeset
42 * GNU compiler collection or posted to the git repository at
kono
parents:
diff changeset
43 * https://bitbucket.org/intelcilkruntime/intel-cilk-runtime.git are
kono
parents:
diff changeset
44 * not tracked.
kono
parents:
diff changeset
45 *
kono
parents:
diff changeset
46 * We welcome your contributions to this open source project. Thank you
kono
parents:
diff changeset
47 * for your assistance in helping us improve Cilk Plus.
kono
parents:
diff changeset
48 **************************************************************************/
kono
parents:
diff changeset
49
kono
parents:
diff changeset
50 /**
kono
parents:
diff changeset
51 * @file global_state.h
kono
parents:
diff changeset
52 *
kono
parents:
diff changeset
53 * @brief The global_state_t structure contains most of the global context
kono
parents:
diff changeset
54 * maintained by the Intel Cilk runtime.
kono
parents:
diff changeset
55 */
kono
parents:
diff changeset
56
kono
parents:
diff changeset
57 #ifndef INCLUDED_GLOBAL_STATE_DOT_H
kono
parents:
diff changeset
58 #define INCLUDED_GLOBAL_STATE_DOT_H
kono
parents:
diff changeset
59
kono
parents:
diff changeset
60 #include <cilk/common.h>
kono
parents:
diff changeset
61
kono
parents:
diff changeset
62 #include "frame_malloc.h"
kono
parents:
diff changeset
63 #include "stats.h"
kono
parents:
diff changeset
64 #include "bug.h"
kono
parents:
diff changeset
65 #include "cilk_fiber.h"
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 __CILKRTS_BEGIN_EXTERN_C
kono
parents:
diff changeset
68
kono
parents:
diff changeset
69 /**
kono
parents:
diff changeset
70 * Non-null place-holder for a stack handle that has no meaningful value.
kono
parents:
diff changeset
71 */
kono
parents:
diff changeset
72 #define PLACEHOLDER_FIBER ((cilk_fiber *) -2)
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 /**
kono
parents:
diff changeset
75 * States for record_or_replay
kono
parents:
diff changeset
76 */
kono
parents:
diff changeset
77 enum record_replay_t {
kono
parents:
diff changeset
78 RECORD_REPLAY_NONE,
kono
parents:
diff changeset
79 RECORD_LOG,
kono
parents:
diff changeset
80 REPLAY_LOG
kono
parents:
diff changeset
81 };
kono
parents:
diff changeset
82
kono
parents:
diff changeset
83 /**
kono
parents:
diff changeset
84 * @brief Global state structure version.
kono
parents:
diff changeset
85 *
kono
parents:
diff changeset
86 * Since the global state is exposed for debugger access, we need a version
kono
parents:
diff changeset
87 * number to let it know that the version of the structure is what it expects
kono
parents:
diff changeset
88 * to see. If any of the fields marked as (fixed) below are changed, the
kono
parents:
diff changeset
89 * version number needs to be bumped.
kono
parents:
diff changeset
90 */
kono
parents:
diff changeset
91 #define GLOBAL_STATE_VERSION 0
kono
parents:
diff changeset
92
kono
parents:
diff changeset
93 /**
kono
parents:
diff changeset
94 * @brief The global state is a structure that is shared by all workers in
kono
parents:
diff changeset
95 * Cilk.
kono
parents:
diff changeset
96 *
kono
parents:
diff changeset
97 * Make the structure ready for use by calling
kono
parents:
diff changeset
98 * cilkg_init_global_state() and then cilkg_publish_global_state().
kono
parents:
diff changeset
99 *
kono
parents:
diff changeset
100 * The same global lock should be held while both of these methods are
kono
parents:
diff changeset
101 * called. These methods are split because it is useful to execute
kono
parents:
diff changeset
102 * other runtime initialization code in between.
kono
parents:
diff changeset
103 *
kono
parents:
diff changeset
104 * After cilkg_publish_global_state() has completed, Cilk runtime
kono
parents:
diff changeset
105 * methods may call cilkg_get_global_state() to look at the published
kono
parents:
diff changeset
106 * value without holding the global lock.
kono
parents:
diff changeset
107 *
kono
parents:
diff changeset
108 * Finally, clean up the global state by calling
kono
parents:
diff changeset
109 * cilkg_deinit_global_state(). This method should be called only
kono
parents:
diff changeset
110 * after all calls to cilkg_get_global_state() have completed, and
kono
parents:
diff changeset
111 * while holding the global lock.
kono
parents:
diff changeset
112 *
kono
parents:
diff changeset
113 * Before initialization and after deinitialization, the fields in the
kono
parents:
diff changeset
114 * global state have unspecified values, except for a few special
kono
parents:
diff changeset
115 * fields labeled "USER SETTING", which can be read and written before
kono
parents:
diff changeset
116 * initialization and after deinitialization.
kono
parents:
diff changeset
117 */
kono
parents:
diff changeset
118
kono
parents:
diff changeset
119 struct global_state_t { /* COMMON_PORTABLE */
kono
parents:
diff changeset
120
kono
parents:
diff changeset
121 /* Fields described as "(fixed)" should not be changed after
kono
parents:
diff changeset
122 * initialization.
kono
parents:
diff changeset
123 */
kono
parents:
diff changeset
124
kono
parents:
diff changeset
125 /*************************************************************************
kono
parents:
diff changeset
126 * Note that debugger integration must reach into the
kono
parents:
diff changeset
127 * global state! The debugger integration is depending on the
kono
parents:
diff changeset
128 * offsets of the addr_size, system_workers, total_workers,
kono
parents:
diff changeset
129 * stealing_disabled, sysdep, and workers. If these offsets change, the
kono
parents:
diff changeset
130 * debugger integration library will need to be changed to match!!!
kono
parents:
diff changeset
131 *************************************************************************/
kono
parents:
diff changeset
132
kono
parents:
diff changeset
133 uint16_t addr_size; ///< Number of bytes for an address, used by debugger (fixed)
kono
parents:
diff changeset
134
kono
parents:
diff changeset
135 uint16_t version; ///< Version of this structure (fixed)
kono
parents:
diff changeset
136
kono
parents:
diff changeset
137 int system_workers; ///< Number of system workers (fixed)
kono
parents:
diff changeset
138
kono
parents:
diff changeset
139 /**
kono
parents:
diff changeset
140 * @brief USER SETTING: Maximum number of user workers that can be
kono
parents:
diff changeset
141 * bound to cilk workers.
kono
parents:
diff changeset
142 *
kono
parents:
diff changeset
143 * 0 unless set by user. Call cilkg_calc_max_user_workers to get
kono
parents:
diff changeset
144 * the value.
kono
parents:
diff changeset
145 */
kono
parents:
diff changeset
146 int max_user_workers;
kono
parents:
diff changeset
147
kono
parents:
diff changeset
148 int total_workers; ///< Total number of worker threads allocated (fixed)
kono
parents:
diff changeset
149
kono
parents:
diff changeset
150 int workers_running; ///< True when system workers have beens started */
kono
parents:
diff changeset
151
kono
parents:
diff changeset
152 /// Set by debugger to disable stealing (fixed)
kono
parents:
diff changeset
153 int stealing_disabled;
kono
parents:
diff changeset
154
kono
parents:
diff changeset
155 /// System-dependent part of the global state
kono
parents:
diff changeset
156 struct global_sysdep_state *sysdep;
kono
parents:
diff changeset
157
kono
parents:
diff changeset
158 /// Array of worker structures.
kono
parents:
diff changeset
159 __cilkrts_worker **workers;
kono
parents:
diff changeset
160
kono
parents:
diff changeset
161 /******* END OF DEBUGGER-INTEGRATION FIELDS ***************/
kono
parents:
diff changeset
162
kono
parents:
diff changeset
163 /// Number of frames in each worker's lazy task queue
kono
parents:
diff changeset
164 __STDNS size_t ltqsize;
kono
parents:
diff changeset
165
kono
parents:
diff changeset
166 /**
kono
parents:
diff changeset
167 * @brief USER SETTING: Force all possible reductions.
kono
parents:
diff changeset
168 *
kono
parents:
diff changeset
169 * TRUE if running a p-tool that requires reducers to call the reduce()
kono
parents:
diff changeset
170 * method even if no actual stealing occurs.
kono
parents:
diff changeset
171 *
kono
parents:
diff changeset
172 * When set to TRUE, runtime will simulate steals, forcing calls to the
kono
parents:
diff changeset
173 * the reduce() methods of reducers.
kono
parents:
diff changeset
174 *
kono
parents:
diff changeset
175 */
kono
parents:
diff changeset
176 int force_reduce;
kono
parents:
diff changeset
177
kono
parents:
diff changeset
178 /// USER SETTING: Per-worker fiber pool size
kono
parents:
diff changeset
179 int fiber_pool_size;
kono
parents:
diff changeset
180
kono
parents:
diff changeset
181 /// USER SETTING: Global fiber pool size
kono
parents:
diff changeset
182 int global_fiber_pool_size;
kono
parents:
diff changeset
183
kono
parents:
diff changeset
184 /**
kono
parents:
diff changeset
185 * @brief TRUE when workers should exit scheduling loop so we can
kono
parents:
diff changeset
186 * shut down the runtime and free the global state.
kono
parents:
diff changeset
187 *
kono
parents:
diff changeset
188 * @note @c work_done will be checked *FREQUENTLY* in the scheduling loop
kono
parents:
diff changeset
189 * by idle workers. We need to ensure that it's not in a cache line which
kono
parents:
diff changeset
190 * may be invalidated by other cores. The surrounding fields are either
kono
parents:
diff changeset
191 * constant after initialization or not used until shutdown (stats) so we
kono
parents:
diff changeset
192 * should be OK.
kono
parents:
diff changeset
193 */
kono
parents:
diff changeset
194 volatile int work_done;
kono
parents:
diff changeset
195
kono
parents:
diff changeset
196 int under_ptool; ///< True when running under a serial PIN tool
kono
parents:
diff changeset
197
kono
parents:
diff changeset
198 statistics stats; ///< Statistics on use of runtime
kono
parents:
diff changeset
199
kono
parents:
diff changeset
200 /**
kono
parents:
diff changeset
201 * @brief USER SETTING: Maximum number of stacks the runtime will
kono
parents:
diff changeset
202 * allocate (apart from those created by the OS when worker
kono
parents:
diff changeset
203 * threads are created).
kono
parents:
diff changeset
204 *
kono
parents:
diff changeset
205 * If max_stacks == 0,there is no pre-defined maximum.
kono
parents:
diff changeset
206 */
kono
parents:
diff changeset
207 unsigned max_stacks;
kono
parents:
diff changeset
208
kono
parents:
diff changeset
209 /// Size of each stack
kono
parents:
diff changeset
210 size_t stack_size;
kono
parents:
diff changeset
211
kono
parents:
diff changeset
212 /// Global cache for per-worker memory
kono
parents:
diff changeset
213 struct __cilkrts_frame_cache frame_malloc;
kono
parents:
diff changeset
214
kono
parents:
diff changeset
215 /// Global fiber pool
kono
parents:
diff changeset
216 cilk_fiber_pool fiber_pool;
kono
parents:
diff changeset
217
kono
parents:
diff changeset
218 /**
kono
parents:
diff changeset
219 * @brief Track whether the runtime has failed to allocate a
kono
parents:
diff changeset
220 * stack.
kono
parents:
diff changeset
221 *
kono
parents:
diff changeset
222 * Setting this flag prevents multiple warnings from being
kono
parents:
diff changeset
223 * issued.
kono
parents:
diff changeset
224 */
kono
parents:
diff changeset
225 int failure_to_allocate_stack;
kono
parents:
diff changeset
226
kono
parents:
diff changeset
227 /**
kono
parents:
diff changeset
228 * @brief USER SETTING: indicate record or replay log.
kono
parents:
diff changeset
229 * Set to NULL if not used in this run.
kono
parents:
diff changeset
230 */
kono
parents:
diff changeset
231 char *record_replay_file_name;
kono
parents:
diff changeset
232
kono
parents:
diff changeset
233 /**
kono
parents:
diff changeset
234 * @brief Record/replay state.
kono
parents:
diff changeset
235 * Valid states are:
kono
parents:
diff changeset
236 * RECORD_REPLAY_NONE - Not recording or replaying a log
kono
parents:
diff changeset
237 * RECORD_LOG - Recording a log for replay later
kono
parents:
diff changeset
238 * REPLAY_LOG - Replay a log recorded earlier
kono
parents:
diff changeset
239 */
kono
parents:
diff changeset
240 enum record_replay_t record_or_replay;
kono
parents:
diff changeset
241
kono
parents:
diff changeset
242 /**
kono
parents:
diff changeset
243 * @brief Buffer to force max_steal_failures to appear on a
kono
parents:
diff changeset
244 * different cache line from the previous member variables.
kono
parents:
diff changeset
245 *
kono
parents:
diff changeset
246 * This padding is needed because max_steal_failures is read
kono
parents:
diff changeset
247 * constantly and other modified values in the global state will
kono
parents:
diff changeset
248 * cause thrashing.
kono
parents:
diff changeset
249 */
kono
parents:
diff changeset
250 char cache_buf[64];
kono
parents:
diff changeset
251
kono
parents:
diff changeset
252 /**
kono
parents:
diff changeset
253 * @brief Maximum number of times a thread should fail to steal
kono
parents:
diff changeset
254 * before checking if Cilk is shutting down.
kono
parents:
diff changeset
255 */
kono
parents:
diff changeset
256 unsigned int max_steal_failures;
kono
parents:
diff changeset
257
kono
parents:
diff changeset
258 /// Pointer to scheduler entry point
kono
parents:
diff changeset
259 void (*scheduler)(__cilkrts_worker *w);
kono
parents:
diff changeset
260
kono
parents:
diff changeset
261 /**
kono
parents:
diff changeset
262 * @brief Buffer to force P and Q to appear on a different cache
kono
parents:
diff changeset
263 * line from the previous member variables.
kono
parents:
diff changeset
264 */
kono
parents:
diff changeset
265 char cache_buf_2[64];
kono
parents:
diff changeset
266
kono
parents:
diff changeset
267 int P; ///< USER SETTING: number of system workers + 1 (fixed)
kono
parents:
diff changeset
268 int Q; ///< Number of user threads currently bound to workers
kono
parents:
diff changeset
269 };
kono
parents:
diff changeset
270
kono
parents:
diff changeset
271 /**
kono
parents:
diff changeset
272 * @brief Initialize the global state object. This method must both
kono
parents:
diff changeset
273 * complete before referencing any fields in the global state, except
kono
parents:
diff changeset
274 * those specified as "user-settable values".
kono
parents:
diff changeset
275 */
kono
parents:
diff changeset
276 global_state_t* cilkg_init_global_state();
kono
parents:
diff changeset
277
kono
parents:
diff changeset
278 /**
kono
parents:
diff changeset
279 * @brief Publish the global state object, so that
kono
parents:
diff changeset
280 * cilkg_is_published can return true.
kono
parents:
diff changeset
281 *
kono
parents:
diff changeset
282 * @param g - the global state created by cilkg_init_global_state() to
kono
parents:
diff changeset
283 * publish.
kono
parents:
diff changeset
284 *
kono
parents:
diff changeset
285 * After the global state object has been published, a thread should
kono
parents:
diff changeset
286 * not modify this state unless it has exclusive access (i.e., holds
kono
parents:
diff changeset
287 * the global lock).
kono
parents:
diff changeset
288 */
kono
parents:
diff changeset
289 void cilkg_publish_global_state(global_state_t* g);
kono
parents:
diff changeset
290
kono
parents:
diff changeset
291 /**
kono
parents:
diff changeset
292 * @brief Return true if the global state has been fully initialized
kono
parents:
diff changeset
293 * and published, and has not been deinitialized.
kono
parents:
diff changeset
294 */
kono
parents:
diff changeset
295 int cilkg_is_published(void);
kono
parents:
diff changeset
296
kono
parents:
diff changeset
297 /**
kono
parents:
diff changeset
298 * @brief De-initializes the global state object. Must be called to free
kono
parents:
diff changeset
299 * resources when the global state is no longer needed.
kono
parents:
diff changeset
300 */
kono
parents:
diff changeset
301 void cilkg_deinit_global_state(void);
kono
parents:
diff changeset
302
kono
parents:
diff changeset
303 /**
kono
parents:
diff changeset
304 * @brief Returns the global state object. Result is valid only if the
kono
parents:
diff changeset
305 * global state has been published (see cilkg_publish_global_state()).
kono
parents:
diff changeset
306 */
kono
parents:
diff changeset
307 static inline
kono
parents:
diff changeset
308 global_state_t* cilkg_get_global_state(void)
kono
parents:
diff changeset
309 {
kono
parents:
diff changeset
310 // "private" extern declaration:
kono
parents:
diff changeset
311 extern global_state_t *cilkg_singleton_ptr;
kono
parents:
diff changeset
312
kono
parents:
diff changeset
313 __CILKRTS_ASSERT(cilkg_singleton_ptr); // Debug only
kono
parents:
diff changeset
314 return cilkg_singleton_ptr;
kono
parents:
diff changeset
315 }
kono
parents:
diff changeset
316
kono
parents:
diff changeset
317
kono
parents:
diff changeset
318 /**
kono
parents:
diff changeset
319 * @brief Implementation of __cilkrts_set_params.
kono
parents:
diff changeset
320 *
kono
parents:
diff changeset
321 * Set user controllable parameters
kono
parents:
diff changeset
322 * @param param - string specifying parameter to be set
kono
parents:
diff changeset
323 * @param value - string specifying new value
kono
parents:
diff changeset
324 * @returns One of: CILKG_SET_PARAM_SUCCESS ( = 0),
kono
parents:
diff changeset
325 * CILKG_SET_PARAM_UNIMP, CILKG_SET_PARAM_XRANGE,
kono
parents:
diff changeset
326 * CILKG_SET_PARAM_INVALID, or CILKG_SET_PARAM_LATE.
kono
parents:
diff changeset
327 *
kono
parents:
diff changeset
328 * @attention The wide character version __cilkrts_set_param_w() is available
kono
parents:
diff changeset
329 * only on Windows.
kono
parents:
diff changeset
330 *
kono
parents:
diff changeset
331 * Allowable parameter names:
kono
parents:
diff changeset
332 *
kono
parents:
diff changeset
333 * - "nworkers" - number of processors that should run Cilk code.
kono
parents:
diff changeset
334 * The value is a string of digits to be parsed by strtol.
kono
parents:
diff changeset
335 *
kono
parents:
diff changeset
336 * - "force reduce" - test reducer callbacks by allocating new views
kono
parents:
diff changeset
337 * for every spawn within which a reducer is accessed. This can
kono
parents:
diff changeset
338 * significantly reduce performance. The value is "1" or "true"
kono
parents:
diff changeset
339 * to enable, "0" or "false" to disable.
kono
parents:
diff changeset
340 * @warning Enabling "force reduce" when running with more than a single
kono
parents:
diff changeset
341 * worker is currently broken.
kono
parents:
diff changeset
342 *
kono
parents:
diff changeset
343 * - "max user workers" - (Not publicly documented) Sets the number of slots
kono
parents:
diff changeset
344 * allocated for user worker threads
kono
parents:
diff changeset
345 *
kono
parents:
diff changeset
346 * - "local stacks" - (Not publicly documented) Number of stacks we'll hold in
kono
parents:
diff changeset
347 * the per-worker stack cache. Range 1 .. 42. See
kono
parents:
diff changeset
348 * cilkg_init_global_state for details.
kono
parents:
diff changeset
349 *
kono
parents:
diff changeset
350 * - "shared stacks" - (Not publicly documented) Maximum number of stacks
kono
parents:
diff changeset
351 * we'll hold in the global stack cache. Maximum value is 42. See
kono
parents:
diff changeset
352 * __cilkrts_make_global_state for details
kono
parents:
diff changeset
353 *
kono
parents:
diff changeset
354 * - "nstacks" - (Not publicly documented at this time, though it may be
kono
parents:
diff changeset
355 * exposed in the future) Sets the maximum number of stacks permitted at one
kono
parents:
diff changeset
356 * time. If the runtime reaches this maximum, it will cease to allocate
kono
parents:
diff changeset
357 * stacks and the app will lose parallelism. 0 means unlimited. Default is
kono
parents:
diff changeset
358 * unlimited. Minimum is twice the number of worker threads, though that
kono
parents:
diff changeset
359 * cannot be tested at this time.
kono
parents:
diff changeset
360 */
kono
parents:
diff changeset
361 int cilkg_set_param(const char* param, const char* value);
kono
parents:
diff changeset
362 #ifdef _WIN32
kono
parents:
diff changeset
363 /**
kono
parents:
diff changeset
364 * @brief Implementation of __cilkrts_set_params for Unicode characters on
kono
parents:
diff changeset
365 * Windows. See the documentation on @ref cilkg_set_param for more details.
kono
parents:
diff changeset
366 *
kono
parents:
diff changeset
367 * Set user controllable parameters
kono
parents:
diff changeset
368 * @param param - string specifying parameter to be set
kono
parents:
diff changeset
369 * @param value - string specifying new value
kono
parents:
diff changeset
370 * @returns One of: CILKG_SET_PARAM_SUCCESS ( = 0),
kono
parents:
diff changeset
371 * CILKG_SET_PARAM_UNIMP, CILKG_SET_PARAM_XRANGE,
kono
parents:
diff changeset
372 * CILKG_SET_PARAM_INVALID, or CILKG_SET_PARAM_LATE.
kono
parents:
diff changeset
373 */
kono
parents:
diff changeset
374 int cilkg_set_param_w(const wchar_t* param, const wchar_t* value);
kono
parents:
diff changeset
375 #endif
kono
parents:
diff changeset
376
kono
parents:
diff changeset
377 /**
kono
parents:
diff changeset
378 * @brief implementation of __cilkrts_get_nworkers()
kono
parents:
diff changeset
379 */
kono
parents:
diff changeset
380 static inline
kono
parents:
diff changeset
381 int cilkg_get_nworkers(void)
kono
parents:
diff changeset
382 {
kono
parents:
diff changeset
383 // "private" extern declaration
kono
parents:
diff changeset
384 extern global_state_t* cilkg_get_user_settable_values(void);
kono
parents:
diff changeset
385 return cilkg_get_user_settable_values()->P;
kono
parents:
diff changeset
386 }
kono
parents:
diff changeset
387
kono
parents:
diff changeset
388 /**
kono
parents:
diff changeset
389 * @brief implementation of __cilkrts_get_total_workers()
kono
parents:
diff changeset
390 */
kono
parents:
diff changeset
391 static inline
kono
parents:
diff changeset
392 int cilkg_get_total_workers(void)
kono
parents:
diff changeset
393 {
kono
parents:
diff changeset
394 // "private" extern declaration
kono
parents:
diff changeset
395 extern int cilkg_calc_total_workers(void);
kono
parents:
diff changeset
396
kono
parents:
diff changeset
397 // This number can fluctate until initialization so we
kono
parents:
diff changeset
398 // compute it from scratch
kono
parents:
diff changeset
399 return cilkg_calc_total_workers();
kono
parents:
diff changeset
400 }
kono
parents:
diff changeset
401
kono
parents:
diff changeset
402 /**
kono
parents:
diff changeset
403 * @brief implementation of __cilkrts_get_force_reduce()
kono
parents:
diff changeset
404 */
kono
parents:
diff changeset
405 static inline
kono
parents:
diff changeset
406 int cilkg_get_force_reduce(void)
kono
parents:
diff changeset
407 {
kono
parents:
diff changeset
408 // "private" extern declaration
kono
parents:
diff changeset
409 extern global_state_t* cilkg_get_user_settable_values(void);
kono
parents:
diff changeset
410 return cilkg_get_user_settable_values()->force_reduce;
kono
parents:
diff changeset
411 }
kono
parents:
diff changeset
412
kono
parents:
diff changeset
413 /**
kono
parents:
diff changeset
414 * @brief implementation of __cilkrts_get_stack_size()
kono
parents:
diff changeset
415 */
kono
parents:
diff changeset
416 static inline
kono
parents:
diff changeset
417 size_t cilkg_get_stack_size(void)
kono
parents:
diff changeset
418 {
kono
parents:
diff changeset
419 // "private" extern declaration
kono
parents:
diff changeset
420 extern global_state_t* cilkg_get_user_settable_values(void);
kono
parents:
diff changeset
421 return cilkg_get_user_settable_values()->stack_size;
kono
parents:
diff changeset
422 }
kono
parents:
diff changeset
423
kono
parents:
diff changeset
424 /**
kono
parents:
diff changeset
425 * @brief Run the scheduler function stored in the global_state
kono
parents:
diff changeset
426 *
kono
parents:
diff changeset
427 * Look up the scheduler function in global_state and run it. Report a fatal
kono
parents:
diff changeset
428 * error if an exception escapes the scheduler function.
kono
parents:
diff changeset
429 *
kono
parents:
diff changeset
430 * @param w - Worker structure to associate with the current thread.
kono
parents:
diff changeset
431 *
kono
parents:
diff changeset
432 * @attention The scheduler field of the global state must be set before this
kono
parents:
diff changeset
433 * function is called.
kono
parents:
diff changeset
434 */
kono
parents:
diff changeset
435 void __cilkrts_run_scheduler_with_exceptions(__cilkrts_worker *w);
kono
parents:
diff changeset
436
kono
parents:
diff changeset
437 __CILKRTS_END_EXTERN_C
kono
parents:
diff changeset
438
kono
parents:
diff changeset
439 #endif // ! defined(INCLUDED_GLOBAL_STATE_DOT_H)