2 @addtogroup ComlibCharmStrategy
5 @brief Optimized all-to-all communication that can combine messages and send them along virtual topologies.
8 #ifndef EACH_TO_MANY_MULTICAST_STRATEGY
9 #define EACH_TO_MANY_MULTICAST_STRATEGY
11 #include "ComlibManager.h"
12 #include "routerstrategy.h"
15 The EachToManyMulticast Strategy optimizes all-to-all
16 communication. It combines messages and sends them along
17 virtual topologies 2d mesh, 3d mesh and hypercube using
18 the RouterStrategy as underlying strategy.
20 For large messages send them directly.
22 This is the object level strategy. For processor level
23 optimizations the underlying RouterStrategy is called.
25 @author Sameer Kumar, Filippo, and Isaac
28 class EachToManyMulticastStrategy
: public RouterStrategy
, public CharmStrategy
{
31 /// Executes common code just after array and group constructors
32 virtual void commonInit(int*);
36 /// If only the first three parameters are provided, the whole group will be used for the multicast(0 to CkNumPes)
37 /// TODO verify that the 0 parameter
38 EachToManyMulticastStrategy(int strategyId
, CkGroupID src
, CkGroupID dest
,
39 int nsrcpes
=0, int *srcpelist
=0,
40 int ndestpes
=0, int *destpelist
=0);
43 /// TODO: Fix this to allow for the same parameters as would be given to an array section creation(ranges of indices).
44 EachToManyMulticastStrategy(int substrategy
, CkArrayID src
,
45 CkArrayID dest
, int nsrc
=0,
46 CkArrayIndex
*srcelements
=0, int ndest
=0,
47 CkArrayIndex
*destelements
=0);
49 EachToManyMulticastStrategy(CkMigrateMessage
*m
) : RouterStrategy(m
), CharmStrategy(m
) {
50 ComlibPrintf("[%d] EachToManyMulticast migration constructor\n",CkMyPe());
53 ~EachToManyMulticastStrategy();
55 void insertMessage(MessageHolder
*msg
) {
56 // ((CharmMessageHolder*)msg) -> checkme();
57 insertMessage((CharmMessageHolder
*)msg
);
60 //Basic function, subclasses should not have to change it
61 virtual void insertMessage(CharmMessageHolder
*msg
);
63 virtual void pup(PUP::er
&p
);
64 virtual void localMulticast(void *msg
);
66 virtual void notifyDone();
68 /** Called by handleMessage at the destinations for the broadcast if in DIRECT mode. */
69 virtual void deliver(char *, int);
71 /// this method can be called when the strategy is in DIRECT mode, so the
72 /// message will go the comlib_handler and then arrive here.
73 virtual void handleMessage(void *msg
) {
74 envelope
*env
= (envelope
*)msg
;
76 deliver((char*)msg
, env
->getTotalsize());
79 PUPable_decl(EachToManyMulticastStrategy
);