From 195d2014cf9e4c830f2392a72774d2ce6b13e105 Mon Sep 17 00:00:00 2001 From: bdemsky Date: Wed, 15 Aug 2007 09:45:11 +0000 Subject: [PATCH] code checked in --- .../Analysis/Locality/LocalityAnalysis.java | 46 ++++++- .../Analysis/Locality/LocalityBinding.java | 3 + Robust/src/IR/Flat/BuildCode.java | 127 +++++++++++++----- Robust/src/Runtime/DSTM/interface/queue.c | 4 +- Robust/src/Runtime/DSTM/interface/queue.h | 4 +- Robust/src/Runtime/DSTM/interface/trans.c | 4 +- Robust/src/buildscript | 2 +- 7 files changed, 149 insertions(+), 41 deletions(-) diff --git a/Robust/src/Analysis/Locality/LocalityAnalysis.java b/Robust/src/Analysis/Locality/LocalityAnalysis.java index a780a3a0..aa3d9b19 100644 --- a/Robust/src/Analysis/Locality/LocalityAnalysis.java +++ b/Robust/src/Analysis/Locality/LocalityAnalysis.java @@ -19,6 +19,7 @@ public class LocalityAnalysis { Hashtable>> tempstosave; Hashtable> classtolb; Hashtable> methodtolb; + private LocalityBinding lbmain; CallGraph callgraph; TypeUtil typeutil; @@ -42,6 +43,40 @@ public class LocalityAnalysis { doAnalysis(); } + public LocalityBinding getMain() { + return lbmain; + } + + /** This method returns the set of LocalityBindings that a given + * flatcall could invoke */ + + public LocalityBinding getBinding(LocalityBinding currlb, FlatCall fc) { + boolean isatomic=getAtomic(currlb).get(fc).intValue()>0; + Hashtable currtable=getNodeTempInfo(currlb).get(fc); + MethodDescriptor md=fc.getMethod(); + + boolean isnative=md.getModifiers().isNative(); + + LocalityBinding lb=new LocalityBinding(md, isatomic); + + for(int i=0;i getClassBindings(ClassDescriptor cd) { @@ -106,7 +141,7 @@ public class LocalityAnalysis { } private void computeLocalityBindings() { - LocalityBinding lbmain=new LocalityBinding(typeutil.getMain(), false); + lbmain=new LocalityBinding(typeutil.getMain(), false); lbmain.setGlobal(0, LOCAL); lbtovisit.add(lbmain); discovered.put(lbmain, lbmain); @@ -259,8 +294,13 @@ public class LocalityAnalysis { void processCallNode(LocalityBinding currlb, FlatCall fc, Hashtable currtable, boolean isatomic) { MethodDescriptor nodemd=fc.getMethod(); - Set methodset=fc.getThis()==null?callgraph.getMethods(nodemd): - callgraph.getMethods(nodemd, fc.getThis().getType()); + Set methodset=null; + if (nodemd.isStatic()||nodemd.getReturnType()==null) { + methodset=new HashSet(); + methodset.add(nodemd); + } else { + methodset=callgraph.getMethods(nodemd, fc.getThis().getType()); + } Integer currreturnval=EITHER; //Start off with the either value for(Iterator methodit=methodset.iterator();methodit.hasNext();) { MethodDescriptor md=(MethodDescriptor) methodit.next(); diff --git a/Robust/src/Analysis/Locality/LocalityBinding.java b/Robust/src/Analysis/Locality/LocalityBinding.java index 9dd6af0e..a2d4cc70 100644 --- a/Robust/src/Analysis/Locality/LocalityBinding.java +++ b/Robust/src/Analysis/Locality/LocalityBinding.java @@ -37,6 +37,8 @@ public class LocalityBinding { } public String getSignature() { + if (md.getModifiers().isNative()) + return ""; String st="_"; if (isatomic) { st+="A"; @@ -132,6 +134,7 @@ public class LocalityBinding { LocalityBinding lb=(LocalityBinding)o; if (md!=lb.md) return false; + for(int i=0;i saveset=state.DSM?locality.getTempSet(lb):null; + Set saveset=lb!=null?locality.getTempSet(lb):null; ParamsObject objectparams=md!=null?new ParamsObject(md,tag++):new ParamsObject(task, tag++); if (md!=null) @@ -732,7 +742,7 @@ public class BuildCode { objectparams.addPtr(temp); else objectparams.addPrim(temp); - if(state.DSM&&saveset.contains(temp)) { + if(lb!=null&&saveset.contains(temp)) { backuptable.put(temp, temp.createNew()); } } @@ -761,14 +771,14 @@ public class BuildCode { objecttemps.addPtr(temp); else objecttemps.addPrim(temp); - if(state.DSM&&saveset.contains(temp)&& + if(lb!=null&&saveset.contains(temp)&& !backuptable.containsKey(temp)) backuptable.put(temp, temp.createNew()); } } /* Create backup temps */ - if (state.DSM) { + if (lb!=null) { for(Iterator tmpit=backuptable.values().iterator();tmpit.hasNext();) { TempDescriptor tmp=tmpit.next(); TypeDescriptor type=tmp.getType(); @@ -966,33 +976,47 @@ public class BuildCode { if (state.DSM) { /* Cycle through LocalityBindings */ + HashSet nativemethods=new HashSet(); Set lbset=locality.getClassBindings(cn); - if (lbset!=null) + if (lbset!=null) { for(Iterator lbit=lbset.iterator();lbit.hasNext();) { LocalityBinding lb=lbit.next(); MethodDescriptor md=lb.getMethod(); + if (md.getModifiers().isNative()) { + //make sure we only print a native method once + if (nativemethods.contains(md)) + continue; + else + nativemethods.add(md); + } generateMethod(cn, md, lb, headersout, output); } - } else { - /* Cycle through methods */ + } + for(Iterator methodit=cn.getMethods();methodit.hasNext();) { + MethodDescriptor md=(MethodDescriptor)methodit.next(); + if (md.getModifiers().isNative()&&!nativemethods.contains(md)) { + //Need to build param structure for library code + FlatMethod fm=state.getMethodFlat(md); + generateTempStructs(fm, null); + generateMethodParam(cn, md, null, output); + } + } + + } else for(Iterator methodit=cn.getMethods();methodit.hasNext();) { - /* Classify parameters */ MethodDescriptor md=(MethodDescriptor)methodit.next(); generateMethod(cn, md, null, headersout, output); } - } } - private void generateMethod(ClassDescriptor cn, MethodDescriptor md, LocalityBinding lb, PrintWriter headersout, PrintWriter output) { - FlatMethod fm=state.getMethodFlat(md); - generateTempStructs(fm, lb); - - ParamsObject objectparams=(ParamsObject) paramstable.get(md); - TempObject objecttemps=(TempObject) tempstable.get(md); - + private void generateMethodParam(ClassDescriptor cn, MethodDescriptor md, LocalityBinding lb, PrintWriter output) { /* Output parameter structure */ if (GENERATEPRECISEGC) { - output.println("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params {"); + ParamsObject objectparams=(ParamsObject) paramstable.get(md); + if (state.DSM&&lb!=null) + output.println("struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params {"); + else + output.println("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params {"); output.println(" int size;"); output.println(" void * next;"); for(int i=0;itype*"+maxcount+"+"+virtualcalls.getMethodNumber(md)+"])"); + if (state.DSM) { + LocalityBinding fclb=locality.getBinding(lb, fc); + output.print("))virtualtable["+generateTemp(fm,fc.getThis())+"->type*"+maxcount+"+"+virtualcalls.getLocalityNumber(fclb)+"])"); + } else + output.print("))virtualtable["+generateTemp(fm,fc.getThis())+"->type*"+maxcount+"+"+virtualcalls.getMethodNumber(md)+"])"); } output.print("("); @@ -1808,9 +1870,12 @@ public class BuildCode { boolean printcomma=false; if (GENERATEPRECISEGC) { - if (md!=null) - output.print("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * "+paramsprefix); - else + if (md!=null) { + if (state.DSM) { + output.print("struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * "+paramsprefix); + } else + output.print("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * "+paramsprefix); + } else output.print("struct "+task.getSafeSymbol()+"_params * "+paramsprefix); printcomma=true; } diff --git a/Robust/src/Runtime/DSTM/interface/queue.c b/Robust/src/Runtime/DSTM/interface/queue.c index ce82aa7e..5ff02329 100644 --- a/Robust/src/Runtime/DSTM/interface/queue.c +++ b/Robust/src/Runtime/DSTM/interface/queue.c @@ -35,7 +35,7 @@ void queueDelete(void) { } /* Inserts to the rear of primary prefetch queue */ -void enqueue(prefetchqelem_t *qnode) { +void pre_enqueue(prefetchqelem_t *qnode) { if(pqueue.front == NULL && pqueue.rear == NULL) { pqueue.front = pqueue.rear = qnode; } else { @@ -46,7 +46,7 @@ void enqueue(prefetchqelem_t *qnode) { } /* Return the node pointed to by the front ptr of the queue */ -prefetchqelem_t *dequeue(void) { +prefetchqelem_t *pre_dequeue(void) { prefetchqelem_t *retnode; if (pqueue.front == NULL) { printf("Queue empty: Underflow %s, %d\n", __FILE__, __LINE__); diff --git a/Robust/src/Runtime/DSTM/interface/queue.h b/Robust/src/Runtime/DSTM/interface/queue.h index ff614903..2a3754dd 100644 --- a/Robust/src/Runtime/DSTM/interface/queue.h +++ b/Robust/src/Runtime/DSTM/interface/queue.h @@ -21,8 +21,8 @@ typedef struct primarypfq { void queueInit(void); void delqnode(); void queueDelete(void); -void enqueue(prefetchqelem_t *); -prefetchqelem_t *dequeue(void); +void pre_enqueue(prefetchqelem_t *); +prefetchqelem_t *pre_dequeue(void); void queueDisplay(); void predealloc(prefetchqelem_t *); #endif diff --git a/Robust/src/Runtime/DSTM/interface/trans.c b/Robust/src/Runtime/DSTM/interface/trans.c index 568cf5c2..e5c9a06b 100644 --- a/Robust/src/Runtime/DSTM/interface/trans.c +++ b/Robust/src/Runtime/DSTM/interface/trans.c @@ -75,7 +75,7 @@ void prefetch(int ntuples, unsigned int *oids, short *endoffsets, short *arrayfi memcpy(node + len, arrayfields, endoffsets[ntuples-1]*sizeof(short)); /* Lock and insert into primary prefetch queue */ pthread_mutex_lock(&pqueue.qlock); - enqueue((prefetchqelem_t *)node); + pre_enqueue((prefetchqelem_t *)node); pthread_cond_signal(&pqueue.qcond); pthread_mutex_unlock(&pqueue.qlock); } @@ -1215,7 +1215,7 @@ void *transPrefetch(void *t) { } /* dequeue node to create a machine piles and finally unlock mutex */ - if((qnode = dequeue()) == NULL) { + if((qnode = pre_dequeue()) == NULL) { printf("Error: No node returned %s, %d\n", __FILE__, __LINE__); return NULL; } diff --git a/Robust/src/buildscript b/Robust/src/buildscript index 69000d15..e5e5f65c 100755 --- a/Robust/src/buildscript +++ b/Robust/src/buildscript @@ -193,7 +193,7 @@ $ROBUSTROOT/Runtime/GenericHashtable.c $ROBUSTROOT/Runtime/object.c" if $DSMFLAG then EXTRAOPTIONS="$EXTRAOPTIONS -lpthread -I$DSMRUNTIME" -FILES="$FILES $DSMRUNTIME/dstm.c $DSMRUNTIME/mlookup.c $DSMRUNTIME/clookup.c $DSMRUNTIME/llookup.c $DSMRUNTIME/dstmserver.c $DSMRUNTIME/plookup.c $DSMRUNTIME/ip.c $DSMRUNTIME/queue.c $DSMRUNTIME/prelookup.c $DSMRUNTIME/machinepile.c $DSMRUNTIME/localobjects.c" +FILES="$FILES $DSMRUNTIME/trans.c $DSMRUNTIME/mcpileq.c $DSMRUNTIME/objstr.c $DSMRUNTIME/dstm.c $DSMRUNTIME/mlookup.c $DSMRUNTIME/clookup.c $DSMRUNTIME/llookup.c $DSMRUNTIME/dstmserver.c $DSMRUNTIME/plookup.c $DSMRUNTIME/ip.c $DSMRUNTIME/queue.c $DSMRUNTIME/prelookup.c $DSMRUNTIME/machinepile.c $DSMRUNTIME/localobjects.c" fi if $RECOVERFLAG -- 2.34.1