Adding example of Fault injection memory register/deregister
authorNikhil Jain <nikhil@illinois.edu>
Thu, 20 Dec 2012 04:54:39 +0000 (22:54 -0600)
committerNikhil Jain <nikhil@illinois.edu>
Thu, 20 Dec 2012 04:54:39 +0000 (22:54 -0600)
examples/charm++/load_balancing/stencil3d/stencil3d.C

index 1bb135827c80605b7a3f315ca5098485ac2411cb..98c78be6df06840af42ba4dd1c1e98f4d1eaf261 100644 (file)
@@ -155,6 +155,8 @@ class Stencil: public CBase_Stencil {
       temperature = new double[(blockDimX+2) * (blockDimY+2) * (blockDimZ+2)];
       new_temperature = new double[(blockDimX+2) * (blockDimY+2) * (blockDimZ+2)];
 
       temperature = new double[(blockDimX+2) * (blockDimY+2) * (blockDimZ+2)];
       new_temperature = new double[(blockDimX+2) * (blockDimY+2) * (blockDimZ+2)];
 
+      FI_registerRegion(temperature,(blockDimX+2)*(blockDimY+2)*(blockDimZ+2)*sizeof(double));
+      FI_registerRegion(new_temperature,(blockDimX+2)*(blockDimY+2)*(blockDimZ+2)*sizeof(double));
       for(k=0; k<blockDimZ+2; ++k)
        for(j=0; j<blockDimY+2; ++j)
          for(i=0; i<blockDimX+2; ++i)
       for(k=0; k<blockDimZ+2; ++k)
        for(j=0; j<blockDimY+2; ++j)
          for(i=0; i<blockDimX+2; ++i)
@@ -172,10 +174,17 @@ class Stencil: public CBase_Stencil {
       p|iterations;
       p|imsg;
 
       p|iterations;
       p|imsg;
 
+      if(p.isDeleting()) {
+        FI_deregisterRegion(temperature);
+        FI_deregisterRegion(new_temperature);
+      }
+
       size_t size = (blockDimX+2) * (blockDimY+2) * (blockDimZ+2);
       if (p.isUnpacking()) {
        temperature = new double[size];
        new_temperature = new double[size];
       size_t size = (blockDimX+2) * (blockDimY+2) * (blockDimZ+2);
       if (p.isUnpacking()) {
        temperature = new double[size];
        new_temperature = new double[size];
+        FI_registerRegion(temperature,size*sizeof(double));
+        FI_registerRegion(new_temperature,size*sizeof(double));
       }
       p(temperature, size);
       p(new_temperature, size);
       }
       p(temperature, size);
       p(new_temperature, size);