From: bdemsky <bdemsky> Date: Wed, 15 Aug 2007 09:45:11 +0000 (+0000) Subject: code checked in X-Git-Tag: preEdgeChange~476 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=195d2014cf9e4c830f2392a72774d2ce6b13e105;p=IRC.git code checked in --- 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<LocalityBinding, Hashtable<FlatAtomicEnterNode, Set<TempDescriptor>>> tempstosave; Hashtable<ClassDescriptor, Set<LocalityBinding>> classtolb; Hashtable<MethodDescriptor, Set<LocalityBinding>> 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<TempDescriptor, Integer> 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<fc.numArgs();i++) { + TempDescriptor arg=fc.getArg(i); + lb.setGlobal(i,currtable.get(arg)); + } + if (fc.getThis()!=null) { + Integer thistype=currtable.get(fc.getThis()); + if (thistype==null) + thistype=EITHER; + lb.setGlobalThis(thistype); + } else + lb.setGlobalThis(EITHER);//default value + if (discovered.containsKey(lb)) + lb=discovered.get(lb); + else throw new Error(); + return lb; + } + + /** This method returns a set of LocalityBindings for the parameter class. */ public Set<LocalityBinding> 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<TempDescriptor, Integer> 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<isglobal.length;i++) if (!isglobal[i].equals(lb.isglobal[i])) return false; diff --git a/Robust/src/IR/Flat/BuildCode.java b/Robust/src/IR/Flat/BuildCode.java index 76f8e03c..41a2713d 100644 --- a/Robust/src/IR/Flat/BuildCode.java +++ b/Robust/src/IR/Flat/BuildCode.java @@ -217,11 +217,21 @@ public class BuildCode { outmethod.println(" {"); if (GENERATEPRECISEGC) { - outmethod.print(" struct "+cd.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={"); + if (state.DSM) { + outmethod.print(" struct "+cd.getSafeSymbol()+locality.getMain().getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={"); + } else + outmethod.print(" struct "+cd.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={"); outmethod.println("1, NULL,"+"stringarray};"); - outmethod.println(" "+cd.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"(& __parameterlist__);"); - } else - outmethod.println(" "+cd.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"(stringarray);"); + if (state.DSM) + outmethod.println(" "+cd.getSafeSymbol()+locality.getMain().getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"(& __parameterlist__);"); + else + outmethod.println(" "+cd.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"(& __parameterlist__);"); + } else { + if (state.DSM) + outmethod.println(" "+cd.getSafeSymbol()+locality.getMain().getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"(stringarray);"); + else + outmethod.println(" "+cd.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"(stringarray);"); + } outmethod.println(" }"); if (state.DSM) { @@ -717,7 +727,7 @@ public class BuildCode { private void generateTempStructs(FlatMethod fm, LocalityBinding lb) { MethodDescriptor md=fm.getMethod(); TaskDescriptor task=fm.getTask(); - Set<TempDescriptor> saveset=state.DSM?locality.getTempSet(lb):null; + Set<TempDescriptor> 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<TempDescriptor> 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<MethodDescriptor> nativemethods=new HashSet<MethodDescriptor>(); Set<LocalityBinding> lbset=locality.getClassBindings(cn); - if (lbset!=null) + if (lbset!=null) { for(Iterator<LocalityBinding> 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;i<objectparams.numPointers();i++) { @@ -1001,10 +1025,24 @@ public class BuildCode { } output.println("};\n"); } + } + + + 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); + + generateMethodParam(cn, md, lb, output); /* Output temp structure */ if (GENERATEPRECISEGC) { - output.println("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals {"); + if (state.DSM) + output.println("struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals {"); + else + output.println("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals {"); output.println(" int size;"); output.println(" void * next;"); for(int i=0;i<objecttemps.numPointers();i++) { @@ -1037,7 +1075,10 @@ public class BuildCode { boolean printcomma=false; if (GENERATEPRECISEGC) { - headersout.print("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * "+paramsprefix); + if (state.DSM) { + headersout.print("struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * "+paramsprefix); + } else + headersout.print("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * "+paramsprefix); printcomma=true; } @@ -1143,7 +1184,9 @@ public class BuildCode { } if (GENERATEPRECISEGC) { - if (md!=null) + if (md!=null&&state.DSM) + output.print(" struct "+cn.getSafeSymbol()+lb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals "+localsprefix+"={"); + else if (md!=null&&!state.DSM) output.print(" struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_locals "+localsprefix+"={"); else output.print(" struct "+task.getSafeSymbol()+"_locals "+localsprefix+"={"); @@ -1447,7 +1490,11 @@ public class BuildCode { ClassDescriptor cn=md.getClassDesc(); output.println("{"); if (GENERATEPRECISEGC) { - output.print(" struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={"); + if (state.DSM) { + LocalityBinding fclb=locality.getBinding(lb, fc); + output.print(" struct "+cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={"); + } else + output.print(" struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params __parameterlist__={"); output.print(objectparams.numPointers()); // output.print(objectparams.getUID()); @@ -1479,8 +1526,15 @@ public class BuildCode { /* Do we need to do virtual dispatch? */ if (md.isStatic()||md.getReturnType()==null||singleCall(fc.getThis().getType().getClassDesc(),md)) { - output.print(cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()); + //no + if (state.DSM) { + LocalityBinding fclb=locality.getBinding(lb, fc); + output.print(cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()); + } else { + output.print(cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()); + } } else { + //yes output.print("(("); if (md.getReturnType().isClass()||md.getReturnType().isArray()) output.print("struct " + md.getReturnType().getSafeSymbol()+" * "); @@ -1490,7 +1544,11 @@ public class BuildCode { boolean printcomma=false; if (GENERATEPRECISEGC) { - output.print("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * "); + if (state.DSM) { + LocalityBinding fclb=locality.getBinding(lb, fc); + output.print("struct "+cn.getSafeSymbol()+fclb.getSignature()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * "); + } else + output.print("struct "+cn.getSafeSymbol()+md.getSafeSymbol()+"_"+md.getSafeMethodDescriptor()+"_params * "); printcomma=true; } @@ -1505,7 +1563,11 @@ public class BuildCode { output.print(temp.getType().getSafeSymbol()); } - output.print("))virtualtable["+generateTemp(fm,fc.getThis())+"->type*"+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