int main() { const unsigned POP_SIZE = 10, CHROM_SIZE = 12; unsigned i; eoBooleanGenerator gen; // the populations: eoPop<Chrom> pop; // Evaluation RoyalRoad<Chrom> rr( 8 ); eoEvalFuncCounter<Chrom> eval( rr ); eoInitVirus<float> random(CHROM_SIZE, gen); for (i = 0; i < POP_SIZE; ++i) { Chrom chrom; random(chrom); eval(chrom); pop.push_back(chrom); } std::cout << "population:" << std::endl; for (i = 0; i < pop.size(); ++i) std::cout << "\t" << pop[i] << " " << pop[i].fitness() << std::endl; // selection eoStochTournamentSelect<Chrom> lottery(0.9 ); // breeder eoOneBitFlip<Chrom> vm; eoUBitXover<Chrom> xover; eoProportionalOp<Chrom> propSel; eoGeneralBreeder<Chrom> breeder( lottery, propSel ); propSel.add(vm, 0.2); propSel.add(xover, 0.8); // Replace a single one eoCommaReplacement<Chrom> replace; // Terminators eoGenContinue<Chrom> continuator1(10); eoFitContinue<Chrom> continuator2(CHROM_SIZE); eoCombinedContinue<Chrom> continuator(continuator1, continuator2); eoCheckPoint<Chrom> checkpoint(continuator); eoStdoutMonitor monitor; checkpoint.add(monitor); eoSecondMomentStats<Chrom> stats; eoPopStat<Chrom> dumper( 10 ); monitor.add(stats); checkpoint.add(dumper); checkpoint.add(stats); // GA generation eoEasyEA<Chrom> ea(checkpoint, eval, breeder, replace ); // evolution try { ea(pop); } catch (std::exception& e) { std::cout << "exception: " << e.what() << std::endl;; exit(EXIT_FAILURE); } std::cout << "pop" << std::endl; for (i = 0; i < pop.size(); ++i) std::cout << "\t" << pop[i] << " " << pop[i].fitness() << std::endl; std::cout << "\n --> Number of Evaluations = " << eval.getValue() << std::endl; return 0; }
void c2040_fdc_t::live_run(const attotime &limit) { if(cur_live.state == IDLE || cur_live.next_state != -1) return; for(;;) { switch(cur_live.state) { case RUNNING: { bool syncpoint = false; if (cur_live.tm > limit) return; int bit = get_next_bit(cur_live.tm, limit); if(bit < 0) return; int cell_counter = cur_live.cell_counter; if (bit) { cur_live.cycle_counter = cur_live.ds; cur_live.cell_counter = 0; } else { cur_live.cycle_counter++; } if (cur_live.cycle_counter == 16) { cur_live.cycle_counter = cur_live.ds; cur_live.cell_counter++; cur_live.cell_counter &= 0xf; } if (!BIT(cell_counter, 1) && BIT(cur_live.cell_counter, 1)) { // read bit cur_live.shift_reg <<= 1; cur_live.shift_reg |= !(BIT(cur_live.cell_counter, 3) || BIT(cur_live.cell_counter, 2)); cur_live.shift_reg &= 0x3ff; if (LOG) logerror("%s read bit %u (%u) >> %03x, rw=%u mode=%u\n", cur_live.tm.as_string(), cur_live.bit_counter, !(BIT(cur_live.cell_counter, 3) || BIT(cur_live.cell_counter, 2)), cur_live.shift_reg, cur_live.rw_sel, cur_live.mode_sel); // write bit if (!cur_live.rw_sel) { // TODO WPS write_next_bit(BIT(cur_live.shift_reg_write, 9), limit); } syncpoint = true; } int sync = !((cur_live.shift_reg == 0x3ff) && cur_live.rw_sel); if (!sync) { cur_live.bit_counter = 0; } else if (!BIT(cell_counter, 1) && BIT(cur_live.cell_counter, 1) && cur_live.sync) { cur_live.bit_counter++; if (cur_live.bit_counter == 10) { cur_live.bit_counter = 0; } } // update GCR if (cur_live.rw_sel) { cur_live.i = (cur_live.rw_sel << 10) | cur_live.shift_reg; } else { cur_live.i = (cur_live.rw_sel << 10) | ((cur_live.pi & 0xf0) << 1) | (cur_live.mode_sel << 4) | (cur_live.pi & 0x0f); } cur_live.e = m_gcr_rom->base()[cur_live.i]; int ready = !(BIT(cell_counter, 1) && !BIT(cur_live.cell_counter, 1) && (cur_live.bit_counter == 9)); if (!ready) { // load write shift register cur_live.shift_reg_write = GCR_ENCODE(cur_live.e, cur_live.i); if (LOG) logerror("%s load write shift register %03x\n",cur_live.tm.as_string(),cur_live.shift_reg_write); } else if (BIT(cell_counter, 1) && !BIT(cur_live.cell_counter, 1)) { // clock write shift register cur_live.shift_reg_write <<= 1; cur_live.shift_reg_write &= 0x3ff; if (LOG) logerror("%s write shift << %03x\n",cur_live.tm.as_string(),cur_live.shift_reg_write); } int error = !(BIT(cur_live.e, 3) || ready); if (ready != cur_live.ready) { if (LOG) logerror("%s READY %u\n", cur_live.tm.as_string(),ready); cur_live.ready = ready; syncpoint = true; } if (sync != cur_live.sync) { if (LOG) logerror("%s SYNC %u\n", cur_live.tm.as_string(),sync); cur_live.sync = sync; syncpoint = true; } if (error != cur_live.error) { cur_live.error = error; syncpoint = true; } if (syncpoint) { commit(cur_live.tm); cur_live.tm += m_period; live_delay(RUNNING_SYNCPOINT); return; } cur_live.tm += m_period; break; } case RUNNING_SYNCPOINT: { m_write_ready(cur_live.ready); m_write_sync(cur_live.sync); m_write_error(cur_live.error); cur_live.state = RUNNING; checkpoint(); break; } } } }
int ge_signal2(int value, void *arg, u32 *listpc) { checkpoint(" * ge_signal: %d at %x, listsync: %08x, drawsync: %08x", value, sceGeGetCmd(GE_CMD_AMBIENTCOLOR), sceGeListSync(listid, 1), sceGeDrawSync(1)); checkpoint(" * Continue: %08x", sceGeContinue()); }
void c64h156_device::live_run(const attotime &limit) { if(cur_live.state == IDLE || cur_live.next_state != -1) return; for(;;) { switch(cur_live.state) { case RUNNING: { bool syncpoint = false; if (cur_live.tm > limit) return; int bit = get_next_bit(cur_live.tm, limit); if(bit < 0) return; int cell_counter = cur_live.cell_counter; if (bit) { cur_live.cycle_counter = cur_live.ds; cur_live.cell_counter = 0; } else { cur_live.cycle_counter++; } if (cur_live.cycle_counter == 16) { cur_live.cycle_counter = cur_live.ds; cur_live.cell_counter++; cur_live.cell_counter &= 0xf; } if (!BIT(cell_counter, 1) && BIT(cur_live.cell_counter, 1)) { // read bit cur_live.shift_reg <<= 1; cur_live.shift_reg |= !(BIT(cur_live.cell_counter, 3) || BIT(cur_live.cell_counter, 2)); cur_live.shift_reg &= 0x3ff; if (LOG) logerror("%s read bit %u (%u) >> %03x, oe=%u soe=%u sync=%u byte=%u\n", cur_live.tm.as_string(), cur_live.bit_counter, !(BIT(cur_live.cell_counter, 3) || BIT(cur_live.cell_counter, 2)), cur_live.shift_reg, cur_live.oe, cur_live.soe, cur_live.sync, cur_live.byte); syncpoint = true; } if (BIT(cell_counter, 1) && !BIT(cur_live.cell_counter, 1) && !cur_live.oe) { write_next_bit(BIT(cur_live.shift_reg_write, 7), limit); } int sync = !((cur_live.shift_reg == 0x3ff) && cur_live.oe); if (!sync) { cur_live.bit_counter = 8; } else if (!BIT(cell_counter, 1) && BIT(cur_live.cell_counter, 1) && cur_live.sync) { cur_live.bit_counter++; cur_live.bit_counter &= 0xf; } int byte = !(((cur_live.bit_counter & 7) == 7) && cur_live.soe && !(cur_live.cell_counter & 2)); int load = !(((cur_live.bit_counter & 7) == 7) && ((cur_live.cell_counter & 3) == 3)); if (!load) { if (cur_live.oe) { cur_live.shift_reg_write = cur_live.shift_reg; if (LOG) logerror("%s load write shift register from read shift register %02x\n",cur_live.tm.as_string(),cur_live.shift_reg_write); } else { cur_live.shift_reg_write = cur_live.yb; if (LOG) logerror("%s load write shift register from YB %02x\n",cur_live.tm.as_string(),cur_live.shift_reg_write); } } else if (!BIT(cell_counter, 1) && BIT(cur_live.cell_counter, 1)) { cur_live.shift_reg_write <<= 1; cur_live.shift_reg_write &= 0xff; if (LOG) logerror("%s shift write register << %02x\n", cur_live.tm.as_string(), cur_live.shift_reg_write); } // update signals if (byte != cur_live.byte) { if (!byte || !cur_live.accl) { if (LOG) logerror("%s BYTE %u\n", cur_live.tm.as_string(),byte); cur_live.byte = byte; syncpoint = true; } if (!byte) { cur_live.accl_yb = cur_live.shift_reg & 0xff; } } if (sync != cur_live.sync) { if (LOG) logerror("%s SYNC %u\n", cur_live.tm.as_string(),sync); cur_live.sync = sync; syncpoint = true; } if (syncpoint) { commit(cur_live.tm); cur_live.tm += m_period; live_delay(RUNNING_SYNCPOINT); return; } cur_live.tm += m_period; break; } case RUNNING_SYNCPOINT: { m_write_sync(cur_live.sync); m_write_byte(cur_live.byte); cur_live.state = RUNNING; checkpoint(); break; } } } }
virtual void operator()(goal_ref const & in, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) { bool models_enabled = in->models_enabled(); bool proofs_enabled = in->proofs_enabled(); bool cores_enabled = in->unsat_core_enabled(); ast_manager & m = in->m(); goal_ref_buffer r1; model_converter_ref mc1; proof_converter_ref pc1; expr_dependency_ref core1(m); result.reset(); mc = 0; pc = 0; core = 0; m_t1->operator()(in, r1, mc1, pc1, core1); SASSERT(!is_decided(r1) || (!pc1 && !core1)); // the pc and core of decided goals is 0 unsigned r1_size = r1.size(); SASSERT(r1_size > 0); checkpoint(); if (r1_size == 1) { if (r1[0]->is_decided()) { result.push_back(r1[0]); if (models_enabled) mc = mc1; SASSERT(!pc); SASSERT(!core); return; } goal_ref r1_0 = r1[0]; m_t2->operator()(r1_0, result, mc, pc, core); if (models_enabled) mc = concat(mc1.get(), mc.get()); if (proofs_enabled) pc = concat(pc1.get(), pc.get()); if (cores_enabled) core = m.mk_join(core1.get(), core); } else { if (cores_enabled) core = core1; proof_converter_ref_buffer pc_buffer; model_converter_ref_buffer mc_buffer; sbuffer<unsigned> sz_buffer; goal_ref_buffer r2; for (unsigned i = 0; i < r1_size; i++) { checkpoint(); goal_ref g = r1[i]; r2.reset(); model_converter_ref mc2; proof_converter_ref pc2; expr_dependency_ref core2(m); m_t2->operator()(g, r2, mc2, pc2, core2); if (is_decided(r2)) { SASSERT(r2.size() == 1); if (is_decided_sat(r2)) { // found solution... result.push_back(r2[0]); if (models_enabled) { // mc2 contains the actual model model_ref md; md = alloc(model, m); apply(mc2, md, 0); apply(mc1, md, i); mc = model2model_converter(md.get()); } SASSERT(!pc); SASSERT(!core); return; } else { SASSERT(is_decided_unsat(r2)); // the proof and unsat core of a decided_unsat goal are stored in the node itself. // pc2 and core2 must be 0. SASSERT(!pc2); SASSERT(!core2); if (models_enabled) mc_buffer.push_back(0); if (proofs_enabled) pc_buffer.push_back(proof2proof_converter(m, r2[0]->pr(0))); if (models_enabled || proofs_enabled) sz_buffer.push_back(0); if (cores_enabled) core = m.mk_join(core.get(), r2[0]->dep(0)); } } else { result.append(r2.size(), r2.c_ptr()); if (models_enabled) mc_buffer.push_back(mc2.get()); if (proofs_enabled) pc_buffer.push_back(pc2.get()); if (models_enabled || proofs_enabled) sz_buffer.push_back(r2.size()); if (cores_enabled) core = m.mk_join(core.get(), core2.get()); } } if (result.empty()) { // all subgoals were shown to be unsat. // create an decided_unsat goal with the proof in->reset_all(); proof_ref pr(m); if (proofs_enabled) apply(m, pc1, pc_buffer, pr); SASSERT(cores_enabled || core == 0); in->assert_expr(m.mk_false(), pr, core); core = 0; result.push_back(in.get()); SASSERT(!mc); SASSERT(!pc); SASSERT(!core); } else { if (models_enabled) mc = concat(mc1.get(), mc_buffer.size(), mc_buffer.c_ptr(), sz_buffer.c_ptr()); if (proofs_enabled) pc = concat(pc1.get(), pc_buffer.size(), pc_buffer.c_ptr(), sz_buffer.c_ptr()); SASSERT(cores_enabled || core == 0); } } }
IndexFileDeleter::IndexFileDeleter(Directory* directory, IndexDeletionPolicy* policy, SegmentInfos* segmentInfos, std::ostream* infoStream, DocumentsWriter* docWriter): refCounts( RefCountsType(true,true) ), commits(CommitsType(true)) { this->docWriter = docWriter; this->infoStream = infoStream; if (infoStream != NULL) message( string("init: current segments file is \"") + segmentInfos->getCurrentSegmentFileName() + "\"; deletionPolicy=" + policy->getObjectName()); this->policy = policy; this->directory = directory; CommitPoint* currentCommitPoint = NULL; // First pass: walk the files and initialize our ref // counts: int64_t currentGen = segmentInfos->getGeneration(); const IndexFileNameFilter* filter = IndexFileNameFilter::getFilter(); vector<string> files; if ( !directory->list(&files) ) _CLTHROWA(CL_ERR_IO, (string("cannot read directory ") + directory->toString() + ": list() returned NULL").c_str()); for(size_t i=0;i<files.size();i++) { string& fileName = files.at(i); if (filter->accept(NULL, fileName.c_str()) && fileName.compare(IndexFileNames::SEGMENTS_GEN) != 0) { // Add this file to refCounts with initial count 0: getRefCount(fileName.c_str()); if ( strncmp(fileName.c_str(), IndexFileNames::SEGMENTS, strlen(IndexFileNames::SEGMENTS)) == 0 ) { // This is a commit (segments or segments_N), and // it's valid (<= the max gen). Load it, then // incref all files it refers to: if (SegmentInfos::generationFromSegmentsFileName(fileName.c_str()) <= currentGen) { if (infoStream != NULL) { message("init: load commit \"" + fileName + "\""); } SegmentInfos sis; bool failed = false; try { sis.read(directory, fileName.c_str()); } catch (CLuceneError& e) { if ( e.number() != CL_ERR_IO ){ throw e; } // LUCENE-948: on NFS (and maybe others), if // you have writers switching back and forth // between machines, it's very likely that the // dir listing will be stale and will claim a // file segments_X exists when in fact it // doesn't. So, we catch this and handle it // as if the file does not exist if (infoStream != NULL) { message("init: hit FileNotFoundException when loading commit \"" + fileName + "\"; skipping this commit point32_t"); } failed = true; } if (!failed) { CommitPoint* commitPoint = _CLNEW CommitPoint(this,&sis); if (sis.getGeneration() == segmentInfos->getGeneration()) { currentCommitPoint = commitPoint; } commits.push_back(commitPoint); incRef(&sis, true); } } } } } if (currentCommitPoint == NULL) { // We did not in fact see the segments_N file // corresponding to the segmentInfos that was passed // in. Yet, it must exist, because our caller holds // the write lock. This can happen when the directory // listing was stale (eg when index accessed via NFS // client with stale directory listing cache). So we // try now to explicitly open this commit point32_t: SegmentInfos sis; try { sis.read(directory, segmentInfos->getCurrentSegmentFileName().c_str()); } catch (CLuceneError& e) { if ( e.number() == CL_ERR_IO ){ _CLTHROWA(CL_ERR_CorruptIndex, "failed to locate current segments_N file"); } } if (infoStream != NULL) message("forced open of current segments file " + segmentInfos->getCurrentSegmentFileName()); currentCommitPoint = _CLNEW CommitPoint(this,&sis); commits.push_back(currentCommitPoint); incRef(&sis, true); } // We keep commits list in sorted order (oldest to newest): std::sort(commits.begin(), commits.end(), CommitPoint::sort); // Now delete anything with ref count at 0. These are // presumably abandoned files eg due to crash of // IndexWriter. RefCountsType::iterator it = refCounts.begin(); while(it != refCounts.end()) { char* fileName = it->first; RefCount* rc = it->second; if (0 == rc->count) { if (infoStream != NULL) { message( string("init: removing unreferenced file \"") + fileName + "\""); } deleteFile(fileName); } it++; } // Finally, give policy a chance to remove things on // startup: policy->onInit(commits); // It's OK for the onInit to remove the current commit // point; we just have to checkpoint our in-memory // SegmentInfos to protect those files that it uses: if (currentCommitPoint->deleted) { checkpoint(segmentInfos, false); } deleteCommits(); }
void testIsState(const char *title) { int fg = sceDisplayIsForeground(); int vsync = sceDisplayIsVsync(); int vblank = sceDisplayIsVblank(); checkpoint("%s: foreground=%d, vsync=%d, vblank=%d", title, fg, vsync, vblank); }
int main(int argc, const char* argv[]) { g_log = stdout; db_thread thr; db_thread threads[RTHREADS]; pthread_t tids[RTHREADS]; priv_data pd; mdbinf* mdb = &thr.mdb; int i, rc; db_connection *cons; g_pd = &pd; char commit = 1; MDB_env *menv = NULL; char *lmpath = "lmdb"; MDB_txn *txn; MDB_val key = {1,(void*)"?"}, data = {0,NULL}; MDB_envinfo stat; sqlite3_initialize(); sqlite3_vfs_register(sqlite3_nullvfs(), 1); unlink(lmpath); memset(threads, 0, sizeof(threads)); memset(&thr, 0, sizeof(db_thread)); memset(&pd, 0, sizeof(priv_data)); pd.wmdb = calloc(1,sizeof(mdbinf)); pd.nEnvs = 1; pd.nReadThreads = RTHREADS; pd.nWriteThreads = 1; pd.syncNumbers = calloc(1,sizeof(u64)); pd.actorIndexes = calloc(1,sizeof(atomic_llong)); atomic_init(pd.actorIndexes,0); g_cons = cons = calloc(NCONS, sizeof(db_connection)); g_tsd_cursync = 0; g_tsd_conn = NULL; g_tsd_wmdb = NULL; g_tsd_thread = &thr; if (mdb_env_create(&menv) != MDB_SUCCESS) return -1; if (mdb_env_set_maxdbs(menv,5) != MDB_SUCCESS) return -1; if (mdb_env_set_mapsize(menv,1024*1024*1024) != MDB_SUCCESS) return -1; // Syncs are handled from erlang. if (mdb_env_open(menv, lmpath, MDB_NOSUBDIR|MDB_NOTLS|MDB_NOSYNC, 0664) != MDB_SUCCESS) //MDB_NOSYNC return -1; if (mdb_txn_begin(menv, NULL, 0, &txn) != MDB_SUCCESS) return -1; if (mdb_dbi_open(txn, "info", MDB_INTEGERKEY | MDB_CREATE, &pd.wmdb[0].infodb) != MDB_SUCCESS) return -1; if (mdb_dbi_open(txn, "actors", MDB_CREATE, &pd.wmdb[0].actorsdb) != MDB_SUCCESS) return -1; if (mdb_dbi_open(txn, "log", MDB_CREATE | MDB_DUPSORT | MDB_DUPFIXED | MDB_INTEGERDUP, &pd.wmdb[0].logdb) != MDB_SUCCESS) return -1; if (mdb_dbi_open(txn, "pages", MDB_CREATE | MDB_DUPSORT, &pd.wmdb[0].pagesdb) != MDB_SUCCESS) return -1; if (mdb_txn_commit(txn) != MDB_SUCCESS) return -1; pd.wmdb[0].env = menv; thr.nEnv = 0; thr.isreadonly = 0; thr.mdb.env = menv; thr.mdb.infodb = pd.wmdb[0].infodb; thr.mdb.actorsdb = pd.wmdb[0].actorsdb; thr.mdb.logdb = pd.wmdb[0].logdb; thr.mdb.pagesdb = pd.wmdb[0].pagesdb; thr.maxvalsize = mdb_env_get_maxkeysize(mdb->env); thr.resFrames = alloca((SQLITE_DEFAULT_PAGE_SIZE/thr.maxvalsize + 1)*sizeof(MDB_val)); open_txn(&thr.mdb, MDB_RDONLY); for (i = 0; i < NCONS; i++) { char filename[256]; char commit = 1; g_tsd_conn = &cons[i]; sprintf(filename, "ac%d.db", i); pthread_mutex_init(&cons[i].wal.mtx, NULL); thr.pagesChanged = 0; rc = sqlite3_open(filename,&(cons[i].db)); if(rc != SQLITE_OK) { DBG("Unable to open db"); break; } rc = sqlite3_exec(cons[i].db,"PRAGMA synchronous=0;PRAGMA journal_mode=wal;",NULL,NULL,NULL); if (rc != SQLITE_OK) { DBG("unable to open wal"); break; } cons[i].wal.inProgressTerm = 1; cons[i].wal.inProgressEvnum = 1; rc = sqlite3_exec(cons[i].db,"CREATE TABLE tab (id INTEGER PRIMARY KEY, txt TEXT);" "insert into tab values (1,'aaaa');",NULL,NULL,NULL); if (rc != SQLITE_OK) { DBG("Cant create table"); break; } unlock_write_txn(thr.nEnv, 0, &commit); mdb_txn_reset(thr.mdb.txn); rc = mdb_txn_renew(thr.mdb.txn); if (rc != MDB_SUCCESS) break; rc = mdb_cursor_renew(thr.mdb.txn, mdb->cursorLog); if (rc != MDB_SUCCESS) break; rc = mdb_cursor_renew(thr.mdb.txn, mdb->cursorPages); if (rc != MDB_SUCCESS) break; rc = mdb_cursor_renew(thr.mdb.txn, mdb->cursorInfo); if (rc != MDB_SUCCESS) break; } // mdb_cursor_close(thr.mdb.cursorLog); // mdb_cursor_close(thr.mdb.cursorPages); // mdb_cursor_close(thr.mdb.cursorInfo); // mdb_txn_abort(thr.mdb.txn); for (i = 0; i < RTHREADS; i++) { threads[i].nEnv = 0; threads[i].isreadonly = 0; threads[i].mdb.env = menv; threads[i].mdb.infodb = pd.wmdb[0].infodb; threads[i].mdb.actorsdb = pd.wmdb[0].actorsdb; threads[i].mdb.logdb = pd.wmdb[0].logdb; threads[i].mdb.pagesdb = pd.wmdb[0].pagesdb; threads[i].maxvalsize = mdb_env_get_maxkeysize(mdb->env); pthread_create(&tids[i], NULL, perform, (void *)&threads[i]); } srand((u32)pthread_self() + time(NULL)); for (i = 0; i < 1000*200; i++) { char commit = 1; int j = rand() % NCONS; db_connection *con = &g_cons[j]; char str[100]; if (pthread_mutex_trylock(&con->wal.mtx) != 0) { i--; continue; } if (i % 1000 == 0) printf("w %d\n",i); g_tsd_conn = con; lock_wtxn(thr.nEnv); thr.pagesChanged = 0; if (con->wal.firstCompleteEvnum+10 < con->wal.lastCompleteEvnum) { // printf("CHECKPOINT? %llu %llu\n",con->wal.firstCompleteEvnum,con->wal.lastCompleteEvnum); if (checkpoint(&con->wal, con->wal.lastCompleteEvnum-10) != SQLITE_OK) { printf("Checkpoint failed\n"); break; } } con->wal.inProgressTerm = 1; con->wal.inProgressEvnum = con->wal.lastCompleteEvnum+1; sprintf(str,"INSERT INTO tab VALUES (%d,'VALUE VALUE13456');", i); sqlite3_exec(con->db,str,NULL,NULL,NULL); pthread_mutex_unlock(&con->wal.mtx); unlock_write_txn(thr.nEnv, 0, &commit); mdb_txn_reset(thr.mdb.txn); rc = mdb_txn_renew(thr.mdb.txn); if (rc != MDB_SUCCESS) break; rc = mdb_cursor_renew(thr.mdb.txn, mdb->cursorLog); if (rc != MDB_SUCCESS) break; rc = mdb_cursor_renew(thr.mdb.txn, mdb->cursorPages); if (rc != MDB_SUCCESS) break; rc = mdb_cursor_renew(thr.mdb.txn, mdb->cursorInfo); if (rc != MDB_SUCCESS) break; } unlock_write_txn(thr.nEnv, 1, &commit); for (i = 0; i < RTHREADS; i++) pthread_join(tids[i],NULL); return 1; }
SceUInt cancelHandler(SceUID uid, SceKernelSysClock *scheduled, SceKernelSysClock *actual, void *common) { checkpoint("Inside handler, cancel timer: %08x", sceKernelCancelVTimerHandler(vtimer)); checkpoint("Inside handler, cancel NULL: %08x", sceKernelCancelVTimerHandler(0)); return 0; }
void amiga_fdc::live_run(attotime limit) { if(cur_live.state == IDLE || cur_live.next_state != -1) return; for(;;) { switch(cur_live.state) { case RUNNING: { int bit = cur_live.pll.get_next_bit(cur_live.tm, floppy, limit); if(bit < 0) return; cur_live.shift_reg = (cur_live.shift_reg << 1) | bit; cur_live.bit_counter++; if((adkcon & 0x0200) && !(cur_live.shift_reg & 0x80)) { cur_live.bit_counter--; // Avoid any risk of livelock live_delay(RUNNING_SYNCPOINT); return; } if(cur_live.bit_counter > 8) fatalerror("amiga_fdc::live_run - cur_live.bit_counter > 8"); if(cur_live.bit_counter == 8) { live_delay(RUNNING_SYNCPOINT); return; } if(dskbyt & 0x1000) { if(cur_live.shift_reg != dsksync) { live_delay(RUNNING_SYNCPOINT); return; } } else { if(cur_live.shift_reg == dsksync) { live_delay(RUNNING_SYNCPOINT); return; } } break; } case RUNNING_SYNCPOINT: { if(cur_live.shift_reg == dsksync) { if(adkcon & 0x0400) { if(dma_state == DMA_WAIT_START) { cur_live.bit_counter = 0; if(!(dsklen & 0x3fff)) dma_done(); else dma_write(dsksync); } else if(dma_state != DMA_IDLE) { dma_write(dsksync); cur_live.bit_counter = 0; } else if(cur_live.bit_counter != 8) cur_live.bit_counter = 0; } dskbyt |= 0x1000; address_space *space = machine().device("maincpu")->memory().space(AS_PROGRAM); amiga_custom_w(space, REG_INTREQ, 0x8000 | INTENA_DSKSYN, 0xffff); } else dskbyt &= ~0x1000; if(cur_live.bit_counter == 8) { dskbyt = (dskbyt & 0xff00) | 0x8000 | (cur_live.shift_reg & 0xff); cur_live.bit_counter = 0; switch(dma_state) { case DMA_IDLE: case DMA_WAIT_START: break; case DMA_RUNNING_BYTE_0: dma_value = (cur_live.shift_reg & 0xff) << 8; dma_state = DMA_RUNNING_BYTE_1; break; case DMA_RUNNING_BYTE_1: { dma_value |= cur_live.shift_reg & 0xff; dma_write(dma_value); break; } } } cur_live.state = RUNNING; checkpoint(); break; } } } }
int main (int __argc, char *__argv[]) { peo :: init( __argc, __argv ); if (getNodeRank()==1) std::cout<<"\n\nTest : PSO Global Best\n\n"; rng.reseed (10); RingTopology topologyMig; eoGenContinue < Indi > genContPara (10); eoCombinedContinue <Indi> continuatorPara (genContPara); eoCheckPoint<Indi> checkpoint(continuatorPara); peoEvalFunc<Indi, double, const Indi& > plainEval(f); peoPopEval< Indi > eval(plainEval); eoUniformGenerator < double >uGen (0, 1.); eoInitFixedLength < Indi > random (2, uGen); eoUniformGenerator < double >sGen (-1., 1.); eoVelocityInitFixedLength < Indi > veloRandom (2, sGen); eoFirstIsBestInit < Indi > localInit; eoRealVectorBounds bndsFlight(2,0,1.); eoStandardFlight < Indi > flight(bndsFlight); eoPop < Indi > pop; pop.append (10, random); eoLinearTopology<Indi> topology(2); eoRealVectorBounds bnds(2,-1.,1.); eoStandardVelocity < Indi > velocity (topology,1,0.5,2.,bnds); eoInitializer <Indi> init(eval,veloRandom,localInit,topology,pop); eoPeriodicContinue< Indi > mig_cont( 2 ); peoPSOSelect<Indi> mig_selec(topology); peoGlobalBestVelocity<Indi> mig_replac (2.,velocity); eoContinuator<Indi> cont(mig_cont, pop); eoSelector <Indi, eoPop<Indi> > mig_select (mig_selec,1,pop); eoReplace <Indi, eoPop<Indi> > mig_replace (mig_replac,pop); eoGenContinue < Indi > genContPara2 (10); eoCombinedContinue <Indi> continuatorPara2 (genContPara2); eoCheckPoint<Indi> checkpoint2(continuatorPara2); peoEvalFunc<Indi, double, const Indi& > plainEval2(f); peoPopEval< Indi > eval2(plainEval2); eoUniformGenerator < double >uGen2 (0, 1.); eoInitFixedLength < Indi > random2 (2, uGen2); eoUniformGenerator < double >sGen2 (-1., 1.); eoVelocityInitFixedLength < Indi > veloRandom2 (2, sGen2); eoFirstIsBestInit < Indi > localInit2; eoRealVectorBounds bndsFlight2(2,0,1.); eoStandardFlight < Indi > flight2(bndsFlight2); eoPop < Indi > pop2; pop2.append (10, random2); eoLinearTopology<Indi> topology2(2); eoRealVectorBounds bnds2(2,-1.,1.); eoStandardVelocity < Indi > velocity2 (topology2,1,0.5,2.,bnds2); eoInitializer <Indi> init2(eval2,veloRandom2,localInit2,topology2,pop2); eoPeriodicContinue< Indi > mig_cont2( 2 ); peoPSOSelect<Indi> mig_selec2(topology2); peoGlobalBestVelocity<Indi> mig_replac2 (2.,velocity2); eoContinuator<Indi> cont2(mig_cont2,pop2); eoSelector <Indi, eoPop<Indi> > mig_select2 (mig_selec2,1,pop2); eoReplace <Indi, eoPop<Indi> > mig_replace2 (mig_replac2,pop2); peoAsyncIslandMig< eoPop<Indi>, eoPop<Indi> > mig(cont,mig_select, mig_replace, topologyMig); checkpoint.add( mig ); peoAsyncIslandMig< eoPop<Indi>, eoPop<Indi> > mig2(cont2,mig_select2, mig_replace2, topologyMig); checkpoint2.add( mig2 ); eoSyncEasyPSO <Indi> psa(init,checkpoint,eval, velocity, flight); peoWrapper parallelPSO( psa, pop); eval.setOwner(parallelPSO); mig.setOwner(parallelPSO); eoSyncEasyPSO <Indi> psa2(init2,checkpoint2,eval2, velocity2, flight2); peoWrapper parallelPSO2( psa2, pop2); eval2.setOwner(parallelPSO2); mig2.setOwner(parallelPSO2); peo :: run(); peo :: finalize(); if (getNodeRank()==1) { pop.sort(); pop2.sort(); std::cout << "Final population :\n" << pop << std::endl; std::cout << "Final population :\n" << pop2 << std::endl; } }
int cli_main(int argc, char *argv[]) { int i, work; asl_out_module_t *mod, *m; asl_out_rule_t *r; asl_out_dst_data_t store, *asl_store_dst = NULL; const char *mname = NULL; if (geteuid() != 0) { if (argc == 0) debug = DEBUG_ASL; else debug = DEBUG_STDERR; debug_log(ASL_LEVEL_ERR, "aslmanager must be run by root\n"); exit(1); } module_ttl = DEFAULT_TTL; /* cobble up a dst_data with defaults and parameter settings */ memset(&store, 0, sizeof(store)); store.ttl[LEVEL_ALL] = DEFAULT_TTL; store.all_max = DEFAULT_MAX_SIZE; for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-s")) { if (((i + 1) < argc) && (argv[i + 1][0] != '-')) { store.path = strdup(argv[++i]); asl_store_dst = &store; } } } /* get parameters from asl.conf */ mod = asl_out_module_init(); if (mod != NULL) { for (r = mod->ruleset; r != NULL; r = r->next) { if ((asl_store_dst == NULL) && (r->action == ACTION_OUT_DEST) && (!strcmp(r->dst->path, PATH_ASL_STORE))) asl_store_dst = r->dst; } for (r = mod->ruleset; r != NULL; r = r->next) { if (r->action == ACTION_SET_PARAM) { if (r->query == NULL) _aslmanager_set_param(asl_store_dst, r->options); } } } work = DO_ASLDB | DO_MODULE; for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-a")) { if (((i + 1) < argc) && (argv[i + 1][0] != '-')) asl_store_dst->rotate_dir = strdup(argv[++i]); else asl_store_dst->rotate_dir = strdup(PATH_ASL_ARCHIVE); asl_store_dst->mode = 0400; } else if (!strcmp(argv[i], "-store_ttl")) { if (((i + 1) < argc) && (argv[i + 1][0] != '-')) asl_store_dst->ttl[LEVEL_ALL] = atoi(argv[++i]); } else if (!strcmp(argv[i], "-module_ttl")) { if (((i + 1) < argc) && (argv[i + 1][0] != '-')) module_ttl = atoi(argv[++i]); } else if (!strcmp(argv[i], "-ttl")) { if (((i + 1) < argc) && (argv[i + 1][0] != '-')) module_ttl = asl_store_dst->ttl[LEVEL_ALL] = atoi(argv[++i]); } else if (!strcmp(argv[i], "-size")) { if (((i + 1) < argc) && (argv[i + 1][0] != '-')) asl_store_dst->all_max = asl_str_to_size(argv[++i]); } else if (!strcmp(argv[i], "-checkpoint")) { work |= DO_CHECKPT; } else if (!strcmp(argv[i], "-module")) { work &= ~DO_ASLDB; /* optional name follows -module */ if ((i +1) < argc) { if (argv[i + 1][0] != '-') mname = argv[++i]; } } else if (!strcmp(argv[i], "-asldb")) { work = DO_ASLDB; } else if (!strcmp(argv[i], "-d")) { if (((i + i) < argc) && (argv[i+1][0] != '-')) set_debug(DEBUG_STDERR, argv[++i]); else set_debug(DEBUG_STDERR, NULL); } else if (!strcmp(argv[i], "-dd")) { dryrun = 1; if (((i + i) < argc) && (argv[i+1][0] != '-')) set_debug(DEBUG_STDERR, argv[++i]); else set_debug(DEBUG_STDERR, NULL); } } if (asl_store_dst->path == NULL) asl_store_dst->path = strdup(PATH_ASL_STORE); debug_log(ASL_LEVEL_ERR, "aslmanager starting%s\n", (dryrun == 1) ? " dryrun" : ""); if (work & DO_ASLDB) process_asl_data_store(asl_store_dst); if (work & DO_MODULE) { if (work & DO_CHECKPT) checkpoint(mname); if (mod != NULL) { for (m = mod; m != NULL; m = m->next) { if ((mname == NULL) || ((m->name != NULL) && (!strcmp(m->name, mname)))) { process_module(m); } } } } asl_out_module_free(mod); debug_log(ASL_LEVEL_NOTICE, "----------------------------------------\n"); debug_log(ASL_LEVEL_ERR, "aslmanager finished%s\n", (dryrun == 1) ? " dryrun" : ""); if (asl_aux_fd >= 0) asl_close_auxiliary_file(asl_aux_fd); return 0; }
void testAudioDataVideoSync(int prio) { u32 *buffer = (u32 *)getPsmfPlayerDisplayBuf() + 120; SceUID *psmf = createPsmfPlayerPlaying(TEST_VIDEO_FILENAME, prio); PsmfInfo info = {0}; scePsmfPlayerGetPsmfInfo(psmf, &info); checkpoint(" Last frame is %d", info.lengthTS); memset(buffer, 0, 16); warmUpVideo(psmf); int myVideoPts = 0; int myAudioPts = audioStatus ? 0 : -4180; PsmfVideoData videoData = {0, getPsmfPlayerDisplayBuf()}; for (int i = 0; i < 800; ++i) { u64 pts = 0; scePsmfPlayerGetCurrentPts(psmf, &pts); scePsmfPlayerUpdate(psmf); scePsmfPlayerUpdate(psmf); scePsmfPlayerUpdate(psmf); audioStatus = scePsmfPlayerGetAudioData(psmf, audioData) == 0; videoStatus = scePsmfPlayerGetVideoData(psmf, &videoData) == 0; if (myVideoPts < myAudioPts) videoStatus = scePsmfPlayerGetVideoData(psmf, &videoData) == 0; sceKernelDelayThread(16000); if (audioStatus) myAudioPts += 4180; if (videoStatus) myVideoPts = videoData.displaypts; if (pts >= info.lengthTS - 3003 - 3003) { break; } if (myAudioPts >= info.lengthTS - 3003) { break; } } checkpoint(" * At last frame? (status=%x) pts=%d", scePsmfPlayerGetCurrentStatus(psmf), videoData.displaypts); tryUpdate(" After last frame 1", psmf); tryUpdate(" After last frame 2", psmf); videoStatus = scePsmfPlayerGetVideoData(psmf, &videoData) == 0; testGetAudioData(" Read audio 1", psmf); checkpoint(" * Read frame 1 (status=%x) pts=%d", scePsmfPlayerGetCurrentStatus(psmf), videoData.displaypts); tryUpdate(" After last frame 2", psmf); videoStatus = scePsmfPlayerGetVideoData(psmf, &videoData) == 0; testGetAudioData(" Read audio 2", psmf); checkpoint(" * Read frame 2 (status=%x) pts=%d", scePsmfPlayerGetCurrentStatus(psmf), videoData.displaypts); tryUpdate(" After last frame 3", psmf); videoStatus = scePsmfPlayerGetVideoData(psmf, &videoData) == 0; videoStatus = scePsmfPlayerGetVideoData(psmf, &videoData) == 0; testGetAudioData(" Read audio 3", psmf); checkpoint(" * Read frame 3 (status=%x) pts=%d", scePsmfPlayerGetCurrentStatus(psmf), videoData.displaypts); tryUpdate(" After last frame 4", psmf); }
int main(int argc, char **argv) { initDisplay(); SceUtilitySavedataParam2 param; initStandardSavedataParams(¶m); // First, let's create some savedata. param.mode = (PspUtilitySavedataMode) SCE_UTILITY_SAVEDATA_TYPE_MAKEDATASECURE; param.saveNameList = saveNameList; strcpy(param.saveName, ""); param.dataBuf = savedata; param.dataBufSize = sizeof(savedata); param.dataSize = sizeof(savedata); checkpointExists(¶m); runStandardSavedataLoop(¶m); // A bit more, non-secure mode. param.mode = (PspUtilitySavedataMode) SCE_UTILITY_SAVEDATA_TYPE_WRITEDATA; param.saveNameList = saveNameList; strcpy(param.fileName, "OTHER.BIN"); param.dataBuf = savedata; param.dataBufSize = sizeof(savedata); param.dataSize = sizeof(savedata); checkpointExists(¶m); runStandardSavedataLoop(¶m); // Now the actual sizes call. param.mode = (PspUtilitySavedataMode) SCE_UTILITY_SAVEDATA_TYPE_FILES; param.saveNameList = saveNameList; // NEW / OTHER same? strcpy(param.fileName, "NEW.BIN"); SceUtilitySavedataFileListInfo fileList; memset(&fileList, 0, sizeof(fileList)); SceUtilitySavedataFileListEntry fileListNormal[10]; memset(fileListNormal, 0, sizeof(fileListNormal)); SceUtilitySavedataFileListEntry fileListSecure[10]; memset(fileListSecure, 0, sizeof(fileListSecure)); SceUtilitySavedataFileListEntry fileListSystem[10]; memset(fileListSystem, 0, sizeof(fileListSystem)); fileList.maxNormalEntries = 10; fileList.maxSecureEntries = 10; fileList.maxSystemEntries = 10; fileList.normalEntries = fileListNormal; fileList.secureEntries = fileListSecure; fileList.systemEntries = fileListSystem; param.fileList = &fileList; checkpointExists(¶m); runStandardSavedataLoop(¶m); checkpoint("Result: %08x", param.base.result); checkpointExists(¶m); // TODO: Better way of cleaning up... checkpoint("sceIoRemove: %08x", sceIoRemove("ms0:/PSP/SAVEDATA/TEST99901ABC/DATA.BIN")); checkpoint("sceIoRemove: %08x", sceIoRemove("ms0:/PSP/SAVEDATA/TEST99901ABC/OTHER.BIN")); checkpoint("sceIoRemove: %08x", sceIoRemove("ms0:/PSP/SAVEDATA/TEST99901ABC/PARAM.SFO")); checkpoint("sceIoRmdir: %08x", sceIoRmdir("ms0:/PSP/SAVEDATA/TEST99901ABC")); checkpoint("sceIoRemove: %08x", sceIoRemove("ms0:/PSP/SAVEDATA/TEST99901/DATA.BIN")); checkpoint("sceIoRemove: %08x", sceIoRemove("ms0:/PSP/SAVEDATA/TEST99901/OTHER.BIN")); checkpoint("sceIoRemove: %08x", sceIoRemove("ms0:/PSP/SAVEDATA/TEST99901/PARAM.SFO")); checkpoint("sceIoRmdir: %08x", sceIoRmdir("ms0:/PSP/SAVEDATA/TEST99901")); checkpoint("sceIoRemove: %08x", sceIoRemove("ms0:/PSP/SAVEDATA/TEST99901F1/DATA.BIN")); checkpoint("sceIoRemove: %08x", sceIoRemove("ms0:/PSP/SAVEDATA/TEST99901F1/OTHER.BIN")); checkpoint("sceIoRemove: %08x", sceIoRemove("ms0:/PSP/SAVEDATA/TEST99901F1/PARAM.SFO")); checkpoint("sceIoRmdir: %08x", sceIoRmdir("ms0:/PSP/SAVEDATA/TEST99901F1")); return 0; }
extern "C" int main(int argc, char *argv[]) { int result; void *addr; void *addr1; void *addr3; void *addrs[50]; SceUID uid1 = sceKernelCreateVpl("bottom", 2, 0x4300, 0x100, NULL); SceUID uid2 = sceKernelCreateVpl("middle", 2, 0x4300, 0x100, NULL); SceUID uid3 = sceKernelCreateVpl("top", 2, 0x4300, 0x100, NULL); result = sceKernelAllocateVpl(uid1, 0x10, &addr1, NULL); result = sceKernelAllocateVpl(uid3, 0x10, &addr3, NULL); VplAccounting *acct = (VplAccounting *)((char *)addr3 + 0x18); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[0], NULL); checkpoint("alloc 0"); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[1], NULL); checkpoint("alloc 1"); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[2], NULL); checkpoint("alloc 2"); schedfAcct(acct); schedfVpl(uid2); checkpoint("free 1: %08x", sceKernelFreeVpl(uid2, addrs[1])); schedfAcct(acct); schedfVpl(uid2); checkpoint("free 0: %08x", sceKernelFreeVpl(uid2, addrs[0])); schedfAcct(acct); schedfVpl(uid2); checkpoint("free 2: %08x", sceKernelFreeVpl(uid2, addrs[2])); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[0], NULL); checkpoint("alloc 0"); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[1], NULL); checkpoint("alloc 1"); schedfAcct(acct); schedfVpl(uid2); checkpoint("free 1: %08x", sceKernelFreeVpl(uid2, addrs[1])); schedfAcct(acct); schedfVpl(uid2); checkpoint("free 0: %08x", sceKernelFreeVpl(uid2, addrs[0])); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[0], NULL); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[1], NULL); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[2], NULL); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[3], NULL); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[4], NULL); void *addr2 = addrs[4]; result = sceKernelAllocateVpl(uid2, 0x10, &addrs[5], NULL); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[6], NULL); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[7], NULL); result = sceKernelAllocateVpl(uid2, 0x18, &addrs[8], NULL); schedfAcct(acct); schedfVpl(uid2); checkpoint("free 4: %08x", sceKernelFreeVpl(uid2, addr2)); schedfAcct(acct); schedfVpl(uid2); for (int i = 0; i <= 8; i += 2) { sceKernelFreeVpl(uid2, addrs[i]); checkpoint("free %d", i); schedfAcct(acct); schedfVpl(uid2); } checkpoint("free every other"); schedfAcct(acct); schedfVpl(uid2); for (int i = 8; i >= 0; --i) { sceKernelFreeVpl(uid2, addrs[i]); } checkpoint("free all"); schedfAcct(acct); schedfVpl(uid2); result = sceKernelAllocateVpl(uid2, 0x10, &addrs[0], NULL); checkpoint("alloc 1"); schedfAcct(acct); schedfVpl(uid2); result = sceKernelFreeVpl(uid2, addrs[0]); checkpoint("free 1"); schedfAcct(acct); schedfVpl(uid2); return 0; }
void GameState::deinitialize() { INFO_PRINT << "Initiating POL Cleanup....\n"; networkManager.deinialize(); deinit_ipc_vars(); if ( Plib::systemstate.config.log_script_cycles ) log_all_script_cycle_counts( false ); checkpoint( "cleaning up vars" ); cleanup_vars(); checkpoint( "cleaning up scripts" ); cleanup_scripts(); // scripts remove their listening points when they exit.. // so there should be no listening points to clean up. checkpoint( "cleaning listen points" ); clear_listen_points(); // unload_other_objects unload_intrinsic_weapons(); unload_weapon_templates( ); // unload_itemdesc_scripts for ( auto &elem : desctable ) { elem.second->unload_scripts(); } system_hooks.unload_system_hooks(); configurationbuffer.deinitialize(); Plib::systemstate.deinitialize(); Multi::multidef_buffer.deinitialize(); unload_npc_templates(); //quick and nasty fix until npcdesc usage is rewritten Turley 2012-08-27: moved before objecthash due to npc-method_script cleanup Bscript::UninitObject::ReleaseSharedInstance(); objStorageManager.deinitialize(); display_leftover_objects(); checkpoint( "unloading data" ); unload_data(); guilds.clear(); Clib::MD5_Cleanup(); checkpoint( "misc cleanup" ); global_properties->clear(); menus.clear(); textcmds.clear(); paramtextcmds.clear(); Global_Ignore_CProps.clear(); mime_types.clear(); console_commands.clear(); animation_translates.clear(); tipfilenames.clear(); checkpoint( "end of xmain2" ); #ifdef __linux__ unlink( ( Plib::systemstate.config.pidfile_path + "pol.pid" ).c_str( ) ); #endif }
int32_t upb_pbdecoder_skipunknown(upb_pbdecoder *d, int32_t fieldnum, uint8_t wire_type) { if (fieldnum >= 0) goto have_tag; while (true) { uint32_t tag; CHECK_RETURN(decode_v32(d, &tag)); wire_type = tag & 0x7; fieldnum = tag >> 3; have_tag: if (fieldnum == 0) { seterr(d, "Saw invalid field number (0)"); return upb_pbdecoder_suspend(d); } // TODO: deliver to unknown field callback. switch (wire_type) { case UPB_WIRE_TYPE_32BIT: CHECK_RETURN(skip(d, 4)); break; case UPB_WIRE_TYPE_64BIT: CHECK_RETURN(skip(d, 8)); break; case UPB_WIRE_TYPE_VARINT: { uint64_t u64; CHECK_RETURN(decode_varint(d, &u64)); break; } case UPB_WIRE_TYPE_DELIMITED: { uint32_t len; CHECK_RETURN(decode_v32(d, &len)); CHECK_RETURN(skip(d, len)); break; } case UPB_WIRE_TYPE_START_GROUP: CHECK_SUSPEND(pushtagdelim(d, -fieldnum)); break; case UPB_WIRE_TYPE_END_GROUP: if (fieldnum == -d->top->groupnum) { pop(d); } else if (fieldnum == d->top->groupnum) { return DECODE_ENDGROUP; } else { seterr(d, "Unmatched ENDGROUP tag."); return upb_pbdecoder_suspend(d); } break; default: seterr(d, "Invalid wire type"); return upb_pbdecoder_suspend(d); } if (d->top->groupnum >= 0) { return DECODE_OK; } if (d->ptr == d->delim_end) { seterr(d, "Enclosing submessage ended in the middle of value or group"); // Unlike most errors we notice during parsing, right now we have consumed // all of the user's input. // // There are three different options for how to handle this case: // // 1. decode() = short count, error = set // 2. decode() = full count, error = set // 3. decode() = full count, error NOT set, short count and error will // be reported on next call to decode() (or end()) // // (1) and (3) have the advantage that they preserve the invariant that an // error occurs iff decode() returns a short count. // // (2) and (3) have the advantage of reflecting the fact that all of the // bytes were in fact parsed (and possibly delivered to the unknown field // handler, in the future when that is supported). // // (3) requires extra state in the decode (a place to store the "permanent // error" that we should return for all subsequent attempts to decode). // But we likely want this anyway. // // Right now we do (1), thanks to the fact that we checkpoint *after* this // check. (3) may be a better choice long term; unclear at the moment. return upb_pbdecoder_suspend(d); } checkpoint(d); } }
void main_function() { const unsigned SIZE = 8; unsigned i, j; eoBooleanGenerator gen; Chrom chrom(SIZE), chrom2; chrom.fitness(binary_value(chrom)); chrom2.fitness(binary_value(chrom2)); std::cout << "chrom: " << chrom << std::endl; chrom[0] = chrom[SIZE - 1] = true; chrom.fitness(binary_value(chrom)); std::cout << "chrom: " << chrom << std::endl; chrom[0] = chrom[SIZE - 1] = false; chrom.fitness(binary_value(chrom)); std::cout << "chrom: " << chrom << std::endl; chrom[0] = chrom[SIZE - 1] = true; chrom.fitness(binary_value(chrom)); std::cout << "chrom.className() = " << chrom.className() << std::endl; std::cout << "chrom: " << chrom << std::endl << "chrom2: " << chrom2 << std::endl; std::ostringstream os; os << chrom; std::istringstream is(os.str()); is >> chrom2; chrom.fitness(binary_value(chrom2)); std::cout << "\nTesting reading, writing\n"; std::cout << "chrom: " << chrom << "\nchrom2: " << chrom2 << '\n'; std::fill(chrom.begin(), chrom.end(), false); std::cout << "--------------------------------------------------" << std::endl << "eoMonOp's aplied to .......... " << chrom << std::endl; eoInitFixedLength<Chrom> random(chrom.size(), gen); random(chrom); chrom.fitness(binary_value(chrom)); std::cout << "after eoBinRandom ............ " << chrom << std::endl; eoOneBitFlip<Chrom> bitflip; bitflip(chrom); chrom.fitness(binary_value(chrom)); std::cout << "after eoBitFlip .............. " << chrom << std::endl; eoBitMutation<Chrom> mutation(0.5); mutation(chrom); chrom.fitness(binary_value(chrom)); std::cout << "after eoBinMutation(0.5) ..... " << chrom << std::endl; eoBitInversion<Chrom> inversion; inversion(chrom); chrom.fitness(binary_value(chrom)); std::cout << "after eoBinInversion ......... " << chrom << std::endl; eoBitNext<Chrom> next; next(chrom); chrom.fitness(binary_value(chrom)); std::cout << "after eoBinNext .............. " << chrom << std::endl; eoBitPrev<Chrom> prev; prev(chrom); chrom.fitness(binary_value(chrom)); std::cout << "after eoBinPrev .............. " << chrom << std::endl; std::fill(chrom.begin(), chrom.end(), false); chrom.fitness(binary_value(chrom)); std::fill(chrom2.begin(), chrom2.end(), true); chrom2.fitness(binary_value(chrom2)); std::cout << "--------------------------------------------------" << std::endl << "eoBinOp's aplied to ... " << chrom << " " << chrom2 << std::endl; eo1PtBitXover<Chrom> xover; std::fill(chrom.begin(), chrom.end(), false); std::fill(chrom2.begin(), chrom2.end(), true); xover(chrom, chrom2); chrom.fitness(binary_value(chrom)); chrom2.fitness(binary_value(chrom2)); std::cout << "eoBinCrossover ........ " << chrom << " " << chrom2 << std::endl; for (i = 1; i < SIZE; i++) { eoNPtsBitXover<Chrom> nxover(i); std::fill(chrom.begin(), chrom.end(), false); std::fill(chrom2.begin(), chrom2.end(), true); nxover(chrom, chrom2); chrom.fitness(binary_value(chrom)); chrom2.fitness(binary_value(chrom2)); std::cout << "eoBinNxOver(" << i << ") ........ " << chrom << " " << chrom2 << std::endl; } for (i = 1; i < SIZE / 2; i++) for (j = 1; j < SIZE / 2; j++) { eoBitGxOver<Chrom> gxover(i, j); std::fill(chrom.begin(), chrom.end(), false); std::fill(chrom2.begin(), chrom2.end(), true); gxover(chrom, chrom2); chrom.fitness(binary_value(chrom)); chrom2.fitness(binary_value(chrom2)); std::cout << "eoBinGxOver(" << i << ", " << j << ") ..... " << chrom << " " << chrom2 << std::endl; } // test SGA algorithm eoGenContinue<Chrom> continuator1(50); eoFitContinue<Chrom> continuator2(65535.f); eoCombinedContinue<Chrom> continuator(continuator1, continuator2); eoCheckPoint<Chrom> checkpoint(continuator); eoStdoutMonitor monitor; checkpoint.add(monitor); eoSecondMomentStats<Chrom> stats; monitor.add(stats); checkpoint.add(stats); eoProportionalSelect<Chrom> select; eoEvalFuncPtr<Chrom> eval(binary_value); eoSGA<Chrom> sga(select, xover, 0.8f, bitflip, 0.1f, eval, checkpoint); eoInitFixedLength<Chrom> init(16, gen); eoPop<Chrom> pop(100, init); apply<Chrom>(eval, pop); sga(pop); pop.sort(); std::cout << "Population " << pop << std::endl; std::cout << "\nBest: " << pop[0].fitness() << '\n'; /* Commented this out, waiting for a definite decision what to do with the mOp's // Check multiOps eoMultiMonOp<Chrom> mOp( &next ); mOp.adOp( &bitflip ); std::cout << "before multiMonOp............ " << chrom << std::endl; mOp( chrom ); std::cout << "after multiMonOp .............. " << chrom << std::endl; eoBinGxOver<Chrom> gxover(2, 4); eoMultiBinOp<Chrom> mbOp( &gxover ); mOp.adOp( &bitflip ); std::cout << "before multiBinOp............ " << chrom << " " << chrom2 << std::endl; mbOp( chrom, chrom2 ); std::cout << "after multiBinOp .............. " << chrom << " " << chrom2 <<std::endl; */ }
int main(int argc, char** argv) { struct tree* tree; ALLOC_PTR(tree); assert(tree != 0); tree_ini(tree, 50); // int tree_node_add(struct tree* vtree, int value) int rc = tree_node_add(tree, 10); rc = tree_node_add(tree, 20); rc = tree_node_add(tree, 1); rc = tree_node_add(tree, 4); //fail rc = tree_node_add(tree, 120); rc = tree_node_add(tree, 110); rc = tree_node_add(tree, 130); rc = tree_node_add(tree, 100); //fail rc = tree_node_add(tree, 3); //fail inorder_tree_walk(tree->root); size_t start = 0; size_t finish = 0; struct node* t = 0; start = checkpoint(); t = tree_search(tree->root, 120); finish = checkpoint(); printf("\nrecursuve search %i\n", t->value); printf("time recursive: %zu\n", finish - start); start = finish = 0; start = checkpoint(); t = iterative_tree_search(tree->root, 120); finish = checkpoint(); printf("\niterative search %i\n", t->value); printf("time iterative: %zu\n", finish - start); t = tree_minimum(tree->root); printf("minimum: %i \n", t->value); t = tree_maximum(tree->root); printf("maximum: %i \n", t->value); struct node* temp; ALLOC_PTR(temp); assert(temp != 0); temp->value = 64; temp->right = 0; temp->left = 0; //T - дерево, z - указатель на вставляемую вершину tree_insert(tree, temp); inorder_tree_walk(tree->root); /* tree = tree_node_add(tree, 1, 1); //bad bug tree = tree_node_add(tree, 4, 1); tree = tree_node_add(tree, 2, 0); tree = tree_node_add(tree, 3, 0); tree = tree_node_add(tree, 4, 1); */ //tree_print(tree); /* tree_fini(tree); */ return 0; }
int main(int argc, char *argv[]) { checkpoint(" Create test file 1: %08x", makeTestFile("ms0:/__iorename_test1.txt")); checkpoint(" Create test file 2: %08x", makeTestFile("ms0:/__iorename_test2.txt")); checkpoint(" Create test file 3: %08x", makeTestFile("ms0:/__iorename_test3.txt")); checkpointNext("Rename behavior:"); checkpoint(" sceIoChdir host0:/: %08x", sceIoChdir("host0:/")); checkpoint(" sceIoRename abs -> abs: %08x", sceIoRename("ms0:/__iorename_test1.txt", "ms0:/__iorename_test1a.txt")); checkpoint(" sceIoRename abs -> abs overwrite: %08x", sceIoRename("ms0:/__iorename_test1a.txt", "ms0:/__iorename_test2.txt")); checkpoint(" sceIoChdir ms0:/PSP: %08x", sceIoChdir("ms0:/PSP")); checkpoint(" sceIoRename rel -> rel: %08x", sceIoRename("../__iorename_test2.txt", "__iorename_test2a.txt")); checkpoint(" renamed to: %s", fileExists("ms0:/__iorename_test2a.txt") ? "origin dir" : (fileExists("ms0:/PSP/__iorename_test2a.txt") ? "cwd" : "nowhere?")); checkpoint(" sceIoRename rel -> abs: %08x", sceIoRename("../__iorename_test3.txt", "ms0:/PSP/__iorename_test3a.txt")); checkpoint(" renamed to: %s", fileExists("ms0:/__iorename_test3a.txt") ? "origin dir" : (fileExists("ms0:/PSP/__iorename_test3a.txt") ? "dest dir" : "nowhere?")); // Okay, we've moved everything around a lot, let's clean it up. sceIoRemove("ms0:/__iorename_test1.txt"); sceIoRemove("ms0:/__iorename_test1a.txt"); sceIoRemove("ms0:/__iorename_test2.txt"); sceIoRemove("ms0:/__iorename_test2a.txt"); sceIoRemove("ms0:/__iorename_test3.txt"); sceIoRemove("ms0:/__iorename_test3a.txt"); sceIoRemove("ms0:/PSP/__iorename_test2a.txt"); sceIoRemove("ms0:/PSP/__iorename_test3a.txt"); checkpointNext("Error handling:"); checkpoint(" Recreate test file 1: %08x", makeTestFile("ms0:/__iorename_test1.txt")); checkpoint(" Recreate test file 2: %08x", makeTestFile("ms0:/__iorename_test2.txt")); checkpoint(" sceIoRename cross device: %08x", sceIoRename("ms0:/__iorename_test1.txt", "host0:/__iorename_test1.txt")); checkpoint(" sceIoRename bad dest path: %08x", sceIoRename("ms0:/__iorename_test2.txt", "ms0:/__DOES_NOT_EXIST/__iorename_test2.txt")); checkpoint(" sceIoRename bad src path: %08x", sceIoRename("ms0:/_DOES_NOT_EXIST/__iorename_test3.txt", "ms0:/__iorename_test3.txt")); checkpoint(" sceIoRename bad src file: %08x", sceIoRename("ms0:/__iorename_test3.txt", "ms0:/__iorename_test3a.txt")); checkpoint(" sceIoRename same path: %08x", sceIoRename("ms0:/__iorename_test1.txt", "ms0:/__iorename_test1.txt")); // Crash. //checkpoint(" sceIoRename NULL -> rel", sceIoRename(NULL, "test.txt")); //checkpoint(" sceIoRename rel -> NULL", sceIoRename("test.txt", NULL)); //checkpoint(" sceIoRename NULL -> NULL", sceIoRename(NULL, NULL)); checkpoint(" sceIoRename wild -> rel: %08x", sceIoRename("ms0:/__iorename_test*.txt", "ms0:/__iorename_test1a.txt")); checkpoint(" sceIoRename rel -> wild: %08x", sceIoRename("ms0:/__iorename_test1.txt", "ms0:/__iorename_test*.txt")); checkpoint(" sceIoRename wild -> wild: %08x", sceIoRename("ms0:/__iorename_test?.txt", "ms0:/__iorename_test?.txt")); sceIoRemove("ms0:/__iorename_test1.txt"); sceIoRemove("ms0:/__iorename_test2.txt"); sceIoRemove("host0:/__iorename_test1.txt"); return 0; }
void c8050_fdc_t::live_run(const attotime &limit) { if(cur_live.state == IDLE || cur_live.next_state != -1) return; for(;;) { switch(cur_live.state) { case RUNNING: { bool syncpoint = false; if (cur_live.tm > limit) return; // read bit int bit = 0; if (cur_live.rw_sel) { bit = pll_get_next_bit(cur_live.tm, get_floppy(), limit); if(bit < 0) return; } // write bit int write_bit = BIT(cur_live.shift_reg_write, 9); if (!cur_live.rw_sel) { // TODO WPS /* write precompensation UA5.A = UM6.Qc UA5.B = !(!(!BRDY && UM6.Qa) && !(BRDY && E7)) UA5.C0 = UA4.Qb = bit clock delayed 333ns UA5.C1 = UA4.Qa = bit clock delayed 166ns UA5.C2 = UA4.Qc = bit clock delayed 499ns UA5.C3 = UA5.Qb = bit clock delayed 333ns DATA OUT = !(!BITCLK || !(UA5.Y && !(WRITE_ENABLE && !UM6.Qb))) */ if (pll_write_next_bit(write_bit, cur_live.tm, get_floppy(), limit)) return; } // clock read shift register cur_live.shift_reg <<= 1; cur_live.shift_reg |= bit; cur_live.shift_reg &= 0x3ff; // sync int sync = !((cur_live.shift_reg == 0x3ff) && cur_live.rw_sel); // bit counter if (!sync) { cur_live.bit_counter = 0; } else if (cur_live.sync) { cur_live.bit_counter++; if (cur_live.bit_counter == 10) { cur_live.bit_counter = 0; } } // GCR decoder if (cur_live.rw_sel) { cur_live.i = (cur_live.rw_sel << 10) | cur_live.shift_reg; } else { cur_live.i = (cur_live.rw_sel << 10) | ((cur_live.pi & 0xf0) << 1) | (cur_live.mode_sel << 4) | (cur_live.pi & 0x0f); } cur_live.e = m_gcr_rom->base()[cur_live.i]; // byte ready int ready = !(cur_live.bit_counter == 9); // 74190 _RC, should be triggered on the falling edge of the clock int brdy = ready; // 74190 TC // GCR error int error = !(ready || BIT(cur_live.e, 3)); if (LOG_BITS) { if (cur_live.rw_sel) { logerror("%s cyl %u bit %u sync %u bc %u sr %03x i %03x e %02x\n",cur_live.tm.as_string(),get_floppy()->get_cyl(),bit,sync,cur_live.bit_counter,cur_live.shift_reg,cur_live.i,cur_live.e); } else { logerror("%s cyl %u writing bit %u bc %u sr %03x i %03x e %02x\n",cur_live.tm.as_string(),get_floppy()->get_cyl(),write_bit,cur_live.bit_counter,cur_live.shift_reg_write,cur_live.i,cur_live.e); } } if (!ready) { // load write shift register cur_live.shift_reg_write = GCR_ENCODE(cur_live.e, cur_live.i); if (LOG_BITS) logerror("%s load write shift register %03x\n",cur_live.tm.as_string(),cur_live.shift_reg_write); } else { // clock write shift register cur_live.shift_reg_write <<= 1; cur_live.shift_reg_write &= 0x3ff; } if (ready != cur_live.ready) { if (cur_live.rw_sel && !ready) if (LOG) logerror("%s READY %u : %02x\n", cur_live.tm.as_string(),ready,GCR_DECODE(cur_live.e, cur_live.i)); cur_live.ready = ready; syncpoint = true; } if (brdy != cur_live.brdy) { if (LOG_MORE) logerror("%s BRDY %u\n", cur_live.tm.as_string(), brdy); cur_live.brdy = brdy; syncpoint = true; } if (sync != cur_live.sync) { if (LOG) logerror("%s SYNC %u\n", cur_live.tm.as_string(), sync); cur_live.sync = sync; syncpoint = true; } if (error != cur_live.error) { if (LOG_MORE) logerror("%s ERROR %u\n", cur_live.tm.as_string(), error); cur_live.error = error; syncpoint = true; } if (syncpoint) { live_delay(RUNNING_SYNCPOINT); return; } break; } case RUNNING_SYNCPOINT: { m_write_ready(cur_live.ready); m_write_brdy(cur_live.brdy); m_write_sync(cur_live.sync); m_write_error(cur_live.error); cur_live.state = RUNNING; checkpoint(); break; } } } }
void operator()(goal_ref const & g, goal_ref_buffer & result, model_converter_ref & mc, proof_converter_ref & pc, expr_dependency_ref & core) { SASSERT(g->is_well_sorted()); mc = 0; pc = 0; core = 0; fail_if_proof_generation("occf", g); bool produce_models = g->models_enabled(); tactic_report report("occf", *g); m_mc = 0; ptr_vector<expr> new_lits; cnstr2bvar c2b; unsigned sz = g->size(); for (unsigned i = 0; i < sz; i++) { checkpoint(); expr * f = g->form(i); expr_dependency * d = g->dep(i); if (!m.is_or(f)) continue; app * cls = to_app(f); if (!is_target(cls)) continue; if (produce_models && !m_mc) { m_mc = alloc(filter_model_converter, m); mc = m_mc; } expr * keep = 0; new_lits.reset(); unsigned num = cls->get_num_args(); for (unsigned j = 0; j < num; j++) { expr * l = cls->get_arg(j); if (is_constraint(l)) { expr * new_l = get_aux_lit(c2b, l, g); if (new_l != 0) { new_lits.push_back(new_l); } else if (keep == 0) { keep = l; } else { new_l = mk_aux_lit(c2b, l, produce_models, g); new_lits.push_back(new_l); } } else { new_lits.push_back(l); } } if (keep != 0) new_lits.push_back(keep); g->update(i, m.mk_or(new_lits.size(), new_lits.c_ptr()), 0, d); } g->inc_depth(); result.push_back(g.get()); TRACE("occf", g->display(tout););
void amiga_fdc::live_run(const attotime &limit) { amiga_state *state = machine().driver_data<amiga_state>(); if(cur_live.state == IDLE || cur_live.next_state != -1) return; for(;;) { switch(cur_live.state) { case RUNNING: { if(!(dskbyt & 0x2000)) { int bit = cur_live.pll.get_next_bit(cur_live.tm, floppy, limit); if(bit < 0) return; cur_live.shift_reg = (cur_live.shift_reg << 1) | bit; cur_live.bit_counter++; if((adkcon & 0x0200) && !(cur_live.shift_reg & 0x80)) { cur_live.bit_counter--; // Avoid any risk of livelock live_delay(RUNNING_SYNCPOINT); return; } if(cur_live.bit_counter > 8) fatalerror("amiga_fdc::live_run - cur_live.bit_counter > 8\n"); if(cur_live.bit_counter == 8) { live_delay(RUNNING_SYNCPOINT); return; } if(dskbyt & 0x1000) { if(cur_live.shift_reg != dsksync) { live_delay(RUNNING_SYNCPOINT); return; } } else { if(cur_live.shift_reg == dsksync) { live_delay(RUNNING_SYNCPOINT); return; } } } else { int bit = (dma_state == DMA_RUNNING_BYTE_0 ? 15 : 7) - cur_live.bit_counter; if(cur_live.pll.write_next_bit((dma_value >> bit) & 1, cur_live.tm, floppy, limit)) return; cur_live.bit_counter++; if(cur_live.bit_counter > 8) fatalerror("amiga_fdc::live_run - cur_live.bit_counter > 8\n"); if(cur_live.bit_counter == 8) { live_delay(RUNNING_SYNCPOINT); return; } } break; } case RUNNING_SYNCPOINT: { if(!(dskbyt & 0x2000)) { if(cur_live.shift_reg == dsksync) { if(adkcon & 0x0400) { if(dma_state == DMA_WAIT_START) { cur_live.bit_counter = 0; if(!(dsklen & 0x3fff)) dma_done(); else if(dsklen & 0x4000) { dskbyt |= 0x2000; cur_live.bit_counter = 0; dma_value = dma_read(); } else dma_write(dsksync); } else if(dma_state != DMA_IDLE) { dma_write(dsksync); cur_live.bit_counter = 0; } else if(cur_live.bit_counter != 8) cur_live.bit_counter = 0; } dskbyt |= 0x1000; state->custom_chip_w(REG_INTREQ, INTENA_SETCLR | INTENA_DSKSYN); } else dskbyt &= ~0x1000; if(cur_live.bit_counter == 8) { dskbyt = (dskbyt & 0xff00) | 0x8000 | (cur_live.shift_reg & 0xff); cur_live.bit_counter = 0; switch(dma_state) { case DMA_IDLE: case DMA_WAIT_START: break; case DMA_RUNNING_BYTE_0: dma_value = (cur_live.shift_reg & 0xff) << 8; dma_state = DMA_RUNNING_BYTE_1; break; case DMA_RUNNING_BYTE_1: { dma_value |= cur_live.shift_reg & 0xff; dma_write(dma_value); break; } } } } else { if(cur_live.bit_counter != 8) fatalerror("amiga_fdc::live_run - cur_live.bit_counter != 8\n"); cur_live.bit_counter = 0; switch(dma_state) { case DMA_IDLE: case DMA_WAIT_START: break; case DMA_RUNNING_BYTE_0: dma_state = DMA_RUNNING_BYTE_1; break; case DMA_RUNNING_BYTE_1: { dma_value = dma_read(); break; } } } cur_live.state = RUNNING; checkpoint(); break; } } } }
void ConnectionsPerformanceTest::runSpatialPoolerTest(UInt numCells, UInt numInputs, UInt w, UInt numWinners, string label) { clock_t timer = clock(); Connections connections(numCells, 1, numInputs); Cell cell; Segment segment; vector<Cell> sdr; Activity activity; // Initialize for (UInt c = 0; c < numCells; c++) { cell = Cell(c); segment = connections.createSegment(c); for (UInt i = 0; i < numInputs; i++) { connections.createSynapse(segment, i, (Permanence)rand()/RAND_MAX); } } checkpoint(timer, label + ": initialize"); // Learn vector<Cell> winnerCells; SynapseData synapseData; Permanence permanence; for (int i = 0; i < 500; i++) { sdr = randomSDR(numInputs, w); activity = connections.computeActivity(sdr, 0.5, 0); winnerCells = computeSPWinnerCells(numWinners, activity); for (Cell winnerCell : winnerCells) { segment = Segment(0, winnerCell); for (Synapse synapse : connections.synapsesForSegment(segment)) { synapseData = connections.dataForSynapse(synapse); permanence = synapseData.permanence; if (find(sdr.begin(), sdr.end(), synapseData.presynapticCell) != sdr.end()) { permanence += 0.2; } else { permanence -= 0.1; } permanence = max(permanence, (Permanence)0); permanence = min(permanence, (Permanence)1); // TODO (Question): Remove synapses with 0 permanence? connections.updateSynapsePermanence(synapse, permanence); } } } checkpoint(timer, label + ": initialize + learn"); // Test for (int i = 0; i < 500; i++) { sdr = randomSDR(numInputs, w); activity = connections.computeActivity(sdr, 0.5, 0); winnerCells = computeSPWinnerCells(numWinners, activity); } checkpoint(timer, label + ": initialize + learn + test"); }
/* this function (a) undoes what make_move() did and (b) determines the next move sequence by calling checkpoint() */ void restore(system_t *system) { // restore the remaining observables memcpy(system->observables, system->checkpoint->observables, sizeof(observables_t)); /* restore state by undoing the steps of make_move() */ switch (system->checkpoint->movetype) { case MOVETYPE_INSERT: /* take altered out of the list */ if (!system->checkpoint->head) { /* handle the case where we inserted at the head of the list */ system->molecules = system->molecules->next; } else { system->checkpoint->head->next = system->checkpoint->tail; } unupdate_pairs_insert(system); free_molecule(system, system->checkpoint->molecule_altered); system->checkpoint->molecule_altered = NULL; /* Insurance against memory errors */ //reset atom and molecule id's enumerate_particles(system); break; case MOVETYPE_REMOVE: /* put backup back into the list */ if (!system->checkpoint->head) { system->molecules = system->checkpoint->molecule_backup; } else { system->checkpoint->head->next = system->checkpoint->molecule_backup; } system->checkpoint->molecule_backup->next = system->checkpoint->tail; unupdate_pairs_remove(system); system->checkpoint->molecule_backup = NULL; //reset atom and molecule id's enumerate_particles(system); break; case MOVETYPE_VOLUME: revert_volume_change(system); break; default: /* link the backup into the working list again */ if (!system->checkpoint->head) system->molecules = system->checkpoint->molecule_backup; else system->checkpoint->head->next = system->checkpoint->molecule_backup; system->checkpoint->molecule_backup->next = system->checkpoint->tail; free_molecule(system, system->checkpoint->molecule_altered); system->checkpoint->molecule_altered = NULL; /* Insurance against memory errors */ system->checkpoint->molecule_backup = NULL; } /* renormalize charges */ if (system->spectre) spectre_charge_renormalize(system); /* establish the previous checkpoint again */ checkpoint(system); return; }
void ConnectionsPerformanceTest::runTemporalMemoryTest(UInt numColumns, UInt w, int numSequences, int numElements, string label) { clock_t timer = clock(); // Initialize TemporalMemory tm; vector<UInt> columnDim; columnDim.push_back(numColumns); tm.initialize(columnDim); checkpoint(timer, label + ": initialize"); // Learn vector< vector< vector<Cell> > >sequences; vector< vector<Cell> >sequence; vector<Cell> sdr; for (int i = 0; i < numSequences; i++) { for (int j = 0; j < numElements; j++) { sdr = randomSDR(numColumns, w); sequence.push_back(sdr); } sequences.push_back(sequence); } for (int i = 0; i < 5; i++) { for (auto sequence : sequences) { for (auto sdr : sequence) { feedTM(tm, sdr); tm.reset(); } } } checkpoint(timer, label + ": initialize + learn"); // Test for (auto sequence : sequences) { for (auto sdr : sequence) { feedTM(tm, sdr, false); tm.reset(); } } checkpoint(timer, label + ": initialize + learn + test"); }
void runReferTests() { SceKernelThreadInfo2 info; int i; SceUID delayThread = sceKernelCreateThread("delay", &delayFunc, sceKernelGetThreadCurrentPriority(), 0x1000, PSP_THREAD_ATTR_VFPU, NULL); SceUID deletedThread = sceKernelCreateThread("deleted", &delayFunc, sceKernelGetThreadCurrentPriority(), 0x1000, 0, NULL); sceKernelDeleteThread(deletedThread); info.size = sizeof(info); checkpointNext("Thread IDs:"); checkpoint(" NULL: %08x", sceKernelReferThreadStatus(0, &info)); checkpoint(" Current: %08x", sceKernelReferThreadStatus(sceKernelGetThreadId(), &info)); checkpoint(" Deleted: %08x", sceKernelReferThreadStatus(deletedThread, &info)); checkpoint(" Invalid: %08x", sceKernelReferThreadStatus(0xDEADBEEF, &info)); // Crashes. //checkpointNext("sceKernelReferThreadStatus info ptr:"); //checkpoint(" NULL info: %08x", sceKernelReferThreadStatus(0, NULL)); checkpointNext("Sizes:"); int sizes[] = {-1, 0, 1, 2, 3, 4, 5, 8, 16, 32, 64, 80, 82, 108, 128, 1024}; for (i = 0; i < ARRAY_SIZE(sizes); ++i) { memset(&info, 0xff, sizeof(info)); info.size = sizes[i]; int result = sceKernelReferThreadStatus(0, &info); checkpoint(" %d: %08x => %d (exit: %x)", sizes[i], result, info.size, info.exitStatus); } info.size = sizeof(info); sceKernelStartThread(delayThread, 0, NULL); sceKernelReferThreadStatus(delayThread, &info); checkpointNext("Values:"); schedfThreadInfo(&info, &delayFunc); SceUID slumberThread = sceKernelCreateThread("slumber", &slumberFunc, sceKernelGetThreadCurrentPriority() - 1, 0x1000, 0, NULL); checkpoint(" slumber before start:"); sceKernelReferThreadStatus(slumberThread, &info); schedfThreadInfo(&info, &slumberFunc); sceKernelStartThread(slumberThread, 0, NULL); checkpoint(" started slumber"); checkpoint(" slumber after start:"); sceKernelReferThreadStatus(slumberThread, &info); schedfThreadInfo(&info, &slumberFunc); sceKernelTerminateThread(slumberThread); checkpoint(" terminated slumber"); checkpoint(" slumber after terminate:"); sceKernelReferThreadStatus(slumberThread, &info); schedfThreadInfo(&info, &slumberFunc); sceKernelStartThread(slumberThread, 0, NULL); checkpoint(" started slumber"); checkpoint(" slumber after start:"); sceKernelReferThreadStatus(slumberThread, &info); schedfThreadInfo(&info, &slumberFunc); checkpoint(" woke slumber: %08x", sceKernelWakeupThread(slumberThread)); checkpoint(" slumber after wake:"); sceKernelReferThreadStatus(slumberThread, &info); schedfThreadInfo(&info, &slumberFunc); sceKernelTerminateDeleteThread(slumberThread); checkpoint(" terminated and deleted slumber"); // TODO: Test more cases. flushschedf(); }
qint64 QBenchmarkCallgrindMeasurer::stop() { return checkpoint(); }
int ge_finish(int value, void *arg, u32 *listpc) { checkpoint(" * ge_finish: %d at %x, listsync: %08x, drawsync: %08x", value, sceGeGetCmd(GE_CMD_AMBIENTCOLOR), sceGeListSync(listid, 1), sceGeDrawSync(1)); }
int main(int argc, char **argv) { void *tmp = haha_this_sux(); checkpoint(); return 0; }