Intel(R) Threading Building Blocks Doxygen Documentation  version 4.2.3
cilk-tbb-interop.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2005-2019 Intel Corporation
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 
16 
17 
18 
19 */
20 
21 /* The API to enable interoperability between Intel(R) Cilk(TM) Plus and
22  Intel(R) Threading Building Blocks. */
23 
24 #ifndef CILK_TBB_INTEROP_H
25 #define CILK_TBB_INTEROP_H
26 
27 #ifndef _WIN32
28 #ifdef IN_CILK_RUNTIME
29 #define CILK_EXPORT __attribute__((visibility("protected")))
30 #else
31 #define CILK_EXPORT /* nothing */
32 #endif
33 #else
34 #ifdef IN_CILK_RUNTIME
35 #define CILK_EXPORT __declspec(dllexport)
36 #else
37 #define CILK_EXPORT __declspec(dllimport)
38 #endif // IN_CILK_RUNTIME
39 #endif // _WIN32
40 
41 #ifdef __cplusplus
42 extern "C" {
43 #endif /* __cplusplus */
44 
45 /* A return code. 0 indicates success */
46 typedef int __cilk_tbb_retcode;
47 
49  CILK_TBB_STACK_ORPHAN, // disconnecting stack from a thread
50  CILK_TBB_STACK_ADOPT, // reconnecting orphaned stack to a trhead
51  CILK_TBB_STACK_RELEASE // releasing stack
52 };
53 
55 
57 
58 /* Each thunk structure has two pointers: "routine" and "data".
59  The caller of the thunk invokes *routine, passing "data" as the void* parameter. */
60 
61 /* Thunk invoked by Intel Cilk Plus runtime (cilkrts) when it changes the relationship
62  between a stack and a thread. It does not matter what stack the thunk runs on.
63  The thread (not fiber) on which the thunk runs is important.
64 
65  CILK_TBB_STACK_ORPHAN
66  The thunk must be invoked on the thread disconnecting itself from the stack.
67  Must "happen before" the stack is adopted elsewhere.
68  CILK_TBB_STACK_ADOPT
69  The thunk must be invoked on the thread adopting the stack.
70  CILK_TBB_STACK_RELEASE
71  The thunk must be invoked on the thread doing the releasing,
72  Must "happen before" the stack is used elsewhere.
73 
74  When a non-empty stack is transferred between threads, the first thread must orphan it
75  and the second thread must adopt it.
76 
77  An empty stack can be transferred similarly, or simply released by the first thread.
78 
79  Here is a summary of the actions as transitions on a state machine.
80 
81  watch ORPHAN
82  -->--> -->--
83  / \ / \
84  (freed empty stack) (TBB sees stack running on thread) (stack in limbo)
85  | \ / \ / |
86  | --<-- --<-- |
87  ^ RELEASE or ADOPT V
88  \ unwatch /
89  \ /
90  --------------------------<---------------------------
91  RELEASE
92 */
95  void* data; /* Set by TBB */
96 };
97 
98 /* Thunk invoked by TBB when it is no longer interested in watching the stack bound to the current thread. */
101  void* data;
102 };
103 
104 /* Defined by cilkrts, called by TBB.
105  Requests that cilkrts invoke __cilk_tbb_stack_op_thunk when it orphans a stack.
106  cilkrts sets *u to a thunk that TBB should call when it is no longer interested in watching the stack. */
109  struct __cilk_tbb_stack_op_thunk o);
110 
111 #ifdef __cplusplus
112 }
113 #endif /* __cplusplus */
114 
115 #endif // CILK_TBB_INTEROP_H
__cilk_tbb_pfn_stack_op routine
#define CILK_EXPORT
int __cilk_tbb_retcode
__cilk_tbb_retcode(* __cilk_tbb_pfn_unwatch_stacks)(void *data)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void * data
__cilk_tbb_retcode(* __cilk_tbb_pfn_stack_op)(enum __cilk_tbb_stack_op, void *data)
__cilk_tbb_stack_op
__cilk_tbb_pfn_unwatch_stacks routine
CILK_EXPORT __cilk_tbb_retcode __cilkrts_watch_stack(struct __cilk_tbb_unwatch_thunk *u, struct __cilk_tbb_stack_op_thunk o)

Copyright © 2005-2019 Intel Corporation. All Rights Reserved.

Intel, Pentium, Intel Xeon, Itanium, Intel XScale and VTune are registered trademarks or trademarks of Intel Corporation or its subsidiaries in the United States and other countries.

* Other names and brands may be claimed as the property of others.