00001 #ifndef TEMPO_H
00002 #define TEMPO_H
00003
00004 #include "charm++.h"
00005 #include <stdlib.h>
00006 #include "tempo.decl.h"
00007
00008 #define TEMPO_ANY CmmWildCard
00009 #define BCAST_TAG 1025
00010 #define BARR_TAG 1026
00011 #define REDUCE_TAG 1027
00012
00013 #define TempoAlign(x) (((x)+7)&~7)
00014
00015 class TempoMessage : public CMessage_TempoMessage
00016 {
00017 public:
00018 int tag1, tag2, length;
00019 void *data;
00020
00021 TempoMessage(void) { data = (char *)this + sizeof(TempoMessage); }
00022 TempoMessage(int t1, int t2, int l, void *d):tag1(t1),tag2(t2),length(l) {
00023 data = (char *)this + sizeof(TempoMessage);
00024 memcpy(data, d, l);
00025 }
00026 static void *alloc(int msgnum, size_t size, int *sizes, int pbits) {
00027 return CkAllocMsg(msgnum, (int)size+sizes[0], pbits);
00028 }
00029 static void *pack(TempoMessage *in) { return (void *) in; }
00030 static TempoMessage *unpack(void *in) { return new (in) TempoMessage; }
00031 };
00032
00033 class Tempo
00034 {
00035 protected:
00036 CmmTable tempoMessages;
00037 int sleeping;
00038 CthThread thread_id;
00039
00040 public :
00041 Tempo();
00042 void ckTempoRecv(int tag, void *buffer, int buflen);
00043 void ckTempoRecv(int tag1, int tag2, void *buffer, int buflen);
00044 static void ckTempoSend(int tag1, int tag2, void *buffer,int buflen,
00045 CkChareID cid);
00046 static void ckTempoSend(int tag, void *buffer,int buflen, CkChareID cid);
00047 void tempoGeneric(TempoMessage *themsg);
00048 int ckTempoProbe(int tag1, int tag2);
00049 int ckTempoProbe(int tag);
00050 };
00051
00052 class TempoChare : public Chare, public Tempo
00053 {
00054 public:
00055 TempoChare(void) {}
00056 TempoChare(CkMigrateMessage *m):Chare(m) {}
00057 };
00058
00059 class TempoGroup : public IrrGroup, public Tempo
00060 {
00061 public :
00062 TempoGroup(void) {};
00063 TempoGroup(CkMigrateMessage *m):IrrGroup(m) {};
00064 static void ckTempoBcast(int tag, void *buffer, int buflen, CkGroupID bocid);
00065 static void ckTempoSendBranch(int tag1, int tag2, void *buffer, int buflen,
00066 CkGroupID bocid, int processor);
00067 static void ckTempoSendBranch(int tag, void *buffer, int buflen,
00068 CkGroupID bocid, int processor);
00069 void ckTempoBcast(int sender, int tag, void *buffer, int buflen);
00070 void ckTempoSendBranch(int tag1, int tag2, void *buffer, int buflen,
00071 int processor);
00072 void ckTempoSendBranch(int tag, void *buffer, int buflen, int processor);
00073 };
00074
00075 #define TEMPO_MAX 1
00076 #define TEMPO_MIN 2
00077 #define TEMPO_SUM 3
00078 #define TEMPO_PROD 4
00079
00080 #define TEMPO_FLOAT 1
00081 #define TEMPO_INT 2
00082 #define TEMPO_DOUBLE 3
00083
00084 class TempoArray : public ArrayElement1D, public Tempo
00085 {
00086 int nGOps;
00087 public:
00088 TempoArray(void) { nGOps=0; }
00089 TempoArray(CkMigrateMessage *msg):ArrayElement1D(msg) { }
00090 static void ckTempoSendElem(int tag1, int tag2, void *buffer, int buflen,
00091 CkArrayID aid, int idx);
00092 static void ckTempoSendElem(int tag, void *buffer, int buflen,
00093 CkArrayID aid, int idx);
00094 void ckTempoSendElem(int tag1, int tag2, void *buffer, int buflen, int idx);
00095 void ckTempoSendElem(int tag, void *buffer, int buflen, int idx);
00096 void ckTempoBarrier(void);
00097 void ckTempoBcast(int sender, int tag, void *buffer, int buflen);
00098 void ckTempoReduce(int root, int op, void *inbuf, void *outbuf, int count,
00099 int type);
00100 void ckTempoAllReduce(int op,void *inbuf,void *outbuf,int count,int type);
00101 void pup(PUP::er& p)
00102 {
00103 ArrayElement1D::pup(p);
00104 p(nGOps);
00105 }
00106 };
00107
00108 #endif