void simd_bench_pass(bx::simd128_t* _dst, bx::simd128_t* _src, uint32_t _numVertices) { const uint32_t numIterations = 10; { int64_t elapsed = 0; for (uint32_t test = 0; test < numIterations; ++test) { flushCache(); elapsed += -bx::getHPCounter(); simd_rsqrt_bench<bx::simd_rsqrt_est>(_dst, _src, _numVertices); elapsed += bx::getHPCounter(); } printf(" simd_rsqrt_est: %15f\n", double(elapsed) ); } { int64_t elapsed = 0; for (uint32_t test = 0; test < numIterations; ++test) { flushCache(); elapsed += -bx::getHPCounter(); simd_rsqrt_bench<bx::simd_rsqrt_nr>(_dst, _src, _numVertices); elapsed += bx::getHPCounter(); } printf(" simd_rsqrt_nr: %15f\n", double(elapsed) ); } { int64_t elapsed = 0; for (uint32_t test = 0; test < numIterations; ++test) { flushCache(); elapsed += -bx::getHPCounter(); simd_rsqrt_bench<bx::simd_rsqrt_carmack>(_dst, _src, _numVertices); elapsed += bx::getHPCounter(); } printf("simd_rsqrt_carmack: %15f\n", double(elapsed) ); } { int64_t elapsed = 0; for (uint32_t test = 0; test < numIterations; ++test) { flushCache(); elapsed += -bx::getHPCounter(); simd_rsqrt_bench<bx::simd_rsqrt>(_dst, _src, _numVertices); elapsed += bx::getHPCounter(); } printf(" simd_rsqrt: %15f\n", double(elapsed) ); } }
uint32_t ScomRegister::ForceRead() const { #define PRDF_FUNC "[ScomRegister::ForceRead] " uint32_t o_rc = FAIL; do { // No read allowed if register access attribute is write-only or no // access. if ( ( ACCESS_NONE == iv_operationType ) && ( ACCESS_WO == iv_operationType ) ) { PRDF_ERR( PRDF_FUNC"Write-only register: 0x%08x 0x%016llx", getChip()->GetId(), iv_scomAddress ); break; } // Read hardware. o_rc = Access( readCache(), MopRegisterAccess::READ ); if ( SUCCESS != o_rc ) { // The read failed. Remove the entry from the cache so a subsequent // Read() will attempt to read from hardware again. flushCache( getChip() ); } } while (0); return o_rc; #undef PRDF_FUNC }
void seqCache::loadAllSequences(void) { if (_allSequencesLoaded) return; flushCache(); delete [] _cacheMap; delete [] _cache; _cacheMap = 0L; _cacheSize = _fb->getNumberOfSequences(); _cacheNext = 0; _cache = new seqInCore * [_cacheSize]; for (uint32 iid=0; iid<_cacheSize; iid++) { uint32 hLen=0, hMax=0, sLen=0, sMax=0; char *h=0L, *s=0L; if (_fb->getSequence(iid, h, hLen, hMax, s, sLen, sMax) == false) fprintf(stderr, "seqCache::loadAllSequences()-- Failed to load iid "F_U32".\n", iid), exit(1); _cache[iid] = new seqInCore(iid, h, hLen, s, sLen, true); } _allSequencesLoaded = true; }
void zStr::getCompressedText(long block, long entry, char **buf) const { __u32 size = 0; if (cacheBlockIndex != block) { __u32 start = 0; zdxfd->seek(block * ZDXENTRYSIZE, SEEK_SET); zdxfd->read(&start, 4); zdxfd->read(&size, 4); start = swordtoarch32(start); size = swordtoarch32(size); SWBuf buf; buf.setSize(size + 5); zdtfd->seek(start, SEEK_SET); zdtfd->read(buf.getRawData(), size); flushCache(); unsigned long len = size; buf.setSize(size); rawZFilter(buf, 0); // 0 = decipher compressor->zBuf(&len, buf.getRawData()); char *rawBuf = compressor->Buf(0, &len); cacheBlock = new EntriesBlock(rawBuf, len); cacheBlockIndex = block; } size = cacheBlock->getEntrySize(entry); *buf = (*buf) ? (char *)realloc(*buf, size*2 + 1) : (char *)malloc(size*2 + 1); strcpy(*buf, cacheBlock->getEntry(entry)); }
// Insert breakpoint at the very first instruction void Trap::install() { if (_entry != NULL) { _saved_insn = *_entry; *_entry = BREAKPOINT; flushCache(_entry); } }
/** \copydoc Bag::flush */ void flush () { if (_synchro) { _synchro->lock(); } flushCache (); _ref->flush(); if (_synchro) { _synchro->unlock(); } }
void seqCache::setCacheSize(uint32 cachesize) { uint32 ns = _fb->getNumberOfSequences(); flushCache(); if (cachesize == 0) { _cacheMap = 0L; _cacheSize = 0; _cacheNext = 0; _cache = 0L; return; } _cacheMap = new uint32 [ns]; _cacheSize = cachesize; _cacheNext = 0; _cache = new seqInCore * [_cacheSize]; for (uint32 i=0; i<ns; i++) _cacheMap[i] = ~uint32ZERO; for (uint32 i=0; i<_cacheSize; i++) _cache[i] = 0L; }
/******************************************* Name : flush Descr.: flush buffers and update disk (sync) Input : volume - volume to flush Output: DOSTRUE ********************************************/ BOOL flush(struct AFSBase *afsbase, struct Volume *volume) { flushCache(afsbase, volume); volume->ioh.ioreq->iotd_Req.io_Command = CMD_UPDATE; DoIO((struct IORequest *)&volume->ioh.ioreq->iotd_Req); clearCache(afsbase, volume->blockcache); return DOSTRUE; }
void LogDispatcher::attachLogOutput(LogOutput *output) { if(output && !m_outputs.contains(output)) { m_outputs.insert(output); flushCache(output); } }
void MM_SegregatedAllocationInterface::disableCachedAllocations(MM_EnvironmentBase* env) { if (_cachedAllocationsEnabled) { _cachedAllocationsEnabled = false; flushCache(env); restartCache(env); } }
GsrProcess::GsrProcess(const Array ×, const Array &vols, const Array &reversions, const Real T, const Date &referenceDate, const DayCounter &dc) : ForwardMeasureProcess1D(T), core_(times,vols,reversions,T), referenceDate_(referenceDate), dc_(dc) { flushCache(); }
void Topology::Close() { if (shapefileopen) { if (shpCache) { flushCache(); free(shpCache); shpCache = NULL; } msSHPCloseFile(&shpfile); shapefileopen = false; // added sgi } }
void Topology::updateCache(MapWindowProjection &map_projection, rectObj thebounds, bool purgeonly) { if (!triggerUpdateCache) return; if (!shapefileopen) return; in_scale = CheckScale(map_projection.GetMapScaleUser()); if (!in_scale) { // not visible, so flush the cache // otherwise we waste time on looking up which shapes are in bounds flushCache(); triggerUpdateCache = false; return; } if (purgeonly) return; triggerUpdateCache = false; msSHPWhichShapes(&shpfile, thebounds, 0); if (!shpfile.status) { // this happens if entire shape is out of range // so clear buffer. flushCache(); return; } shapes_visible_count = 0; for (int i=0; i<shpfile.numshapes; i++) { if (msGetBit(shpfile.status, i)) { if (shpCache[i]==NULL) { // shape is now in range, and wasn't before shpCache[i] = addShape(i); } shapes_visible_count++; } else { removeShape(i); } } }
void TGAWriter::writePixel(unsigned char r, unsigned char g,unsigned char b) { if (cacheIndex > INTERNAL_CACHE_SIZE -3) { flushCache(); } cache[cacheIndex++] = b; cache[cacheIndex++] = g; cache[cacheIndex++] = r; }
QCheckBox* ConfigPage::newCheckbox(QString label, QString ID, bool checked) { QCheckBox* widget = new QCheckBox(label); widget->setCheckState(BOOL_TO_CHECKED(checked)); WidgetCache<bool> cache(widget, checked); checkboxCache.insert(std::pair<QString, WidgetCache<bool> >(ID, cache)); connect(widget, SIGNAL(released()), ConfigDialog::getInstance(), SLOT(flushCache())); connect(widget, SIGNAL(released()), ConfigDialog::getInstance(), SIGNAL(settingsChanged())); return widget; }
/** \copydoc Bag::insert */ void insert (const Item& item) { if (_idx+1 > _nbMax) { if (_synchro) { _synchro->lock(); } flushCache (); if (_synchro) { _synchro->unlock(); } } _items[_idx++] = item; }
void FileBufferMgr::flushPartition(const vector<OID_t> &oids, const set<BRM::LogicalPartition> &partitions) { DBRM dbrm; uint32_t i; vector<EMEntry> extents; int err; uint32_t currentExtent; LBID_t currentLBID; typedef tr1::unordered_multimap<LBID_t, filebuffer_uset_t::iterator> byLBID_t; byLBID_t byLBID; pair<byLBID_t::iterator, byLBID_t::iterator> itList; filebuffer_uset_t::iterator it; uint32_t count = oids.size(); mutex::scoped_lock lk(fWLock); if (fCacheSize == 0 || oids.size() == 0 || partitions.size() == 0) return; /* Index the cache by LBID */ for (it = fbSet.begin(); it != fbSet.end(); it++) byLBID.insert(pair<LBID_t, filebuffer_uset_t::iterator>(it->lbid, it)); for (i = 0; i < count; i++) { extents.clear(); err = dbrm.getExtents(oids[i], extents, true, true,true); // @Bug 3838 Include outofservice extents if (err < 0) { lk.unlock(); flushCache(); // better than returning an error code to the user return; } for (currentExtent = 0; currentExtent < extents.size(); currentExtent++) { EMEntry &range = extents[currentExtent]; LogicalPartition logicalPartNum(range.dbRoot, range.partitionNum, range.segmentNum); if (partitions.find(logicalPartNum) == partitions.end()) continue; LBID_t lastLBID = range.range.start + (range.range.size * 1024); for (currentLBID = range.range.start; currentLBID < lastLBID; currentLBID++) { itList = byLBID.equal_range(currentLBID); for (byLBID_t::iterator tmpIt = itList.first; tmpIt != itList.second; tmpIt++) { fbList.erase(fFBPool[tmpIt->second->poolIdx].listLoc()); fEmptyPoolSlots.push_back(tmpIt->second->poolIdx); fbSet.erase(tmpIt->second); fCacheSize--; } } } } }
void FileBufferMgr::flushOIDs(const uint32_t *oids, uint32_t count) { DBRM dbrm; uint32_t i; vector<EMEntry> extents; int err; uint32_t currentExtent; LBID_t currentLBID; typedef tr1::unordered_multimap<LBID_t, filebuffer_uset_t::iterator> byLBID_t; byLBID_t byLBID; pair<byLBID_t::iterator, byLBID_t::iterator> itList; filebuffer_uset_t::iterator it; // If there are more than this # of extents to drop, the whole cache will be cleared const uint32_t clearThreshold = 50000; mutex::scoped_lock lk(fWLock); if (fCacheSize == 0 || count == 0) return; /* Index the cache by LBID */ for (it = fbSet.begin(); it != fbSet.end(); it++) byLBID.insert(pair<LBID_t, filebuffer_uset_t::iterator>(it->lbid, it)); for (i = 0; i < count; i++) { extents.clear(); err = dbrm.getExtents(oids[i], extents, true,true,true); // @Bug 3838 Include outofservice extents if (err < 0 || (i == 0 && (extents.size() * count) > clearThreshold)) { // (The i == 0 should ensure it's not a dictionary column) lk.unlock(); flushCache(); return; } for (currentExtent = 0; currentExtent < extents.size(); currentExtent++) { EMEntry &range = extents[currentExtent]; LBID_t lastLBID = range.range.start + (range.range.size * 1024); for (currentLBID = range.range.start; currentLBID < lastLBID; currentLBID++) { itList = byLBID.equal_range(currentLBID); for (byLBID_t::iterator tmpIt = itList.first; tmpIt != itList.second; tmpIt++) { fbList.erase(fFBPool[tmpIt->second->poolIdx].listLoc()); fEmptyPoolSlots.push_back(tmpIt->second->poolIdx); fbSet.erase(tmpIt->second); fCacheSize--; } } } } }
/** \copydoc Bag::flush */ void flush () { //printf("main flush \n"); if (this->_synchro) { this->_synchro->lock(); } flushLocalCache (); flushCache (); if (this->_synchro) { this->_synchro->unlock(); } if (this->_outsynchro) { this->_outsynchro->lock(); } this->_ref->flush(); if (this->_outsynchro) { this->_outsynchro->unlock(); } }
pair<void*,uint64_t> IOBufQueue::preallocateSlow(uint64_t min, uint64_t newAllocationSize, uint64_t max) { // Avoid grabbing update guard, since we're manually setting the cache ptrs. flushCache(); // Allocate a new buffer of the requested max size. unique_ptr<IOBuf> newBuf(IOBuf::create(std::max(min, newAllocationSize))); tailStart_ = newBuf->writableTail(); cachePtr_->cachedRange = std::pair<uint8_t*, uint8_t*>( tailStart_, tailStart_ + newBuf->tailroom()); appendToChain(head_, std::move(newBuf), false); return make_pair(writableTail(), std::min<uint64_t>(max, tailroom())); }
void writeData(char * data, size_t size) { if (size >= memsize) { printf("ERROR WRITING TO RINGBUFFER\n"); } else if (flushCache() && rb.writeSpace() >= size) { //printf("scheduled message\n"); rb.write(data, size); } else { //printf("cached message\n"); char * cpy = new char[size]; memcpy(cpy, data, size); cache(cpy, size); } }
int updateGetSingleChunk(Packet *pkt, int peerID) { recvWindow *rw = &(downloadPool[peerID].rw); int dataSize = getPacketSize(pkt) - 16; uint8_t *dataPtr = pkt->payload + 16; uint32_t seq = (uint32_t)getPacketSeq(pkt); downloadPool[peerID].timeoutCount = 0; fprintf(stderr,"Got pkt %d expecting %d\n", seq, rw->nextPacketExpected); if(seq >= rw->nextPacketExpected) { if((seq > rw->nextPacketExpected) && ((seq - rw->nextPacketExpected) <= INIT_THRESH)) { insertInOrder(&(downloadPool[peerID].cache), newFreePacketACK(seq), seq); newPacketACK(rw->nextPacketExpected - 1, downloadPool[peerID].ackSendQueue); } else if(seq - rw->nextPacketExpected <= INIT_THRESH) { newPacketACK(seq, downloadPool[peerID].ackSendQueue); rw->nextPacketExpected = flushCache(rw->nextPacketExpected, downloadPool[peerID].ackSendQueue, &(downloadPool[peerID].cache)); } rw->lastPacketRead = seq; rw->lastPacketRcvd = seq; int curChunk = downloadPool[peerID].curChunkID; long offset = (seq - 1) * PACKET_DATA_SIZE + BT_CHUNK_SIZE * curChunk; FILE *of = getChunk.filePtr; fprintf(stderr,"In: %d [%ld-%ld]\n", seq, offset, offset + dataSize); if(of != NULL) { fseek(of, offset, SEEK_SET); fwrite(dataPtr, sizeof(uint8_t), dataSize, of); } if(rw->nextPacketExpected > BT_CHUNK_SIZE / PACKET_DATA_SIZE + 1){ clearQueue(downloadPool[peerID].timeoutQueue); fprintf(stderr,"Chunk finished downloading! Next expected %d thresh %d\n", rw->nextPacketExpected, BT_CHUNK_SIZE / PACKET_DATA_SIZE + 1); getChunk.list[curChunk].fetchState = 1; downloadPool[peerID].state = 0; clearQueue(downloadPool[peerID].timeoutQueue); initWindows(&(downloadPool[peerID].rw), &(uploadPool[peerID].sw)); fprintf(stderr,"Chunk %d fetched!\n", curChunk); // fprintf(stderr,"%d More GETs in queue\n", downloadPool[peerID].getQueue->size); return 1; } else { return 0; } } else { fprintf(stderr,"Received an unexpected packet!" "Expecting %d but received %d!", rw->nextPacketExpected, seq); newPacketACK(seq, downloadPool[peerID].ackSendQueue); return 0; } }
void zCom::setEntry(const char *inbuf, long len) { VerseKey *key = &getVerseKey(); // see if we've jumped across blocks since last write if (lastWriteKey) { if (!sameBlock(lastWriteKey, key)) { flushCache(); } delete lastWriteKey; } doSetText(key->Testament(), key->TestamentIndex(), inbuf, len); lastWriteKey = (VerseKey *)key->clone(); // must delete }
int DbFileOp::readDBFile( CommBlock& cb, unsigned char* readBuf, const uint64_t lbid ) { CacheKey key; if( Cache::getUseCache() ) { if( Cache::cacheKeyExist( cb.file.oid, lbid ) ) { key = Cache::getCacheKey( cb.file.oid, lbid ); RETURN_ON_ERROR( Cache::loadCacheBlock( key, readBuf ) ); return NO_ERROR; } } RETURN_ON_ERROR( readDBFile( cb.file.pFile, readBuf, lbid ) ); if( Cache::getUseCache() ) { int fbo = lbid; uint16_t dbRoot; uint32_t partition; uint16_t segment; RETURN_ON_ERROR( BRMWrapper::getInstance()->getFboOffset( lbid, dbRoot, partition, segment, fbo ) ); if( Cache::getListSize( FREE_LIST ) == 0 ) { if ( isDebug( DEBUG_1 ) ) { printf( "\nBefore flushing cache " ); Cache::printCacheList(); } // flush cache to give up more space RETURN_ON_ERROR( flushCache() ); if ( isDebug( DEBUG_1 ) ) { printf( "\nAfter flushing cache " ); Cache::printCacheList(); } } RETURN_ON_ERROR( Cache::insertLRUList( cb, lbid, fbo, readBuf ) ); } return NO_ERROR; }
void Topology::Close() { if (shapefileopen) { if (shpCache) { flushCache(); free(shpCache); shpCache = NULL; } if (shpBounds) { free(shpBounds); shpBounds = NULL; } if (shps) { for (int i=0; i<shpfile.numshapes; i++) { if (shps[i]) delete shps[i]; } free(shps); shps = NULL; } msSHPCloseFile(&shpfile); shapefileopen = false; // added sgi } }
zStr::~zStr() { flushCache(); if (path) delete [] path; --instance; FileMgr::getSystemFileMgr()->close(idxfd); FileMgr::getSystemFileMgr()->close(datfd); FileMgr::getSystemFileMgr()->close(zdxfd); FileMgr::getSystemFileMgr()->close(zdtfd); if (compressor) delete compressor; }
//update the globall struct line, so that it contains the next line's attributes void grabNextLine(int PID, char RW, uint addr){ program.runNumber++; line.previousProcessId = line.processId; line.processId = PID; line.currentAddress = addr; if(RW == 'W'){ line.currentOperation = 1; } else { line.currentOperation = 0; } //if there was a process switch, we need to flush the cache entries and flush all the pages from the frames //this is because our simulation does not distinguish between two virtual address from different processes if(line.previousProcessId != line.processId){ flushCache(); //flushMainMemory(); } return; }//grabNextLine
struct object * gcollect(int sz) { int i; gccount++; /* first change spaces */ if (globalBudd.inSpaceOne) { memoryBase = globalBudd.spaceTwo; globalBudd.inSpaceOne = 0; oldBase = globalBudd.spaceOne; } else { memoryBase = globalBudd.spaceOne; globalBudd.inSpaceOne = 1; oldBase = globalBudd.spaceTwo; } memoryPointer = memoryTop = memoryBase + globalBudd.spaceSize; oldTop = oldBase + globalBudd.spaceSize; /* then do the collection */ for (i = 0; i < rootTop; i++) { rootStack[i] = gc_move((struct mobject *)rootStack[i]); } for (i = 0; i < staticRootTop; i++) { (*staticRoots[i]) = gc_move((struct mobject *) *staticRoots[i]); } flushCache(); /* then see if there is room for allocation */ memoryPointer = WORDSDOWN(memoryPointer, sz + 2); if (memoryPointer < memoryBase) { budd_panic_int("insufficient memory after garbage collection", sz); } SETSIZE(memoryPointer, sz); return(memoryPointer); }
void flushLocalCache () //flush local cache to shared buffer { // printf("flush local cache to %p from %p %zu \n",_sharedBuffer + *_idxShared,this->_items,this->_idx); if (this->_idx > 0) { while(*_idxShared + this->_idx > _sharedCacheSize) // must be a while, not an 'if' : flushCache may release temporarily the lock, so must re-check when exiting flushcache { //sort and flush shared buffer to ref bag flushCache (); } system::impl::System::memory().memcpy (_sharedBuffer + *_idxShared, this->_items, this->_idx*sizeof(Item)); *_idxShared += this->_idx; //this->_ref->insert (this->_items, this->_idx); } this->_idx = 0; }
//used to init all global variables from parameters and malloc space for the data structures void initialization(void){ //malloc space for our datastructures mainMemory = malloc(sizeof(struct frame)*numFrames); program.runNumber = 0; program.totalPageFaults = 0; program.totalEvictions = 0; //init our empty page table flushMainMemory(); //init TLB flushCache(); int idx; switch(pageTableType){ case 1: //multi pageDirectory = (struct pageTablePage*) malloc(sizeof(struct pageTablePage)*numPageTablePages); for(idx = 0; idx<numPageTablePages; idx++){ struct pageTablePage thisPageTablePage; thisPageTablePage.idx = -1; thisPageTablePage.startAddress = idx*4096; pageDirectory[idx] = thisPageTablePage; } break; case 2: //inverted hashTable = (int*) malloc(sizeof(int)*modNum); break; } // init working sets for(idx = 0; idx< NUMPROCESSES; idx++ ) initWorkingSet(&processWorkingSets[idx]); //init the first line line.processId = -1; }//initilization