changes
authorjzhou <jzhou>
Wed, 12 Nov 2008 03:34:14 +0000 (03:34 +0000)
committerjzhou <jzhou>
Wed, 12 Nov 2008 03:34:14 +0000 (03:34 +0000)
Robust/src/Benchmarks/Scheduling/PSFluidAnimate/Grid.java
Robust/src/Benchmarks/Scheduling/PSFluidAnimate/PSFADemo.java
Robust/src/Benchmarks/Scheduling/PSFluidAnimate/PSFluidAnimateBench.java
Robust/src/IR/Flat/BuildCodeMultiCore.java
Robust/src/Makefile.raw.io
Robust/src/Runtime/Queue.c
Robust/src/Runtime/Queue.h
Robust/src/Runtime/multicoretask.c

index ddc47e16a95d2d2e5ac29f31a3ea6dbf02231335..acd73a7d0c2ee128499b22ed27f0a41f9ad457b7 100644 (file)
@@ -250,6 +250,12 @@ public class Grid {
                            cell = this.m_cells[ix][iy][iz];
                        }
                        np = cell.m_numPars;
+                       if(cell.m_p[np] == null) {
+                           cell.m_p[np] = new Vec3();
+                           cell.m_hv[np] = new Vec3();
+                           cell.m_v[np] = new Vec3();
+                           cell.m_a[np] = new Vec3();
+                       }
                        cell.m_p[np].m_x = cell2.m_p[j].m_x;
                        cell.m_p[np].m_y = cell2.m_p[j].m_y;
                        cell.m_p[np].m_z = cell2.m_p[j].m_z;
index 8e87d64a9875ea47b3b1f7657ae430fcaf831d39..fdc07bc54743cff32d1dc4bd67bf56db6ae17662 100644 (file)
@@ -88,6 +88,12 @@ public class PSFADemo {
                Cell toadd = (Cell)(g.m_neighCells.get(key));
                int toaddnp = toadd.m_numPars;
                for(int j = 0; j < toaddnp; ++j) {
+                   if(cell.m_p[np] == null) {
+                       cell.m_p[np] = new Vec3();
+                       cell.m_hv[np] = new Vec3();
+                       cell.m_v[np] = new Vec3();
+                       cell.m_a[np] = new Vec3();
+                   }
                    cell.m_p[np].m_x = toadd.m_p[j].m_x;
                    cell.m_p[np].m_y = toadd.m_p[j].m_y;
                    cell.m_p[np].m_z = toadd.m_p[j].m_z;
@@ -120,6 +126,12 @@ public class PSFADemo {
                        Cell toadd = g.m_cells[ix][iy][iz];
                        int toaddnp = toadd.m_numPars;
                        for(int j = 0; j < toaddnp; ++j) {
+                           if(cell.m_p[np] == null) {
+                               cell.m_p[np] = new Vec3();
+                               cell.m_hv[np] = new Vec3();
+                               cell.m_v[np] = new Vec3();
+                               cell.m_a[np] = new Vec3();
+                           }
                            cell.m_p[np].m_x = toadd.m_p[j].m_x;
                            cell.m_p[np].m_y = toadd.m_p[j].m_y;
                            cell.m_p[np].m_z = toadd.m_p[j].m_z;
@@ -159,6 +171,12 @@ public class PSFADemo {
                        Cell toadd = g.m_cells[ix][iy][iz];
                        int toaddnp = toadd.m_numPars;
                        for(int j = 0; j < toaddnp; ++j) {
+                           if(cell.m_p[np] == null) {
+                               cell.m_p[np] = new Vec3();
+                               cell.m_hv[np] = new Vec3();
+                               cell.m_v[np] = new Vec3();
+                               cell.m_a[np] = new Vec3();
+                           }
                            cell.m_p[np].m_x = toadd.m_p[j].m_x;
                            cell.m_p[np].m_y = toadd.m_p[j].m_y;
                            cell.m_p[np].m_z = toadd.m_p[j].m_z;
@@ -200,6 +218,12 @@ public class PSFADemo {
                cell.m_numPars = 0;
                int np = 0;
                for(int j = 0; j < toflushnp; ++j) {
+                   if(cell.m_p[np] == null) {
+                       cell.m_p[np] = new Vec3();
+                       cell.m_hv[np] = new Vec3();
+                       cell.m_v[np] = new Vec3();
+                       cell.m_a[np] = new Vec3();
+                   }
                    cell.m_p[np].m_x = toflush.m_p[j].m_x;
                    cell.m_p[np].m_y = toflush.m_p[j].m_y;
                    cell.m_p[np].m_z = toflush.m_p[j].m_z;
@@ -234,6 +258,12 @@ public class PSFADemo {
                        cell.m_numPars = 0;
                        int np = 0;
                        for(int j = 0; j < toflushnp; ++j) {
+                           if(cell.m_p[np] == null) {
+                               cell.m_p[np] = new Vec3();
+                               cell.m_hv[np] = new Vec3();
+                               cell.m_v[np] = new Vec3();
+                               cell.m_a[np] = new Vec3();
+                           }
                            cell.m_p[np].m_x = toflush.m_p[j].m_x;
                            cell.m_p[np].m_y = toflush.m_p[j].m_y;
                            cell.m_p[np].m_z = toflush.m_p[j].m_z;
@@ -274,6 +304,12 @@ public class PSFADemo {
                        cell.m_numPars = 0;
                        int np = 0;
                        for(int j = 0; j < toflushnp; ++j) {
+                           if(cell.m_p[np] == null) {
+                               cell.m_p[np] = new Vec3();
+                               cell.m_hv[np] = new Vec3();
+                               cell.m_v[np] = new Vec3();
+                               cell.m_a[np] = new Vec3();
+                           }
                            cell.m_p[np].m_x = toflush.m_p[j].m_x;
                            cell.m_p[np].m_y = toflush.m_p[j].m_y;
                            cell.m_p[np].m_z = toflush.m_p[j].m_z;
@@ -318,7 +354,6 @@ public class PSFADemo {
                visited.put(key, key);
            }
        }
-       
        // border cells of g
        for(int iz = 0; iz < g.m_ez - g.m_sz;) {
            for(int iy = 0; iy < g.m_ey - g.m_sy; iy++) {
@@ -343,7 +378,6 @@ public class PSFADemo {
                iz++;
            }
        }
-       
        for(int ix = 0; ix < g.m_ex - g.m_sx;) {
            for(int iy = 0; iy < g.m_ey - g.m_sy; iy++) {
                for(int iz = 0; iz < g.m_ez - g.m_sz; iz++) {
@@ -512,6 +546,12 @@ public class PSFADemo {
                int np = cell.m_numPars;
                Cell toadd = (Cell)(g.m_neighCells.get(key));
                for(int j = 0; j < np; ++j) {
+                   if(cell.m_p[np] == null) {
+                       cell.m_p[np] = new Vec3();
+                       cell.m_hv[np] = new Vec3();
+                       cell.m_v[np] = new Vec3();
+                       cell.m_a[np] = new Vec3();
+                   }
                    cell.m_v[j].m_x += toadd.m_v[j].m_x - cell.m_a[j].m_x;
                    cell.m_v[j].m_y += toadd.m_v[j].m_y - cell.m_a[j].m_y;
                    cell.m_v[j].m_z += toadd.m_v[j].m_z - cell.m_a[j].m_z;
@@ -531,6 +571,12 @@ public class PSFADemo {
                        int np = cell.m_numPars;
                        Cell toadd = g.m_cells[ix][iy][iz];
                        for(int j = 0; j < np; ++j) {
+                           if(cell.m_p[np] == null) {
+                               cell.m_p[np] = new Vec3();
+                               cell.m_hv[np] = new Vec3();
+                               cell.m_v[np] = new Vec3();
+                               cell.m_a[np] = new Vec3();
+                           }
                            cell.m_v[j].m_x = toadd.m_v[j].m_x - 
                                               cell.m_a[j].m_x;
                            cell.m_v[j].m_y = toadd.m_v[j].m_y - 
@@ -560,6 +606,12 @@ public class PSFADemo {
                        int np = cell.m_numPars;
                        Cell toadd = g.m_cells[ix][iy][iz];
                        for(int j = 0; j < np; ++j) {
+                           if(cell.m_p[np] == null) {
+                               cell.m_p[np] = new Vec3();
+                               cell.m_hv[np] = new Vec3();
+                               cell.m_v[np] = new Vec3();
+                               cell.m_a[np] = new Vec3();
+                           }
                            cell.m_v[j].m_x = toadd.m_v[j].m_x - 
                                              cell.m_a[j].m_x;
                            cell.m_v[j].m_y = toadd.m_v[j].m_y - 
@@ -584,6 +636,12 @@ public class PSFADemo {
                Cell cell = (Cell)it_values.next();
                int np = cell.m_numPars;
                for(int j = 0; j < np; ++j) {
+                   if(cell.m_p[np] == null) {
+                       cell.m_p[np] = new Vec3();
+                       cell.m_hv[np] = new Vec3();
+                       cell.m_v[np] = new Vec3();
+                       cell.m_a[np] = new Vec3();
+                   }
                    cell.m_a[j].m_x += cell.m_v[j].m_x;
                    cell.m_a[j].m_y += cell.m_v[j].m_y;
                    cell.m_a[j].m_z += cell.m_v[j].m_z;
@@ -603,6 +661,12 @@ public class PSFADemo {
                Cell cell = (Cell)(g.m_neighCells.get(key));
                int np = cell.m_numPars;
                for(int j = 0; j < np; ++j) {
+                   if(cell.m_p[np] == null) {
+                       cell.m_p[np] = new Vec3();
+                       cell.m_hv[np] = new Vec3();
+                       cell.m_v[np] = new Vec3();
+                       cell.m_a[np] = new Vec3();
+                   }
                    cell.m_a[j].m_x = toflush.m_a[j].m_x;
                    cell.m_a[j].m_y = toflush.m_a[j].m_y;
                    cell.m_a[j].m_z = toflush.m_a[j].m_z;
@@ -623,6 +687,12 @@ public class PSFADemo {
                        Cell cell = g.m_cells[ix][iy][iz];
                        int np = cell.m_numPars;
                        for(int j = 0; j < np; ++j) {
+                           if(cell.m_p[np] == null) {
+                               cell.m_p[np] = new Vec3();
+                               cell.m_hv[np] = new Vec3();
+                               cell.m_v[np] = new Vec3();
+                               cell.m_a[np] = new Vec3();
+                           }
                            cell.m_a[j].m_x = toflush.m_a[j].m_x;
                            cell.m_a[j].m_y = toflush.m_a[j].m_y;
                            cell.m_a[j].m_z = toflush.m_a[j].m_z;
@@ -649,6 +719,12 @@ public class PSFADemo {
                        Cell cell = g.m_cells[ix][iy][iz];
                        int np = cell.m_numPars;
                        for(int j = 0; j < np; ++j) {
+                           if(cell.m_p[np] == null) {
+                               cell.m_p[np] = new Vec3();
+                               cell.m_hv[np] = new Vec3();
+                               cell.m_v[np] = new Vec3();
+                               cell.m_a[np] = new Vec3();
+                           }
                            cell.m_a[j].m_x = toflush.m_a[j].m_x;
                            cell.m_a[j].m_y = toflush.m_a[j].m_y;
                            cell.m_a[j].m_z = toflush.m_a[j].m_z;
index 2ea3abaf254f4adf146a682542d4c719875af253..7b8b56c00c5157e64b2bd62a53a580e5e5822764 100644 (file)
@@ -4,30 +4,10 @@ task t1(StartupObject s{initialstate}) {
     //System.printString("task t1\n");
     
     int threadnum = 16;
-    int lsb = 0;
-    int framenum = 1;
+    int framenum = 4;
     
-    int weight=0;
-    int mask= 1;
-    int count=0;
-    lsb=-1;
-    int x = threadnum;
-    while(x > 0) {
-       int temp;
-       temp=(x&mask);
-       if((x&mask) == 1) {
-           weight++;
-           if(lsb == -1) {
-               lsb = count;
-           }
-       }
-       x >>= 1;
-       count++;
-    }
-    
-    int XDIVS = 1<<(lsb/2);    // number of partitions in X
-    int ZDIVS = 1<<(lsb/2);    // number of partitions in Z
-    if(XDIVS*ZDIVS != threadnum) XDIVS*=2;
+    int XDIVS = 4;// number of partitions in X
+    int ZDIVS = 4;// number of partitions in Z
     int NUM_GRIDS = XDIVS * ZDIVS;
     
     // initialize the simulation
@@ -74,90 +54,53 @@ task t1(StartupObject s{initialstate}) {
     
     PSFADemo demo = new PSFADemo(NUM_GRIDS, numCells, numParticles, nx, ny, nz, 
            viscosityCoeff, new Vec3(delta.m_x, delta.m_y, delta.m_z)){tosum};
-           
+
+    float px, py, pz, hvx, hvy, hvz, vx, vy, vz;
+    long seed = 12345678;
+    Random r = new Random(seed);
+    int maxint = (1<<31) - 1;
+    float dx = (float)0.005;
+    float dy = (float)0.005;
+    float dz = (float)0.005;
+    px = domainMin.m_x;
+    py = domainMin.m_y;
+    pz = domainMin.m_z;
+    hvx = (float)0.2;
+    hvy = (float)0.5;
+    hvz = (float)0.3;
+    vx = (float)0.2;
+    vy = (float)0.5;
+    vz = (float)0.3;
+    //int p = 0;
+    int xn = 0;
+    int yn = 0;
+    int zn = 0;
     Cell[][][] cells = new Cell[nx][ny][nz];
+    int p=0;
     for(int i = 0; i < nx; i++) {
        for(int j = 0; j < ny; j++) {
            for(int k = 0; k < nz; k++) {
                int index = (k*ny + j)*nx + i;
                cells[i][j][k] = new Cell(index);
+               if (p<numParticles) {
+                   Cell cell = cells[i][j][k];
+                   int np = cell.m_numPars;
+                   cell.m_p[np].m_x = (float)((i+0.5)*delta.m_x+px);
+                   cell.m_p[np].m_y = (float)((j+0.5)*delta.m_y+py);
+                   cell.m_p[np].m_z = (float)((k+0.5)*delta.m_z+pz);
+                   cell.m_hv[np].m_x = hvx;
+                   cell.m_hv[np].m_y = hvy;
+                   cell.m_hv[np].m_z = hvz;
+                   cell.m_v[np].m_x = vx;
+                   cell.m_v[np].m_y = vy;
+                   cell.m_v[np].m_z = vz;
+                   ++cell.m_numPars;
+                   p++;
+               }
            }
        }
     }
-    
-    float px, py, pz, hvx, hvy, hvz, vx, vy, vz;
-    long seed = 12345678;
-    Random r = new Random(seed);
-    int maxint = (1<<31) - 1;
-    for(int i = 0; i < numParticles; ) {
-       
-       do {
-           px = (float)((((float)r.nextInt()) / maxint) * 0.07 - 0.06);
-       } while((px < -0.0661478) || (px > 0.0108902));
-       do {
-           py = (float)((((float)r.nextInt()) / maxint) * 0.079975 - 0.08);
-       } while((py < -0.08255) || (py > -0.0000257124));
-       do {
-           pz = (float)((((float)r.nextInt()) / maxint) * 0.12 - 0.06);
-       } while((pz < -0.0656068) || (pz > 0.06557));
-       do {
-           hvx = (float)((((float)r.nextInt()) / maxint) * 0.71 - 0.44);
-       } while((hvx < -0.442022) || (hvx > 0.277284));
-       do {
-           hvy = (float)((((float)r.nextInt()) / maxint) * 0.84 - 0.33);
-       } while((hvy < -0.336931) || (hvy > 0.513108));
-       do {
-           hvz = (float)((((float)r.nextInt()) / maxint) * 0.63 - 0.32);
-       } while((hvz < -0.320125) || (hvz > 0.315038));
-       do {
-           vx = (float)((((float)r.nextInt()) / maxint) * 0.69 - 0.41);
-       } while((vx < -0.41846) || (vx > 0.280465));
-       do {
-           vy = (float)((((float)r.nextInt()) / maxint) * 0.87 - 0.36);
-       } while((vy < -0.36748) || (vy > 0.515511));
-       do {
-           vz = (float)((((float)r.nextInt()) / maxint) * 0.64 - 0.32);
-       } while((vz < -0.321845) || (vz > 0.32013));
-       
-       int ci = (int)((px - domainMin.m_x) / delta.m_x);
-       int cj = (int)((py - domainMin.m_y) / delta.m_y);
-       int ck = (int)((pz - domainMin.m_z) / delta.m_z);
 
-       if(ci < 0) {
-           ci = 0; 
-       } else if(ci > (nx-1)) {
-           ci = nx-1;
-       }
-       if(cj < 0) {
-           cj = 0; 
-       } else if(cj > (ny-1)) {
-           cj = ny-1;
-       }
-       if(ck < 0) {
-           ck = 0; 
-       } else if(ck > (nz-1)) {
-           ck = nz-1;
-       }
-
-       Cell cell = cells[ci][cj][ck];
-       int np = cell.m_numPars;
-       if(np < 16) {
-               cell.m_p[np].m_x = px;
-               cell.m_p[np].m_y = py;
-               cell.m_p[np].m_z = pz;
-               cell.m_hv[np].m_x = hvx;
-               cell.m_hv[np].m_y = hvy;
-               cell.m_hv[np].m_z = hvz;
-               cell.m_v[np].m_x = vx;
-               cell.m_v[np].m_y = vy;
-               cell.m_v[np].m_z = vz;
-               ++cell.m_numPars;
-               i++;
-       }
-       
-    }
-
-    
     int gi = 0;
     int sx, sz, ex, ez;
     ex = 0;
@@ -174,6 +117,7 @@ task t1(StartupObject s{initialstate}) {
                    new Vec3(delta.m_x, delta.m_y, delta.m_z),
                    densityCoeff, pressureCoeff, viscosityCoeff, nx, ny, nz,
                    framenum){rebuild};
+           // initialize the cells
            grid.initCells(cells);
            grid.initNeighCells(cells, demo);
        }
index 11699e3b5c5552a67a7aac0cc8edfa304aae16e4..0a4eb6634f4c30ec71abefa30e8134bdc9d4d826 100644 (file)
@@ -1611,7 +1611,9 @@ public class BuildCodeMultiCore extends BuildCode {
       }
     }
     // generate codes for profiling, recording how many new objects are created
-    if((fn.getType().getClassDesc() != null) && (fn.getType().getClassDesc().hasFlags())) {
+    if(!fn.getType().isArray() && 
+           (fn.getType().getClassDesc() != null) 
+           && (fn.getType().getClassDesc().hasFlags())) {
        output.println("#ifdef RAWPROFILE");
        output.println("addNewObjInfo(\"" + fn.getType().getClassDesc().getSymbol() + "\");");
        output.println("#endif");
index 93f86f00d4b003282969e2059f0b865cc0abbde6..d402f10da4becf9124bcdbf23eab3ec891628cec 100644 (file)
@@ -12,7 +12,7 @@ DEFS  += -D$(shell uname -s) -D__raw__
 TOPDIR=/home/jzhou/starsearch
 include $(TOPDIR)/Makefile.include
 
-RGCCFLAGS += -O0 
+RGCCFLAGS += -O2 
 RGCCFLAGS += ${RAWRGCCFLAGS} 
 
 USE_SLGCC=1
index b00a7d78fb7a9d8bb81a6dfed63d6b62057511dd..33bfcc700e30cb7728086652a7ee06e8782f616d 100644 (file)
@@ -75,7 +75,7 @@ struct QueueItem * getTail(struct Queue * queue) {
   return queue->tail;
 }
 
-struct QueueItem * getNext(struct QueueItem * qi) {
+struct QueueItem * getNextQueueItem(struct QueueItem * qi) {
   return qi->next;
 }
 
index 01253409bd66c80b531ba87922000f283a428587..3f368f9a02447a15cc960311c5418149c116321b 100644 (file)
@@ -25,6 +25,6 @@ struct QueueItem * addNewItem_I(struct Queue * queue, void * ptr);
 struct QueueItem * findItem(struct Queue * queue, void * ptr);
 void removeItem(struct Queue * queue, struct QueueItem * item);
 struct QueueItem * getTail(struct Queue * queue);
-
+struct QueueItem * getNextQueueItem(struct QueueItem * qi);
 
 #endif
index 37bb8f829bb25d0a384861c11f8c4a60aee2b2c7..aef2a45a45588b862d50af5ad0975742d574737e 100644 (file)
@@ -117,7 +117,7 @@ void releasewritelock(void* ptr);
 // profiling mode of RAW version
 #ifdef RAWPROFILE
 
-#define TASKINFOLENGTH 300
+#define TASKINFOLENGTH 10000
 //#define INTERRUPTINFOLENGTH 500
 
 bool stall;
@@ -1534,7 +1534,7 @@ void transferObject(struct transObjInfo * transObj) {
 #ifdef RAWDEBUG
   raw_test_pass_reg(msgsize);
 #endif
-  gdn_send(obj);
+  gdn_send((int)obj);
 #ifdef RAWDEBUG
   raw_test_pass_reg(obj);
 #endif
@@ -2157,7 +2157,7 @@ msg:
          if(prev == NULL) {
            qitem = getTail(&objqueue);
          } else {
-           qitem = getNext(prev);
+           qitem = getNextQueueItem(prev);
          }
        }
        addNewItem_I(&objqueue, (void *)transObj);
@@ -2606,7 +2606,7 @@ bool getreadlock(void * ptr) {
 #ifdef RAWDEBUG
   raw_test_pass(0);
 #endif
-  gdn_send(ptr);
+  gdn_send((int)ptr);
 #ifdef RAWDEBUG
   raw_test_pass_reg(ptr);
 #endif
@@ -2773,7 +2773,7 @@ void releasereadlock(void * ptr) {
 #ifdef RAWDEBUG
   raw_test_pass(0);
 #endif
-  gdn_send(ptr);
+  gdn_send((int)ptr);
 #ifdef RAWDEBUG
   raw_test_pass_reg(ptr);
   raw_test_pass(0xffff);
@@ -2908,7 +2908,7 @@ bool getreadlock_I(void * ptr) {
 #ifdef RAWDEBUG
   raw_test_pass(0);
 #endif
-  gdn_send(ptr);
+  gdn_send((int)ptr);
 #ifdef RAWDEBUG
   raw_test_pass_reg(ptr);
 #endif
@@ -2961,7 +2961,7 @@ void releasereadlock_I(void * ptr) {
 #ifdef RAWDEBUG
   raw_test_pass(0);
 #endif
-  gdn_send(ptr);
+  gdn_send((int)ptr);
 #ifdef RAWDEBUG
   raw_test_pass_reg(ptr);
   raw_test_pass(0xffff);
@@ -3084,7 +3084,7 @@ bool getwritelock(void * ptr) {
 #ifdef RAWDEBUG
   raw_test_pass(1);
 #endif
-  gdn_send(ptr);
+  gdn_send((int)ptr);
 #ifdef RAWDEBUG
   raw_test_pass_reg(ptr);
 #endif
@@ -3266,7 +3266,7 @@ void releasewritelock(void * ptr) {
 #ifdef RAWDEBUG
   raw_test_pass(1);
 #endif
-  gdn_send(ptr);
+  gdn_send((int)ptr);
 #ifdef RAWDEBUG
   raw_test_pass_reg(ptr);
   raw_test_pass(0xffff);
@@ -4074,7 +4074,7 @@ execute:
 #endif
              if(tmpparam->numlocks == 0) {
                numlocks = 1;
-               locks = tmpparam;
+               locks = (int*)tmpparam;
              } else {
                numlocks = tmpparam->numlocks;
                locks = tmpparam->locks;
@@ -4090,7 +4090,7 @@ execute:
                struct ___Object___ * tmpparam = (struct ___Object___ *)taskpointerarray[i+OFFSET];
                if(tmpparam->numlocks == 0) {
                  numlocks = 1;
-                 locks = tmpparam;
+                 locks = (int*)tmpparam;
                } else {
                  numlocks = tmpparam->numlocks;
                  locks = tmpparam->locks;