Fixing some bugs in the new node aware multicast strategy.
[charm.git] / src / ck-com / BroadcastStrategy.h
1 /**
2    @addtogroup ComlibCharmStrategy
3    @{
4    @file
5 */
6
7 #ifndef BRAODCAST_STRATEGY
8 #define BRAODCAST_STRATEGY
9
10 #define DEFAULT_BROADCAST_SPANNING_FACTOR 4
11
12 #include "ComlibManager.h"
13
14 /**
15    Broadcast strategy for charm++ programs using the net version.
16    This stategy will only work for groups.
17    This strategy implements a tree based broadcast
18
19    Developed by Sameer Kumar 04/10/04
20
21    @warning This strategy works only in particular situations and is not
22    generic. Its usage is adviced against.
23
24 */
25
26 class BroadcastStrategy : public Strategy, public CharmStrategy {
27
28     int _topology;         //Topology to use Tree or Hypercube
29
30     //int handlerId;          //broadcast handler id
31     int spanning_factor;    //the spanning factor of the tree
32
33     double logp;       //ceil of log of number of processors
34
35     void initHypercube();      
36
37     void handleTree(void *msg);
38     void handleHypercube(void *msg);    
39
40  public:
41     BroadcastStrategy(int topology = USE_HYPERCUBE);
42     BroadcastStrategy(CkArrayID aid, int topology = USE_HYPERCUBE);
43     BroadcastStrategy(CkMigrateMessage *m): Strategy(m), CharmStrategy(m) {}
44     void insertMessage(MessageHolder *msg) {insertMessage((CharmMessageHolder*)msg);};
45     void insertMessage(CharmMessageHolder *msg);
46     //void doneInserting();
47
48     void handleMessage(void *msg);
49     //void beginProcessing(int nelements);
50
51     virtual void pup(PUP::er &p);
52     PUPable_decl(BroadcastStrategy);
53 };
54 #endif
55
56 /*@}*/