3 // #include "AAMLearner.h"
4 // #include "ComlibManager.h"
6 // #include "EachToManyMulticastStrategy.h"
7 // //#include "RingMulticastStrategy.h"
9 // AAMLearner::AAMLearner() {
13 // void AAMLearner::init() {
19 // Strategy *AAMLearner::optimizePattern(Strategy *strat,
20 // ComlibGlobalStats &stats) {
21 // CharmStrategy *in_strat = (CharmStrategy *)strat;
22 // double npes; //, *pelist;
23 // CharmStrategy *ostrat = NULL;
25 // double degree = 0, msgsize = 0, nmsgs = 0;
26 // stats.getAverageStats(strat->getInstance(), msgsize, nmsgs,
29 // double dcost = computeDirect(npes, msgsize, degree);
30 // double mcost = computeMesh(npes, msgsize, degree);
31 // double gcost = computeGrid(npes, msgsize, degree);
32 // double hcost = computeHypercube(npes, msgsize, degree);
33 // double mincost = min4(dcost, mcost, gcost, hcost);
36 // if(in_strat->getType() == ARRAY_STRATEGY) {
37 // CkArrayID said, daid;
38 // CkArrayIndex *sidxlist, *didxlist;
41 // in_strat->ainfo.getSourceArray(said, sidxlist, nsrc);
42 // in_strat->ainfo.getDestinationArray(daid, didxlist, ndest);
44 // if(dcost == mincost)
45 // minstrat = USE_DIRECT;
47 // else if(mcost == mincost)
48 // minstrat = USE_MESH;
49 // else if(gcost == mincost)
50 // minstrat = USE_GRID;
51 // else if(hcost == mincost)
52 // minstrat = USE_HYPERCUBE;
54 // //CkPrintf("Choosing router %d, %g, %g, %g\n", minstrat,
55 // // mcost, hcost, dcost);
57 // //if(minstrat != USE_DIRECT) {
58 // ostrat = new EachToManyMulticastStrategy
59 // (minstrat, said, daid,
60 // nsrc, sidxlist, ndest,
63 // ostrat->setMulticast();
68 // ostrat = new RingMulticastStrategy(said, daid);
73 // ostrat->setInstance(in_strat->getInstance());
74 // ((EachToManyMulticastStrategy *)ostrat)->enableLearning();
77 // CkAbort("Groups Not Implemented Yet\n");
79 // //Group strategy implement later, foo bar !!
84 // //P = number of processors, m = msgsize, d = degree
85 // double AAMLearner::computeDirect(double P, double m, double d) {
88 // cost += d * m * beta;
93 // /******************* CHECK EQUATIONS FOR AAM ***********/
94 // //P = number of processors, m = msgsize, d = degree
95 // double AAMLearner::computeMesh(double P, double m, double d) {
97 // cost = 2 * sqrt((double) P) * alpha;
98 // cost += d * m * (beta + gamma);
103 // //P = number of processors, m = msgsize, d = degree
104 // double AAMLearner::computeHypercube(double P, double m, double d) {
109 // double cost = 0.0;
110 // double log_2_P = log(P)/log(2.0);
112 // cost = log_2_P * alpha;
113 // cost += d * m * (beta + gamma);
118 // //P = number of processors, m = msgsize, d = degree
119 // double AAMLearner::computeGrid(double P, double m, double d) {
121 // double cost = 0.0;
122 // cost = 3 * cubeRoot((double) P) * alpha;
123 // cost += d * m * (beta + gamma);