00001
00002
00003
00004
00005
00006 #include "converse.h"
00007 #include "queueing.h"
00008 #include "cldb.h"
00009 #include <stdlib.h>
00010
00011 void LoadNotifyFn(int l)
00012 {
00013 }
00014
00015 const char *CldGetStrategy(void)
00016 {
00017 return "none";
00018 }
00019
00020 void CldHandler(char *msg)
00021 {
00022 int len, queueing, priobits;
00023 unsigned int *prioptr; CldInfoFn ifn; CldPackFn pfn;
00024 CldRestoreHandler((char *)msg);
00025 ifn = (CldInfoFn)CmiHandlerToFunction(CmiGetInfo(msg));
00026 ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
00027 CsdEnqueueGeneral(msg, queueing, priobits, prioptr);
00028 }
00029
00030 void CldEnqueueMulti(int npes, const int *pes, void *msg, int infofn)
00031 {
00032 int len, queueing, priobits,i; unsigned int *prioptr;
00033 CldInfoFn ifn = (CldInfoFn)CmiHandlerToFunction(infofn);
00034 CldPackFn pfn;
00035 ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
00036 if (pfn) {
00037 pfn(&msg);
00038 ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
00039 }
00040 CldSwitchHandler((char *)msg, CpvAccess(CldHandlerIndex));
00041 CmiSetInfo(msg,infofn);
00042
00043
00044
00045
00046
00047
00048
00049
00050 CmiSyncListSendAndFree(npes, pes, len, msg);
00051 }
00052
00053 void CldEnqueue(int pe, void *msg, int infofn)
00054 {
00055 int len, queueing, priobits; unsigned int *prioptr;
00056 CldInfoFn ifn = (CldInfoFn)CmiHandlerToFunction(infofn);
00057 CldPackFn pfn;
00058 if (pe == CLD_ANYWHERE) {
00059 pe = CmiMyPe();
00060 }
00061 if (pe == CmiMyPe() && !CmiImmIsRunning()) {
00062 ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
00063
00064 CsdEnqueueGeneral(msg, queueing, priobits, prioptr);
00065 } else {
00066 ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
00067 if (pfn) {
00068 pfn(&msg);
00069 ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
00070 }
00071 CldSwitchHandler((char *)msg, CpvAccess(CldHandlerIndex));
00072 CmiSetInfo(msg,infofn);
00073 if (pe==CLD_BROADCAST) { CmiSyncBroadcastAndFree(len, msg); }
00074 else if (pe==CLD_BROADCAST_ALL) { CmiSyncBroadcastAllAndFree(len, msg); }
00075 else CmiSyncSendAndFree(pe, len, msg);
00076 }
00077 }
00078
00079 void CldNodeEnqueue(int node, void *msg, int infofn)
00080 {
00081 int len, queueing, priobits; unsigned int *prioptr;
00082 CldInfoFn ifn = (CldInfoFn)CmiHandlerToFunction(infofn);
00083 CldPackFn pfn;
00084 if (node == CLD_ANYWHERE) {
00085 node = CmiMyNode();
00086 }
00087 if (node == CmiMyNode() && !CmiImmIsRunning()) {
00088 ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
00089 CsdNodeEnqueueGeneral(msg, queueing, priobits, prioptr);
00090 } else {
00091 ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
00092 if (pfn) {
00093 pfn(&msg);
00094 ifn(msg, &pfn, &len, &queueing, &priobits, &prioptr);
00095 }
00096 CldSwitchHandler((char *)msg, CpvAccess(CldHandlerIndex));
00097 CmiSetInfo(msg,infofn);
00098 if (node==CLD_BROADCAST) { CmiSyncNodeBroadcastAndFree(len, msg); }
00099 else if (node==CLD_BROADCAST_ALL){CmiSyncNodeBroadcastAllAndFree(len,msg);}
00100 else CmiSyncNodeSendAndFree(node, len, msg);
00101 }
00102 }
00103
00104 void CldModuleInit(char **argv)
00105 {
00106 CpvInitialize(int, CldHandlerIndex);
00107 CpvAccess(CldHandlerIndex) = CmiRegisterHandler((CmiHandler)CldHandler);
00108 CpvInitialize(int, CldRelocatedMessages);
00109 CpvInitialize(int, CldLoadBalanceMessages);
00110 CpvInitialize(int, CldMessageChunks);
00111 CpvAccess(CldRelocatedMessages) = CpvAccess(CldLoadBalanceMessages) =
00112 CpvAccess(CldMessageChunks) = 0;
00113 CldModuleGeneralInit(argv);
00114 }
00115
00116 void CldCallback(void){}