00001 #ifndef _ENTRY_H
00002 #define _ENTRY_H
00003
00004 #include "CEntry.h"
00005 #include "xi-Member.h"
00006 #include "xi-SdagConstruct.h"
00007 #include "xi-Template.h"
00008
00009 using std::cerr;
00010
00011 namespace xi {
00012
00013 class Value;
00014 class CStateVar;
00015
00016 class WhenConstruct;
00017 class WhenStatementEChecker;
00018
00019
00020
00021 #define STHREADED 0x01
00022 #define SSYNC 0x02
00023 #define SLOCKED 0x04
00024 #define SPURE 0x10
00025 #define SMIGRATE 0x20 //<- is magic migration constructor
00026 #define SCREATEHERE 0x40 //<- is a create-here-if-nonexistant
00027 #define SCREATEHOME 0x80 //<- is a create-at-home-if-nonexistant
00028 #define SIMMEDIATE 0x100 //<- is a immediate
00029 #define SNOKEEP 0x200
00030 #define SNOTRACE 0x400
00031 #define SSKIPSCHED 0x800 //<- is a message skipping charm scheduler
00032 #define SPYTHON 0x1000
00033 #define SINLINE 0x2000 //<- inline message
00034 #define SIGET 0x4000
00035 #define SLOCAL 0x8000 //<- local message
00036 #define SACCEL 0x10000
00037 #define SMEM 0x20000
00038 #define SREDUCE 0x40000 // <- reduction target
00039 #define SAPPWORK 0x80000 // <- reduction target
00040 #define SAGGREGATE 0x100000
00041
00042
00043 class Entry : public Member {
00044 public:
00045 XStr* genClosureTypeName;
00046 XStr* genClosureTypeNameProxy;
00047 XStr* genClosureTypeNameProxyTemp;
00048 int line, entryCount;
00049 int first_line_, last_line_;
00050 int numRdmaSendParams;
00051 int numRdmaRecvParams;
00052
00053 private:
00054 int attribs;
00055 Type* retType;
00056 Value* stacksize;
00057 const char* pythonDoc;
00058
00059 public:
00060 XStr proxyName(void);
00061 XStr indexName(void);
00062
00063 private:
00064
00065 int hasCallMarshall;
00066 void genCall(XStr& dest, const XStr& preCall, bool redn_wrapper = false,
00067 bool usesImplBuf = false);
00068
00069 void genRegularCall(XStr& dest, const XStr& preCall, bool redn_wrapper = false,
00070 bool usesImplBuf = false, bool isRdmaPost = false);
00071
00072 XStr epStr(bool isForRedn = false, bool templateCall = false);
00073 XStr epIdx(int fromProxy = 1, bool isForRedn = false);
00074 XStr epRegFn(int fromProxy = 1, bool isForRedn = false);
00075 XStr chareIdx(int fromProxy = 1);
00076 void genEpIdxDecl(XStr& str);
00077 void genEpIdxDef(XStr& str);
00078
00079 void genClosure(XStr& str, bool isDef);
00080 void genClosureEntryDefs(XStr& str);
00081 void genClosureEntryDecls(XStr& str);
00082
00083 void genChareDecl(XStr& str);
00084 void genChareStaticConstructorDecl(XStr& str);
00085 void genChareStaticConstructorDefs(XStr& str);
00086 void genChareDefs(XStr& str);
00087
00088 void genArrayDefs(XStr& str);
00089 void genArrayStaticConstructorDecl(XStr& str);
00090 void genArrayStaticConstructorDefs(XStr& str);
00091 void genArrayDecl(XStr& str);
00092
00093 void genGroupDecl(XStr& str);
00094 void genGroupStaticConstructorDecl(XStr& str);
00095 void genGroupStaticConstructorDefs(XStr& str);
00096 void genGroupDefs(XStr& str);
00097
00098 void genPythonDecls(XStr& str);
00099 void genPythonDefs(XStr& str);
00100 void genPythonStaticDefs(XStr& str);
00101 void genPythonStaticDocs(XStr& str);
00102
00103 void genTramTypes();
00104 void genTramDefs(XStr& str);
00105 void genTramInstantiation(XStr& str);
00106
00107
00108 void genAccelFullParamList(XStr& str, int makeRefs);
00109 void genAccelFullCallList(XStr& str);
00110 void genAccelIndexWrapperDecl_general(XStr& str);
00111 void genAccelIndexWrapperDef_general(XStr& str);
00112 void genAccelIndexWrapperDecl_spe(XStr& str);
00113 void genAccelIndexWrapperDef_spe(XStr& str);
00114 int genAccels_spe_c_funcBodies(XStr& str);
00115 void genAccels_spe_c_regFuncs(XStr& str);
00116 void genAccels_ppe_c_regFuncs(XStr& str);
00117
00118 XStr aggregatorIndexType();
00119 XStr dataItemType();
00120 XStr tramBaseType();
00121 XStr aggregatorType();
00122 XStr aggregatorGlobalType(XStr& scope);
00123 XStr aggregatorName();
00124 XStr paramType(int withDefaultVals, int withEO = 0, int useConst = 1, int rValue = 0);
00125 XStr paramComma(int withDefaultVals, int withEO = 0);
00126 XStr eo(int withDefaultVals, int priorComma = 1);
00127 XStr syncPreCall(void);
00128 XStr syncPostCall(void);
00129 XStr marshallMsg(void);
00130 XStr callThread(const XStr& procName, int prependEntryName = 0);
00131
00132
00133 std::list<CStateVar*> estateVars;
00134
00135 public:
00136 XStr* label;
00137 char* name;
00138 TParamList* targs;
00139
00140
00141 SdagConstruct* sdagCon;
00142 std::list<CStateVar*> stateVars;
00143 CEntry* entryPtr;
00144 const char* intExpr;
00145 ParamList* param;
00146 int isWhenEntry;
00147 bool containsWhenConstruct;
00148
00149 void addEStateVar(CStateVar* sv) {
00150 estateVars.push_back(sv);
00151 stateVars.push_back(sv);
00152 }
00153
00154 int tramInstanceIndex;
00155
00156
00157 ParamList* accelParam;
00158 XStr* accelCodeBody;
00159 XStr* accelCallbackName;
00160 void setAccelParam(ParamList* apl);
00161 void setAccelCodeBody(XStr* acb);
00162 void setAccelCallbackName(XStr* acbn);
00163
00164
00165 int accel_numScalars;
00166 int accel_numArrays;
00167 int accel_dmaList_numReadOnly;
00168 int accel_dmaList_numReadWrite;
00169 int accel_dmaList_numWriteOnly;
00170 int accel_dmaList_scalarNeedsWrite;
00171
00172 Entry(int l, int a, Type* r, const char* n, ParamList* p, Value* sz = 0,
00173 SdagConstruct* sc = 0, const char* e = 0, int fl = -1, int ll = -1);
00174 void setChare(Chare* c);
00175 int paramIsMarshalled(void);
00176 int getStackSize(void);
00177 int isThreaded(void);
00178 int isSync(void);
00179 int isIget(void);
00180 int isConstructor(void);
00181 bool isMigrationConstructor();
00182 int isExclusive(void);
00183 int isImmediate(void);
00184 int isSkipscheduler(void);
00185 int isInline(void);
00186 int isLocal(void);
00187 int isCreate(void);
00188 int isCreateHome(void);
00189 int isCreateHere(void);
00190 int isPython(void);
00191 int isNoTrace(void);
00192 int isAppWork(void);
00193 int isNoKeep(void);
00194 int isSdag(void);
00195 bool isTramTarget(void);
00196
00197
00198 int isAccel(void);
00199
00200 int isMemCritical(void);
00201 int isReductionTarget(void);
00202
00203 void print(XStr& str);
00204 void check();
00205 void genIndexDecls(XStr& str);
00206 void genDecls(XStr& str);
00207 void genDefs(XStr& str);
00208 void genReg(XStr& str);
00209 XStr genRegEp(bool isForRedn = false);
00210 void preprocess();
00211 void preprocessSDAG();
00212 char* getEntryName();
00213 void generateEntryList(std::list<CEntry*>&, WhenConstruct*);
00214 void collectSdagCode(SdagCollection* sc);
00215 void propagateState(int);
00216 void lookforCEntry(CEntry* centry);
00217 int getLine();
00218 void genTramRegs(XStr& str);
00219 void genTramPups(XStr& scope, XStr& decls, XStr& defs);
00220
00221 Chare* getContainer(void) const;
00222 };
00223
00224
00225 class EntryList {
00226 public:
00227 Entry* entry;
00228 EntryList* next;
00229 EntryList(Entry* e, EntryList* elist = NULL) : entry(e), next(elist) {}
00230 void generateEntryList(std::list<CEntry*>&, WhenConstruct*);
00231 };
00232
00233 }
00234
00235 #endif // ifndef _ENTRY_H