cilk-tbb-interop.h
Go to the documentation of this file.
/*
Copyright (c) 2005-2020 Intel Corporation
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
/* The API to enable interoperability between Intel(R) Cilk(TM) Plus and
Intel(R) Threading Building Blocks. */
#ifndef CILK_TBB_INTEROP_H
#define CILK_TBB_INTEROP_H
#ifndef _WIN32
#ifdef IN_CILK_RUNTIME
#define CILK_EXPORT __attribute__((visibility("protected")))
#else
#define CILK_EXPORT /* nothing */
#endif
#else
#ifdef IN_CILK_RUNTIME
#define CILK_EXPORT __declspec(dllexport)
#else
#define CILK_EXPORT __declspec(dllimport)
#endif // IN_CILK_RUNTIME
#endif // _WIN32
#ifdef __cplusplus
extern "C" {
#endif /* __cplusplus */
/* A return code. 0 indicates success */
typedef int __cilk_tbb_retcode;
enum __cilk_tbb_stack_op {
CILK_TBB_STACK_ORPHAN, // disconnecting stack from a thread
CILK_TBB_STACK_ADOPT, // reconnecting orphaned stack to a trhead
CILK_TBB_STACK_RELEASE // releasing stack
};
typedef __cilk_tbb_retcode (*__cilk_tbb_pfn_stack_op)(enum __cilk_tbb_stack_op, void* data);
typedef __cilk_tbb_retcode (*__cilk_tbb_pfn_unwatch_stacks)(void *data);
/* Each thunk structure has two pointers: "routine" and "data".
The caller of the thunk invokes *routine, passing "data" as the void* parameter. */
/* Thunk invoked by Intel Cilk Plus runtime (cilkrts) when it changes the relationship
between a stack and a thread. It does not matter what stack the thunk runs on.
The thread (not fiber) on which the thunk runs is important.
CILK_TBB_STACK_ORPHAN
The thunk must be invoked on the thread disconnecting itself from the stack.
Must "happen before" the stack is adopted elsewhere.
CILK_TBB_STACK_ADOPT
The thunk must be invoked on the thread adopting the stack.
CILK_TBB_STACK_RELEASE
The thunk must be invoked on the thread doing the releasing,
Must "happen before" the stack is used elsewhere.
When a non-empty stack is transferred between threads, the first thread must orphan it
and the second thread must adopt it.
An empty stack can be transferred similarly, or simply released by the first thread.
Here is a summary of the actions as transitions on a state machine.
watch ORPHAN
-->--> -->--
/ \ / \
(freed empty stack) (TBB sees stack running on thread) (stack in limbo)
| \ / \ / |
| --<-- --<-- |
^ RELEASE or ADOPT V
\ unwatch /
\ /
--------------------------<---------------------------
RELEASE
*/
struct __cilk_tbb_stack_op_thunk {
__cilk_tbb_pfn_stack_op routine;
void* data; /* Set by TBB */
};
/* Thunk invoked by TBB when it is no longer interested in watching the stack bound to the current thread. */
struct __cilk_tbb_unwatch_thunk {
__cilk_tbb_pfn_unwatch_stacks routine;
void* data;
};
/* Defined by cilkrts, called by TBB.
Requests that cilkrts invoke __cilk_tbb_stack_op_thunk when it orphans a stack.
cilkrts sets *u to a thunk that TBB should call when it is no longer interested in watching the stack. */
CILK_EXPORT
__cilk_tbb_retcode __cilkrts_watch_stack(struct __cilk_tbb_unwatch_thunk* u,
struct __cilk_tbb_stack_op_thunk o);
#ifdef __cplusplus
}
#endif /* __cplusplus */
#endif // CILK_TBB_INTEROP_H
__cilk_tbb_unwatch_thunk
Definition: cilk-tbb-interop.h:95
__cilk_tbb_retcode
int __cilk_tbb_retcode
Definition: cilk-tbb-interop.h:42
CILK_EXPORT
#define CILK_EXPORT
Definition: cilk-tbb-interop.h:27
__cilk_tbb_stack_op_thunk
Definition: cilk-tbb-interop.h:89
__cilk_tbb_stack_op
__cilk_tbb_stack_op
Definition: cilk-tbb-interop.h:44
__cilk_tbb_stack_op_thunk::data
void * data
Definition: cilk-tbb-interop.h:91
__cilk_tbb_pfn_stack_op
__cilk_tbb_retcode(* __cilk_tbb_pfn_stack_op)(enum __cilk_tbb_stack_op, void *data)
Definition: cilk-tbb-interop.h:50
__cilk_tbb_unwatch_thunk::routine
__cilk_tbb_pfn_unwatch_stacks routine
Definition: cilk-tbb-interop.h:96
CILK_TBB_STACK_ORPHAN
Definition: cilk-tbb-interop.h:45
__cilkrts_watch_stack
CILK_EXPORT __cilk_tbb_retcode __cilkrts_watch_stack(struct __cilk_tbb_unwatch_thunk *u, struct __cilk_tbb_stack_op_thunk o)
CILK_TBB_STACK_ADOPT
Definition: cilk-tbb-interop.h:46
CILK_TBB_STACK_RELEASE
Definition: cilk-tbb-interop.h:47
__cilk_tbb_stack_op_thunk::routine
__cilk_tbb_pfn_stack_op routine
Definition: cilk-tbb-interop.h:90
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_string_handle unsigned long long ITT_FORMAT lu const __itt_domain __itt_id __itt_string_handle __itt_metadata_type size_t void * data
Definition: ittnotify_static.h:198
__cilk_tbb_pfn_unwatch_stacks
__cilk_tbb_retcode(* __cilk_tbb_pfn_unwatch_stacks)(void *data)
Definition: cilk-tbb-interop.h:52
__cilk_tbb_unwatch_thunk::data
void * data
Definition: cilk-tbb-interop.h:97

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.