81 #include <lib/prof-lean/atomic.h> 85 #define LUSHCB_DECL(FN) \ 86 LUSH ## FN ## _fn_t FN 105 LUSHCB_malloc_fn_t malloc_fn,
106 LUSHCB_free_fn_t free_fn,
107 LUSHCB_step_fn_t step_fn,
108 LUSHCB_loadmap_find_fn_t loadmap_fn)
112 CB_malloc = malloc_fn;
115 CB_loadmap_find = loadmap_fn;
163 assert(0 &&
"LUSHI_step_bichord: should never be called");
171 assert(0 &&
"LUSHI_step_pnote: should never be called");
179 assert(0 &&
"LUSHI_step_lnote: should never be called");
229 bool*
doMetric,
bool* doMetricIdleness,
230 uint64_t* incrMetric,
double* incrMetricIdleness)
232 lushPthr_t* pthr = &
TD_GET(pthr_metrics);
233 bool isWorking = pthr->is_working;
236 #if (LUSH_PTHR_FN_TY == 1) 239 *doMetricIdleness = (pthr->idleness > 0);
240 *incrMetric = incrMetricIn;
241 *incrMetricIdleness = pthr->idleness;
243 #elif (LUSH_PTHR_FN_TY == 2) 246 double num_working = *(pthr->ps_num_working);
247 double num_working_lock = *(pthr->ps_num_working_lock);
248 double num_idle_cond =
MAX(0, *(pthr->ps_num_idle_cond));
253 double idleness = 0.0;
254 if (is_working_lock) {
258 double num_idle = (*(pthr->ps_num_threads) - num_working);
259 double num_idle_lock =
MAX(0, num_idle - num_idle_cond);
260 num_working_lock =
MAX(1, num_working_lock);
261 idleness = (num_idle_lock / num_working_lock);
268 double num_working_othr =
MAX(1, num_working - num_working_lock);
269 idleness = (num_idle_cond / num_working_othr);
273 *doMetricIdleness =
true;
274 *incrMetric = incrMetricIn;
275 *incrMetricIdleness = (double)incrMetricIn * idleness;
276 #elif (LUSH_PTHR_FN_TY == 3) 279 *doMetricIdleness = (pthr->idleness > 0);
280 *incrMetric = incrMetricIn;
281 *incrMetricIdleness = pthr->idleness;
284 # error "agent-pthread.c!" 288 #if (LUSH_PTHR_FN_TY == 1) 290 *doMetricIdleness =
true;
292 *incrMetricIdleness = (double)incrMetricIn;
293 #elif (LUSH_PTHR_FN_TY == 2) 295 *doMetricIdleness =
false;
298 #elif (LUSH_PTHR_FN_TY == 3) 299 if (pthr->syncObjData) {
301 hpcrun_atomicAdd(&pthr->syncObjData->idleness, incrMetricIn);
304 *doMetricIdleness =
false;
306 # error "agent-pthread.c!"
int LUSHI_lip_destroy(lush_lip_t *lip)
lush_step_t LUSHI_step_lnote(lush_cursor_t *cursor)
#define doMetric(metricIdExpr, metricIncr, type)
lush_step_t LUSHI_step_pnote(lush_cursor_t *cursor)
lush_step_t LUSHI_step_bichord(lush_cursor_t *cursor)
int LUSHI_set_active_frame_marker()
static lush_agentid_t MY_lush_aid
enum lush_step lush_step_t
bool LUSHI_do_metric(uint64_t incrMetricIn, bool *doMetric, bool *doMetricIdleness, uint64_t *incrMetric, double *incrMetricIdleness)
bool LUSHI_ismycode(void *addr)
int LUSHI_lip_eq(lush_lip_t *lip)
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)
char * LUSHI_strerror(int code)
static bool lushPthr_isWorking_lock(lushPthr_t *x)