void Engine::solve(Problem *p) { problem = p; init(); so.time_out += time(NULL); init_time = wallClockTime() - start_time; base_memory = memUsed(); if (!so.parallel) { // sequential status = search(); if (status == RES_GUN) { if (solutions > 0) printf("==========\n"); else printf("=====UNSATISFIABLE=====\n"); } } else { // parallel if (so.thread_no == -1) master.solve(); else slave.solve(); if (so.thread_no == -1 && master.status == RES_GUN) printf("==========\n"); } if (so.verbosity >= 1) printStats(); if (so.parallel) master.finalizeMPI(); }
void printStats(Solver& solver) { double cpu_time = cpuTime(); uint64_t mem_used = memUsed(); reportf("restarts : %lld\n", solver.starts); reportf("conflicts : %-12lld (%.0f /sec)\n", solver.conflicts , solver.conflicts /cpu_time); reportf("decisions : %-12lld (%4.2f %% random) (%.0f /sec)\n", solver.decisions, (float)solver.rnd_decisions*100 / (float)solver.decisions, solver.decisions /cpu_time); reportf("propagations : %-12lld (%.0f /sec)\n", solver.propagations, solver.propagations/cpu_time); reportf("conflict literals : %-12lld (%4.2f %% deleted)\n", solver.tot_literals, (solver.max_literals - solver.tot_literals)*100 / (double)solver.max_literals); if (mem_used != 0) reportf("Memory used : %.2f MB\n", mem_used / 1048576.0); reportf("CPU time : %g s\n", cpu_time); }
void OpenSMTContext::PrintResult( const lbool & result, const lbool & config_status ) { ostream & out = config.getRegularOut( ); #ifdef SMTCOMP (void)config_status; #else fflush( stderr ); (void)config_status; // // For testing purposes we return error if bug is found // if ( config_status != l_Undef && result != l_Undef && result != config_status ) out << "error" << endl; else #endif if ( result == l_True ) out << "sat" << endl; else if ( result == l_False ) out << "unsat" << endl; else if ( result == l_Undef ) out << "unknown" << endl; else opensmt_error( "unexpected result" ); fflush( stdout ); #ifndef SMTCOMP if ( config.verbosity ) { // // Statistics // double cpu_time = cpuTime(); reportf( "#\n" ); reportf( "# CPU Time used: %g s\n", cpu_time == 0 ? 0 : cpu_time ); uint64_t mem_used = memUsed(); reportf( "# Memory used: %.3f MB\n", mem_used == 0 ? 0 : mem_used / 1048576.0 ); reportf( "#\n" ); } #endif }
int main () { srand(time(NULL)); int handle[3]; int *myInts[30]; int bytesRequested[30]; int totalBytesRequested; long n_bytes = 1048576; // 1 MB int parm2[10]; parm2[0] = 16; parm2[1] = 32; parm2[2] = 64; parm2[3] = 128; parm2[4] = 12432; parm2[5] = 1223; parm2[6] = 0; handle[0] = meminit (n_bytes, BUDDY_FLAG, 4, parm2); handle[1] = meminit (n_bytes, SLAB_FLAG, 8, parm2); handle[2] = meminit (n_bytes, FREELIST_FLAG, 0, parm2); int handleCount; for (handleCount = 0; handleCount < 3; handleCount++) { totalBytesRequested = 0; if (handle[handleCount] < 0) printf ("%s: %s %d %s\n", "ERROR", "handle", handleCount, "did not initialize"); int counter; for (counter = 0; counter < 30; counter++) { int randBytes = sizeof(char)*((rand()%99)+1); //1 - 100 bytes myInts[counter] = (int*)memalloc (handle[handleCount], randBytes); bytesRequested[counter] = randBytes; totalBytesRequested += randBytes; } // Free half for (counter = 0; counter < 30; counter+=2) { memfree(myInts[counter]); totalBytesRequested -= bytesRequested[counter]; bytesRequested[counter] = 0; } // Reallocate for (counter = 0; counter < 30; counter+=2) { int randBytes = sizeof(char)*((rand()%99)+1); //1 - 100 bytes myInts[counter] = (int*)memalloc (handle[handleCount], randBytes); bytesRequested[counter] = randBytes; totalBytesRequested += randBytes; } int memoryUsed = memUsed(handle[handleCount]); printf("Allocator %d:\n", handleCount); printf("Total bytes: %d\n", memSize(handle[handleCount])); printf("Total bytes requested: %d\n", totalBytesRequested); printf("Total bytes used: %d\n", memoryUsed); printf("Total waste: %f%%\n", (1- (float)totalBytesRequested/memoryUsed)*100); if (handleCount == 0) handle[0] = handle[1]; else if (handleCount == 1) handle[0] = handle[2]; } printf("Tester complete.\n"); }
double memUsedPeak(void) { return memUsed(); }
double memUsedPeak() { double peak = memReadPeak() / 1024; return peak == 0 ? memUsed() : peak; }