6 void LoadNotifyFn(int l
)
10 char *CldGetStrategy(void)
15 void CldBalanceHandler(void *msg
)
17 CldRestoreHandler(msg
);
21 void CldHandler(char *msg
)
23 int len
, queueing
, priobits
;
24 unsigned int *prioptr
;
25 CldInfoFn ifn
; CldPackFn pfn
;
27 CldRestoreHandler(msg
);
28 ifn
= (CldInfoFn
)CmiHandlerToFunction(CmiGetInfo(msg
));
29 ifn(msg
, &pfn
, &len
, &queueing
, &priobits
, &prioptr
);
30 CsdEnqueueGeneral(msg
, queueing
, priobits
, prioptr
);
33 void CldEnqueueMulti(int npes
, int *pes
, void *msg
, int infofn
)
35 int len
, queueing
, priobits
,i
; unsigned int *prioptr
;
36 CldInfoFn ifn
= (CldInfoFn
)CmiHandlerToFunction(infofn
);
38 ifn(msg
, &pfn
, &len
, &queueing
, &priobits
, &prioptr
);
41 ifn(msg
, &pfn
, &len
, &queueing
, &priobits
, &prioptr
);
43 CldSwitchHandler(msg
, CpvAccess(CldHandlerIndex
));
44 CmiSetInfo(msg
,infofn
);
46 CmiSyncSend(pes
[i
], len
, msg
);
51 void CldEnqueue(int pe
, void *msg
, int infofn
)
53 int len
, queueing
, priobits
; unsigned int *prioptr
;
54 CldInfoFn ifn
= (CldInfoFn
)CmiHandlerToFunction(infofn
);
57 if (pe
== CLD_ANYWHERE
) {
58 pe
= (((CrnRand()+CmiMyPe())&0x7FFFFFFF)%CmiNumPes());
59 while (!CldPresentPE(pe
))
60 pe
= (((CrnRand()+CmiMyPe())&0x7FFFFFFF)%CmiNumPes());
62 CpvAccess(CldRelocatedMessages
)++;
63 if (pe
== CmiMyPe()) {
64 ifn(msg
, &pfn
, &len
, &queueing
, &priobits
, &prioptr
);
65 CmiSetInfo(msg
,infofn
);
69 ifn(msg
, &pfn
, &len
, &queueing
, &priobits
, &prioptr
);
72 ifn(msg
, &pfn
, &len
, &queueing
, &priobits
, &prioptr
);
74 CldSwitchHandler(msg
, CpvAccess(CldBalanceHandlerIndex
));
75 CmiSetInfo(msg
,infofn
);
76 CmiSyncSendAndFree(pe
, len
, msg
);
79 else if ((pe
== CmiMyPe()) || (CmiNumPes() == 1)) {
80 ifn(msg
, &pfn
, &len
, &queueing
, &priobits
, &prioptr
);
81 CmiSetInfo(msg
,infofn
);
82 CsdEnqueueGeneral(msg
, CQS_QUEUEING_LIFO
, priobits
, prioptr
);
85 ifn(msg
, &pfn
, &len
, &queueing
, &priobits
, &prioptr
);
88 ifn(msg
, &pfn
, &len
, &queueing
, &priobits
, &prioptr
);
90 CldSwitchHandler(msg
, CpvAccess(CldHandlerIndex
));
91 CmiSetInfo(msg
,infofn
);
92 if (pe
==CLD_BROADCAST
) { CmiSyncBroadcastAndFree(len
, msg
); }
93 else if (pe
==CLD_BROADCAST_ALL
) { CmiSyncBroadcastAllAndFree(len
, msg
); }
94 else CmiSyncSendAndFree(pe
, len
, msg
);
98 void CldNodeEnqueue(int node
, void *msg
, int infofn
)
100 int len
, queueing
, priobits
; unsigned int *prioptr
;
101 CldInfoFn ifn
= (CldInfoFn
)CmiHandlerToFunction(infofn
);
103 if (node
== CLD_ANYWHERE
) {
104 /* node = (((rand()+CmiMyNode())&0x7FFFFFFF)%CmiNumNodes()); */
105 node
= (((CrnRand()+CmiMyNode())&0x7FFFFFFF)%CmiNumNodes());
106 if (node
!= CmiMyNode())
107 CpvAccess(CldRelocatedMessages
)++;
109 if (node
== CmiMyNode()) {
110 ifn(msg
, &pfn
, &len
, &queueing
, &priobits
, &prioptr
);
111 CsdNodeEnqueueGeneral(msg
, queueing
, priobits
, prioptr
);
114 ifn(msg
, &pfn
, &len
, &queueing
, &priobits
, &prioptr
);
117 ifn(msg
, &pfn
, &len
, &queueing
, &priobits
, &prioptr
);
119 CldSwitchHandler(msg
, CpvAccess(CldHandlerIndex
));
120 CmiSetInfo(msg
,infofn
);
121 if (node
==CLD_BROADCAST
) { CmiSyncNodeBroadcastAndFree(len
, msg
); }
122 else if (node
==CLD_BROADCAST_ALL
){CmiSyncNodeBroadcastAllAndFree(len
,msg
);}
123 else CmiSyncNodeSendAndFree(node
, len
, msg
);
127 void CldModuleInit(char **argv
)
129 CpvInitialize(int, CldHandlerIndex
);
130 CpvInitialize(int, CldBalanceHandlerIndex
);
131 CpvAccess(CldHandlerIndex
) = CmiRegisterHandler((CmiHandler
)CldHandler
);
132 CpvAccess(CldBalanceHandlerIndex
) = CmiRegisterHandler(CldBalanceHandler
);
133 CpvInitialize(int, CldRelocatedMessages
);
134 CpvInitialize(int, CldLoadBalanceMessages
);
135 CpvInitialize(int, CldMessageChunks
);
136 CpvAccess(CldRelocatedMessages
) = CpvAccess(CldLoadBalanceMessages
) =
137 CpvAccess(CldMessageChunks
) = 0;
138 CldModuleGeneralInit(argv
);