HPCToolkit
lush.h
Go to the documentation of this file.
1 // -*-Mode: C++;-*- // technically C99
2 
3 // * BeginRiceCopyright *****************************************************
4 //
5 // $HeadURL$
6 // $Id$
7 //
8 // --------------------------------------------------------------------------
9 // Part of HPCToolkit (hpctoolkit.org)
10 //
11 // Information about sources of support for research and development of
12 // HPCToolkit is at 'hpctoolkit.org' and in 'README.Acknowledgments'.
13 // --------------------------------------------------------------------------
14 //
15 // Copyright ((c)) 2002-2019, Rice University
16 // All rights reserved.
17 //
18 // Redistribution and use in source and binary forms, with or without
19 // modification, are permitted provided that the following conditions are
20 // met:
21 //
22 // * Redistributions of source code must retain the above copyright
23 // notice, this list of conditions and the following disclaimer.
24 //
25 // * Redistributions in binary form must reproduce the above copyright
26 // notice, this list of conditions and the following disclaimer in the
27 // documentation and/or other materials provided with the distribution.
28 //
29 // * Neither the name of Rice University (RICE) nor the names of its
30 // contributors may be used to endorse or promote products derived from
31 // this software without specific prior written permission.
32 //
33 // This software is provided by RICE and contributors "as is" and any
34 // express or implied warranties, including, but not limited to, the
35 // implied warranties of merchantability and fitness for a particular
36 // purpose are disclaimed. In no event shall RICE or contributors be
37 // liable for any direct, indirect, incidental, special, exemplary, or
38 // consequential damages (including, but not limited to, procurement of
39 // substitute goods or services; loss of use, data, or profits; or
40 // business interruption) however caused and on any theory of liability,
41 // whether in contract, strict liability, or tort (including negligence
42 // or otherwise) arising in any way out of the use of this software, even
43 // if advised of the possibility of such damage.
44 //
45 // ******************************************************* EndRiceCopyright *
46 
47 //***************************************************************************
48 //
49 // File:
50 // $HeadURL$
51 //
52 // Purpose:
53 // LUSH: Logical Unwind Support for HPCToolkit
54 //
55 // Description:
56 // [The set of functions, macros, etc. defined in the file]
57 //
58 // Author:
59 // Nathan Tallent, Rice University.
60 //
61 //***************************************************************************
62 
63 #ifndef lush_lush_h
64 #define lush_lush_h
65 
66 //************************* System Include Files ****************************
67 
68 #include <stdlib.h>
69 #include <ucontext.h>
70 
71 //*************************** User Include Files ****************************
72 
73 #include "lushi.h"
74 #include "lush-support-rt.h"
75 
76 //*************************** Forward Declarations **************************
77 
78 #if defined(__cplusplus)
79 extern "C" {
80 #endif
81 
82 //***************************************************************************
83 // LUSH Agents
84 //***************************************************************************
85 
86 // ---------------------------------------------------------
87 // A pool of LUSH agents
88 // ---------------------------------------------------------
89 
90 // FIXME: put this and agent decls in lush-support.h into one file.
92 
93  lush_agent_t agent; // FIXME: one agent for now
94 
95  int metric_time; // FIXME: only one for now
96  int metric_idleness; // idleness is relative to time
97 
98  // for each LUSHI routine, a vector of pointers for each agent
99  // (indexed by agent id)
100 #define POOL_DECL(FN) \
101  FN ## _fn_t* FN
102 
112 
113 #undef POOL_DECL
114 };
115 
116 int
117 lush_agent__init(lush_agent_t* x, int id, const char* path,
118  lush_agent_pool_t* pool);
119 
120 int
122 
123 
124 int
125 lush_agent_pool__init(lush_agent_pool_t* x, const char* path);
126 
127 int
129 
130 
131 //***************************************************************************
132 // LUSH Unwinding Interface
133 //***************************************************************************
134 
135 // Given an agent-pool and context, initialize the lush_cursor but do
136 // not step to the first (innermost) bichord.
137 void
139  lush_agent_pool_t* apool, ucontext_t* context);
140 
141 
142 // Given a lush_cursor, step the cursor to the next (less deeply
143 // nested) bichord. Returns:
144 // LUSH_STEP_CONT: if step was sucessful
145 // LUSH_STEP_END_PROJ: if chord was end of projection
146 // LUSH_STEP_ERROR: on account of an error.
149 
150 
151 // Given a lush_cursor, step the cursor to the next (less deeply
152 // nested) p-note/l-note of the current p-chord/l-chord.
153 // Returns:
154 // LUSH_STEP_CONT: if step was sucessful
155 // (for l-notes, only possible if not a-to-0)
156 // LUSH_STEP_END_CHORD: if prev note was the end of the chord
157 // LUSH_STEP_ERROR: on account of an error.
160 
163 
164 
165 //***************************************************************************
166 // LUSH Unwinding Primitives
167 //***************************************************************************
168 
169 // Given a lush_cursor, _forcefully_ step the cursor to the next (less
170 // deeply nested) p-chord. Return values are same as
171 // lush_step_bichord.
174 
175 
176 // Given a lush_cursor, _forcefully_ step the cursor to the next (less
177 // deeply nested) p-note which may also be the next p-chord.
178 // Returns:
179 // LUSH_STEP_CONT: if step was sucessful
180 // LUSH_STEP_END_CHORD: if prev p-note was the end of the p-chord
181 // LUSH_STEP_END_PROJ: if prev p-chord was end of p-projection
182 // LUSH_STEP_ERROR: on account of an error.
183 //
184 // Sets zero or more of the following flags (as appropriate):
185 // LUSH_CURSOR_FLAGS_END_PPROJ:
186 // LUSH_CURSOR_FLAGS_BEG_PCHORD:
187 // LUSH_CURSOR_FLAGS_END_PCHORD:
190 
191 
192 //***************************************************************************
193 
194 #if defined(__cplusplus)
195 } /* extern "C" */
196 #endif
197 
198 #endif /* lush_lush_h */
lush_step_t LUSHI_step_bichord(lush_cursor_t *cursor)
Definition: agent-cilk.c:206
char * LUSHI_strerror(int code)
Definition: agent-cilk.c:152
lush_step_t lush_step_pnote(lush_cursor_t *cursor)
Definition: lush.c:300
int LUSHI_fini()
Definition: agent-cilk.c:145
lush_step_t LUSHI_step_lnote(lush_cursor_t *cursor)
Definition: agent-cilk.c:327
int lush_agent_pool__init(lush_agent_pool_t *x, const char *path)
Definition: lush.c:168
lush_step_t lush_forcestep_pchord(lush_cursor_t *cursor)
int lush_agent__init(lush_agent_t *x, int id, const char *path, lush_agent_pool_t *pool)
Definition: lush.c:97
int LUSHI_init(int argc, char **argv, lush_agentid_t aid, LUSHCB_malloc_fn_t malloc_fn, LUSHCB_free_fn_t free_fn, LUSHCB_step_fn_t step_fn, LUSHCB_loadmap_find_fn_t loadmap_fn)
Definition: agent-cilk.c:126
int LUSHI_reg_dlopen()
Definition: agent-cilk.c:163
bool LUSHI_do_metric(uint64_t incrMetricIn, bool *doMetric, bool *doMetricIdleness, uint64_t *incrMetric, double *incrMetricIdleness)
Definition: agent-cilk.c:557
bool LUSHI_ismycode(void *addr)
Definition: agent-cilk.c:170
lush_step_t lush_step_bichord(lush_cursor_t *cursor)
Definition: lush.c:244
lush_step_t LUSHI_step_pnote(lush_cursor_t *cursor)
Definition: agent-cilk.c:291
int lush_agent__fini(lush_agent_t *x, lush_agent_pool_t *pool)
Definition: lush.c:135
POOL_DECL(LUSHI_init)
lush_step_t lush_forcestep_pnote(lush_cursor_t *cursor)
Definition: lush.c:412
enum lush_step lush_step_t
int metric_idleness
Definition: lush.h:96
lush_step_t lush_step_lnote(lush_cursor_t *cursor)
Definition: lush.c:335
void lush_init_unw(lush_cursor_t *cursor, lush_agent_pool_t *apool, ucontext_t *context)
Definition: lush.c:231
lush_agent_t agent
Definition: lush.h:93
int lush_agent_pool__fini(lush_agent_pool_t *x)
Definition: lush.c:203
int metric_time
Definition: lush.h:95