00001 #include "xi-Chare.h"
00002 #include "xi-Entry.h"
00003 #include "xi-Member.h"
00004 #include "xi-Parameter.h"
00005 #include "xi-SdagCollection.h"
00006
00007 #include "sdag/constructs/When.h"
00008
00009 #include "CParsedFile.h"
00010
00011 using std::cout;
00012 using std::endl;
00013
00014 namespace xi {
00015
00016 static void disambig_group(XStr& str, const XStr& super);
00017 static void disambig_array(XStr& str, const XStr& super);
00018 static void disambig_reduction_client(XStr& str, const XStr& super);
00019
00020 static XStr indexSuffix2object(const XStr& indexSuffix);
00021
00022 static const char* CIClassStart =
00023 "{\n"
00024 " public:\n";
00025
00026 static const char* CIClassEnd = "};\n";
00027
00028 extern int fortranMode;
00029 extern int internalMode;
00030
00031 Chare::Chare(int ln, attrib_t Nattr, NamedType* t, TypeList* b, AstChildren<Member>* l)
00032 : attrib(Nattr), type(t), list(l), bases(b) {
00033 line = ln;
00034 entryCount = 1;
00035 hasElement = 0;
00036 forElement = forAll;
00037 hasSection = 0;
00038 bases_CBase = NULL;
00039 setTemplate(0);
00040 hasSdagEntry = 0;
00041 }
00042
00043 void Chare::check() {
00044 if (list) {
00045 list->check();
00046 }
00047 }
00048
00049 void Chare::genRegisterMethodDef(XStr& str) {
00050 if (external || type->isTemplated()) return;
00051 templateGuardBegin(isTemplated(), str);
00052 str << tspec(false) << "void " << indexName()
00053 << "::__register(const char *s, size_t size) {\n"
00054 " __idx = CkRegisterChare(s, size,";
00055 if (isMainChare())
00056 str << " TypeMainChare";
00057 else if (isGroup())
00058 str << " TypeGroup";
00059 else if (isNodeGroup())
00060 str << " TypeNodeGroup";
00061 else if (isArray())
00062 str << " TypeArray";
00063 else if (isChare())
00064 str << " TypeChare";
00065 else
00066 str << " TypeInvalid";
00067 str << ");\n";
00068
00069 if (isArray()) {
00070 str << " CkRegisterArrayDimensions(__idx, ";
00071 XStr dim = ((Array*)this)->dim();
00072 if (dim == (const char*)"1D")
00073 str << "1";
00074 else if (dim == (const char*)"2D")
00075 str << "2";
00076 else if (dim == (const char*)"3D")
00077 str << "3";
00078 else if (dim == (const char*)"4D")
00079 str << "4";
00080 else if (dim == (const char*)"5D")
00081 str << "5";
00082 else if (dim == (const char*)"6D")
00083 str << "6";
00084 else
00085 str << "-1";
00086
00087 str << ");\n";
00088 }
00089
00090 if (internalMode) str << " CkRegisterChareInCharm(__idx);\n";
00091
00092 genIndexNames(str, " CkRegisterBase(__idx, ", NULL, "::__idx);\n", "");
00093 genSubRegisterMethodDef(str);
00094 if (list) list->genReg(str);
00095 if (hasSdagEntry) {
00096 str << " " << baseName() << "::__sdag_register(); // Potentially missing "
00097 << baseName() << "_SDAG_CODE in your class definition?\n";
00098 }
00099 str << "}\n";
00100 templateGuardEnd(str);
00101 }
00102
00103 void Chare::outputClosuresDecl(XStr& str) { str << closuresDecl; }
00104
00105 void Chare::outputClosuresDef(XStr& str) { str << closuresDef; }
00106
00107 void Chare::genDecls(XStr& str) {
00108 if (type->isTemplated()) return;
00109 str << "/* DECLS: ";
00110 print(str);
00111 str << " */\n";
00112
00113
00114
00115
00116 if (isPython()) {
00117 str << "#include \"PythonCCS.h\"\n";
00118 if (list) {
00119 Entry* etemp =
00120 new Entry(0, 0, new BuiltinType("void"), "pyRequest",
00121 new ParamList(new Parameter(
00122 0, new PtrType(new NamedType("CkCcsRequestMsg", 0)), "msg")),
00123 0, 0, 0);
00124 list->push_back(etemp);
00125 etemp->setChare(this);
00126
00127
00128
00129
00130 }
00131 }
00132
00133 genTramTypes();
00134
00135
00136 str << tspec(false) << " class " << type << ";\n";
00137 str << tspec(false) << " class " << Prefix::Index << type << ";\n";
00138 str << tspec(false) << " class " << Prefix::Proxy << type << ";\n";
00139 if (hasElement)
00140 str << tspec(false) << " class " << Prefix::ProxyElement << type << ";\n";
00141 if (hasSection)
00142 str << tspec(false) << " class " << Prefix::ProxySection << type << ";\n";
00143 if (isPython()) str << tspec(false) << " class " << Prefix::Python << type << ";\n";
00144
00145
00146 str << "/* --------------- index object ------------------ */\n";
00147 str << tspec() << "class " << Prefix::Index << type;
00148 str << ":";
00149 genIndexNames(str, "public ", NULL, "", ", ");
00150 if (external ||
00151 type->isTemplated()) {
00152 str << ";";
00153 } else {
00154 str << CIClassStart;
00155 genTypedefs(str);
00156 str << " static int __idx;\n";
00157 str << " static void __register(const char *s, size_t size);\n";
00158 if (list) list->recurse<XStr&>(str, &Member::genIndexDecls);
00159 str << CIClassEnd;
00160 }
00161 str << "/* --------------- element proxy ------------------ */\n";
00162 generateTramInits = true;
00163 genSubDecls(str);
00164 generateTramInits = false;
00165 if (hasElement) {
00166 str << "/* ---------------- collective proxy -------------- */\n";
00167 forElement = forAll;
00168 genSubDecls(str);
00169 forElement = forIndividual;
00170 }
00171 if (hasSection) {
00172 str << "/* ---------------- section proxy -------------- */\n";
00173 forElement = forSection;
00174 genSubDecls(str);
00175 forElement = forIndividual;
00176 }
00177 if (isPython()) {
00178 str << "/* ---------------- python wrapper -------------- */\n";
00179 genPythonDecls(str);
00180 }
00181
00182 closuresDecl << "/* ---------------- method closures -------------- */\n";
00183 closuresDef << closuresDecl;
00184 genClosureEntryDecls(closuresDecl);
00185 genClosureEntryDefs(closuresDef);
00186
00187 if (list) {
00188
00189 int sdagPresent = 0;
00190 XStr sdagStr;
00191 CParsedFile myParsedFile(this);
00192 SdagCollection sc(&myParsedFile);
00193 list->recurse(&sc, &Member::collectSdagCode);
00194 if (sc.sdagPresent) {
00195 XStr classname;
00196 XStr sdagDecls;
00197 classname << baseName(0);
00198 resetNumbers();
00199 myParsedFile.doProcess(classname, sdagDecls, sdagDefs);
00200 str << sdagDecls;
00201 } else {
00202 str << "#define " << baseName(0) << "_SDAG_CODE \n";
00203 }
00204 }
00205
00206
00207
00208 XStr CBaseName;
00209 CBaseName << "CBase_" << type;
00210 if (isTemplateDeclaration()) {
00211 templat->genSpec(str);
00212 str << "\nstruct " << CBaseName << ";\n";
00213 } else {
00214 str << "typedef " << cbaseTType() << CBaseName << ";\n";
00215 }
00216 }
00217
00218 void Chare::preprocess() {
00219 if (list) {
00220 list->preprocess();
00221 list->recurse(this, &Member::setChare);
00222 list->recursev(&Member::preprocessSDAG);
00223
00224 if (isMigratable()) {
00225 Entry* e = new Entry(line, SMIGRATE, NULL, (char*)type->getBaseName(),
00226 new ParamList(new Parameter(
00227 line, new PtrType(new NamedType("CkMigrateMessage")))),
00228 0, 0, 0);
00229 e->setChare(this);
00230 list->push_back(e);
00231 }
00232 }
00233
00234 if (bases == NULL)
00235 bases = new TypeList(new NamedType("Chare"), NULL);
00236 }
00237
00238
00239
00240
00241
00242
00243
00244 static void disambig_proxy(XStr& str, const XStr& super) {
00245 str << "\n int ckIsDelegated(void) const"
00246 << "\n { return " << super << "::ckIsDelegated(); }"
00247 << "\n inline CkDelegateMgr *ckDelegatedTo(void) const"
00248 << "\n { return " << super << "::ckDelegatedTo(); }"
00249 << "\n inline CkDelegateData *ckDelegatedPtr(void) const"
00250 << "\n { return " << super << "::ckDelegatedPtr(); }"
00251 << "\n CkGroupID ckDelegatedIdx(void) const"
00252 << "\n { return " << super << "::ckDelegatedIdx(); }"
00253 << "\n";
00254 }
00255
00256
00257
00258
00259
00260
00261 XStr Chare::virtualPupDef(const XStr& name) {
00262 XStr str;
00263 str << "virtual_pup(PUP::er &p) {"
00264 << "\n recursive_pup<" << name << ">(dynamic_cast<" << name << "*>(this), p);"
00265 << "\n}";
00266 return str;
00267 }
00268
00269 void Chare::genRecursivePup(XStr& scopedName, XStr templateSpec, XStr& decls,
00270 XStr& defs) {
00271 templateGuardBegin(false, defs);
00272
00273 XStr rec_pup_impl_name, rec_pup_impl_sig, rec_pup_impl_body;
00274 rec_pup_impl_name << "recursive_pup_impl<" << scopedName << ", 1>";
00275 rec_pup_impl_sig << "operator()(" << scopedName << " *obj, PUP::er &p)";
00276
00277 rec_pup_impl_body << rec_pup_impl_sig << " {"
00278 << "\n obj->parent_pup(p);";
00279 if (hasSdagEntry) rec_pup_impl_body << "\n obj->_sdag_pup(p);";
00280 rec_pup_impl_body << "\n obj->" << scopedName << "::pup(p);"
00281 << "\n}\n";
00282
00283 decls << "\ntemplate <>"
00284 << "\nvoid " << rec_pup_impl_name << "::" << rec_pup_impl_sig << ";\n";
00285
00286 defs << templateSpec << "void " << rec_pup_impl_name << "::" << rec_pup_impl_body;
00287
00288 templateGuardEnd(defs);
00289 }
00290
00291 void Chare::genGlobalCode(XStr scope, XStr& decls, XStr& defs) {
00292 if (isTemplateInstantiation()) return;
00293
00294 XStr templatedType;
00295 templatedType << type;
00296 if (templat) templat->genVars(templatedType);
00297
00298 XStr scopedName;
00299 scopedName << scope << templatedType;
00300
00301 if (list) list->genTramPups(scope, decls, defs);
00302
00303 if (!isTemplateDeclaration()) {
00304
00305
00306 if (0 != strcmp(type->getBaseName(), "ArrayElement")) {
00307 templateGuardBegin(false, defs);
00308 defs << "template <>\n"
00309 << "void " << scope << "CBase_" << baseName(true)
00310 << "::" << virtualPupDef(scopedName) << "\n";
00311 templateGuardEnd(defs);
00312 }
00313 }
00314 }
00315
00316 void Chare::genClosureEntryDecls(XStr& str) {
00317 XStr ptype;
00318 ptype << "Closure_" << type;
00319 str << tspec() << "class " << ptype << " ";
00320 str << CIClassStart;
00321 if (list) list->genClosureEntryDecls(str);
00322 str << CIClassEnd;
00323 }
00324
00325 void Chare::genClosureEntryDefs(XStr& str) {
00326 if (list) list->genClosureEntryDefs(str);
00327 }
00328
00329 void Chare::genSubDecls(XStr& str) {
00330 XStr ptype;
00331 ptype << proxyPrefix() << type;
00332
00333
00334 str << tspec() << "class " << ptype;
00335 if (external || type->isTemplated()) {
00336 str << ";";
00337 return;
00338 }
00339 str << ":";
00340 genProxyNames(str, "public ", NULL, "", ", ");
00341 str << CIClassStart;
00342
00343 genTypedefs(str);
00344
00345
00346 str << " " << ptype << "(void) {};\n";
00347
00348 str << " " << ptype << "(CkChareID __cid) : ";
00349 genProxyNames(str, "", NULL, "(__cid)", ", ");
00350 str << "{ }\n";
00351
00352 str << " " << ptype << "(const Chare *c) : ";
00353 genProxyNames(str, "", NULL, "(c)", ", ");
00354 str << "{ }\n";
00355
00356
00357 XStr super;
00358 bases->getFirst()->genProxyName(super, forElement);
00359 disambig_proxy(str, super);
00360 str << "\n inline void ckCheck(void) const"
00361 << "\n { " << super << "::ckCheck(); }"
00362 << "\n const CkChareID &ckGetChareID(void) const"
00363 << "\n { return " << super << "::ckGetChareID(); }"
00364 << "\n operator const CkChareID &(void) const"
00365 << "\n { return ckGetChareID(); }"
00366 << "\n";
00367
00368 sharedDisambiguation(str, super);
00369 str << "\n void ckSetChareID(const CkChareID &c)"
00370 << "\n {";
00371 genProxyNames(str, " ", NULL, "::ckSetChareID(c); ", "");
00372 str << "}"
00373 << "\n " << type << tvars() << " *ckLocal(void) const"
00374 << "\n { return (" << type << tvars() << " *)CkLocalChare(&ckGetChareID()); }"
00375 << "\n";
00376
00377 genMemberDecls(str);
00378 str << CIClassEnd;
00379 if (!isTemplated()) str << "PUPmarshall(" << ptype << ")\n";
00380 }
00381
00382 void Chare::genMemberDecls(XStr& str) {
00383 if (list) list->genDecls(str);
00384 }
00385
00386 void Chare::genPythonDecls(XStr& str) {
00387 XStr ptype;
00388 ptype << Prefix::Python << type;
00389
00390
00391 str << tspec() << "class " << ptype;
00392 if (external || type->isTemplated()) {
00393 str << ";";
00394 return;
00395 }
00396 str << ":";
00397 TypeList* b = bases_CBase;
00398 if (b == NULL) b = bases;
00399 b->genProxyNames(str, "public ", NULL, "", ", ", forPython);
00400 str << ", public PythonObject ";
00401 str << CIClassStart;
00402
00403
00404 str << " " << ptype << "(void) {}\n";
00405 str << " " << ptype << "(CkMigrateMessage *msg): ";
00406 b->genProxyNames(str, "", NULL, "(msg)", ", ", forPython);
00407 str << " {}\n";
00408
00409
00410 str << " void pup(PUP::er &p) {\n";
00411 b->genProxyNames(str, " ", NULL, "::pup(p);", "\n", forPython);
00412 str << "\n }\n";
00413
00414
00415 str << " static PyMethodDef CkPy_MethodsCustom[];\n";
00416 str << " PyMethodDef *getMethods(void) {return CkPy_MethodsCustom;}\n";
00417 str << " static const char *CkPy_MethodsCustomDoc;\n";
00418 str << " const char *getMethodsDoc(void) {return CkPy_MethodsCustomDoc;}\n";
00419
00420 str << CIClassEnd;
00421
00422
00423 if (list) list->recurse<XStr&>(str, &Member::genPythonDecls);
00424 str << "\n";
00425
00426 if (!isTemplated()) str << "PUPmarshall(" << ptype << ")\n";
00427 }
00428
00429 void Chare::genPythonDefs(XStr& str) {
00430 XStr ptype;
00431 ptype << Prefix::Python << type;
00432
00433
00434 str << "PyMethodDef " << ptype << "::CkPy_MethodsCustom[] = {\n";
00435 if (list) list->recurse<XStr&>(str, &Member::genPythonStaticDefs);
00436 str << " {NULL, NULL}\n};\n\n";
00437
00438 str << "const char * " << ptype
00439 << "::CkPy_MethodsCustomDoc = \"charm.__doc__ = \\\"Available methods for object "
00440 << type << ":\\\\n\"";
00441 if (list) list->recurse<XStr&>(str, &Member::genPythonStaticDocs);
00442 str << "\n \"\\\"\";\n\n";
00443
00444 if (list) list->recurse<XStr&>(str, &Member::genPythonDefs);
00445 }
00446
00447 void Chare::printChareNames() { cout << baseName(0) << endl; }
00448
00449 XStr Chare::proxyName(int withTemplates) {
00450 XStr str;
00451 str << proxyPrefix() << type;
00452 if (withTemplates) str << tvars();
00453 return str;
00454 }
00455
00456 XStr Chare::indexName(int withTemplates) {
00457 XStr str;
00458 str << Prefix::Index << type;
00459 if (withTemplates) str << tvars();
00460 return str;
00461 }
00462
00463
00464 XStr Chare::sectionName(int withTemplates) {
00465 XStr str;
00466 str << Prefix::ProxySection << type;
00467 if (withTemplates) str << tvars();
00468 return str;
00469 }
00470
00471 XStr Chare::indexList() {
00472
00473 XStr str;
00474 if (!isArray()) {
00475 cerr << (char*)baseName() << ": only chare arrays are currently supported\n";
00476 exit(1);
00477 }
00478 XStr dim = ((Array*)this)->dim();
00479 if (dim == (const char*)"1D")
00480 str << "const int *index1";
00481 else if (dim == (const char*)"2D")
00482 str << "const int *index1, const int *index2";
00483 else if (dim == (const char*)"3D")
00484 str << "const int *index1, const int *index2, const int *index3";
00485 else {
00486 cerr << (char*)baseName()
00487 << ": only up to 3 dimension chare arrays are currently supported\n";
00488 exit(1);
00489 }
00490 return str;
00491 }
00492
00493 void Chare::genProxyNamesExceptFirst(XStr& str, const char* prefix, const char* middle,
00494 const char* suffix, const char* sep) {
00495 TypeList* base2 = bases->next;
00496 if (base2 != NULL) base2->genProxyNames(str, prefix, middle, suffix, sep, forElement);
00497 }
00498
00499 void Chare::genProxyNames(XStr& str, const char* prefix, const char* middle,
00500 const char* suffix, const char* sep) {
00501 bases->genProxyNames(str, prefix, middle, suffix, sep, forElement);
00502 }
00503
00504 void Chare::genIndexNames(XStr& str, const char* prefix, const char* middle,
00505 const char* suffix, const char* sep) {
00506 bases->genProxyNames(str, prefix, middle, suffix, sep, forIndex);
00507 }
00508
00509 char* Chare::proxyPrefix(void) { return (char*)forWhomStr(forElement); }
00510
00511
00512 void Chare::sharedDisambiguation(XStr& str, const XStr& super) {
00513 (void)super;
00514 str << "\n void ckDelegate(CkDelegateMgr *dTo,CkDelegateData *dPtr=NULL)"
00515 << "\n { ";
00516 genProxyNames(str, " ", NULL, "::ckDelegate(dTo,dPtr); ", "");
00517 str << "}"
00518 << "\n void ckUndelegate(void)"
00519 << "\n { ";
00520 genProxyNames(str, " ", NULL, "::ckUndelegate(); ", "");
00521 str << "}"
00522 << "\n void pup(PUP::er &p)"
00523 << "\n { ";
00524 genProxyNames(str, " ", NULL, "::pup(p);\n", "");
00525 if (isForElement() && !tramInstances.empty()) {
00526 str << " if (p.isUnpacking()) {\n";
00527 for (int i = 0; i < tramInstances.size(); i++) {
00528 str << " " << tramInstances[i].name.c_str() << " = NULL;\n";
00529 }
00530 str << " }\n";
00531 }
00532 str << " }";
00533 if (isPython()) {
00534 str << "\n void registerPython(const char *str)"
00535 << "\n { CcsRegisterHandler(str, CkCallback(" << Prefix::Index << type
00536 << "::pyRequest(0), *this)); }";
00537 }
00538 str << "\n";
00539 }
00540
00541 void Chare::genTypedefs(XStr& str) {
00542 str << " typedef " << baseName(1) << " local_t;\n";
00543 str << " typedef " << Prefix::Index << baseName(1) << " index_t;\n";
00544 str << " typedef " << Prefix::Proxy << baseName(1) << " proxy_t;\n";
00545
00546 if (hasElement)
00547 str << " typedef " << Prefix::ProxyElement << baseName(1) << " element_t;\n";
00548 else
00549 str << " typedef " << Prefix::Proxy << baseName(1) << " element_t;\n";
00550
00551 if (hasSection)
00552 str << " typedef " << Prefix::ProxySection << baseName(1) << " section_t;\n";
00553 str << "\n";
00554 }
00555
00556 void Chare::genDefs(XStr& str) {
00557 str << "/* DEFS: ";
00558 print(str);
00559 str << " */\n";
00560 if (fortranMode) {
00561 if (!isArray()) {
00562 cerr << (char*)baseName() << ": only chare arrays are currently supported\n";
00563 exit(1);
00564 }
00565
00566 str << "/* FORTRAN */\n";
00567 str << "extern \"C\" void " << fortranify(baseName(), "_allocate")
00568 << "(char **, void *, " << indexList() << ");\n";
00569 str << "extern \"C\" void " << fortranify(baseName(), "_pup")
00570 << "(pup_er p, char **, void *);\n";
00571 str << "extern \"C\" void " << fortranify(baseName(), "_resumefromsync")
00572 << "(char **, void *, " << indexList() << ");\n";
00573 str << "\n";
00574 XStr dim = ((Array*)this)->dim();
00575 str << "class " << baseName() << " : public CBase_" << baseName() << "\n";
00576 str << "{\n";
00577 if (hasSdagEntry)
00578 str << " " << baseName() << "_SDAG_CODE\n";
00579 str << "public:\n";
00580 str << " char user_data[64];\n";
00581 str << "public:\n";
00582 str << " " << baseName() << "()\n";
00583 str << " {\n";
00584
00585 str << " CkArrayID *aid = &thisArrayID;\n";
00586 if (dim == (const char*)"1D")
00587 str << " " << fortranify(baseName(), "_allocate")
00588 << "((char **)&user_data, &aid, &thisIndex);\n";
00589 else if (dim == (const char*)"2D")
00590 str << " " << fortranify(baseName(), "_allocate")
00591 << "((char **)&user_data, &aid, &thisIndex.x, &thisIndex.y);\n";
00592 else if (dim == (const char*)"3D")
00593 str << " " << fortranify(baseName(), "_allocate")
00594 << "((char **)&user_data, &aid, &thisIndex.x, &thisIndex.y, &thisIndex.z);\n";
00595 str << " usesAtSync = true;\n";
00596 str << " }\n";
00597 str << "\n";
00598 str << " " << baseName() << "(CkMigrateMessage *m)\n";
00599 str << " {\n";
00600 str << " /* CkPrintf(\"" << baseName() << " %d migrating\\n\",thisIndex);*/ \n";
00601 str << " }\n";
00602 str << "\n";
00603
00604 str << " virtual void pup(PUP::er &p)\n";
00605 str << " {\n";
00606 str << " p(user_data, 64);\n";
00607 str << " CkArrayID *aid = &thisArrayID;\n";
00608 str << " ::" << fortranify(baseName(), "_pup")
00609 << "(&p, (char **)&user_data, &aid); \n";
00610 str << " }\n";
00611 str << "\n";
00612
00613
00614 str << " void ResumeFromSync()\n";
00615 str << " {\n";
00616 str << " CkArrayID *aid = &thisArrayID;\n";
00617 str << " ::" << fortranify(baseName(), "_resumefromSync");
00618 if (dim == (const char*)"1D") {
00619 str << "((char **)&user_data, &aid, &thisIndex);\n";
00620 } else if (dim == (const char*)"2D") {
00621 str << "((char **)&user_data, &aid, &thisIndex.x, &thisIndex.y);\n";
00622 } else if (dim == (const char*)"3D") {
00623 str << "((char **)&user_data, &aid, &thisIndex.x, &thisIndex.y, &thisIndex.z);\n";
00624 }
00625 str << " }\n";
00626
00627 str << "};\n";
00628 str << "\n";
00629 if (dim == (const char*)"1D") {
00630 str << "extern \"C\" void " << fortranify(baseName(), "_cknew")
00631 << "(int *numElem, void **aindex)\n";
00632 str << "{\n";
00633 str << " CkArrayID *aid = new CkArrayID;\n";
00634 str << " *aid = CProxy_" << baseName() << "::ckNew(*numElem); \n";
00635 } else if (dim == (const char*)"2D") {
00636 str << "extern \"C\" void " << fortranify(baseName(), "_cknew")
00637 << "(int *numx, int *numy, void **aindex)\n";
00638 str << "{\n";
00639 str << " CkArrayID *aid = new CkArrayID;\n";
00640 str << " *aid = CProxy_" << baseName() << "::ckNew(); \n";
00641 str << " CProxy_" << baseName() << " p(*aid);\n";
00642 str << " for (int i=0; i<*numx; i++) \n";
00643 str << " for (int j=0; j<*numy; j++) \n";
00644 str << " p[CkArrayIndex2D(i, j)].insert(); \n";
00645 str << " p.doneInserting(); \n";
00646 } else if (dim == (const char*)"3D") {
00647 str << "extern \"C\" void " << fortranify(baseName(), "_cknew")
00648 << "(int *numx, int *numy, int *numz, void **aindex)\n";
00649 str << "{\n";
00650 str << " CkArrayID *aid = new CkArrayID;\n";
00651 str << " *aid = CProxy_" << baseName() << "::ckNew(); \n";
00652 str << " CProxy_" << baseName() << " p(*aid);\n";
00653 str << " for (int i=0; i<*numx; i++) \n";
00654 str << " for (int j=0; j<*numy; j++) \n";
00655 str << " for (int k=0; k<*numz; k++) \n";
00656 str << " p[CkArrayIndex3D(i, j, k)].insert(); \n";
00657 str << " p.doneInserting(); \n";
00658 }
00659 str << " *aindex = (void*)aid;\n";
00660 str << "}\n";
00661
00662
00663 if (dim == (const char*)"1D") {
00664 str << "extern \"C\" void " << fortranify(baseName(), "_atsync")
00665 << "(void** aindex, int *index1)\n";
00666 str << "{\n";
00667 str << " CkArrayID *aid = (CkArrayID *)*aindex;\n";
00668 str << "\n";
00669 str << " CProxy_" << baseName() << " h(*aid);\n";
00670 str << " h[*index1].ckLocal()->AtSync();\n";
00671 } else if (dim == (const char*)"2D") {
00672 str << "extern \"C\" void " << fortranify(baseName(), "_atsync")
00673 << "(void** aindex, int *index1, int *index2)\n";
00674 str << "{\n";
00675 str << " CkArrayID *aid = (CkArrayID *)*aindex;\n";
00676 str << "\n";
00677 str << " CProxy_" << baseName() << " h(*aid);\n";
00678 str << " h[CkArrayIndex2D(*index1, *index2)].ckLocal()->AtSync();\n";
00679 } else if (dim == (const char*)"3D") {
00680 str << "extern \"C\" void " << fortranify(baseName(), "_atsync")
00681 << "(void** aindex, int *index1, int *index2, int *index3)\n";
00682 str << "{\n";
00683 str << " CkArrayID *aid = (CkArrayID *)*aindex;\n";
00684 str << "\n";
00685 str << " CProxy_" << baseName() << " h(*aid);\n";
00686 str << " h[CkArrayIndex3D(*index1, *index2, *index3)].ckLocal()->AtSync();\n";
00687 }
00688 str << "}\n";
00689
00690
00691 if (dim == (const char*)"1D") {
00692 str << "extern \"C\" void "
00693 << fortranify(baseName(), "_contribute")
00694 << "(void** aindex, int *index1, int *size, void *data, int *op, int (*target)())\n";
00695 str << "{\n";
00696 str << " CkArrayID *aid = (CkArrayID *)*aindex;\n";
00697 str << " CProxy_" << baseName() << " h(*aid);\n";
00698 str << " h[*index1].ckLocal()->contribute(*size, data, CkReduction::reducerType(*op), CkCallback(target(), h[0]));\n";
00699 }
00700 else if (dim == (const char*)"2D") {
00701 str << "extern \"C\" void "
00702 << fortranify(baseName(), "_contribute")
00703 << "(void** aindex, int *index1, int *index2, int *size, void *data, int *op, int (*target)())\n";
00704 str << "{\n";
00705 str << " CkArrayID *aid = (CkArrayID *)*aindex;\n";
00706 str << " CProxy_" << baseName() << " h(*aid);\n";
00707 str << " h(*index1, *index2).ckLocal()->contribute(*size, data, CkReduction::reducerType(*op), CkCallback(target(), h(0, 0)));\n";
00708 }
00709 else if (dim == (const char*)"3D") {
00710 str << "extern \"C\" void "
00711 << fortranify(baseName(), "_contribute")
00712 << "(void** aindex, int *index1, int *index2, int *index3, int *size, void *data, int *op, int (*target)())\n";
00713 str << "{\n";
00714 str << " CkArrayID *aid = (CkArrayID *)*aindex;\n";
00715 str << " CProxy_" << baseName() << " h(*aid);\n";
00716 str << " h(*index1, *index2, *index3).ckLocal()->contribute(*size, data, CkReduction::reducerType(*op), CkCallback(target(), h(0, 0, 0)));\n";
00717 }
00718 str << "}\n";
00719
00720 str << "/* FORTRAN END */\n\n";
00721 }
00722
00723 templateGuardBegin(isTemplated(), str);
00724 if (!type->isTemplated()) {
00725 if (external) str << "extern ";
00726 str << tspec(false) << " int " << indexName() << "::__idx";
00727 if (!external) str << "=0";
00728 str << ";\n";
00729 }
00730 templateGuardEnd(str);
00731
00732 templateGuardBegin(isTemplated(), str);
00733 if (isArray() && hasSection && !isTemplateInstantiation()) {
00734 if (isTemplated()) str << tspec(false) << "\n";
00735 str << "void " << sectionName()
00736 << "::contribute(CkSectionInfo &sid, int userData, int fragSize)\n";
00737 str << "{\n";
00738 str << " CkArray *ckarr = CProxy_CkArray(sid.get_aid()).ckLocalBranch();\n";
00739 str << " CkMulticastMgr *mCastGrp = "
00740 "CProxy_CkMulticastMgr(ckarr->getmCastMgr()).ckLocalBranch();\n";
00741 str << " mCastGrp->contribute(sid, userData, fragSize);\n";
00742 str << "}\n\n";
00743
00744 if (isTemplated()) str << tspec(false) << "\n";
00745 str << "void " << sectionName()
00746 << "::contribute(int dataSize,void *data,CkReduction::reducerType type, "
00747 "CkSectionInfo &sid, int userData, int fragSize)\n";
00748 str << "{\n";
00749 str << " CkArray *ckarr = CProxy_CkArray(sid.get_aid()).ckLocalBranch();\n";
00750 str << " CkMulticastMgr *mCastGrp = "
00751 "CProxy_CkMulticastMgr(ckarr->getmCastMgr()).ckLocalBranch();\n";
00752 str << " mCastGrp->contribute(dataSize, data, type, sid, userData, fragSize);\n";
00753 str << "}\n\n";
00754
00755 if (isTemplated()) str << tspec(false) << "\n";
00756 str << "template <typename T>\n";
00757 str << "void " << sectionName()
00758 << "::contribute(std::vector<T> &data, CkReduction::reducerType type, "
00759 "CkSectionInfo &sid, int userData, int fragSize)\n";
00760 str << "{\n";
00761 str << " CkArray *ckarr = CProxy_CkArray(sid.get_aid()).ckLocalBranch();\n";
00762 str << " CkMulticastMgr *mCastGrp = "
00763 "CProxy_CkMulticastMgr(ckarr->getmCastMgr()).ckLocalBranch();\n";
00764 str << " mCastGrp->contribute(data, type, sid, userData, fragSize);\n";
00765 str << "}\n\n";
00766
00767 if (isTemplated()) str << tspec(false) << "\n";
00768 str << "void " << sectionName()
00769 << "::contribute(CkSectionInfo &sid, const CkCallback &cb, int userData, int fragSize)\n";
00770 str << "{\n";
00771 str << " CkArray *ckarr = CProxy_CkArray(sid.get_aid()).ckLocalBranch();\n";
00772 str << " CkMulticastMgr *mCastGrp = "
00773 "CProxy_CkMulticastMgr(ckarr->getmCastMgr()).ckLocalBranch();\n";
00774 str << " mCastGrp->contribute(sid, cb, userData, fragSize);\n";
00775 str << "}\n\n";
00776
00777 if (isTemplated()) str << tspec(false) << "\n";
00778 str << "void " << sectionName()
00779 << "::contribute(int dataSize,void *data,CkReduction::reducerType type, "
00780 "CkSectionInfo &sid, const CkCallback &cb, int userData, int fragSize)\n";
00781 str << "{\n";
00782 str << " CkArray *ckarr = CProxy_CkArray(sid.get_aid()).ckLocalBranch();\n";
00783 str << " CkMulticastMgr *mCastGrp = "
00784 "CProxy_CkMulticastMgr(ckarr->getmCastMgr()).ckLocalBranch();\n";
00785 str << " mCastGrp->contribute(dataSize, data, type, sid, cb, userData, "
00786 "fragSize);\n";
00787 str << "}\n\n";
00788
00789 if (isTemplated()) str << tspec(false) << "\n";
00790 str << "template <typename T>\n";
00791 str << "void " << sectionName()
00792 << "::contribute(std::vector<T> &data, CkReduction::reducerType type, "
00793 "CkSectionInfo &sid, const CkCallback &cb, int userData, int fragSize)\n";
00794 str << "{\n";
00795 str << " CkArray *ckarr = CProxy_CkArray(sid.get_aid()).ckLocalBranch();\n";
00796 str << " CkMulticastMgr *mCastGrp = "
00797 "CProxy_CkMulticastMgr(ckarr->getmCastMgr()).ckLocalBranch();\n";
00798 str << " mCastGrp->contribute(data, type, sid, cb, userData, fragSize);\n";
00799 str << "}\n\n";
00800 }
00801 templateGuardEnd(str);
00802
00803 if (list) {
00804 list->genDefs(str);
00805 if (hasElement) {
00806 forElement = forAll;
00807 list->genDefs(str);
00808 if (hasSection) {
00809 forElement = forSection;
00810 list->genDefs(str);
00811 }
00812 forElement = forIndividual;
00813 }
00814 }
00815
00816 templateGuardBegin(isTemplated(), str);
00817
00818 if (isPython()) {
00819 str << "/* ---------------- python wrapper -------------- */\n";
00820
00821
00822 genPythonDefs(str);
00823 }
00824 templateGuardEnd(str);
00825
00826 if (!external && !type->isTemplated()) genRegisterMethodDef(str);
00827 if (hasSdagEntry) {
00828 str << "\n";
00829 str << sdagDefs;
00830 }
00831
00832 XStr templateSpec;
00833 if (templat)
00834 templat->genSpec(templateSpec, false);
00835 else
00836 templateSpec << "template <>";
00837 templateSpec << "\n";
00838
00839 if (isTemplateDeclaration()) {
00840 templateGuardBegin(true, str);
00841
00842 TypeList* b = bases_CBase;
00843 if (b == NULL) b = bases;
00844
00845 XStr baseClass;
00846 if (isPython()) {
00847 baseClass << Prefix::Python << type;
00848 } else {
00849 baseClass << b;
00850 }
00851
00852 XStr CBaseName;
00853 CBaseName << "CBase_" << type;
00854
00855 str << templateSpec << "struct " << CBaseName << " : public " << baseClass
00856 << ", virtual CBase";
00857 str << "\n";
00858 str << " {"
00859 << "\n CProxy_" << type << tvars() << " thisProxy;";
00860
00861
00862
00863 str << "\n " << CBaseName << "() : thisProxy(this)";
00864 for (TypeList* t = b; t; t = t->next) {
00865 str << "\n , " << t->type << "()";
00866 }
00867 str << "\n { }";
00868
00869
00870 str << "\n " << CBaseName << "(CkMigrateMessage* m) : thisProxy(this)";
00871 for (TypeList* t = b; t; t = t->next) {
00872 str << "\n , " << t->type << "(m)";
00873 }
00874 str << " { }";
00875
00876
00877 if (b->length() == 1) {
00878 str << "\n template <typename... Args>"
00879 << "\n " << CBaseName << "(Args... args) : thisProxy(this)";
00880 for (TypeList* t = b; t; t = t->next) {
00881 str << "\n , " << t->type << "(args...)";
00882 }
00883 str << " { }";
00884 }
00885
00886
00887 str << "\n void pup(PUP::er &p) { }"
00888 << "\n void _sdag_pup(PUP::er &p) { }"
00889 << "\n void " << virtualPupDef(baseName(true))
00890 << "\n void parent_pup(PUP::er &p) {";
00891 for (TypeList* t = b; t; t = t->next) {
00892 str << "\n recursive_pup<" << t->type << ">(this, p);";
00893 }
00894 str << "\n p|thisProxy;"
00895 << "\n }"
00896 << "\n};\n";
00897
00898 templateGuardEnd(str);
00899 }
00900 }
00901
00902 XStr Chare::cbaseTType() {
00903 TypeList* b = bases_CBase;
00904 if (b == NULL) b = bases;
00905
00906 XStr baseClass;
00907 if (isPython()) {
00908 baseClass << Prefix::Python << type;
00909 } else {
00910 baseClass << b;
00911 }
00912
00913 XStr templatedType;
00914 templatedType << type;
00915 if (isTemplateDeclaration()) templat->genVars(templatedType);
00916
00917 XStr CBaseT_type;
00918 CBaseT_type << "CBaseT" << b->length() << "<" << baseClass << ", CProxy_"
00919 << templatedType << ">";
00920 return CBaseT_type;
00921 }
00922
00923 void Chare::genReg(XStr& str) {
00924 str << "/* REG: ";
00925 print(str);
00926 str << "*/\n";
00927 if (external || templat) return;
00928 str << " " << indexName() << "::__register(\"" << type << "\", sizeof(" << type
00929 << "));\n";
00930
00931 if (list) {
00932 list->genTramRegs(str);
00933 }
00934 }
00935
00936 void Chare::print(XStr& str) {
00937 if (external) str << "extern ";
00938 if (templat) templat->genSpec(str);
00939
00940 str << chareTypeName() << " " << type;
00941 if (bases) {
00942 str << ": ";
00943 bases->print(str);
00944 }
00945 if (list) {
00946 str << "{\n";
00947 list->print(str);
00948 str << "};\n";
00949 } else {
00950 str << ";\n";
00951 }
00952 }
00953
00954 void Chare::lookforCEntry(CEntry* centry) {
00955 if (list) list->recurse(centry, &Member::lookforCEntry);
00956 }
00957
00958 bool Chare::isTramTarget() {
00959 if (list)
00960 return list->isTramTarget();
00961 else
00962 return false;
00963 }
00964
00965 void Chare::genTramTypes() {
00966 if (list) {
00967 list->genTramTypes();
00968 }
00969 }
00970
00971 void Chare::genTramDecls(XStr& str) {
00972 if (isForElement()) {
00973 str << "\n /* TRAM aggregators */\n";
00974 for (int i = 0; i < tramInstances.size(); i++) {
00975 str << " " << tramInstances[i].type.c_str() << "* "
00976 << tramInstances[i].name.c_str() << ";\n";
00977 }
00978 str << "\n";
00979 }
00980 }
00981
00982 void Chare::genTramInits(XStr& str) {
00983 if (generateTramInits) {
00984 for (int i = 0; i < tramInstances.size(); i++) {
00985 str << " " << tramInstances[i].name.c_str() << " = NULL;\n";
00986 }
00987 }
00988 }
00989
00990 Group::Group(int ln, attrib_t Nattr, NamedType* t, TypeList* b, AstChildren<Member>* l)
00991 : Chare(ln, Nattr | CGROUP, t, b, l) {
00992 hasElement = 1;
00993 forElement = forIndividual;
00994 hasSection = 1;
00995 bases_CBase = NULL;
00996 if (b == NULL) {
00997
00998 delete bases;
00999 if (isNodeGroup()) {
01000 bases = new TypeList(new NamedType("NodeGroup"), NULL);
01001 } else {
01002 bases = new TypeList(new NamedType("IrrGroup"), NULL);
01003 bases_CBase = new TypeList(new NamedType("Group"), NULL);
01004 }
01005 }
01006 }
01007
01008 void Group::genSubRegisterMethodDef(XStr& str) {
01009 if (!isTemplated()) {
01010 str << " CkRegisterGroupIrr(__idx," << type << "::isIrreducible());\n";
01011 } else {
01012 str << " CkRegisterGroupIrr(__idx," << type << tvars() << "::isIrreducible());\n";
01013 }
01014 }
01015
01016 void Group::genSubDecls(XStr& str) {
01017 XStr ptype;
01018 ptype << proxyPrefix() << type;
01019 XStr ttype;
01020 ttype << type << tvars();
01021 XStr super;
01022 bases->getFirst()->genProxyName(super, forElement);
01023
01024
01025 str << tspec() << "class " << ptype;
01026 if (external || type->isTemplated()) {
01027 str << ";";
01028 return;
01029 }
01030 str << ": ";
01031
01032 genProxyNames(str, "public ", NULL, "", ", ");
01033 str << CIClassStart;
01034
01035 genTypedefs(str);
01036
01037 genTramDecls(str);
01038
01039 XStr constructorBody;
01040 constructorBody << "{\n";
01041 genTramInits(constructorBody);
01042 constructorBody << " }\n";
01043
01044
01045 str << " " << ptype << "(void) " << constructorBody;
01046 str << " " << ptype << "(const IrrGroup *g) : ";
01047 genProxyNames(str, "", NULL, "(g)", ", ");
01048 str << constructorBody;
01049
01050 if (forElement == forIndividual) {
01051 str << " " << ptype << "(CkGroupID _gid,int _onPE,CK_DELCTOR_PARAM) : ";
01052 genProxyNames(str, "", NULL, "(_gid,_onPE,CK_DELCTOR_ARGS)", ", ");
01053 str << constructorBody;
01054 str << " " << ptype << "(CkGroupID _gid,int _onPE) : ";
01055 genProxyNames(str, "", NULL, "(_gid,_onPE)", ", ");
01056 str << constructorBody;
01057
01058 disambig_group(str, super);
01059 str << "int ckGetGroupPe(void) const\n"
01060 << "{return " << super << "::ckGetGroupPe();}\n";
01061
01062 } else if (forElement == forSection) {
01063 str << " " << ptype
01064 << "(const CkGroupID &_gid,const int *_pelist,int _npes, CK_DELCTOR_PARAM) : ";
01065 genProxyNames(str, "", NULL, "(_gid,_pelist,_npes,CK_DELCTOR_ARGS)", ", ");
01066 str << "{ }\n";
01067 str << " " << ptype
01068 << "(const CkGroupID &_gid,const int *_pelist,int _npes, int factor = "
01069 "USE_DEFAULT_BRANCH_FACTOR) : ";
01070 genProxyNames(str, "", NULL, "(_gid,_pelist,_npes,factor)", ", ");
01071 str << "{ }\n";
01072 str << " " << ptype
01073 << "(int n,const CkGroupID *_gid, int const * const *_pelist,const int *_npes, "
01074 "int factor = USE_DEFAULT_BRANCH_FACTOR) : ";
01075 genProxyNames(str, "", NULL, "(n,_gid,_pelist,_npes,factor)", ", ");
01076 str << "{ }\n";
01077 str << " " << ptype
01078 << "(int n,const CkGroupID *_gid, int const * const *_pelist,const int *_npes, "
01079 "CK_DELCTOR_PARAM) : ";
01080 genProxyNames(str, "", NULL, "(n,_gid,_pelist,_npes,CK_DELCTOR_ARGS)", ", ");
01081 str << "{ }\n";
01082
01083 disambig_group(str, super);
01084 str << "inline int ckGetNumSections() const\n"
01085 << "{ return " << super << "::ckGetNumSections(); }\n"
01086 << "inline CkSectionInfo &ckGetSectionInfo()\n"
01087 << "{ return " << super << "::ckGetSectionInfo(); }\n"
01088 << "inline CkSectionID *ckGetSectionIDs()\n"
01089 << "{ return " << super << "::ckGetSectionIDs(); }\n"
01090 << "inline CkSectionID &ckGetSectionID()\n"
01091 << "{ return " << super << "::ckGetSectionID(); }\n"
01092 << "inline CkSectionID &ckGetSectionID(int i)\n"
01093 << "{ return " << super << "::ckGetSectionID(i); }\n"
01094 << "inline CkGroupID ckGetGroupIDn(int i) const\n"
01095 << "{ return " << super << "::ckGetGroupIDn(i); }\n"
01096 << "inline const int *ckGetElements() const\n"
01097 << "{ return " << super << "::ckGetElements(); }\n"
01098 << "inline const int *ckGetElements(int i) const\n"
01099 << "{ return " << super << "::ckGetElements(i); }\n"
01100 << "inline int ckGetNumElements() const\n"
01101 << "{ return " << super << "::ckGetNumElements(); } \n"
01102 << "inline int ckGetNumElements(int i) const\n"
01103 << "{ return " << super << "::ckGetNumElements(i); }\n";
01104 } else if (forElement == forAll) {
01105 str << " " << ptype << "(CkGroupID _gid,CK_DELCTOR_PARAM) : ";
01106 genProxyNames(str, "", NULL, "(_gid,CK_DELCTOR_ARGS)", ", ");
01107 str << "{ }\n";
01108 str << " " << ptype << "(CkGroupID _gid) : ";
01109 genProxyNames(str, "", NULL, "(_gid)", ", ");
01110 str << "{ }\n";
01111
01112
01113 forElement = forIndividual;
01114 str << " " << proxyName(1) << " operator[](int onPE) const\n";
01115 str << " {return " << proxyName(1)
01116 << "(ckGetGroupID(),onPE,CK_DELCTOR_CALL);}\n";
01117 forElement = forAll;
01118
01119 disambig_group(str, super);
01120 }
01121
01122
01123 sharedDisambiguation(str, super);
01124 str << " void ckSetGroupID(CkGroupID g) {\n";
01125 genProxyNames(str, " ", NULL, "::ckSetGroupID(g);\n", "");
01126 str << " }\n";
01127
01128 str << " " << ttype << "* ckLocalBranch(void) const {\n";
01129 str << " return ckLocalBranch(ckGetGroupID());\n";
01130 str << " }\n";
01131 str << " static " << ttype << "* ckLocalBranch(CkGroupID gID) {\n";
01132 str << " return (" << ttype << "*)";
01133 if (isNodeGroup())
01134 str << "CkLocalNodeBranch(gID);\n";
01135 else
01136 str << "CkLocalBranch(gID);\n";
01137 str << " }\n";
01138 genMemberDecls(str);
01139 str << CIClassEnd;
01140 if (!isTemplated()) str << "PUPmarshall(" << ptype << ")\n";
01141 }
01142
01143
01144 Array::Array(int ln, attrib_t Nattr, NamedType* index, NamedType* t, TypeList* b,
01145 AstChildren<Member>* l)
01146 : Chare(ln, Nattr | CARRAY | CMIGRATABLE, t, b, l), hasVoidConstructor(false) {
01147 hasElement = 1;
01148 forElement = forIndividual;
01149 hasSection = 1;
01150 index->print(indexSuffix);
01151
01152 if (indexSuffix != (const char*)"none")
01153 indexType << "CkArrayIndex" << indexSuffix;
01154 else
01155 indexType << "CkArrayIndex";
01156
01157 if (b == 0) {
01158 delete bases;
01159 if (0 == strcmp(type->getBaseName(), "ArrayElement"))
01160
01161 bases = new TypeList(new NamedType("ArrayBase"), NULL);
01162 else {
01163 bases = new TypeList(new NamedType("ArrayElement"), NULL);
01164 XStr indexObject(indexSuffix2object(indexSuffix));
01165 XStr parentClass;
01166 parentClass << "ArrayElementT<" << indexObject << ">";
01167 char* parentClassName = strdup(parentClass);
01168 bases_CBase = new TypeList(new NamedType(parentClassName), NULL);
01169 }
01170 }
01171
01172 }
01173
01174 void Array::genSubDecls(XStr& str) {
01175 XStr ptype;
01176 ptype << proxyPrefix() << type;
01177
01178
01179 str << tspec() << " class " << ptype;
01180 if (external || type->isTemplated()) {
01181 str << ";";
01182 return;
01183 }
01184 str << " : ";
01185 genProxyNames(str, "public ", NULL, "", ", ");
01186 str << CIClassStart;
01187
01188 genTypedefs(str);
01189 str << " using array_index_t = " << indexType << ";\n";
01190
01191 genTramDecls(str);
01192
01193 XStr constructorBody;
01194 constructorBody << "{\n";
01195 genTramInits(constructorBody);
01196 constructorBody << " }\n";
01197
01198 str << " " << ptype << "(void) " << constructorBody;
01199 if (forElement != forSection) {
01200 str << " " << ptype << "(const ArrayElement *e) : ";
01201 genProxyNames(str, "", NULL, "(e)", ", ");
01202 str << constructorBody;
01203 }
01204
01205
01206 XStr super;
01207 bases->getFirst()->genProxyName(super, forElement);
01208 sharedDisambiguation(str, super);
01209
01210 if (forElement == forIndividual) {
01211 disambig_array(str, super);
01212 str << "\n inline void ckInsert(CkArrayMessage *m,int ctor,int onPe)"
01213 << "\n { " << super << "::ckInsert(m,ctor,onPe); }"
01214 << "\n inline void ckSend(CkArrayMessage *m, int ep, int opts = 0) const"
01215 << "\n { " << super << "::ckSend(m,ep,opts); }"
01216 << "\n inline void *ckSendSync(CkArrayMessage *m, int ep) const"
01217 << "\n { return " << super << "::ckSendSync(m,ep); }"
01218 << "\n inline const CkArrayIndex &ckGetIndex() const"
01219 << "\n { return " << super << "::ckGetIndex(); }"
01220 << "\n"
01221 << "\n " << type << tvars() << " *ckLocal(void) const"
01222 << "\n { return (" << type << tvars() << " *)" << super << "::ckLocal(); }"
01223 << "\n";
01224
01225
01226 str << "\n " << ptype << "(const CkArrayID &aid,const " << indexType
01227 << " &idx,CK_DELCTOR_PARAM)"
01228 << "\n :";
01229 genProxyNames(str, "", NULL, "(aid,idx,CK_DELCTOR_ARGS)", ", ");
01230 str << "\n {\n";
01231 genTramInits(str);
01232 str << "}"
01233 << "\n " << ptype << "(const CkArrayID &aid,const " << indexType << " &idx)"
01234 << "\n :";
01235 genProxyNames(str, "", NULL, "(aid,idx)", ", ");
01236 str << "\n {\n";
01237 genTramInits(str);
01238 str << "}"
01239 << "\n";
01240
01241 if ((indexType != (const char*)"CkArrayIndex") &&
01242 (indexType != (const char*)"CkArrayIndexMax")) {
01243
01244
01245
01246
01247
01248 str << "\n " << ptype
01249 << "(const CkArrayID &aid,const CkArrayIndex &idx,CK_DELCTOR_PARAM)"
01250 << "\n :";
01251 genProxyNames(str, "", NULL, "(aid,idx,CK_DELCTOR_ARGS)", ", ");
01252 str << "\n {\n";
01253 genTramInits(str);
01254 str << "}"
01255 << "\n " << ptype << "(const CkArrayID &aid,const CkArrayIndex &idx)"
01256 << "\n :";
01257 genProxyNames(str, "", NULL, "(aid,idx)", ", ");
01258 str << "\n {\n";
01259 genTramInits(str);
01260 str << "}"
01261 << "\n";
01262 }
01263 } else if (forElement == forAll) {
01264 disambig_array(str, super);
01265
01266
01267
01268
01269 if (!hasVoidConstructor) {
01270 str << "\n // Empty array construction";
01271 str << "\n static CkArrayID ckNew(CkArrayOptions opts = CkArrayOptions()) { "
01272 "return ckCreateEmptyArray(opts); }";
01273 str << "\n static void ckNew(CkCallback cb, CkArrayOptions opts = "
01274 "CkArrayOptions()) { ckCreateEmptyArrayAsync(cb, opts); }\n";
01275 }
01276
01277 XStr etype;
01278 etype << Prefix::ProxyElement << type << tvars();
01279 if (indexSuffix != (const char*)"none") {
01280 str << "\n // Generalized array indexing:"
01281 << "\n " << etype << " operator [] (const " << indexType << " &idx) const"
01282 << "\n { return " << etype << "(ckGetArrayID(), idx, CK_DELCTOR_CALL); }"
01283 << "\n " << etype << " operator() (const " << indexType << " &idx) const"
01284 << "\n { return " << etype << "(ckGetArrayID(), idx, CK_DELCTOR_CALL); }"
01285 << "\n";
01286 }
01287
01288
01289 if (indexSuffix == (const char*)"1D") {
01290 str << " " << etype << " operator [] (int idx) const \n"
01291 << " {return " << etype
01292 << "(ckGetArrayID(), CkArrayIndex1D(idx), CK_DELCTOR_CALL);}\n"
01293 << " " << etype << " operator () (int idx) const \n"
01294 << " {return " << etype
01295 << "(ckGetArrayID(), CkArrayIndex1D(idx), CK_DELCTOR_CALL);}\n";
01296 } else if (indexSuffix == (const char*)"2D") {
01297 str << " " << etype
01298 << " operator () (int i0,int i1) const \n"
01299 " {return "
01300 << etype
01301 << "(ckGetArrayID(), CkArrayIndex2D(i0,i1), CK_DELCTOR_CALL);}\n"
01302 " "
01303 << etype
01304 << " operator () (CkIndex2D idx) const \n"
01305 " {return "
01306 << etype << "(ckGetArrayID(), CkArrayIndex2D(idx), CK_DELCTOR_CALL);}\n";
01307 } else if (indexSuffix == (const char*)"3D") {
01308 str << " " << etype
01309 << " operator () (int i0,int i1,int i2) const \n"
01310 " {return "
01311 << etype
01312 << "(ckGetArrayID(), CkArrayIndex3D(i0,i1,i2), CK_DELCTOR_CALL);}\n"
01313 " "
01314 << etype
01315 << " operator () (CkIndex3D idx) const \n"
01316 " {return "
01317 << etype << "(ckGetArrayID(), CkArrayIndex3D(idx), CK_DELCTOR_CALL);}\n";
01318 } else if (indexSuffix == (const char*)"4D") {
01319 str << " " << etype
01320 << " operator () (short int i0,short int i1,short int i2,short int i3) const \n"
01321 " {return "
01322 << etype
01323 << "(ckGetArrayID(), CkArrayIndex4D(i0,i1,i2,i3), CK_DELCTOR_CALL);}\n"
01324 " "
01325 << etype
01326 << " operator () (CkIndex4D idx) const \n"
01327 " {return "
01328 << etype << "(ckGetArrayID(), CkArrayIndex4D(idx), CK_DELCTOR_CALL);}\n";
01329 } else if (indexSuffix == (const char*)"5D") {
01330 str << " " << etype
01331 << " operator () (short int i0,short int i1,short int i2,short int i3,short "
01332 "int i4) const \n"
01333 " {return "
01334 << etype
01335 << "(ckGetArrayID(), CkArrayIndex5D(i0,i1,i2,i3,i4), CK_DELCTOR_CALL);}\n"
01336 " "
01337 << etype
01338 << " operator () (CkIndex5D idx) const \n"
01339 " {return "
01340 << etype << "(ckGetArrayID(), CkArrayIndex5D(idx), CK_DELCTOR_CALL);}\n";
01341 } else if (indexSuffix == (const char*)"6D") {
01342 str << " " << etype
01343 << " operator () (short int i0,short int i1,short int i2,short int i3,short "
01344 "int i4,short int i5) const \n"
01345 " {return "
01346 << etype
01347 << "(ckGetArrayID(), CkArrayIndex6D(i0,i1,i2,i3,i4,i5), CK_DELCTOR_CALL);}\n"
01348 " "
01349 << etype
01350 << " operator () (CkIndex6D idx) const \n"
01351 " {return "
01352 << etype << "(ckGetArrayID(), CkArrayIndex6D(idx), CK_DELCTOR_CALL);}\n";
01353 }
01354 str << " " << ptype
01355 << "(const CkArrayID &aid,CK_DELCTOR_PARAM) \n"
01356 " :";
01357 genProxyNames(str, "", NULL, "(aid,CK_DELCTOR_ARGS)", ", ");
01358 str << " {}\n";
01359 str << " " << ptype
01360 << "(const CkArrayID &aid) \n"
01361 " :";
01362 genProxyNames(str, "", NULL, "(aid)", ", ");
01363 str << " {}\n";
01364 } else if (forElement == forSection) {
01365 disambig_array(str, super);
01366 str << "\n inline void ckSend(CkArrayMessage *m, int ep, int opts = 0)"
01367 << "\n { " << super << "::ckSend(m,ep,opts); }"
01368 << "\n inline CkSectionInfo &ckGetSectionInfo()"
01369 << "\n { return " << super << "::ckGetSectionInfo(); }"
01370 << "\n inline CkSectionID *ckGetSectionIDs()"
01371 << "\n { return " << super << "::ckGetSectionIDs(); }"
01372 << "\n inline CkSectionID &ckGetSectionID()"
01373 << "\n { return " << super << "::ckGetSectionID(); }"
01374 << "\n inline CkSectionID &ckGetSectionID(int i)"
01375 << "\n { return " << super << "::ckGetSectionID(i); }"
01376 << "\n inline CkArrayID ckGetArrayIDn(int i) const"
01377 << "\n { return " << super << "::ckGetArrayIDn(i); } "
01378 << "\n inline CkArrayIndex *ckGetArrayElements() const"
01379 << "\n { return " << super << "::ckGetArrayElements(); }"
01380 << "\n inline CkArrayIndex *ckGetArrayElements(int i) const"
01381 << "\n { return " << super << "::ckGetArrayElements(i); }"
01382 << "\n inline int ckGetNumElements() const"
01383 << "\n { return " << super << "::ckGetNumElements(); } "
01384 << "\n inline int ckGetNumElements(int i) const"
01385 << "\n { return " << super << "::ckGetNumElements(i); }";
01386
01387 XStr etype;
01388 etype << Prefix::ProxyElement << type << tvars();
01389 if (indexSuffix != (const char*)"none") {
01390 str << " // Generalized array indexing:\n"
01391 " "
01392 << etype << " operator [] (const " << indexType
01393 << " &idx) const\n"
01394 " {return "
01395 << etype
01396 << "(ckGetArrayID(), idx, CK_DELCTOR_CALL);}\n"
01397 " "
01398 << etype << " operator() (const " << indexType
01399 << " &idx) const\n"
01400 " {return "
01401 << etype << "(ckGetArrayID(), idx, CK_DELCTOR_CALL);}\n";
01402 }
01403
01404
01405 if (indexSuffix == (const char*)"1D") {
01406 str << " " << etype
01407 << " operator [] (int idx) const \n"
01408 " {return "
01409 << etype
01410 << "(ckGetArrayID(), *(CkArrayIndex1D*)&ckGetArrayElements()[idx], "
01411 "CK_DELCTOR_CALL);}\n"
01412 " "
01413 << etype
01414 << " operator () (int idx) const \n"
01415 " {return "
01416 << etype
01417 << "(ckGetArrayID(), *(CkArrayIndex1D*)&ckGetArrayElements()[idx], "
01418 "CK_DELCTOR_CALL);}\n"
01419 " static CkSectionID ckNew(const CkArrayID &aid, CkArrayIndex1D *elems, "
01420 "int nElems, int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01421 " return CkSectionID(aid, elems, nElems, factor);\n"
01422 " } \n"
01423 " static CkSectionID ckNew(const CkArrayID &aid, const std::vector<CkArrayIndex1D> &elems, "
01424 "int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01425 " return CkSectionID(aid, elems, factor);\n"
01426 " } \n"
01427 " static CkSectionID ckNew(const CkArrayID &aid, int l, int u, int s, "
01428 "int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01429 " std::vector<CkArrayIndex1D> al;\n"
01430 " for (int i=l; i<=u; i+=s) al.emplace_back(i);\n"
01431 " return CkSectionID(aid, al, factor);\n"
01432 " } \n";
01433 } else if (indexSuffix == (const char*)"2D") {
01434 str << " " << etype
01435 << " operator () (int idx) const \n"
01436 " {return "
01437 << etype
01438 << "(ckGetArrayID(), *(CkArrayIndex2D*)&ckGetArrayElements()[idx], "
01439 "CK_DELCTOR_CALL);}\n"
01440 " static CkSectionID ckNew(const CkArrayID &aid, CkArrayIndex2D *elems, "
01441 "int nElems, int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01442 " return CkSectionID(aid, elems, nElems, factor);\n"
01443 " } \n"
01444 " static CkSectionID ckNew(const CkArrayID &aid, const std::vector<CkArrayIndex2D> &elems, "
01445 "int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01446 " return CkSectionID(aid, elems, factor);\n"
01447 " } \n"
01448 " static CkSectionID ckNew(const CkArrayID &aid, int l1, int u1, int s1, "
01449 "int l2, int u2, int s2, int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01450 " std::vector<CkArrayIndex2D> al;\n"
01451 " for (int i=l1; i<=u1; i+=s1) \n"
01452 " for (int j=l2; j<=u2; j+=s2) \n"
01453 " al.emplace_back(i, j);\n"
01454 " return CkSectionID(aid, al, factor);\n"
01455 " } \n";
01456 } else if (indexSuffix == (const char*)"3D") {
01457 str << " " << etype
01458 << " operator () (int idx) const \n"
01459 " {return "
01460 << etype
01461 << "(ckGetArrayID(), *(CkArrayIndex3D*)&ckGetArrayElements()[idx], "
01462 "CK_DELCTOR_CALL);}\n"
01463 " static CkSectionID ckNew(const CkArrayID &aid, CkArrayIndex3D *elems, "
01464 "int nElems, int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01465 " return CkSectionID(aid, elems, nElems, factor);\n"
01466 " } \n"
01467 " static CkSectionID ckNew(const CkArrayID &aid, const std::vector<CkArrayIndex3D> &elems, "
01468 "int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01469 " return CkSectionID(aid, elems, factor);\n"
01470 " } \n"
01471 " static CkSectionID ckNew(const CkArrayID &aid, int l1, int u1, int s1, "
01472 "int l2, int u2, int s2, int l3, int u3, int s3, int "
01473 "factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01474 " std::vector<CkArrayIndex3D> al;\n"
01475 " for (int i=l1; i<=u1; i+=s1) \n"
01476 " for (int j=l2; j<=u2; j+=s2) \n"
01477 " for (int k=l3; k<=u3; k+=s3) \n"
01478 " al.emplace_back(i, j, k);\n"
01479 " return CkSectionID(aid, al, factor);\n"
01480 " } \n";
01481 } else if (indexSuffix == (const char*)"4D") {
01482 str << " " << etype
01483 << " operator () (int idx) const \n"
01484 " {return "
01485 << etype
01486 << "(ckGetArrayID(), *(CkArrayIndex4D*)&ckGetArrayElements()[idx], "
01487 "CK_DELCTOR_CALL);}\n"
01488 " static CkSectionID ckNew(const CkArrayID &aid, CkArrayIndex4D *elems, "
01489 "int nElems, int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01490 " return CkSectionID(aid, elems, nElems, factor);\n"
01491 " } \n"
01492 " static CkSectionID ckNew(const CkArrayID &aid, const std::vector<CkArrayIndex4D> &elems, "
01493 "int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01494 " return CkSectionID(aid, elems, factor);\n"
01495 " } \n"
01496 " static CkSectionID ckNew(const CkArrayID &aid, int l1, int u1, int s1, "
01497 "int l2, int u2, int s2, int l3, int u3, int s3, int l4, int u4, int s4, "
01498 "int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01499 " std::vector<CkArrayIndex4D> al;\n"
01500 " for (int i=l1; i<=u1; i+=s1) \n"
01501 " for (int j=l2; j<=u2; j+=s2) \n"
01502 " for (int k=l3; k<=u3; k+=s3) \n"
01503 " for (int l=l4; l<=u4; l+=s4) \n"
01504 " al.emplace_back(i, j, k, l);\n"
01505 " return CkSectionID(aid, al, factor);\n"
01506 " } \n";
01507 } else if (indexSuffix == (const char*)"5D") {
01508 str << " " << etype
01509 << " operator () (int idx) const \n"
01510 " {return "
01511 << etype
01512 << "(ckGetArrayID(), *(CkArrayIndex5D*)&ckGetArrayElements()[idx], "
01513 "CK_DELCTOR_CALL);}\n"
01514 " static CkSectionID ckNew(const CkArrayID &aid, CkArrayIndex5D *elems, "
01515 "int nElems, int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01516 " return CkSectionID(aid, elems, nElems, factor);\n"
01517 " } \n"
01518 " static CkSectionID ckNew(const CkArrayID &aid, const std::vector<CkArrayIndex5D> &elems, "
01519 "int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01520 " return CkSectionID(aid, elems, factor);\n"
01521 " } \n"
01522 " static CkSectionID ckNew(const CkArrayID &aid, int l1, int u1, int s1, "
01523 "int l2, int u2, int s2, int l3, int u3, int s3, int l4, int u4, int s4, "
01524 "int l5, int u5, int s5, int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01525 " std::vector<CkArrayIndex5D> al;\n"
01526 " for (int i=l1; i<=u1; i+=s1) \n"
01527 " for (int j=l2; j<=u2; j+=s2) \n"
01528 " for (int k=l3; k<=u3; k+=s3) \n"
01529 " for (int l=l4; l<=u4; l+=s4) \n"
01530 " for (int m=l5; m<=u5; m+=s5) \n"
01531 " al.emplace_back(i, j, k, l, m);\n"
01532 " return CkSectionID(aid, al, factor);\n"
01533 " } \n";
01534 } else if (indexSuffix == (const char*)"6D") {
01535 str << " " << etype
01536 << " operator () (int idx) const \n"
01537 " {return "
01538 << etype
01539 << "(ckGetArrayID(), *(CkArrayIndex6D*)&ckGetArrayElements()[idx], "
01540 "CK_DELCTOR_CALL);}\n"
01541 " static CkSectionID ckNew(const CkArrayID &aid, CkArrayIndex6D *elems, "
01542 "int nElems, int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01543 " return CkSectionID(aid, elems, nElems, factor);\n"
01544 " } \n"
01545 " static CkSectionID ckNew(const CkArrayID &aid, const std::vector<CkArrayIndex6D> &elems, "
01546 "int factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01547 " return CkSectionID(aid, elems, factor);\n"
01548 " } \n"
01549 " static CkSectionID ckNew(const CkArrayID &aid, int l1, int u1, int s1, "
01550 "int l2, int u2, int s2, int l3, int u3, int s3, int l4, int u4, int s4, "
01551 "int l5, int u5, int s5, int l6, int u6, int s6, int "
01552 "factor=USE_DEFAULT_BRANCH_FACTOR) {\n"
01553 " std::vector<CkArrayIndex6D> al;\n"
01554 " for (int i=l1; i<=u1; i+=s1) \n"
01555 " for (int j=l2; j<=u2; j+=s2) \n"
01556 " for (int k=l3; k<=u3; k+=s3) \n"
01557 " for (int l=l4; l<=u4; l+=s4) \n"
01558 " for (int m=l5; m<=u5; m+=s5) \n"
01559 " for (int n=l6; n<=u6; n+=s6) \n"
01560 " al.emplace_back(i, j, k, l, m, n);\n"
01561 " return CkSectionID(aid, al, factor);\n"
01562 " } \n";
01563 }
01564
01565 str << " " << ptype
01566 << "(const CkArrayID &aid, CkArrayIndex *elems, int nElems, CK_DELCTOR_PARAM) \n"
01567 " :";
01568 genProxyNames(str, "", NULL, "(aid,elems,nElems,CK_DELCTOR_ARGS)", ", ");
01569 str << " {}\n";
01570 str << " " << ptype
01571 << "(const CkArrayID &aid, const std::vector<CkArrayIndex> &elems, CK_DELCTOR_PARAM) \n"
01572 " :";
01573 genProxyNames(str, "", NULL, "(aid,elems,CK_DELCTOR_ARGS)", ", ");
01574 str << " {}\n";
01575 str << " " << ptype
01576 << "(const CkArrayID &aid, CkArrayIndex *elems, int nElems, int "
01577 "factor=USE_DEFAULT_BRANCH_FACTOR) \n"
01578 " :";
01579 genProxyNames(str, "", NULL, "(aid,elems,nElems, factor)", ", ");
01580 str << " {}\n";
01581 str << " " << ptype
01582 << "(const CkArrayID &aid, const std::vector<CkArrayIndex> &elems, int "
01583 "factor=USE_DEFAULT_BRANCH_FACTOR) \n"
01584 " :";
01585 genProxyNames(str, "", NULL, "(aid,elems, factor)", ", ");
01586 str << " { ckAutoDelegate(); }\n";
01587 str << " " << ptype
01588 << "(const CkSectionID &sid) \n"
01589 " :";
01590 genProxyNames(str, "", NULL, "(sid)", ", ");
01591 str << " { ckAutoDelegate(); }\n";
01592 str << " " << ptype
01593 << "(int n, const CkArrayID *aid, CkArrayIndex const * const *elems, const int "
01594 "*nElems, CK_DELCTOR_PARAM) \n"
01595 " :";
01596 genProxyNames(str, "", NULL, "(n,aid,elems,nElems,CK_DELCTOR_ARGS)", ", ");
01597 str << " {}\n";
01598 str << " " << ptype
01599 << "(const std::vector<CkArrayID> &aid, const std::vector<std::vector<CkArrayIndex> > &elems, "
01600 "CK_DELCTOR_PARAM) \n"
01601 " :";
01602 genProxyNames(str, "", NULL, "(aid,elems,CK_DELCTOR_ARGS)", ", ");
01603 str << " {}\n";
01604 str << " " << ptype
01605 << "(int n, const CkArrayID *aid, CkArrayIndex const * const *elems, const int "
01606 "*nElems) \n"
01607 " :";
01608 genProxyNames(str, "", NULL, "(n,aid,elems,nElems)", ", ");
01609 str << " { ckAutoDelegate(); }\n";
01610 str << " " << ptype
01611 << "(const std::vector<CkArrayID> &aid, const std::vector<std::vector<CkArrayIndex> > &elems) \n"
01612 " :";
01613 genProxyNames(str, "", NULL, "(aid,elems)", ", ");
01614 str << " { ckAutoDelegate(); }\n";
01615 str << " " << ptype
01616 << "(int n, const CkArrayID *aid, CkArrayIndex const * const *elems, const int "
01617 "*nElems, int factor) \n"
01618 " :";
01619 genProxyNames(str, "", NULL, "(n,aid,elems,nElems, factor)", ", ");
01620 str << " { ckAutoDelegate(); }\n";
01621 str << " " << ptype
01622 << "(const std::vector<CkArrayID> &aid, const std::vector<std::vector<CkArrayIndex> > &elems, "
01623 "int factor) \n"
01624 " :";
01625 genProxyNames(str, "", NULL, "(aid,elems, factor)", ", ");
01626 str << " { ckAutoDelegate(); }\n";
01627 str << " static CkSectionID ckNew(const CkArrayID &aid, CkArrayIndex *elems, int "
01628 "nElems) {\n"
01629 " return CkSectionID(aid, elems, nElems);\n"
01630 " } \n";
01631 str << " static CkSectionID ckNew(const CkArrayID &aid, const std::vector<CkArrayIndex> &elems) {\n "
01632 " return CkSectionID(aid, elems);\n"
01633 " } \n";
01634
01635 str << " static CkSectionID ckNew(const CkArrayID &aid, CkArrayIndex *elems, int "
01636 "nElems, int factor) {\n"
01637 " return CkSectionID(aid, elems, nElems, factor);\n"
01638 " } \n";
01639 str << " static CkSectionID ckNew(const CkArrayID &aid, const std::vector<CkArrayIndex> &elems, int "
01640 "factor) {\n"
01641 " return CkSectionID(aid, elems, factor);\n"
01642 " } \n";
01643
01644 str << " void ckAutoDelegate(int opts=1) {\n"
01645 << " if(ckIsDelegated()) return;\n"
01646 << " " << super << "::ckAutoDelegate(opts);";
01647 genProxyNamesExceptFirst(str, "", NULL, "::ckAutoDelegate(0);", "; ");
01648 str << "\n";
01649 str << " } \n";
01650
01651 str << " void setReductionClient(CkCallback *cb) {\n"
01652 " "
01653 << super
01654 << "::setReductionClient(cb);\n"
01655 " } \n";
01656 str << " void resetSection() {\n"
01657 " "
01658 << super
01659 << "::resetSection();\n"
01660 " } \n";
01661
01662 str << " static void contribute(CkSectionInfo &sid, int userData=-1, int fragSize=-1);\n";
01663 str << " static void contribute(int dataSize,void *data,CkReduction::reducerType "
01664 "type, CkSectionInfo &sid, int userData=-1, int fragSize=-1);\n";
01665 str << " template <typename T>\n"
01666 " static void contribute(std::vector<T> &data, CkReduction::reducerType "
01667 "type, CkSectionInfo &sid, int userData=-1, int fragSize=-1);\n";
01668 str << " static void contribute(CkSectionInfo &sid, const CkCallback &cb, int userData=-1, int fragSize=-1);\n";
01669 str << " static void contribute(int dataSize,void *data,CkReduction::reducerType "
01670 "type, CkSectionInfo &sid, const CkCallback &cb, int userData=-1, int "
01671 "fragSize=-1);\n";
01672 str << " template <typename T>\n"
01673 " static void contribute(std::vector<T> &data, CkReduction::reducerType "
01674 "type, CkSectionInfo &sid, const CkCallback &cb, int userData=-1, int "
01675 "fragSize=-1);\n";
01676 }
01677
01678 genMemberDecls(str);
01679 str << CIClassEnd;
01680 if (!isTemplated()) str << "PUPmarshall(" << ptype << ")\n";
01681 }
01682
01683 static void disambig_array(XStr& str, const XStr& super) {
01684 disambig_proxy(str, super);
01685 str << "\n inline void ckCheck(void) const"
01686 << "\n { " << super << "::ckCheck(); }"
01687 << "\n inline operator CkArrayID () const"
01688 << "\n { return ckGetArrayID(); }"
01689 << "\n inline CkArrayID ckGetArrayID(void) const"
01690 << "\n { return " << super << "::ckGetArrayID(); }"
01691 << "\n inline CkArray *ckLocalBranch(void) const"
01692 << "\n { return " << super << "::ckLocalBranch(); }"
01693 << "\n inline CkLocMgr *ckLocMgr(void) const"
01694 << "\n { return " << super << "::ckLocMgr(); }"
01695 << "\n"
01696 << "\n inline static CkArrayID ckCreateEmptyArray(CkArrayOptions opts = "
01697 "CkArrayOptions())"
01698 << "\n { return " << super << "::ckCreateEmptyArray(opts); }"
01699 << "\n inline static void ckCreateEmptyArrayAsync(CkCallback cb, CkArrayOptions "
01700 "opts = CkArrayOptions())"
01701 << "\n { " << super << "::ckCreateEmptyArrayAsync(cb, opts); }"
01702 << "\n inline static CkArrayID ckCreateArray(CkArrayMessage *m,int ctor,const "
01703 "CkArrayOptions &opts)"
01704 << "\n { return " << super << "::ckCreateArray(m,ctor,opts); }"
01705 << "\n inline void ckInsertIdx(CkArrayMessage *m,int ctor,int onPe,const "
01706 "CkArrayIndex &idx)"
01707 << "\n { " << super << "::ckInsertIdx(m,ctor,onPe,idx); }"
01708 << "\n inline void doneInserting(void)"
01709 << "\n { " << super << "::doneInserting(); }"
01710 << "\n"
01711 << "\n inline void ckBroadcast(CkArrayMessage *m, int ep, int opts=0) const"
01712 << "\n { " << super << "::ckBroadcast(m,ep,opts); }";
01713 disambig_reduction_client(str, super);
01714 }
01715
01716 static void disambig_reduction_client(XStr& str, const XStr& super) {
01717 str << "\n inline void setReductionClient(CkReductionClientFn fn,void *param=NULL) "
01718 "const"
01719 << "\n { " << super << "::setReductionClient(fn,param); }"
01720 << "\n inline void ckSetReductionClient(CkReductionClientFn fn,void "
01721 "*param=NULL) const"
01722 << "\n { " << super << "::ckSetReductionClient(fn,param); }"
01723 << "\n inline void ckSetReductionClient(CkCallback *cb) const"
01724 << "\n { " << super << "::ckSetReductionClient(cb); }"
01725 << "\n";
01726 }
01727
01728 static void disambig_group(XStr& str, const XStr& super) {
01729 disambig_proxy(str, super);
01730 str << "inline void ckCheck(void) const {" << super << "::ckCheck();}\n"
01731 << "CkChareID ckGetChareID(void) const\n"
01732 << " {return " << super << "::ckGetChareID();}\n"
01733 << "CkGroupID ckGetGroupID(void) const\n"
01734 << " {return " << super << "::ckGetGroupID();}\n"
01735 << "operator CkGroupID () const { return ckGetGroupID(); }\n";
01736 disambig_reduction_client(str, super);
01737 }
01738
01739 static XStr indexSuffix2object(const XStr& indexSuffix) {
01740 if (indexSuffix == (const char*)"1D") return "CkIndex1D";
01741 if (indexSuffix == (const char*)"2D") return "CkIndex2D";
01742 if (indexSuffix == (const char*)"3D") return "CkIndex3D";
01743 if (indexSuffix == (const char*)"4D") return "CkIndex4D";
01744 if (indexSuffix == (const char*)"5D") return "CkIndex5D";
01745 if (indexSuffix == (const char*)"6D") return "CkIndex6D";
01746 if (indexSuffix == (const char*)"Max")
01747 return "CkIndexMax";
01748 else
01749 return indexSuffix;
01750 }
01751
01752 }