PPL Logo

conv-core/conv-conds.c File Reference

Go to the source code of this file.

Data Structures

struct  _ccd_callback
 Structure to hold the requisites for a callback. More...
struct  _ccd_cblist_elem
 An element (a single callback) in a list of callbacks. More...
struct  _ccd_cblist
 A list of callbacks stored as an array and handled like a list. More...
struct  ccd_cond_callbacks
 Lists of conditional callbacks that are maintained by the scheduler. More...
struct  ccd_periodic_callbacks
 List of periodic callbacks maintained by the scheduler. More...
struct  ccd_heap_elem
 Structure used to manage callbacks in a heap. More...

Typedefs

typedef struct _ccd_callback ccd_callback
typedef struct _ccd_cblist_elem ccd_cblist_elem
typedef struct _ccd_cblist ccd_cblist

Functions

static void init_cblist (ccd_cblist *l, unsigned int ml)
 Initialize a list of callbacks.
static void expand_cblist (ccd_cblist *l, unsigned int ml)
 Expand the callback list to a max length of ml.
static void remove_elem (ccd_cblist *l, int idx)
 Remove element referred to by given list index idx.
static void remove_n_elems (ccd_cblist *l, int n)
 Remove n elements from the beginning of the list.
static int append_elem (ccd_cblist *l, CcdVoidFn fn, void *arg, int pe)
 Append callback to the given cblist, and return the index.
static void call_cblist_keep (ccd_cblist *l, double curWallTime)
 Trigger the callbacks in the provided callback list and *retain* them after they are called.
static void call_cblist_remove (ccd_cblist *l, double curWallTime)
 Trigger the callbacks in the provided callback list and *remove* them from the list after they are called.
 CpvStaticDeclare (ccd_cond_callbacks, conds)
 CpvStaticDeclare (ccd_periodic_callbacks, pcb)
 CpvDeclare (int, _ccd_numchecks)
 CpvStaticDeclare (ccd_heap_elem *, ccd_heap)
 An array of time-scheduled callbacks managed as a heap.
 CpvStaticDeclare (int, ccd_heaplen)
 The length of the callback heap.
 CpvStaticDeclare (int, ccd_heapmaxlen)
 The max allowed length of the callback heap.
static void ccd_heap_swap (int index1, int index2)
 Swap two elements on the heap.
static void expand_ccd_heap ()
 Expand the ccd_heap to make more room.
static void ccd_heap_insert (double t, CcdVoidFn fnp, void *arg, int pe)
 Insert a new callback into the heap.
static void ccd_heap_remove (void)
 Remove the top of the heap.
static void ccd_heap_update (double curWallTime)
 Identify any (over)due callbacks that were scheduled and trigger them.
void CcdCallBacksReset (void *ignored, double curWallTime)
 Called when something drastic changes-- restart ccd_num_checks.
void CcdModuleInit (void)
 Initialize the callback containers.
int CcdCallOnCondition (int condnum, CcdVoidFn fnp, void *arg)
 Register a callback function that will be triggered when the specified condition is raised the next time.
int CcdCallOnConditionOnPE (int condnum, CcdVoidFn fnp, void *arg, int pe)
 Register a callback function that will be triggered on the specified PE when the specified condition is raised the next time.
int CcdCallOnConditionKeep (int condnum, CcdVoidFn fnp, void *arg)
 Register a callback function that will be triggered *whenever* the specified condition is raised.
int CcdCallOnConditionKeepOnPE (int condnum, CcdVoidFn fnp, void *arg, int pe)
 Register a callback function that will be triggered on the specified PE *whenever* the specified condition is raised.
void CcdCancelCallOnCondition (int condnum, int idx)
 Cancel a previously registered conditional callback.
void CcdCancelCallOnConditionKeep (int condnum, int idx)
 Cancel a previously registered conditional callback.
void CcdCallFnAfterOnPE (CcdVoidFn fnp, void *arg, double deltaT, int pe)
 Register a callback function that will be triggered on the specified PE after a minimum delay of deltaT.
void CcdCallFnAfter (CcdVoidFn fnp, void *arg, double deltaT)
 Register a callback function that will be triggered after a minimum delay of deltaT.
void CcdRaiseCondition (int condnum)
 Raise a condition causing all registered callbacks corresponding to that condition to be triggered.
void CcdCallBacks ()

Variables

static const double periodicCallInterval [CCD_PERIODIC_MAX]


Typedef Documentation

typedef struct _ccd_callback ccd_callback

typedef struct _ccd_cblist ccd_cblist


Function Documentation

static void init_cblist ( ccd_cblist l,
unsigned int  ml 
) [static]

Initialize a list of callbacks.

Alloc memory, set counters etc.

Definition at line 43 of file conv-conds.c.

References _ccd_cblist::elems, _ccd_cblist::first, _ccd_cblist::first_free, _ccd_cblist::flag, _ccd_cblist::last, _ccd_cblist::len, malloc(), _ccd_cblist::maxlen, _ccd_cblist_elem::next, and _ccd_cblist_elem::prev.

Referenced by CcdModuleInit().

static void expand_cblist ( ccd_cblist l,
unsigned int  ml 
) [static]

Expand the callback list to a max length of ml.

Definition at line 63 of file conv-conds.c.

References _ccd_cblist::elems, _ccd_cblist::first_free, free(), _ccd_cblist::len, malloc(), _ccd_cblist::maxlen, _ccd_cblist_elem::next, and _ccd_cblist_elem::prev.

Referenced by append_elem().

static void remove_elem ( ccd_cblist l,
int  idx 
) [static]

static void remove_n_elems ( ccd_cblist l,
int  n 
) [static]

Remove n elements from the beginning of the list.

Definition at line 109 of file conv-conds.c.

References _ccd_cblist::first, _ccd_cblist::len, and remove_elem().

Referenced by call_cblist_remove().

static int append_elem ( ccd_cblist l,
CcdVoidFn  fn,
void *  arg,
int  pe 
) [static]

static void call_cblist_keep ( ccd_cblist l,
double  curWallTime 
) [static]

Trigger the callbacks in the provided callback list and *retain* them after they are called.

Callbacks that are added after this function is started (e.g. callbacks registered from other callbacks) are ignored.

Note:
: It is illegal to cancel callbacks from within ccd callbacks.

Definition at line 155 of file conv-conds.c.

References _ccd_callback::arg, _ccd_cblist_elem::cb, CmiSwitchToPE, _ccd_cblist::elems, _ccd_cblist::first, _ccd_callback::fn, idx, _ccd_cblist::len, _ccd_cblist_elem::next, and _ccd_callback::pe.

Referenced by CcdRaiseCondition().

static void call_cblist_remove ( ccd_cblist l,
double  curWallTime 
) [static]

Trigger the callbacks in the provided callback list and *remove* them from the list after they are called.

Callbacks that are added after this function is started (e.g. callbacks registered from other callbacks) are ignored.

Note:
: It is illegal to cancel callbacks from within ccd callbacks.

Definition at line 176 of file conv-conds.c.

References _ccd_callback::arg, _ccd_cblist_elem::cb, CmiSwitchToPE, _ccd_cblist::elems, _ccd_cblist::first, _ccd_cblist::flag, _ccd_callback::fn, idx, _ccd_cblist::last, _ccd_cblist::len, _ccd_cblist_elem::next, _ccd_callback::pe, _ccd_cblist_elem::prev, and remove_n_elems().

Referenced by CcdRaiseCondition().

CpvStaticDeclare ( ccd_cond_callbacks  ,
conds   
)

CpvStaticDeclare ( ccd_periodic_callbacks  ,
pcb   
)

CpvDeclare ( int  ,
_ccd_numchecks   
)

CpvStaticDeclare ( ccd_heap_elem ,
ccd_heap   
)

An array of time-scheduled callbacks managed as a heap.

CpvStaticDeclare ( int  ,
ccd_heaplen   
)

The length of the callback heap.

CpvStaticDeclare ( int  ,
ccd_heapmaxlen   
)

The max allowed length of the callback heap.

static void ccd_heap_swap ( int  index1,
int  index2 
) [static]

Swap two elements on the heap.

Definition at line 264 of file conv-conds.c.

Referenced by ccd_heap_insert(), and ccd_heap_remove().

static void expand_ccd_heap (  )  [static]

Expand the ccd_heap to make more room.

Double the heap size and copy everything over. Initial 256 is reasonably big, so expanding won't happen often.

Had a bug previously due to late expansion, should work now - Gengbin 12/4/03

Definition at line 284 of file conv-conds.c.

References CmiMyPe(), CmiPrintf(), free(), and malloc().

Referenced by ccd_heap_insert().

static void ccd_heap_insert ( double  t,
CcdVoidFn  fnp,
void *  arg,
int  pe 
) [static]

Insert a new callback into the heap.

Definition at line 310 of file conv-conds.c.

References _ccd_callback::arg, ccd_heap_elem::cb, ccd_heap_swap(), expand_ccd_heap(), _ccd_callback::fn, _ccd_callback::pe, stats::time(), and ccd_heap_elem::time.

Referenced by CcdCallFnAfterOnPE().

static void ccd_heap_remove ( void   )  [static]

Remove the top of the heap.

Definition at line 343 of file conv-conds.c.

References ccd_heap_swap(), and stats::time().

Referenced by ccd_heap_update().

static void ccd_heap_update ( double  curWallTime  )  [static]

Identify any (over)due callbacks that were scheduled and trigger them.

Definition at line 376 of file conv-conds.c.

References _ccd_callback::arg, ccd_heap_elem::cb, ccd_heap_remove(), CmiSwitchToPE, _ccd_callback::fn, and stats::time().

Referenced by CcdCallBacks().

void CcdCallBacksReset ( void *  ignored,
double  curWallTime 
)

Called when something drastic changes-- restart ccd_num_checks.

Definition at line 577 of file conv-conds.c.

References ccd_periodic_callbacks::lastCheck, and ccd_periodic_callbacks::nSkip.

Referenced by CcdModuleInit().

void CcdModuleInit ( void   ) 

Initialize the callback containers.

Definition at line 408 of file conv-conds.c.

References CcdCallBacksReset(), CcdCallOnConditionKeep(), CmiWallTimer(), init_cblist(), and malloc().

Referenced by ConverseCommonInit().

int CcdCallOnCondition ( int  condnum,
CcdVoidFn  fnp,
void *  arg 
)

Register a callback function that will be triggered when the specified condition is raised the next time.

Definition at line 444 of file conv-conds.c.

References append_elem().

Referenced by _initCharm(), _qdHandler(), CIdleTimeoutInit(), CkMemCheckPT::CkMemCheckPT(), CkMessageDetailReplay::CkMessageDetailReplay(), CldGraphModuleInit(), CQdHandler(), CQdRegisterCallback(), CkMemCheckPT::isMaster(), and CkMemCheckPT::pup().

int CcdCallOnConditionOnPE ( int  condnum,
CcdVoidFn  fnp,
void *  arg,
int  pe 
)

Register a callback function that will be triggered on the specified PE when the specified condition is raised the next time.

Definition at line 453 of file conv-conds.c.

References append_elem().

int CcdCallOnConditionKeep ( int  condnum,
CcdVoidFn  fnp,
void *  arg 
)

int CcdCallOnConditionKeepOnPE ( int  condnum,
CcdVoidFn  fnp,
void *  arg,
int  pe 
)

Register a callback function that will be triggered on the specified PE *whenever* the specified condition is raised.

Definition at line 471 of file conv-conds.c.

References append_elem().

Referenced by CkLocMgr::CkLocMgr().

void CcdCancelCallOnCondition ( int  condnum,
int  idx 
)

Cancel a previously registered conditional callback.

Definition at line 480 of file conv-conds.c.

References remove_elem().

void CcdCancelCallOnConditionKeep ( int  condnum,
int  idx 
)

Cancel a previously registered conditional callback.

Definition at line 489 of file conv-conds.c.

References remove_elem().

Referenced by AMPI_Uninstall_Idle_Timer(), LBMachineUtil::StatsOff(), traceCommonInit(), and LV3D0_ClientManager_toMaster::~LV3D0_ClientManager_toMaster().

void CcdCallFnAfterOnPE ( CcdVoidFn  fnp,
void *  arg,
double  deltaT,
int  pe 
)

Register a callback function that will be triggered on the specified PE after a minimum delay of deltaT.

Definition at line 499 of file conv-conds.c.

References ccd_heap_insert(), and CmiWallTimer().

Referenced by CcdCallFnAfter(), CldBalancePeriod(), controlPointManager::controlPointManager(), periodicDebugPrintStatus(), periodicProcessControlPoints(), and LBDB::batsyncer::resumeFromSync().

void CcdCallFnAfter ( CcdVoidFn  fnp,
void *  arg,
double  deltaT 
)

void CcdRaiseCondition ( int  condnum  ) 

Raise a condition causing all registered callbacks corresponding to that condition to be triggered.

Definition at line 520 of file conv-conds.c.

References call_cblist_keep(), call_cblist_remove(), and CmiWallTimer().

Referenced by CcdCallBacks(), CQdAnnounceHandler(), CsdBeginIdle(), CsdEndIdle(), CsdStillIdle(), KillOnAllSigs(), and LrtsInitCpuTopo().

void CcdCallBacks (  ) 


Variable Documentation

const double periodicCallInterval[CCD_PERIODIC_MAX] [static]

Initial value:

{0.001, 0.010, 0.100, 1.0, 5.0, 10.0, 60.0, 2*60.0, 5*60.0, 10*60.0, 3600.0, 12*3600.0, 24*3600.0}

Definition at line 221 of file conv-conds.c.


Generated on Fri May 25 08:00:44 2012 for Charm++ by  doxygen 1.5.5