Skip to content

Commit

Permalink
Bug #2037: Execute callbacks to inline EMs in an inline manner
Browse files Browse the repository at this point in the history
Previously, callbacks targeting inline entry methods had to be
declared with a 'true' value for the doInline variable to specify
inline execution. With this fix, callbacks execute inline when
the target is an inline entry method. The CkCallback constructors
still have the 'doInline' variable, now called 'forceInline', to
preserve existing behavior.

Co-authored-by: Evan Ramos <evan@hpccharm.com>

Change-Id: I2b21c7848b2428a367e79cdbaa9424f929c27ee1
  • Loading branch information
Nitin Bhat authored and evan-charmworks committed Feb 15, 2019
1 parent e4fa773 commit 045a564
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 34 deletions.
1 change: 1 addition & 0 deletions src/ck-core/charm.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ extern int CkRegisterMsg(const char *name, CkPackFnPtr pack,
#define CK_EP_MEMCRITICAL (1<<5)
#define CK_EP_APPWORK (1<<6)
#define CK_EP_IMMEDIATE (1<<7)
#define CK_EP_INLINE (1<<8)

/** type of a chare */
#if CMK_MESSAGE_LOGGING
Expand Down
36 changes: 18 additions & 18 deletions src/ck-core/ckcallback.C
Original file line number Diff line number Diff line change
Expand Up @@ -90,30 +90,30 @@ void *CkCallback::impl_thread_delay(void) const
/*These can't be defined in the .h file like the other constructors
* because we need CkCallback before CProxyElement* are defined.
*/
CkCallback::CkCallback(Chare *p, int ep, bool doInline) {
CkCallback::CkCallback(Chare *p, int ep, bool forceInline) {
#if CMK_ERROR_CHECKING
memset(this, 0, sizeof(CkCallback));
#endif
type=doInline?isendChare:sendChare;
type = (forceInline || _entryTable[ep]->isInline) ? isendChare : sendChare;
d.chare.ep=ep;
d.chare.id=p->ckGetChareID();
d.chare.hasRefnum= false;
d.chare.refnum = 0;
}
CkCallback::CkCallback(Group *p, int ep, bool doInline) {
CkCallback::CkCallback(Group *p, int ep, bool forceInline) {
#if CMK_ERROR_CHECKING
memset(this, 0, sizeof(CkCallback));
#endif
type=doInline?isendGroup:sendGroup;
type = (forceInline || _entryTable[ep]->isInline) ? isendGroup : sendGroup;
d.group.ep=ep; d.group.id=p->ckGetGroupID(); d.group.onPE=CkMyPe();
d.group.hasRefnum= false;
d.group.refnum = 0;
}
CkCallback::CkCallback(NodeGroup *p, int ep, bool doInline) {
CkCallback::CkCallback(NodeGroup *p, int ep, bool forceInline) {
#if CMK_ERROR_CHECKING
memset(this, 0, sizeof(CkCallback));
#endif
type=doInline?isendNodeGroup:sendNodeGroup;
type = (forceInline || _entryTable[ep]->isInline) ? isendNodeGroup : sendNodeGroup;
d.group.ep=ep; d.group.id=p->ckGetGroupID(); d.group.onPE=CkMyNode();
d.group.hasRefnum= false;
d.group.refnum = 0;
Expand All @@ -129,57 +129,57 @@ CkCallback::CkCallback(int ep,const CProxy_NodeGroup &ngp) {
d.group.refnum = 0;
}

CkCallback::CkCallback(int ep,int onPE,const CProxy_NodeGroup &ngp,bool doInline) {
CkCallback::CkCallback(int ep,int onPE,const CProxy_NodeGroup &ngp,bool forceInline) {
#if CMK_ERROR_CHECKING
memset(this, 0, sizeof(CkCallback));
#endif
type=doInline?isendNodeGroup:sendNodeGroup;
type = (forceInline || _entryTable[ep]->isInline) ? isendNodeGroup : sendNodeGroup;
d.group.ep=ep; d.group.id=ngp.ckGetGroupID(); d.group.onPE=onPE;
d.group.hasRefnum= false;
d.group.refnum = 0;
}

CkCallback::CkCallback(int ep,const CProxyElement_Group &grpElt,bool doInline) {
CkCallback::CkCallback(int ep,const CProxyElement_Group &grpElt,bool forceInline) {
#if CMK_ERROR_CHECKING
memset(this, 0, sizeof(CkCallback));
#endif
type=doInline?isendGroup:sendGroup;
type = (forceInline || _entryTable[ep]->isInline) ? isendGroup : sendGroup;
d.group.ep=ep;
d.group.id=grpElt.ckGetGroupID();
d.group.onPE=grpElt.ckGetGroupPe();
d.group.hasRefnum= false;
d.group.refnum = 0;
}

CkCallback::CkCallback(int ep, const CProxyElement_NodeGroup &grpElt, bool doInline) {
CkCallback::CkCallback(int ep, const CProxyElement_NodeGroup &grpElt, bool forceInline) {
#if CMK_ERROR_CHECKING
memset(this, 0, sizeof(CkCallback));
#endif
type = doInline ? isendNodeGroup : sendNodeGroup;
type = (forceInline || _entryTable[ep]->isInline) ? isendNodeGroup : sendNodeGroup;
d.group.ep = ep;
d.group.id = grpElt.ckGetGroupID();
d.group.onPE = grpElt.ckGetGroupPe();
d.group.hasRefnum = false;
d.group.refnum = 0;
}

CkCallback::CkCallback(int ep,const CProxyElement_ArrayBase &arrElt,bool doInline) {
CkCallback::CkCallback(int ep,const CProxyElement_ArrayBase &arrElt,bool forceInline) {
#if CMK_ERROR_CHECKING
memset(this, 0, sizeof(CkCallback));
#endif
type=doInline?isendArray:sendArray;
type = (forceInline || _entryTable[ep]->isInline) ? isendArray : sendArray;
d.array.ep=ep;
d.array.id=arrElt.ckGetArrayID();
d.array.idx = arrElt.ckGetIndex();
d.array.hasRefnum= false;
d.array.refnum = 0;
}

CkCallback::CkCallback(int ep,CProxySection_ArrayBase &sectElt,bool doInline) {
CkCallback::CkCallback(int ep,CProxySection_ArrayBase &sectElt,bool forceInline) {
#if CMK_ERROR_CHECKING
memset(this, 0, sizeof(CkCallback));
#endif
type=bcastSection;
type=bcastSection; // forceInline currently ignored
d.section.ep=ep;
CkSectionID secID=sectElt.ckGetSectionID(0);
d.section.sinfo = secID._cookie.info;
Expand All @@ -206,11 +206,11 @@ CkCallback::CkCallback(int ep, CkSectionID &id) {
d.section.refnum = 0;
}

CkCallback::CkCallback(ArrayElement *p, int ep,bool doInline) {
CkCallback::CkCallback(ArrayElement *p, int ep,bool forceInline) {
#if CMK_ERROR_CHECKING
memset(this, 0, sizeof(CkCallback));
#endif
type=doInline?isendArray:sendArray;
type = (forceInline || _entryTable[ep]->isInline) ? isendArray : sendArray;
d.array.ep=ep;
d.array.id=p->ckGetArrayID();
d.array.idx = p->ckGetArrayIndex();
Expand Down
31 changes: 16 additions & 15 deletions src/ck-core/ckcallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Initial version by Orion Sky Lawlor, olawlor@acm.org, 2/8/2002
#include "conv-ccs.h" /*for CcsDelayedReply struct*/
#include "charm.h"
#include "ckarrayindex.h"
#include "register.h"

typedef void (*CkCallbackFn)(void *param,void *message);
typedef void (*Ck1CallbackFn)(void *message);
Expand Down Expand Up @@ -250,11 +251,11 @@ class CkCallback {
}

// Call a chare entry method
CkCallback(int ep,const CkChareID &id,bool doInline=false) {
CkCallback(int ep,const CkChareID &id,bool forceInline=false) {
#if CMK_REPLAYSYSTEM
memset(this, 0, sizeof(CkCallback));
#endif
type=doInline?isendChare:sendChare;
type = (forceInline || _entryTable[ep]->isInline) ? isendChare : sendChare;
d.chare.ep=ep; d.chare.id=id;
d.chare.hasRefnum = false;
d.chare.refnum = 0;
Expand All @@ -275,24 +276,24 @@ class CkCallback {
}

// Send to nodegroup element
CkCallback(int ep,int onPE,const CProxy_NodeGroup &ngp,bool doInline=false);
CkCallback(int ep,int onPE,const CProxy_NodeGroup &ngp,bool forceInline=false);

// Send to group/nodegroup element
CkCallback(int ep,int onPE,const CkGroupID &id,bool doInline=false, bool isNodeGroup=false) {
CkCallback(int ep,int onPE,const CkGroupID &id,bool forceInline=false, bool isNodeGroup=false) {
#if CMK_REPLAYSYSTEM
memset(this, 0, sizeof(CkCallback));
#endif
type=doInline?(isNodeGroup?isendNodeGroup:isendGroup):(isNodeGroup?sendNodeGroup:sendGroup);
type = (forceInline || _entryTable[ep]->isInline) ? (isNodeGroup?isendNodeGroup:isendGroup) : (isNodeGroup?sendNodeGroup:sendGroup);
d.group.ep=ep; d.group.id=id; d.group.onPE=onPE;
d.group.hasRefnum = false;
d.group.refnum = 0;
}

// Send to specified group element
CkCallback(int ep,const CProxyElement_Group &grpElt,bool doInline=false);
CkCallback(int ep,const CProxyElement_Group &grpElt,bool forceInline=false);

// Send to specified nodegroup element
CkCallback(int ep,const CProxyElement_NodeGroup &grpElt,bool doInline=false);
CkCallback(int ep,const CProxyElement_NodeGroup &grpElt,bool forceInline=false);

// Bcast to array
CkCallback(int ep,const CkArrayID &id) {
Expand All @@ -306,34 +307,34 @@ class CkCallback {
}

// Send to array element
CkCallback(int ep,const CkArrayIndex &idx,const CkArrayID &id,bool doInline=false) {
CkCallback(int ep,const CkArrayIndex &idx,const CkArrayID &id,bool forceInline=false) {
#if CMK_REPLAYSYSTEM
memset(this, 0, sizeof(CkCallback));
#endif
type=doInline?isendArray:sendArray;
type = (forceInline || _entryTable[ep]->isInline) ? isendArray : sendArray;
d.array.ep=ep; d.array.id=id; d.array.idx = idx;
d.array.hasRefnum = false;
d.array.refnum = 0;
}

// Bcast to array
CkCallback(int ep,const CProxyElement_ArrayBase &arrElt,bool doInline=false);
CkCallback(int ep,const CProxyElement_ArrayBase &arrElt,bool forceInline=false);

//Bcast to section
CkCallback(int ep,CProxySection_ArrayBase &sectElt,bool doInline=false);
CkCallback(int ep,CProxySection_ArrayBase &sectElt,bool forceInline=false);
CkCallback(int ep, CkSectionID &sid);

// Send to chare
CkCallback(Chare *p, int ep, bool doInline=false);
CkCallback(Chare *p, int ep, bool forceInline=false);

// Send to group element on current PE
CkCallback(Group *p, int ep, bool doInline=false);
CkCallback(Group *p, int ep, bool forceInline=false);

// Send to nodegroup element on current node
CkCallback(NodeGroup *p, int ep, bool doInline=false);
CkCallback(NodeGroup *p, int ep, bool forceInline=false);

// Send to specified array element
CkCallback(ArrayElement *p, int ep,bool doInline=false);
CkCallback(ArrayElement *p, int ep,bool forceInline=false);

CkCallback(const CcsDelayedReply &reply) {
#if CMK_REPLAYSYSTEM
Expand Down
1 change: 1 addition & 0 deletions src/ck-core/register.C
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ int CkRegisterEpInternal(const char *name, CkCallFnPtr call, int msgIdx, int cha
if (ck_ep_flags & CK_EP_TRACEDISABLE) e->traceEnabled=false;
if (ck_ep_flags & CK_EP_APPWORK) e->appWork=true;
if (ck_ep_flags & CK_EP_IMMEDIATE) e->isImmediate=true;
if (ck_ep_flags & CK_EP_INLINE) e->isInline=true;
#if ADAPT_SCHED_MEM
if (ck_ep_flags & CK_EP_MEMCRITICAL){
e->isMemCritical=true;
Expand Down
4 changes: 3 additions & 1 deletion src/ck-core/register.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ class EntryInfo {
bool noKeep;
/// Method is an immediate entry method and can bypass scheduler
bool isImmediate;
/// Method is an inline entry method and can bypass scheduler and execute inline
bool isInline;
/// true if this EP is charm internal functions
bool inCharm;
bool appWork;
Expand All @@ -102,7 +104,7 @@ class EntryInfo {
#if CMK_CHARMDEBUG
,messagePup(0)
#endif
,traceEnabled(true), noKeep(false), isImmediate(false), inCharm(false), appWork(false),
,traceEnabled(true), noKeep(false), isImmediate(false), isInline(false), inCharm(false), appWork(false),
ownsName(ownsN), name(n)
{
if (ownsName) initName(n);
Expand Down
1 change: 1 addition & 0 deletions src/xlat-i/xi-Entry.C
Original file line number Diff line number Diff line change
Expand Up @@ -2858,6 +2858,7 @@ XStr Entry::genRegEp(bool isForRedn) {
str << "+CK_EP_TRACEDISABLE";
str << "+CK_EP_IMMEDIATE";
}
if (attribs & SINLINE) str << "+CK_EP_INLINE";
if (attribs & SAPPWORK) str << "+CK_EP_APPWORK";

/*MEICHAO*/
Expand Down

0 comments on commit 045a564

Please sign in to comment.