1 /* pedigrees.h -*-C++-*-
3 *************************************************************************
6 * Copyright (C) 2009-2013, Intel Corporation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
14 * * Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * * Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in
18 * the documentation and/or other materials provided with the
20 * * Neither the name of Intel Corporation nor the names of its
21 * contributors may be used to endorse or promote products derived
22 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
29 * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
32 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
33 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY
35 * WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 **************************************************************************/
39 #ifndef INCLUDED_PEDIGREES_DOT_H
40 #define INCLUDED_PEDIGREES_DOT_H
43 #include <cilk/common.h>
44 #include <internal/abi.h>
46 #include "rts-common.h"
47 #include "global_state.h"
50 __CILKRTS_BEGIN_EXTERN_C
55 * @brief pedigrees.h declares common routines related to pedigrees
56 * and the pedigree API.
61 * @brief Sets the leaf pedigree node for the current user thread.
63 * A typical implementation stores this pedigree node in thread-local
67 * - Current thread should be a user thread.
69 * @param leaf The pedigree node to store as a leaf.
72 void __cilkrts_set_pedigree_leaf(__cilkrts_pedigree
* leaf
);
76 * Load the pedigree leaf node from thread-local storage into the
77 * current user worker. This method should execute as a part of
78 * binding the user thread to a worker.
82 * - w should be the worker for the current thread
83 * - w should be a user thread.
86 void load_pedigree_leaf_into_user_worker(__cilkrts_worker
*w
);
89 * Save the pedigree leaf node from the worker into thread-local
90 * storage. This method should execute as part of unbinding a user
91 * thread from a worker.
95 * - w should be the worker for the current thread
96 * - w should be a user thread.
99 void save_pedigree_leaf_from_user_worker(__cilkrts_worker
*w
);
104 * Update pedigree for a worker when leaving a frame.
106 * If this is the frame of a spawn helper (indicated by the
107 * CILK_FRAME_DETACHED flag) we must update the pedigree. The
108 * pedigree points to nodes allocated on the stack. Failing to
109 * update it will result in a accvio/segfault if the pedigree is
110 * walked. This must happen for all spawn helper frames, even if
111 * we're processing an exception.
114 inline void update_pedigree_on_leave_frame(__cilkrts_worker
*w
,
115 __cilkrts_stack_frame
*sf
)
117 // Update the worker's pedigree information if this is an ABI 1 or later
119 if (CILK_FRAME_VERSION_VALUE(sf
->flags
) >= 1)
121 w
->pedigree
.rank
= sf
->spawn_helper_pedigree
.rank
+ 1;
122 w
->pedigree
.parent
= sf
->spawn_helper_pedigree
.parent
;
128 __CILKRTS_END_EXTERN_C
130 #endif // ! defined(INCLUDED_PEDIGREES_DOT_H)