new fastcheck option for bristlecone
authorbdemsky <bdemsky>
Mon, 2 Feb 2009 09:29:42 +0000 (09:29 +0000)
committerbdemsky <bdemsky>
Mon, 2 Feb 2009 09:29:42 +0000 (09:29 +0000)
Robust/src/Runtime/garbage.c
Robust/src/Runtime/localobjects.c [new file with mode: 0644]
Robust/src/Runtime/localobjects.h [new file with mode: 0644]
Robust/src/Runtime/runtime.h
Robust/src/Runtime/task.c

index 44a51c40ab2c85692cd9566ce510774e5add76eb..bad83e8f84e3399f5f872ce727195c43bbbb95da 100644 (file)
@@ -54,6 +54,13 @@ int listcount=0;
       dst=copy; \
     } \
   }
+#elif defined(FASTCHECK)
+#define ENQUEUE(orig, dst) \
+  if (((unsigned int)orig)!=1) { \
+  void *copy; \
+  if (gc_createcopy(orig,&copy)) \
+    enqueue(orig);\
+  dst=copy; }
 #else
 #define ENQUEUE(orig, dst) \
   void *copy; \
@@ -187,6 +194,10 @@ void collect(struct garbagelist * stackptr) {
 }
 #endif
 
+#ifdef FASTCHECK
+  ENQUEUE(___fcrevert___, ___fcrevert___);
+#endif
+
 #ifdef TASK
   {
     /* Update objectsets */
diff --git a/Robust/src/Runtime/localobjects.c b/Robust/src/Runtime/localobjects.c
new file mode 100644 (file)
index 0000000..bd991ea
--- /dev/null
@@ -0,0 +1,66 @@
+#include "localobjects.h"
+#include <string.h>
+
+void REVERT_OBJ(struct ___Object___ * obj) {
+  int type=((int *)obj)[0];
+  struct ___Object___ * copyobj=obj->___localcopy___;
+  if(((int)copyobj)==1) {
+    obj->___localcopy___=NULL;
+    obj->___nextobject___=NULL;
+  } else if (type<NUMCLASSES) {
+    /* We have a normal object */
+    int size=classsize[type];
+    memcpy(obj, copyobj, size);
+  } else {
+    /* We have an array */
+    struct ArrayObject *ao=(struct ArrayObject *)obj;
+    int elementsize=classsize[type];
+    int length=ao->___length___;
+    int size=sizeof(struct ArrayObject)+length*elementsize;
+    memcpy(obj, copyobj, size);
+  }
+}
+
+#ifdef PRECISE_GC
+void COPY_OBJ(struct garbagelist * gl, struct ___Object___ *obj) {
+#else
+void COPY_OBJ(struct ___Object___ *obj) {
+#endif
+  int type=((int *)obj)[0];
+  if (type<NUMCLASSES) {
+    /* We have a normal object */
+    int size=classsize[type];
+#ifdef PRECISE_GC
+    int ptrarray[]={1, (int) gl, (int) obj};
+    struct ___Object___ * newobj=mygcmalloc((struct garbagelist *)ptrarray, size);
+#else
+    struct ___Object___ * newobj=FREEMALLOC(size);
+#endif
+#ifdef PRECISE_GC
+    memcpy(newobj, (struct ___Object___ *) ptrarray[2], size);
+    ((struct ___Object___*)ptrarray[2])->___localcopy___=newobj;
+#else
+    memcpy(newobj, obj, size);
+    obj->___localcopy___=newobj;
+#endif
+  } else {
+    /* We have an array */
+    struct ArrayObject *ao=(struct ArrayObject *)obj;
+    int elementsize=classsize[type];
+    int length=ao->___length___;
+    int size=sizeof(struct ArrayObject)+length*elementsize;
+#ifdef PRECISE_GC
+    int ptrarray[]={1, (int) gl, (int) obj};
+    struct ___Object___ * newobj=mygcmalloc((struct garbagelist *)ptrarray, size);
+#else
+    struct ___Object___ * newobj=FREEMALLOC(size);
+#endif
+#ifdef PRECISE_GC
+    memcpy(newobj, (struct ___Object___ *) ptrarray[2], size);
+    ((struct ___Object___*)ptrarray[2])->___localcopy___=newobj;
+#else
+    memcpy(newobj, obj, size);
+    obj->___localcopy___=newobj;
+#endif
+  }
+}
diff --git a/Robust/src/Runtime/localobjects.h b/Robust/src/Runtime/localobjects.h
new file mode 100644 (file)
index 0000000..c1c7be1
--- /dev/null
@@ -0,0 +1,14 @@
+#ifndef LOCALOBJECT_H
+#define LOCALOBJECT_H
+#include "structdefs.h"
+#include "garbage.h"
+void REVERT_OBJ(struct ___Object___ *);
+#define COMMIT_OBJ(obj) obj->___localcopy___=NULL; \
+  obj->___nextobject___=NULL
+
+#ifdef PRECISE_GC
+void COPY_OBJ(struct garbagelist * gl, struct ___Object___ *obj);
+#else
+void COPY_OBJ(struct ___Object___ *obj);
+#endif
+#endif
index d6e332be67935f8f984572ac4868255540dca573..68692e8029dc04c83f868c61b9b043d6c92451b5 100644 (file)
@@ -111,6 +111,10 @@ struct RuntimeHash * lockRedirectTbl;
 #endif
 #endif
 
+#ifdef FASTCHECK
+extern struct ___Object___ * ___fcrevert___;
+#endif
+
 #ifdef MULTICORE
 void flagorand(void * ptr, int ormask, int andmask, struct parameterwrapper ** queues, int length);
 void flagorandinit(void * ptr, int ormask, int andmask);
index 229e66f758921d18d3dba5ed179fd476f87f3f04..3fa38516906457394f3dd2aca71c1aee0854ed54 100644 (file)
@@ -22,6 +22,11 @@ extern int errors;
 #include "instrument.h"
 #endif
 
+#ifdef FASTCHECK
+struct ___Object___ * ___fcrevert___;
+#include "localobjects.h"
+#endif
+
 struct genhashtable * activetasks;
 struct parameterwrapper * objectqueues[NUMCLASSES];
 struct genhashtable * failedtasks;
@@ -1166,9 +1171,13 @@ parameterpresent:
 
       {
        /* Checkpoint the state */
+#ifdef FASTCHECK
+       ___fcrevert___=NULL;
+#else
        forward=cCreate(256, 0.4);
        reverse=cCreate(256, 0.4);
        void ** checkpoint=makecheckpoint(currtpd->task->numParameters, currtpd->parameterArray, forward, reverse);
+#endif
        int x;
        if (x=setjmp(error_handler)) {
          int counter;
@@ -1177,7 +1186,11 @@ parameterpresent:
          printf("Fatal Error=%d, Recovering!\n",x);
 #endif
          genputtable(failedtasks,currtpd,currtpd);
+#ifdef FASTCHECK
+         REVERT_OBJ(___fcrevert___);
+#else
          restorecheckpoint(currtpd->task->numParameters, currtpd->parameterArray, checkpoint, forward, reverse);
+#endif
 
 #ifdef OPTIONAL
          for(counter=0; counter<currtpd->task->numParameters; counter++) {
@@ -1189,11 +1202,14 @@ parameterpresent:
              RUNFREE(fsesarray[counter]);
          }
 #endif
+#ifndef FASTCHECK
          cDelete(forward);
          cDelete(reverse);
          freemalloc();
          forward=NULL;
          reverse=NULL;
+#endif
+
        } else {
          if (injectfailures) {
            if ((((double)random())/RAND_MAX)<failurechance) {
@@ -1229,9 +1245,17 @@ parameterpresent:
          }
 #endif
 
+#ifdef FASTCHECK
+         while(___fcrevert___) {
+           struct ___Object___ *tmpptr=___fcrevert___->___nextobject___;
+           COMMIT_OBJ(___fcrevert___);
+           ___fcrevert___=tmpptr;
+         }
+#else
          cDelete(forward);
          cDelete(reverse);
          freemalloc();
+#endif
          // Free up task parameter descriptor
          RUNFREE(currtpd->parameterArray);
 #ifdef OPTIONAL