my changes
authorbdemsky <bdemsky>
Thu, 16 Aug 2007 22:30:37 +0000 (22:30 +0000)
committerbdemsky <bdemsky>
Thu, 16 Aug 2007 22:30:37 +0000 (22:30 +0000)
Robust/src/Analysis/Locality/LocalityAnalysis.java
Robust/src/IR/Flat/BuildCode.java
Robust/src/Runtime/DSTM/interface/dstm.h
Robust/src/Runtime/DSTM/interface/trans.c
Robust/src/Runtime/runtime.c
Robust/src/Runtime/runtime.h
Robust/src/buildscript

index 56179dcc6eb7291c8fc2581975a22daf6fe53359..60695a26d9b258e4b12a1fb6e064ddbaa6e5cdb2 100644 (file)
@@ -128,10 +128,11 @@ public class LocalityAnalysis {
     public Set<TempDescriptor> getTempSet(LocalityBinding lb) {
        HashSet<TempDescriptor> set=new HashSet<TempDescriptor>();
        Hashtable<FlatAtomicEnterNode, Set<TempDescriptor>> table=getTemps(lb);
-       for(Iterator<FlatAtomicEnterNode> faenit=table.keySet().iterator();faenit.hasNext();) {
-           FlatAtomicEnterNode faen=faenit.next();
-           set.addAll(table.get(faen));
-       }
+       if (table!=null)
+           for(Iterator<FlatAtomicEnterNode> faenit=table.keySet().iterator();faenit.hasNext();) {
+               FlatAtomicEnterNode faen=faenit.next();
+               set.addAll(table.get(faen));
+           }
        return set;
     }
 
index de30c31eb5398002e953eb88675fe03b38277558..387a327ef63661a8f3f0fffca393ec63d03cefb3 100644 (file)
@@ -105,6 +105,8 @@ public class BuildCode {
        outmethodheader.println("#ifndef METHODHEADERS_H");
        outmethodheader.println("#define METHODHEADERS_H");
        outmethodheader.println("#include \"structdefs.h\"");
+       if (state.DSM)
+           outmethodheader.println("#include \"dstm.h\"");
 
        /* Output Structures */
        outputStructs(outstructs);
@@ -290,8 +292,7 @@ public class BuildCode {
        outmethod.println("#include \"methodheaders.h\"");
        outmethod.println("#include \"virtualtable.h\"");
        outmethod.println("#include <runtime.h>");
-       if (state.DSM) 
-{          outmethod.println("#include \"dstm.h\"");
+       if (state.DSM) {
            outmethod.println("#include \"localobjects.h\"");
        }
        if (state.THREAD)
@@ -1412,7 +1413,7 @@ public class BuildCode {
            return;
        /* Have to generate flat globalconv */
        if (fgcn.getMakePtr()) {
-           output.println(generateTemp(fm, fgcn.getSrc(),lb)+"=transRead(trans,"+generateTemp(fm, fgcn.getSrc(),lb)+");");
+           output.println(generateTemp(fm, fgcn.getSrc(),lb)+"=(void *)transRead(trans, (unsigned int) "+generateTemp(fm, fgcn.getSrc(),lb)+");");
        } else {
            /* Need to convert to OID */
            output.println(generateTemp(fm, fgcn.getSrc(),lb)+"=OID("+generateTemp(fm, fgcn.getSrc(),lb)+");");
@@ -1590,15 +1591,27 @@ public class BuildCode {
        if (GENERATEPRECISEGC) {
            output.print("&__parameterlist__");
            needcomma=true;
-       } else {
+       }
+
+       if (state.DSM&&locality.getBinding(lb,fc).isAtomic()) {
+           if (needcomma)
+               output.print(",");
+           output.print("trans");
+           needcomma=true;
+       }
+
+       if (!GENERATEPRECISEGC) {
            if (fc.getThis()!=null) {
                TypeDescriptor ptd=md.getThis().getType();
+               if (needcomma)
+                   output.print(",");
                if (ptd.isClass()&&!ptd.isArray())
                    output.print("(struct "+ptd.getSafeSymbol()+" *) ");
                output.print(generateTemp(fm,fc.getThis(),lb));
                needcomma=true;
            }
        }
+
        for(int i=0;i<fc.numArgs();i++) {
            Descriptor var=md.getParameter(i);
            TempDescriptor paramtemp=(TempDescriptor)temptovar.get(var);
@@ -1650,7 +1663,7 @@ public class BuildCode {
                    //output.println("{");
                    //output.println("void * temp="+src+";");
                    //output.println("if (temp&0x1) {");
-                   //output.println("temp=transRead(trans, temp);");
+                   //output.println("temp=(void *) transRead(trans, (unsigned int) temp);");
                    //output.println(src+"->"+field+"="+temp+";");
                    //output.println("}");
                    //output.println(dst+"=temp;");
@@ -1658,7 +1671,7 @@ public class BuildCode {
                    //} else {
                    output.println(dst+"="+ src +"->"+field+ ";");
                    //output.println("if ("+dst+"&0x1) {");
-                   output.println(dst+"=transRead(trans,"+dst+");");
+                   output.println(dst+"=(void *) transRead(trans, (unsigned int) "+dst+");");
                    //output.println(src+"->"+field+"="+src+"->"+field+";");
                    //output.println("}");
                    //}
@@ -1683,9 +1696,9 @@ public class BuildCode {
        if (fsfn.getField().getSymbol().equals("length")&&fsfn.getDst().getType().isArray())
            throw new Error("Can't set array length");
        if (state.DSM && locality.getAtomic(lb).get(fsfn).intValue()>0) {
-           Integer statussrc=locality.getNodeTempInfo(lb).get(fsfn).get(fsfn.getDst());
+           Integer statussrc=locality.getNodeTempInfo(lb).get(fsfn).get(fsfn.getSrc());
            Integer statusdst=locality.getNodeTempInfo(lb).get(fsfn).get(fsfn.getDst());
-           boolean srcglobal=statusdst==LocalityAnalysis.GLOBAL;
+           boolean srcglobal=statussrc==LocalityAnalysis.GLOBAL;
 
            String src=generateTemp(fm,fsfn.getSrc(),lb);
            String dst=generateTemp(fm,fsfn.getDst(),lb);
@@ -1694,12 +1707,13 @@ public class BuildCode {
                output.println("int srcoid="+src+"->"+oidstr+";");
            }
            if (statusdst.equals(LocalityAnalysis.GLOBAL)) {
-               String glbdst="(struct "+fsfn.getDst().getType().getSafeSymbol()+" *)((unsigned int)"+dst+" +sizeof(objheader_t)))";
+               String glbdst="((struct "+fsfn.getDst().getType().getSafeSymbol()+" *)((unsigned int)"+dst+" +sizeof(objheader_t)))";
                //mark it dirty
-               output.println("((objheader_t *)"+dst+")->status|=DIRTY;");
-               if (srcglobal)
-                   output.println(glbdst+"->"+ fsfn.getField().getSafeSymbol()+"=srcoid;");
-               else
+               output.println("*((unsigned int *)&("+dst+"->___localcopy___))|=DIRTY;");
+               if (srcglobal) {
+                   output.println("*((unsigned int *)&("+glbdst+"->"+ fsfn.getField().getSafeSymbol()+"))=srcoid;");
+                   output.println("}");
+               } else
                    output.println(glbdst+"->"+ fsfn.getField().getSafeSymbol()+"="+ src+";");          
            } else if (statusdst.equals(LocalityAnalysis.LOCAL)) {
                /** Check if we need to copy */
@@ -1771,18 +1785,21 @@ public class BuildCode {
     }
 
     private void generateFlatNew(FlatMethod fm, LocalityBinding lb, FlatNew fn, PrintWriter output) {
+       String isglobal="";
+       if (fn.isGlobal())
+           isglobal="global";
        if (fn.getType().isArray()) {
            int arrayid=state.getArrayNumber(fn.getType())+state.numClasses();
            if (GENERATEPRECISEGC) {
-               output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray(&"+localsprefix+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
+               output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray"+isglobal+"(&"+localsprefix+", "+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
            } else {
-               output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray("+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
+               output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_newarray"+isglobal+"("+arrayid+", "+generateTemp(fm, fn.getSize(),lb)+");");
            }
        } else {
            if (GENERATEPRECISEGC) {
-               output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new(&"+localsprefix+", "+fn.getType().getClassDesc().getId()+");");
+               output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new"+isglobal+"(&"+localsprefix+", "+fn.getType().getClassDesc().getId()+");");
            } else {
-               output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new("+fn.getType().getClassDesc().getId()+");");
+               output.println(generateTemp(fm,fn.getDst(),lb)+"=allocate_new"+isglobal+"("+fn.getType().getClassDesc().getId()+");");
            }
        }
     }
index cf2a3b2a85123e614ce7f6add9b2c939fd957e14..8fbc6edd094337894f4a3c7789d604971a6df5b0 100644 (file)
@@ -216,6 +216,7 @@ int transCommitProcess(trans_commit_data_t *, int);
 
 int dstmStartup(const char *);
 void transInit();
+void * dstmalloc(int size);
 
 void randomdelay(void);
 transrecord_t *transStart();
index 45b30ff031181a8ceb5890ad7cfaa45b13dc0b70..338c718e6fcd4e76c84b07a117fc00b7d710fa1a 100644 (file)
@@ -80,6 +80,17 @@ void prefetch(int ntuples, unsigned int *oids, short *endoffsets, short *arrayfi
        pthread_mutex_unlock(&pqueue.qlock);
 }
 
+static int objid=1;
+/* This function allocates an object */
+void * dstmalloc(int size) {
+  objheader_t * newobj=(objheader_t *)objstrAlloc(mainobjstore, size+sizeof(objheader_t));
+  OID(newobj)=objid;
+  newobj->version=1;
+  newobj->rcount=0;
+  STATUS(newobj)=NEW;
+  objid+=2;
+  return newobj;
+}
 
 /* This function starts up the transaction runtime. */
 int dstmStartup(const char * option) {
index de7b1a49745f141c56b5740b672a11e0c1f9cc2d..803f19db429a3933e305e6ec2ed1cc7683a8f826 100644 (file)
@@ -7,6 +7,9 @@
 #include<signal.h>
 #include<stdio.h>
 #include "option.h"
+#ifdef DSTM
+#include "dstm.h"
+#endif
 
 extern int classsize[];
 jmp_buf error_handler;
@@ -86,6 +89,38 @@ void CALL01(___System______printString____L___String___,struct ___String___ * __
 
 /* Object allocation function */
 
+#ifdef DSTM
+void * allocate_newglobal(void * ptr, int type) {
+  struct ___Object___ * v=(struct ___Object___ *) dstmalloc(classsize[type]);
+  v->type=type;
+#ifdef THREADS
+  v->tid=0;
+  v->lockentry=0;
+  v->lockcount=0;
+#endif
+  return v;
+}
+
+/* Array allocation function */
+
+struct ArrayObject * allocate_newarrayglobal(void * ptr, int type, int length) {
+  struct ArrayObject * v=(struct ArrayObject *)dstmalloc(classsize[type]);
+  v->type=type;
+  if (length<0) {
+    printf("ERROR: negative array\n");
+    return NULL;
+  }
+  v->___length___=length;
+#ifdef THREADS
+  v->tid=0;
+  v->lockentry=0;
+  v->lockcount=0;
+#endif
+  return v;
+}
+#endif
+
+
 #ifdef PRECISE_GC
 void * allocate_new(void * ptr, int type) {
   struct ___Object___ * v=(struct ___Object___ *) mygcmalloc((struct garbagelist *) ptr, classsize[type]);
index bfa832012d0c296f81bc725dd005e17e8265547a..aa92815416cae64137a8eb368f9b5ddd09a0a9ac 100644 (file)
@@ -16,11 +16,19 @@ extern int failurecount;
 
 #ifdef PRECISE_GC
 #include "garbage.h"
+#ifdef DSTM
+void * allocate_newglobal(void *, int type);
+struct ArrayObject * allocate_newarrayglobal(void *, int type, int length);
+#endif
 void * allocate_new(void *, int type);
 struct ArrayObject * allocate_newarray(void *, int type, int length);
 struct ___String___ * NewString(void *, const char *str,int length);
 struct ___TagDescriptor___ * allocate_tag(void *ptr, int index);
 #else
+#ifdef DSTM
+void * allocate_newglobal(int type);
+struct ArrayObject * allocate_newarrayglobal(int type, int length);
+#endif
 void * allocate_new(int type);
 struct ArrayObject * allocate_newarray(int type, int length);
 struct ___String___ * NewString(const char *str,int length);
index 1ee6e48c304168c4ec06ab98fe321391d908285f..55e661a00619ad23d84a40897932cb20d1a70702 100755 (executable)
@@ -192,7 +192,7 @@ $ROBUSTROOT/Runtime/GenericHashtable.c $ROBUSTROOT/Runtime/object.c"
 
 if $DSMFLAG
 then
-EXTRAOPTIONS="$EXTRAOPTIONS -lpthread -DCOMPILER -I$DSMRUNTIME"
+EXTRAOPTIONS="$EXTRAOPTIONS -lpthread -DCOMPILER -DDSTM -I$DSMRUNTIME"
 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