
00001 #ifndef _CKLOOPAPI_H 00002 #define _CKLOOPAPI_H 00003 00004 #include "CkLoop.decl.h" 00005 00006 /* "result" is the buffer for reduction result on a single simple-type variable */ 00007 typedef void (*HelperFn)(int first,int last, void *result, int paramNum, void *param); 00008 /* Function that will be executed by the caller PE before ckloop is done */ 00009 typedef void (*CallerFn)(int paramNum, void *param); 00010 00011 typedef enum REDUCTION_TYPE { 00012 CKLOOP_NONE=0, 00013 CKLOOP_INT_SUM, 00014 CKLOOP_FLOAT_SUM, 00015 CKLOOP_DOUBLE_SUM, 00016 CKLOOP_DOUBLE_MAX 00017 } REDUCTION_TYPE; 00018 00019 typedef enum CkLoop_sched { CKLOOP_NODE_QUEUE=0, CKLOOP_TREE, CKLOOP_LIST} CkLoop_sched; 00020 00021 class CProxy_FuncCkLoop; 00022 /* 00023 * "numThreads" argument is intended to be used in non-SMP mode to specify 00024 * the number of pthreads to be spawned. In SMP mode, this argument is 00025 * ignored. This function should be called only on one PE, say PE 0. 00026 **/ 00027 extern CProxy_FuncCkLoop CkLoop_Init(int numThreads=0); 00028 00029 /* used to free resources if using the library in non-SMP mode. It should be called on just one PE, say PE 0 */ 00030 extern void CkLoop_Exit(CProxy_FuncCkLoop ckLoop); 00031 00032 extern void CkLoop_Parallelize( 00033 HelperFn func, /* the function that finishes a partial work on another thread */ 00034 int paramNum, void * param, /* the input parameters for the above func */ 00035 int numChunks, /* number of chunks to be partitioned */ 00036 int lowerRange, int upperRange, /* the loop-like parallelization happens in [lowerRange, upperRange] */ 00037 int sync=1, /* whether the flow will continue unless all chunks have finished */ 00038 void *redResult=NULL, REDUCTION_TYPE type=CKLOOP_NONE, /* the reduction result, ONLY SUPPORT SINGLE VAR of TYPE int/float/double */ 00039 CallerFn cfunc=NULL, /* caller PE will call this function before ckloop is done and before starting to work on its chunks */ 00040 int cparamNum=0, void *cparam=NULL /* the input parameters to the above function */ 00041 ); 00042 00043 extern void CkLoop_ParallelizeHybrid( 00044 float staticFraction, 00045 HelperFn func, /* the function that finishes a partial work on another thread */ 00046 int paramNum, void * param, /* the input parameters for the above func */ 00047 int numChunks, /* number of chunks to be partitioned */ 00048 int lowerRange, int upperRange, /* the loop-like parallelization happens in [lowerRange, upperRange] */ 00049 int sync=1, /* whether the flow will continue unless all chunks have finished */ 00050 void *redResult=NULL, REDUCTION_TYPE type=CKLOOP_NONE, /* the reduction result, ONLY SUPPORT SINGLE VAR of TYPE int/float/double */ 00051 CallerFn cfunc=NULL, /* caller PE will call this function before ckloop is done and before starting to work on its chunks */ 00052 int cparamNum=0, void *cparam=NULL /* the input parameters to the above function */ 00053 ); 00054 00055 00056 extern void CkLoop_SetSchedPolicy(CkLoop_sched schedPolicy); 00057 00058 extern void CkLoop_DestroyHelpers(); 00059 #endif
1.5.5