Function* Create(const STREAMOUT_COMPILE_STATE& state) { static std::size_t soNum = 0; std::stringstream fnName("SOShader", std::ios_base::in | std::ios_base::out | std::ios_base::ate); fnName << soNum++; // SO function signature // typedef void(__cdecl *PFN_SO_FUNC)(SWR_STREAMOUT_CONTEXT*) std::vector<Type*> args{ PointerType::get(Gen_SWR_STREAMOUT_CONTEXT(JM()), 0), // SWR_STREAMOUT_CONTEXT* }; FunctionType* fTy = FunctionType::get(IRB()->getVoidTy(), args, false); Function* soFunc = Function::Create(fTy, GlobalValue::ExternalLinkage, fnName.str(), JM()->mpCurrentModule); // create return basic block BasicBlock* entry = BasicBlock::Create(JM()->mContext, "entry", soFunc); BasicBlock* returnBB = BasicBlock::Create(JM()->mContext, "return", soFunc); IRB()->SetInsertPoint(entry); // arguments auto argitr = soFunc->getArgumentList().begin(); Value* pSoCtx = &*argitr++; pSoCtx->setName("pSoCtx"); const STREAMOUT_STREAM& streamState = state.stream; buildStream(state, streamState, pSoCtx, returnBB, soFunc); BR(returnBB); IRB()->SetInsertPoint(returnBB); RET_VOID(); JitManager::DumpToFile(soFunc, "SoFunc"); ::FunctionPassManager passes(JM()->mpCurrentModule); passes.add(createBreakCriticalEdgesPass()); passes.add(createCFGSimplificationPass()); passes.add(createEarlyCSEPass()); passes.add(createPromoteMemoryToRegisterPass()); passes.add(createCFGSimplificationPass()); passes.add(createEarlyCSEPass()); passes.add(createInstructionCombiningPass()); passes.add(createInstructionSimplifierPass()); passes.add(createConstantPropagationPass()); passes.add(createSCCPPass()); passes.add(createAggressiveDCEPass()); passes.run(*soFunc); JitManager::DumpToFile(soFunc, "SoFunc_optimized"); return soFunc; }
void LinkBackupThread::processDir(QDir& currentFromDir, QDir& currentToDir) { long numErrors = getLogger().errorCount(); if (numErrors > 1000) { QString errorMessage = QString("%1 errors found, quit?"); QMessageBox::StandardButton reply = QMessageBox::question(nullptr, "Test", errorMessage, QMessageBox::Yes|QMessageBox::No); if (reply == QMessageBox::Yes) { requestCancel(); } else { getLogger().clearErrorCount(); } } TRACE_MSG(QString("Processing directory %1").arg(currentFromDir.canonicalPath()), 1); // Process directories, then process files. QList<QFileInfo> list = currentFromDir.entryInfoList(QDir::Dirs | QDir::NoDotAndDotDot | QDir::NoSymLinks | QDir::Hidden | QDir::Readable); QFileInfo info; foreach (info, list) { if (isCancelRequested()) { return; } TRACE_MSG(QString("Found Dir to processes %1").arg(info.canonicalFilePath()), 2); if (passes(info)) { DEBUG_MSG(QString("Dir Passes: %1").arg(info.canonicalFilePath()), 2); if (!currentToDir.mkdir(info.fileName())) { ERROR_MSG(QString("Failed to create directory %1/%2").arg(currentToDir.canonicalPath(), info.fileName()), 1); } else if (!currentToDir.cd(info.fileName())) { ERROR_MSG(QString("Failed to cd to directory %1/%2").arg(currentToDir.canonicalPath(), info.fileName()), 1); } else if (!currentFromDir.cd(info.fileName())) { ERROR_MSG(QString("Failed to cd to directory %1/%2").arg(currentFromDir.canonicalPath(), info.fileName()), 1); if (!currentToDir.cdUp()) { ERROR_MSG("Failed to cd up a directory for the to directory", 1); requestCancel(); return; } } else { processDir(currentFromDir, currentToDir); if (!currentToDir.cdUp()) { ERROR_MSG("Failed to cd up a directory for the to directory", 1); requestCancel(); return; } if (!currentFromDir.cdUp()) { ERROR_MSG("Failed to cd up a directory for the from directory", 1); requestCancel(); return; } } } else { DEBUG_MSG(QString("Skipping Dir: %1").arg(info.canonicalFilePath()), 2); } } // Now handle files list = currentFromDir.entryInfoList(QDir::Files | QDir::NoSymLinks | QDir::Hidden | QDir::Readable); foreach (info, list) { if (isCancelRequested()) { return; } QString fullPathFileToRead = info.canonicalFilePath(); //TRACE_MSG(QString("Found File to test %1").arg(fullPathFileToRead), 2); if (passes(info)) { //TRACE_MSG(QString("File passes %1").arg(fullPathFileToRead), 2); QFile fileToRead(fullPathFileToRead); // Just in case someone deleted the file. if (fileToRead.exists()) { DBFileEntry* currentEntry = new DBFileEntry(info, m_fromDirWithoutTopDirName); const DBFileEntry* linkEntry = m_oldEntries->findEntry(m_backupSet.getCriteria(), currentEntry, m_fromDirWithoutTopDirName); QString pathToLinkFile = m_previousDirRoot; // If not in the old backup, search the current backup. if (linkEntry == nullptr) { linkEntry = m_currentEntries->findEntry(m_backupSet.getCriteria(), currentEntry, m_fromDirWithoutTopDirName); pathToLinkFile = m_toDirRoot; } if (linkEntry == nullptr) { bool failedToCopy = false; QString fullFileNameToWrite = m_toDirRoot + "/" + currentEntry->getPath(); bool needHash = (currentEntry->getHash().length() == 0); if (needHash) { failedToCopy = !::getCopyLinkUtil().copyFileGenerateHash(fullPathFileToRead, fullFileNameToWrite); if (!failedToCopy) { currentEntry->setHash(getCopyLinkUtil().getLastHash()); } } else if (!getCopyLinkUtil().copyFile(fullPathFileToRead, fullFileNameToWrite)) { failedToCopy = true; } if (failedToCopy) { ERROR_MSG(QString(tr("EC %1")).arg(currentEntry->getPath()), 1); } else { INFO_MSG(QString(tr("C %1")).arg(currentEntry->getPath()), 1); currentEntry->setLinkTypeCopy(); m_currentEntries->addEntry(currentEntry); currentEntry = nullptr; } } else { if (getCopyLinkUtil().linkFile(pathToLinkFile + "/" + linkEntry->getPath(), m_toDirRoot + "/" + currentEntry->getPath())) { currentEntry->setLinkTypeLink(); currentEntry->setHash(linkEntry->getHash()); m_currentEntries->addEntry(currentEntry); INFO_MSG(QString(tr("L %1")).arg(currentEntry->getPath()), 1); currentEntry = nullptr; } else { ERROR_MSG(QString(tr("EL %1")).arg(currentEntry->getPath()), 1); ERROR_MSG(QString(tr("(%1)(%2)(%3)")).arg(pathToLinkFile, linkEntry->getPath(), m_toDirRoot), 1); } } if (currentEntry != nullptr) { delete currentEntry; currentEntry= nullptr; } } } } TRACE_MSG(QString("Finished with directory %1").arg(currentFromDir.canonicalPath()), 1); }
/* * FowlerLittle * * http://www.geog.ubc.ca/courses/klink/gis.notes/ncgia/u39.html#SEC39.1.1 * */ void FowlerLittle(const DEMGeo& orig, DEMGeo& deriv) { DEMGeo passes(orig.mWidth, orig.mHeight); DEMGeo lowest(orig.mWidth, orig.mHeight); DEMGeo highest(orig.mWidth, orig.mHeight); passes = NO_DATA; int x, y; for (y = 1; y < (orig.mHeight-1); ++y) for (x = 1; x < (orig.mWidth-1); ++x) { float e = orig.get(x,y); bool dif[8]; dif[0] = orig.get(x ,y+1) > e; dif[1] = orig.get(x+1,y+1) > e; dif[2] = orig.get(x+1,y ) > e; dif[3] = orig.get(x+1,y-1) > e; dif[4] = orig.get(x ,y-1) > e; dif[5] = orig.get(x-1,y-1) > e; dif[6] = orig.get(x-1,y ) > e; dif[7] = orig.get(x-1,y+1) > e; int cycles = 0; for (int n = 0; n < 8; ++n) if (dif[n] != dif[(n+7)%8]) ++cycles; if (cycles == 0) deriv(x,y) = orig(x,y); if (cycles > 2) passes(x,y) = 1.0; } for (y = 1; y < (orig.mHeight); ++y) for (x = 1; x < (orig.mWidth); ++x) { float e[4]; e[0] = orig.get(x-1,y-1); e[1] = orig.get(x ,y-1); e[2] = orig.get(x-1,y ); e[3] = orig.get(x ,y ); if (e[0] < e[1] && e[0] < e[2] && e[0] < e[3]) lowest(x-1,y-1) = 1; if (e[0] > e[1] && e[0] > e[2] && e[0] > e[3]) highest(x-1,y-1) = 1; if (e[1] < e[0] && e[1] < e[2] && e[1] < e[3]) lowest(x ,y-1) = 1; if (e[1] > e[0] && e[1] > e[2] && e[1] > e[3]) highest(x ,y-1) = 1; if (e[2] < e[0] && e[2] < e[1] && e[2] < e[3]) lowest(x-1,y ) = 1; if (e[2] > e[0] && e[2] > e[1] && e[2] > e[3]) highest(x-1,y ) = 1; if (e[3] < e[0] && e[3] < e[1] && e[3] < e[2]) lowest(x ,y ) = 1; if (e[3] > e[0] && e[3] > e[1] && e[3] > e[2]) highest(x ,y ) = 1; } for (y = 0; y < (orig.mHeight); ++y) for (x = 0; x < (orig.mWidth); ++x) { if (passes(x,y) != 0.0) if (lowest(x,y) == 0.0 || highest(x,y) == 0.0) deriv(x,y) = orig(x,y); } }