Home ⌂Doc Index ◂Up ▴
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-2020 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 /* The API to enable interoperability between Intel(R) Cilk(TM) Plus and
18  Intel(R) Threading Building Blocks. */
19 
20 #ifndef CILK_TBB_INTEROP_H
21 #define CILK_TBB_INTEROP_H
22 
23 #ifndef _WIN32
24 #ifdef IN_CILK_RUNTIME
25 #define CILK_EXPORT __attribute__((visibility("protected")))
26 #else
27 #define CILK_EXPORT /* nothing */
28 #endif
29 #else
30 #ifdef IN_CILK_RUNTIME
31 #define CILK_EXPORT __declspec(dllexport)
32 #else
33 #define CILK_EXPORT __declspec(dllimport)
34 #endif // IN_CILK_RUNTIME
35 #endif // _WIN32
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif /* __cplusplus */
40 
41 /* A return code. 0 indicates success */
42 typedef int __cilk_tbb_retcode;
43 
45  CILK_TBB_STACK_ORPHAN, // disconnecting stack from a thread
46  CILK_TBB_STACK_ADOPT, // reconnecting orphaned stack to a trhead
47  CILK_TBB_STACK_RELEASE // releasing stack
48 };
49 
51 
53 
54 /* Each thunk structure has two pointers: "routine" and "data".
55  The caller of the thunk invokes *routine, passing "data" as the void* parameter. */
56 
57 /* Thunk invoked by Intel Cilk Plus runtime (cilkrts) when it changes the relationship
58  between a stack and a thread. It does not matter what stack the thunk runs on.
59  The thread (not fiber) on which the thunk runs is important.
60 
61  CILK_TBB_STACK_ORPHAN
62  The thunk must be invoked on the thread disconnecting itself from the stack.
63  Must "happen before" the stack is adopted elsewhere.
64  CILK_TBB_STACK_ADOPT
65  The thunk must be invoked on the thread adopting the stack.
66  CILK_TBB_STACK_RELEASE
67  The thunk must be invoked on the thread doing the releasing,
68  Must "happen before" the stack is used elsewhere.
69 
70  When a non-empty stack is transferred between threads, the first thread must orphan it
71  and the second thread must adopt it.
72 
73  An empty stack can be transferred similarly, or simply released by the first thread.
74 
75  Here is a summary of the actions as transitions on a state machine.
76 
77  watch ORPHAN
78  -->--> -->--
79  / \ / \
80  (freed empty stack) (TBB sees stack running on thread) (stack in limbo)
81  | \ / \ / |
82  | --<-- --<-- |
83  ^ RELEASE or ADOPT V
84  \ unwatch /
85  \ /
86  --------------------------<---------------------------
87  RELEASE
88 */
91  void* data; /* Set by TBB */
92 };
93 
94 /* Thunk invoked by TBB when it is no longer interested in watching the stack bound to the current thread. */
97  void* data;
98 };
99 
100 /* Defined by cilkrts, called by TBB.
101  Requests that cilkrts invoke __cilk_tbb_stack_op_thunk when it orphans a stack.
102  cilkrts sets *u to a thunk that TBB should call when it is no longer interested in watching the stack. */
105  struct __cilk_tbb_stack_op_thunk o);
106 
107 #ifdef __cplusplus
108 }
109 #endif /* __cplusplus */
110 
111 #endif // CILK_TBB_INTEROP_H
__cilk_tbb_pfn_stack_op routine
__cilk_tbb_stack_op
int __cilk_tbb_retcode
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_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_retcode(* __cilk_tbb_pfn_unwatch_stacks)(void *data)
__cilk_tbb_pfn_unwatch_stacks routine
#define CILK_EXPORT
CILK_EXPORT __cilk_tbb_retcode __cilkrts_watch_stack(struct __cilk_tbb_unwatch_thunk *u, struct __cilk_tbb_stack_op_thunk o)

Copyright © 2005-2020 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.