void MasterTimer_Test::stopAllFunctions() { MasterTimer* mt = m_doc->masterTimer(); mt->start(); Function_Stub fs1(m_doc); fs1.start(mt, FunctionParent::master()); DMXSource_Stub s1; mt->registerDMXSource(&s1, "s1"); Function_Stub fs2(m_doc); fs2.start(mt, FunctionParent::master()); DMXSource_Stub s2; mt->registerDMXSource(&s2, "s2"); Function_Stub fs3(m_doc); fs3.start(mt, FunctionParent::master()); QTest::qWait(60); QVERIFY(mt->runningFunctions() == 3); QVERIFY(mt->m_dmxSourceList.size() == 2); mt->stopAllFunctions(); QVERIFY(mt->runningFunctions() == 0); QVERIFY(mt->m_dmxSourceList.size() == 2); // Shouldn't stop mt->unregisterDMXSource(&s1); mt->unregisterDMXSource(&s2); }
void MasterTimer_Test::runMultipleFunctions() { MasterTimer* mt = m_doc->masterTimer(); mt->start(); Function_Stub fs1(m_doc); fs1.start(mt, FunctionParent::master()); mt->timerTick(); QVERIFY(mt->runningFunctions() == 1); Function_Stub fs2(m_doc); fs2.start(mt, FunctionParent::master()); mt->timerTick(); QVERIFY(mt->runningFunctions() == 2); Function_Stub fs3(m_doc); fs3.start(mt, FunctionParent::master()); mt->timerTick(); QVERIFY(mt->runningFunctions() == 3); /* Wait a while so that the functions start running */ QTest::qWait(100); /* Stop the functions after they have been running for a while */ fs1.stop(FunctionParent::master()); fs2.stop(FunctionParent::master()); fs3.stop(FunctionParent::master()); /* Wait a while so that the functions stop */ QTest::qWait(100); QVERIFY(mt->runningFunctions() == 0); }
void Build_Vocabulary::doKmeansAll(String postFix){ clock_t start, finish; double elapsed_time; start = time(NULL); cout << "Loading Descriptor Files..." << endl; FileStorage fs("training_descriptors_bike_" +postFix+ ".txt", FileStorage::READ); Mat training_descriptors_bike; fs["training_descriptors"] >> training_descriptors_bike; fs.release(); FileStorage fs1("training_descriptors_cars_" +postFix+ ".txt", FileStorage::READ); Mat training_descriptors_cars; fs1["training_descriptors"] >> training_descriptors_cars; fs1.release(); FileStorage fs2("training_descriptors_person_" +postFix+ ".txt", FileStorage::READ); Mat training_descriptors_person; fs2["training_descriptors"] >> training_descriptors_person; fs2.release(); FileStorage fs3("training_descriptors_none_" +postFix+ ".txt", FileStorage::READ); Mat training_descriptors_none; fs3["training_descriptors"] >> training_descriptors_none; fs3.release(); /* */ BOWKMeansTrainer bowtrainer(1000); //num clusters bowtrainer.add(training_descriptors_bike); bowtrainer.add(training_descriptors_person); bowtrainer.add(training_descriptors_cars); bowtrainer.add(training_descriptors_none); cout << "Clustering Bag-of-Words features..." << endl; Mat vocabulary = bowtrainer.cluster(); FileStorage fs4("vocabulary_1000_" +postFix+ ".txt", FileStorage::WRITE); fs4 << "vocabulary" << vocabulary; fs4.release(); /* */ finish=time(NULL); elapsed_time = finish-start; int hours = (int) elapsed_time / 3600; int minutes = (int) (elapsed_time - hours * 3600) / 60; int seconds = (int) elapsed_time - hours * 3600 - minutes * 60; cout << "Elapsed Time for Clustering: " << hours << ":" << minutes << ":" << seconds << endl << endl; cout << "------- Finished Build Vocabulary ---------\n" << endl; }
//Because of Unknow Error, so I have to use 6 XML files to save those matrixs void myPCA::saveModel() { FileStorage fs1("mean.xml", FileStorage::WRITE); FileStorage fs2("sample.xml", FileStorage::WRITE); FileStorage fs3("eigen.xml", FileStorage::WRITE); FileStorage fs4("proj.xml", FileStorage::WRITE); FileStorage fs5("ID.xml", FileStorage::WRITE); FileStorage fs6("sampleOri.xml", FileStorage::WRITE); fs1 << "MeanFace" << meanFace; fs2 << "SampleMatrix" << sampleMatrix ; fs3 << "EigenVectors" << eigenVectors; fs4 << "ProjFaces" << projFaces; fs5 << "TrainImageID" << trainImageID; fs6 << "SampleMatrixOri" << sampleMatrixOri ; }
void myPCA::loadModel() { FileStorage fs1("mean.xml", FileStorage::READ); FileStorage fs2("sample.xml", FileStorage::READ); FileStorage fs3("eigen.xml", FileStorage::READ); FileStorage fs4("proj.xml", FileStorage::READ); FileStorage fs5("ID.xml", FileStorage::READ); FileStorage fs6("sampleOri.xml", FileStorage::READ); fs1["MeanFace"] >> meanFace; fs2["SampleMatrix"] >> sampleMatrix ; fs3["EigenVectors"] >> eigenVectors; fs4["ProjFaces"] >> projFaces; fs5["TrainImageID"] >> trainImageID; fs6["SampleMatrixOri"] >> sampleMatrixOri ; }
void MasterTimer_Test::restart() { MasterTimer* mt = m_doc->masterTimer(); mt->start(); Function_Stub fs1(m_doc); fs1.start(mt, FunctionParent::master()); Function_Stub fs2(m_doc); fs2.start(mt, FunctionParent::master()); Function_Stub fs3(m_doc); fs3.start(mt, FunctionParent::master()); QTest::qWait(60); QVERIFY(mt->runningFunctions() == 3); mt->stop(); QTest::qWait(60); QVERIFY(mt->runningFunctions() == 0); QVERIFY(mt->m_functionList.size() == 0); QVERIFY(mt->m_functionListMutex.tryLock() == true); mt->m_functionListMutex.unlock(); // QVERIFY(mt->m_running == false); QVERIFY(mt->m_stopAllFunctions == false); mt->start(); QVERIFY(mt->runningFunctions() == 0); QVERIFY(mt->m_functionList.size() == 0); QVERIFY(mt->m_functionListMutex.tryLock() == true); mt->m_functionListMutex.unlock(); // QVERIFY(mt->m_running == true); QVERIFY(mt->m_stopAllFunctions == false); fs1.start(mt, FunctionParent::master()); fs2.start(mt, FunctionParent::master()); fs3.start(mt, FunctionParent::master()); QTest::qWait(60); QVERIFY(mt->runningFunctions() == 3); mt->stopAllFunctions(); }
void MasterTimer_Test::stop() { MasterTimer* mt = m_doc->masterTimer(); mt->start(); Function_Stub fs1(m_doc); fs1.start(mt, FunctionParent::master()); Function_Stub fs2(m_doc); fs2.start(mt, FunctionParent::master()); Function_Stub fs3(m_doc); fs3.start(mt, FunctionParent::master()); QTest::qWait(60); QVERIFY(mt->runningFunctions() == 3); mt->stop(); QTest::qWait(60); QVERIFY(mt->runningFunctions() == 0); // QVERIFY(mt->m_running == false); }
nmethod* SICompiler::compile() { EventMarker em("SIC-compiling %#lx %#lx", L->selector(), NULL); ShowCompileInMonitor sc(L->selector(), "SIC", recompilee != NULL); // cannot recompile uncommon branches in DI nmethods & top nmethod yet FlagSetting fs2(SICDeferUncommonBranches, SICDeferUncommonBranches && diLink == NULL && L->adeps->length() == 0 && L->selector() != VMString[DO_IT]); // don't use uncommon traps when recompiling because of trap useUncommonTraps = SICDeferUncommonBranches && !currentProcess->isUncommon(); // don't inline into doIt FlagSetting fs3(Inline, Inline && L->selector() != VMString[DO_IT]); # if TARGET_ARCH != I386_ARCH // no FastMapTest possible on I386 // don't use fast map loads if this nmethod trapped a lot FlagSetting fs4(FastMapTest, FastMapTest && (recompilee == NULL || recompilee->flags.trapCount < MapLoadTrapLimit)); # endif FlagSetting fs5(PrintCompilation, PrintCompilation || PrintSICCompilation); timer t; FlagSetting fs6(verifyOften, SICDebug || CheckAssertions); if(PrintCompilation || PrintLongCompilation || PrintCompilationStatistics || VMSICLongProfiling) { t.start(); } if (PrintCompilation || PrintSICCode) { lprintf("*SIC-%s%scompiling %s%s: (SICCompilationCount=%d)", currentProcess->isUncommon() ? "uncommon-" : "", recompilee ? "re" : "", sprintName( (methodMap*) method()->map(), L->selector()), sprintValueMethod( L->receiver ), (void*)SICCompilationCount); } topScope->genCode(); buildBBs(); if (verifyOften) bbIterator->verify(false); bbIterator->eliminateUnreachableNodes(); // needed for removeUptoMerge to work // compute exposed blocks and up-level accessed vars bbIterator->computeExposedBlocks(); bbIterator->computeUplevelAccesses(); // make defs & uses and insert flush nodes for uplevel-accessed vars bbIterator->makeUses(); // added verify here cause want to catch unreachable merge preds // before elimination -- dmu if (verifyOften) bbIterator->verify(); if (SICLocalCopyPropagate) { bbIterator->localCopyPropagate(); if (verifyOften) bbIterator->verify(); } if (SICGlobalCopyPropagate) { bbIterator->globalCopyPropagate(); if (verifyOften) bbIterator->verify(); } if (SICEliminateUnneededNodes) { bbIterator->eliminateUnneededResults(); if (verifyOften) bbIterator->verify(); } // do after CP to explot common type test source regs if (SICOptimizeTypeTests) { bbIterator->computeDominators(); bbIterator->optimizeTypeTests(); if (verifyOften) bbIterator->verify(); } // allocate the temp (i.e. volatile) registers bbIterator->allocateTempRegisters(); // allocate the callee-saved (i.e. non-volatile) registers SICAllocator* a = theAllocator; a->allocate(bbIterator->globals, topScope->incoming); stackLocCount = a->stackTemps; // make sure frame size is aligned properly int32 frame_size_so_far = frameSize(); stackLocCount += roundTo(frame_size_so_far, frame_word_alignment) - frame_size_so_far; // compute the register masks for inline caches bbIterator->computeMasks(stackLocCount, nonRegisterArgCount()); topScope->computeMasks(regStringToMask(topScope->incoming), stackLocCount, nonRegisterArgCount()); if (PrintSICCode) { print_code(false); lprintf("\n\n"); } topScope->describe(); // must come before gen to set scopeInfo genHelper = new SICGenHelper; bbIterator->gen(); assert(theAssembler->verifyLabels(), "undefined labels"); rec->generate(); topScope->fixupBlocks(); // must be after rec->gen to know offsets if (vscopes) computeMarkers(); // ditto nmethod* nm = new_nmethod(this, false); if (theAssembler->lastBackpatch >= theAssembler->instsEnd) fatal("dangling branch"); em.event.args[1] = nm; fint ms = IntervalTimer::dont_use_any_timer ? 0 : t.millisecs(); if (PrintCompilation || PrintLongCompilation) { if (!PrintCompilation && PrintLongCompilation && ms >= MaxCompilePause) { lprintf("*SIC-%s%scompiling ", currentProcess->isUncommon() ? "uncommon-" : "", recompilee ? "re" : ""); methodMap* mm = method() ? (methodMap*) method()->map() : NULL; printName(mm, L->selector()); lprintf(": %#lx (%ld ms; level %ld)\n", nm, (void*)ms, (void*)nm->level()); } else if (PrintCompilation) { lprintf(": %#lx (%ld ms; level %ld v%d)\n", (void*)nm, (void*)ms, (void*)nm->level(), (void*)nm->version()); } } if (SICDebug && estimatedSize() > inlineLimit[NmInstrLimit]) { float rat = (float)estimatedSize() / (float)nm->instsLen(); lprintf("*est. size = %ld, true size = %ld, ratio = %4.2f\n", (void*)estimatedSize(), (void*)nm->instsLen(), *(void**)&rat); } if (PrintCompilationStatistics) { static fint counter = 0; lprintf("\n*SIC-time= |%ld| ms; to/co/sc/lo/de= |%ld|%ld|%ld|%ld|%ld| %ld|%ld|%ld| %ld |", (void*)ms, (void*) (nm->instsLen() + nm->scopes->length() + nm->locsLen() + nm->depsLen), (void*)nm->instsLen(), (void*)nm->scopes->length(), (void*)nm->locsLen(), (void*)nm->depsLen, (void*)BasicNode::currentID, (void*)bbIterator->bbCount, (void*)ncodes, (void*)counter++); } # if GENERATE_DEBUGGING_AIDS if (CheckAssertions) { // nm->verify(); } # endif return nm; }
bool ShapeMatch::importThresholds() { if(!ShapeMatch::THRESH_IMPORTED) { String folderName = "Thresholds/"; String filename = folderName+"shape_shifting_rules.csv"; String filename2 = folderName+"shape_penalties.csv"; String filename3 = folderName+"shape_weights.csv"; assert(fs::exists(filename)==true); assert(fs::exists(filename2)==true); assert(fs::exists(filename3)==true); fstream fs(filename); fstream fs2(filename2); fstream fs3(filename3); if(fs.is_open() && fs2.is_open() && fs3.is_open()) { String temp; vector<String> vec; vector<String> vec2; vector<float> vec3; while(getline(fs,temp)) { ip::getSubstr(temp,',',vec); for(unsigned int i=0; i<vec.size(); i++) { if(vec.at(i)!="") { if(i>0) { vec2.push_back(vec.at(i)); } } } ShapeMatch::shiftingRules.push_back(vec2); vec2.clear(); } getline(fs2,temp); while(getline(fs2,temp)) { ip::getSubstr(temp,',',vec); for(unsigned int i=0; i<vec.size(); i++) { if(i>0) { vec3.push_back(atof(vec.at(i).c_str())); } } ShapeMatch::shiftingPenalties.push_back(vec3); vec3.clear(); } getline(fs3,temp); while(getline(fs3,temp)) { ip::getSubstr(temp,',',vec); ShapeMatch::shapeWeightsVec.push_back(atof(vec.at(1).c_str())); ShapeMatch::shapeWeightsVec2.push_back(atof(vec.at(2).c_str())); } assert(ShapeMatch::shapeNames.size()==ShapeMatch::shiftingPenalties.size()); assert(ShapeMatch::shapeNames.size()==ShapeMatch::shiftingRules.size()); assert(ShapeMatch::shapeNames.size()==ShapeMatch::shapeWeightsVec.size()); assert(ShapeMatch::shapeNames.size()==ShapeMatch::shapeWeightsVec2.size()); fs.close(); fs2.close(); fs3.close(); return true; } else { cout << "Importing ShapeMatch Thresholds failed!" << endl; return false; } } return true; }