Checking in a new broadcast strategy which broadcasts to arrays along a load-balanced...
[charm.git] / src / ck-com / BroadcastStrategy.h
1 #ifndef BRAODCAST_STRATEGY
2 #define BRAODCAST_STRATEGY
3
4 #define DEFAULT_BROADCAST_SPANNING_FACTOR 4
5
6 #include "ComlibManager.h"
7
8 //Broadcast strategy for charm++ programs using the net version
9 //This stategy will wonly work for groups.
10 //This strategy implements a tree based broadcast
11 //I will extent it for arrays later.
12 //Developed by Sameer Kumar 04/10/04
13
14 class BroadcastStrategy : public CharmStrategy {
15
16     int _topology;         //Topology to use Tree or Hypercube
17
18     int handlerId;          //broadcast handler id
19     int spanning_factor;    //the spanning factor of the tree
20
21     double logp;       //ceil of log of number of processors
22
23     void initHypercube();      
24
25     void handleTree(char *msg);
26     void handleHypercube(char *msg);    
27
28  public:
29     BroadcastStrategy(int topology = USE_HYPERCUBE);
30     BroadcastStrategy(CkArrayID aid, int topology = USE_HYPERCUBE);
31     BroadcastStrategy(CkMigrateMessage *){}
32     void insertMessage(CharmMessageHolder *msg);
33     void doneInserting();
34
35     void handleMessage(char *msg);
36     void beginProcessing(int nelements);
37
38     virtual void pup(PUP::er &p);
39     PUPable_decl(BroadcastStrategy);
40 };
41 #endif