/* send global tuple information */ void FixedTupleListAdress::beforeSendParticles (ParticleList& pl, OutBuffer& buf) { std::vector<longint> atpl; // loop over the particle list for (ParticleList::Iterator pit(pl); pit.isValid(); ++pit) { longint pidK = pit->id(); LOG4ESPP_DEBUG(theLogger, "send particle with pid " << pidK << ", find tuples"); // find particle that involves this particle id GlobalTuples::const_iterator it = globalTuples.find(pidK); if (it != globalTuples.end()) { // first write the pid of the first particle //toSend.push_back(pidK); //std::cout << "write pidK "<< pidK << "\n"; buf.write(pidK); // write the size of the vector int s = it->second.size(); //toSend.push_back(s); //std::cout << "write s "<< s << "\n"; buf.write(s); atpl.reserve(s); // iterate through vector and add pids //std::cout << storage->getRank() << ": removing AT particles "; for (tuple::const_iterator it2 = it->second.begin(); it2 != it->second.end(); ++it2) { //toSend.push_back(*it2); //std::cout << " write pid "<< *it2 << " ("; Particle* tp = storage->lookupAdrATParticle(*it2); //std::cout << " write " << tp->getId() << " (" << tp->getPos() << ")\n"; buf.write(*tp); atpl.push_back(*it2); // remove AT particle from storage storage->removeAdrATParticle(*it2); //std::cout << " " << *it2; } //std::cout << "\n"; // delete this pid from the global list globalTuples.erase(pidK); } } beforeSendATParticles(atpl, buf); }
void beforeResort(ParticleList &pl, OutBuffer& out) { if (pl.size() == 1) { beforeResortCalled = true; int res = 42; out.write(res); } }
void FixedSingleList::beforeSendParticles(ParticleList& pl, OutBuffer& buf) { std::vector< longint > toSend(pl.size()); // loop over the particle list for (ParticleList::Iterator pit(pl); pit.isValid(); ++pit) { longint pid = pit->id(); toSend.push_back(pid); globalSingles.erase(pid); LOG4ESPP_DEBUG(theLogger, "erase and send particle with pid from FixedSingleList" << pid); } // send the list buf.write(toSend); LOG4ESPP_INFO(theLogger, "prepared fixed single list before send particles"); }
void FixedListComm::beforeSendParticles (ParticleList& pl, OutBuffer& buf) { std::vector<longint> toSend; // loop over the particle list for (ParticleList::Iterator pit(pl); pit.isValid(); ++pit) { longint pid = pit->id(); LOG4ESPP_DEBUG(theLogger, "send particle with pid " << pid << ", find pairs"); // find all particles that involve this particle id int n = globalLists.count(pid); if (n > 0) { std::pair<GlobalList::const_iterator, GlobalList::const_iterator> equalRange = globalLists.equal_range(pid); // get the length of the vector in the map int l = equalRange.first->second.size(); toSend.reserve(toSend.size()+3+n*l); // first write the pid of the first particle toSend.push_back(pid); // then the number of partners toSend.push_back(n); // then the size of the vector toSend.push_back(l); // and then the pids of the partners for (GlobalList::const_iterator it = equalRange.first; it != equalRange.second; ++it) { // iterate through vector to add pids for (pvec::const_iterator it2=it->second.begin(); it2!=it->second.end(); ++it2) { toSend.push_back(*it2); LOG4ESPP_DEBUG(theLogger, "send global bond: pid " << pid << " and its vector"); } } // delete all of these pairs from the global list globalLists.erase(equalRange.first, equalRange.second); } } // send the list buf.write(toSend); LOG4ESPP_INFO(theLogger, "prepared fixed pair list before send particles"); }
/** * Creates the data symbol for a TLS variable for Mach-O. * * Input: * vd the variable declaration for the symbol * s the regular symbol for the variable * * Returns: the newly create symbol */ Symbol *createTLVDataSymbol(VarDeclaration *vd, Symbol *s) { assert(config.objfmt == OBJ_MACH && I64 && (s->ty() & mTYLINK) == mTYthread); OutBuffer buffer; buffer.writestring(s->Sident); buffer.write("$tlv$init", 9); const char *tlvInitName = buffer.extractString(); Symbol *tlvInit = symbol_name(tlvInitName, SCstatic, type_fake(vd->type->ty)); tlvInit->Sdt = NULL; tlvInit->Salignment = type_alignsize(s->Stype); type_setty(&tlvInit->Stype, tlvInit->Stype->Tty | mTYthreadData); type_setmangle(&tlvInit->Stype, mangle(vd, tlvInit)); return tlvInit; }
void FixedTripleListAdress::beforeSendATParticles(std::vector<longint>& atpl, OutBuffer& buf) { //std::cout << "beforeSendATParticles() fixed pl (size " << atpl.size() << ")\n"; std::vector< longint > toSend; // loop over the VP particle list for (std::vector<longint>::iterator it = atpl.begin(); it != atpl.end(); ++it) { longint pid = *it; LOG4ESPP_DEBUG(theLogger, "send particle with pid " << pid << ", find pairs"); // find all triples that involve this particle int n = globalTriples.count(pid); if (n > 0) { std::pair<GlobalTriples::const_iterator, GlobalTriples::const_iterator> equalRange = globalTriples.equal_range(pid); // first write the pid of this particle // then the number of partners (n) // and then the pids of the partners toSend.reserve(toSend.size()+2*n+1); toSend.push_back(pid); toSend.push_back(n); for (GlobalTriples::const_iterator it = equalRange.first; it != equalRange.second; ++it) { toSend.push_back(it->second.first); toSend.push_back(it->second.second); } // delete all of these triples from the global list globalTriples.erase(equalRange.first, equalRange.second); } } // send the list buf.write(toSend); LOG4ESPP_INFO(theLogger, "prepared fixed triple list before send particles"); }
/** * Creates the data symbol used to initialize a TLS variable for Mach-O. * * Params: * vd = the variable declaration for the symbol * s = the back end symbol corresponding to vd * * Returns: the newly created symbol */ Symbol *createTLVDataSymbol(VarDeclaration *vd, Symbol *s) { assert(config.objfmt == OBJ_MACH && I64 && (s->ty() & mTYLINK) == mTYthread); // Compute identifier for tlv symbol OutBuffer buffer; buffer.writestring(s->Sident); buffer.write("$tlv$init", 9); const char *tlvInitName = buffer.peekString(); // Compute type for tlv symbol type *t = type_fake(vd->type->ty); type_setty(&t, t->Tty | mTYthreadData); type_setmangle(&t, mangle(vd)); Symbol *tlvInit = symbol_name(tlvInitName, SCstatic, t); tlvInit->Sdt = NULL; tlvInit->Salignment = type_alignsize(s->Stype); if (vd->linkage == LINKcpp) tlvInit->Sflags |= SFLpublic; return tlvInit; }
int runLINK() { #if _WIN32 char *p; int i; int status; OutBuffer cmdbuf; global.params.libfiles->push((void *) "user32"); global.params.libfiles->push((void *) "kernel32"); for (i = 0; i < global.params.objfiles->dim; i++) { if (i) cmdbuf.writeByte('+'); p = (char *)global.params.objfiles->data[i]; char *ext = FileName::ext(p); if (ext) cmdbuf.write(p, ext - p - 1); else cmdbuf.writestring(p); } cmdbuf.writeByte(','); if (global.params.exefile) cmdbuf.writestring(global.params.exefile); else { // Generate exe file name from first obj name char *n = (char *)global.params.objfiles->data[0]; char *ex; n = FileName::name(n); FileName *fn = FileName::forceExt(n, "exe"); global.params.exefile = fn->toChars(); } cmdbuf.writeByte(','); if (global.params.run) cmdbuf.writestring("nul"); // if (mapfile) // cmdbuf.writestring(output); cmdbuf.writeByte(','); for (i = 0; i < global.params.libfiles->dim; i++) { if (i) cmdbuf.writeByte('+'); cmdbuf.writestring((char *) global.params.libfiles->data[i]); } if (global.params.deffile) { cmdbuf.writeByte(','); cmdbuf.writestring(global.params.deffile); } /* Eliminate unnecessary trailing commas */ while (1) { i = cmdbuf.offset; if (!i || cmdbuf.data[i - 1] != ',') break; cmdbuf.offset--; } if (global.params.resfile) { cmdbuf.writestring("/RC:"); cmdbuf.writestring(global.params.resfile); } #if 0 if (mapfile) cmdbuf.writestring("/m"); if (debuginfo) cmdbuf.writestring("/li"); if (codeview) { cmdbuf.writestring("/co"); if (codeview3) cmdbuf.writestring(":3"); } #else if (global.params.symdebug) cmdbuf.writestring("/co"); #endif cmdbuf.writestring("/noi"); for (i = 0; i < global.params.linkswitches->dim; i++) { cmdbuf.writestring((char *) global.params.linkswitches->data[i]); } cmdbuf.writeByte(';'); p = cmdbuf.toChars(); char *linkcmd = getenv("LINKCMD"); if (!linkcmd) linkcmd = "link"; status = executecmd(linkcmd, p, 1); return status; #elif linux pid_t childpid; int i; int status; // Build argv[] Array argv; char *cc = getenv("CC"); if (!cc) cc = "gcc"; argv.push((void *)cc); argv.insert(1, global.params.objfiles); // None of that a.out stuff. Use explicit exe file name, or // generate one from name of first source file. argv.push((void *)"-o"); if (global.params.exefile) { argv.push(global.params.exefile); } else { // Generate exe file name from first obj name char *n = (char *)global.params.objfiles->data[0]; char *e; char *ex; n = FileName::name(n); e = FileName::ext(n); if (e) { e--; // back up over '.' ex = (char *)mem.malloc(e - n + 1); memcpy(ex, n, e - n); ex[e - n] = 0; } else ex = (char *)"a.out"; // no extension, so give up argv.push(ex); global.params.exefile = ex; } argv.insert(argv.dim, global.params.libfiles); if (global.params.symdebug) argv.push((void *)"-g"); argv.push((void *)"-m32"); argv.push((void *)"-lphobos"); // turns into /usr/lib/libphobos.a argv.push((void *)"-lpthread"); argv.push((void *)"-lm"); if (0 && global.params.exefile) { /* This switch enables what is known as 'smart linking' * in the Windows world, where unreferenced sections * are removed from the executable. It eliminates unreferenced * functions, essentially making a 'library' out of a module. * Although it is documented to work with ld version 2.13, * in practice it does not, but just seems to be ignored. * Thomas Kuehne has verified that it works with ld 2.16.1. * BUG: disabled because it causes exception handling to fail */ argv.push((void *)"-Xlinker"); argv.push((void *)"--gc-sections"); } for (i = 0; i < global.params.linkswitches->dim; i++) { argv.push((void *)"-Xlinker"); argv.push((void *) global.params.linkswitches->data[i]); } if (!global.params.quiet) { // Print it for (i = 0; i < argv.dim; i++) printf("%s ", (char *)argv.data[i]); printf("\n"); fflush(stdout); } argv.push(NULL); childpid = fork(); if (childpid == 0) { execvp((char *)argv.data[0], (char **)argv.data); perror((char *)argv.data[0]); // failed to execute return -1; } waitpid(childpid, &status, 0); status=WEXITSTATUS(status); if (status) printf("--- errorlevel %d\n", status); return status; #else printf ("Linking is not yet supported for this version of DMD.\n"); return -1; #endif }