long getIntId(char *s) { long res = (long)hashTableGet(idToIntMap, s); if (!res) { void *key = copyStr(s); void *value = (void *)(idToIntMap->size + 1L); hashTablePut(idToIntMap, key, value); hashTablePut(intToIdMap, value, key); res = idToIntMap->size; } return res; }
static RetCode mpeg2PmtActivate(Mpeg2Pmt mpeg2Pmt, MmpContextObject *cop, Mpeg2PmtTsProgramMapSection * pmsp) { Mpeg2PmtStream *streamp; Mpeg2PmtTsProgramMapSection *curPmsp; Mpeg2PmtCurrentNextIndicator cni; unsigned pn; cni = Mpeg2PmtCurrentNextIndicator(pmsp->psiExtension.currentNextIndicator); pn = MPEG2_PMT_PROGRAM_NUMBER(&pmsp->psiExtension); curPmsp = (Mpeg2PmtTsProgramMapSection*)hashTableGet(mpeg2Pmt->pmtTable[cni], pn); if (curPmsp == NULL || curPmsp->psiExtension.versionNumber != pmsp->psiExtension.versionNumber) { mpeg2PmtDeactivate(mpeg2Pmt, pn, cni); (void) hashTablePut(mpeg2Pmt->pmtTable[cni], pn, DUP(Mpeg2PmtTsProgramMapSection, pmsp)); if (mpeg2Pmt->shouldPmtStop) { return RETCODE_CONS(retCodeId, MPEG2_PMT_ERROR_STOP); } for (streamp = pmsp->streamList; streamp != NULL; streamp = streamp->next) { unsigned streamType = streamp->streamHeader.streamType; unsigned ePid = MPEG2_PMT_STREAM_HEADER_ELEMENTARY_PID( &streamp->streamHeader); Pipe pidPipe; if (MMP_CONTEXT_PIDTOPIPE(cop, ePid) == NULL) { MmpParserObject *pop = mpeg2Pmt->streamTypeToPop[streamType]; RetCode retCode; streamp->cop = cop; pidPipe = MMP_PARSER_NEWPIPE(pop, cop); retCode = MMP_CONTEXT_ADDPIPE(cop, ePid, pidPipe); ABORT_IF_FALSE(retCode == RETCODE_SUCCESS); } else if (streamp->cop != cop) { return RETCODE_CONS(retCodeId, MPEG2_PMT_ERROR_PID_USE); } } } else { mpeg2PmtDescListFree(pmsp->descList); mpeg2PmtStreamListFree(pmsp->streamList); } return RETCODE_SUCCESS; }
static void rehash(HashTable *t) { LinkedList **old = t->a; int oldCap = t->cap; t->cap *= 2; t->a = (LinkedList **)tlMalloc(t->cap * sizeof(LinkedList *)); t->size = 0; memset(t->a, 0, t->cap * sizeof(LinkedList *)); int i; for (i = 0; i < oldCap; i++) { LinkedList *l = old[i], *next; while (l) { hashTablePut(t, l->key, l->value); next = l->next; l->next = 0; tlFree(l); l = next; } } tlFree(old); }
/// The unloadBuffer function for a halo exchange of atom data. /// Iterates the receive buffer and places each atom that was received /// into the link cell that corresponds to the atom coordinate. Note /// that this naturally accomplishes transfer of ownership of atoms that /// have moved from one spatial domain to another. Atoms with /// coordinates in local link cells automatically become local /// particles. Atoms that are owned by other ranks are automatically /// placed in halo kink cells. /// \see HaloExchangeSt::unloadBuffer for an explanation of the /// unloadBuffer parameters. /// @param face Not used for this function. The only reason we keep it is to match the unloadForcesBuffer declaration void unloadAtomsBuffer(void* vparms, void* data, int face, int bufSize, char* charBuf) { AtomExchangeParms* parms = (AtomExchangeParms*) vparms; SimFlat* sim = (SimFlat*) data; assert(bufSize % sizeof(AtomMsg) == 0); int nBuf = bufSize / sizeof(AtomMsg); if(sim->method == CPU_NL) { AtomMsg* buf = (AtomMsg*) charBuf; // const int nlUpdateRequired = neighborListUpdateRequired(s->atoms->neighborList,s->boxes,s->atoms); const int nlUpdateRequired = neighborListUpdateRequired(sim); for (int ii=0; ii<nBuf; ++ii) { int gid = buf[ii].gid; int type = buf[ii].type; real_t rx = buf[ii].rx; real_t ry = buf[ii].ry; real_t rz = buf[ii].rz; real_t px = buf[ii].px; real_t py = buf[ii].py; real_t pz = buf[ii].pz; if(nlUpdateRequired){ int iOff = putAtomInBox(sim->boxes, sim->atoms, gid, type, rx, ry, rz, px, py, pz); if(iOff >= (MAXATOMS*sim->boxes->nLocalBoxes)) hashTablePut(sim->atomExchange->hashTable, iOff); //remember iOff only for particles which are mapped to haloCells else //putting particle to local sim->atoms->neighborList->updateLinkCellsRequired = 1; }else{ int iOff = hashTableGet(sim->atomExchange->hashTable); updateAtomInBoxAt(sim->boxes, sim->atoms, gid, type, rx, ry, rz, px, py, pz,iOff); } } }else{ unloadAtomsBufferToGpu(charBuf, nBuf, sim, sim->gpu_atoms_buf, sim->boundary_stream); } }