disable the test in reduction that migrating during reduction.
[charm.git] / tests / charm++ / megatest / reduction.C
1 #include "reduction.h"
2
3 /*These aren't readonlies, because they're only used on PE 0*/
4 static CProxy_reductionArray redArr;
5 static CProxy_reductionGroup redGrp;
6 static int nFinished;
7
8 class reductionInfo {
9 public:
10         int properValue;
11         reductionInfo(int v) :properValue(v) {}
12         void check(void *data,int size) {
13                 int *v=(int *)data;
14                 if (size!=2*sizeof(int))
15                         CkAbort("Unexpected-size reduction result!");
16                 if (v[0]!=properValue)
17                         CkAbort("Corrupted first field!");
18                 if (v[1]!=0 && v[1]!=(2*properValue))
19                         CkAbort("Corrupted second field!");
20         }
21 };
22
23 static void reductionClient(void *redInfo,int size,void *data) {
24         reductionInfo *info=(reductionInfo *)redInfo;
25         info->check(data,size);
26         nFinished++;
27         if (nFinished%4 == 0) megatest_finish();
28 }
29
30 void reduction_moduleinit(void) {
31         nFinished=0;
32         const int numElements = 5;
33         redArr=CProxy_reductionArray::ckNew(numElements);
34         redArr.setReductionClient(reductionClient,new reductionInfo(numElements));
35         redGrp=CProxy_reductionGroup::ckNew();
36         redGrp.setReductionClient(reductionClient,new reductionInfo(CkNumPes()));
37 }
38
39 void reduction_init(void)
40 {
41         redArr.start();
42         redGrp.start();
43 }
44
45 void reductionArray::start(void) {
46         int i[2];
47         i[0]=1; //Sum=numElements
48         i[1]=0; //Sum=0
49         contribute(sizeof(i),&i,CkReduction::sum_int);
50         i[1]=2; //Sum=2*numElements
51         contribute(sizeof(i),&i,CkReduction::sum_int);
52         if (0) //Migrate to the next processor
53                 ckMigrate((CkMyPe()+1)%CkNumPes());
54 }
55 void reductionGroup::start(void) {
56         int i[2];
57         i[0]=1;
58         i[1]=0;
59         contribute(sizeof(i),&i,CkReduction::sum_int);  
60         i[1]=2; 
61         contribute(sizeof(i),&i,CkReduction::sum_int);
62 }
63
64 MEGATEST_REGISTER_TEST(reduction,"olawlor",1)
65 #include "reduction.def.h"