add more ckloop reduction type
authorYanhua Sun <yanhuas@jyc1.(none)>
Wed, 17 Oct 2012 22:27:25 +0000 (17:27 -0500)
committerYanhua Sun <yanhuas@jyc1.(none)>
Wed, 17 Oct 2012 22:27:25 +0000 (17:27 -0500)
src/libs/ck-libs/ckloop/CkLoop.C
src/libs/ck-libs/ckloop/CkLoopAPI.h

index 31369c584e5ea2fe79ca2d4323b1ed759d316955..e118740143a8230abb8db6df81621a1651ac8d38 100644 (file)
@@ -292,7 +292,12 @@ void FuncCkLoop::parallelizeFunc(HelperFn func, int paramNum, void * param,
      /*CkPrintf("CkLoop Reduce: %d\n", result);*/ \
     }\
 }
-
+#define COMPUTE_REDUCTION_MAX(T) {\
+    for(int i=0; i<numChunks; i++) {\
+     if( *((T *)(redBufs[i])) > result ) result = *((T *)(redBufs[i])); \
+     /*CkPrintf("CkLoop Reduce: %d\n", result);*/ \
+    }\
+}
 void FuncCkLoop::reduce(void **redBufs, void *redBuf, REDUCTION_TYPE type, int numChunks) {
     switch (type) {
     case CKLOOP_INT_SUM: {
@@ -313,6 +318,12 @@ void FuncCkLoop::reduce(void **redBufs, void *redBuf, REDUCTION_TYPE type, int n
         *((double *)redBuf) = result;
         break;
     }
+    case CKLOOP_DOUBLE_MAX: {
+        double result=0;
+        COMPUTE_REDUCTION_MAX(double)
+        *((double *)redBuf) = result;
+        break;
+    }
     default:
         break;
     }
index 4fef9a9e609919db8104a9f516252eb17ce11bf3..a79fbc54d9f2a62938a59fe7881aa65f5734945d 100644 (file)
@@ -10,7 +10,8 @@ typedef enum REDUCTION_TYPE {
     CKLOOP_NONE=0,
     CKLOOP_INT_SUM,
     CKLOOP_FLOAT_SUM,
-    CKLOOP_DOUBLE_SUM
+    CKLOOP_DOUBLE_SUM,
+    CKLOOP_DOUBLE_MAX
 } REDUCTION_TYPE;
 
 class CProxy_FuncCkLoop;