void AsyncCopy::Run(void* data) { START_KROLL_THREAD; Logger* logger = Logger::Get("Filesystem.AsyncCopy"); AsyncCopy* ac = static_cast<AsyncCopy*>(data); std::vector<std::string>::iterator iter = ac->files.begin(); Poco::Path to(ac->destination); Poco::File tof(to.toString()); logger->Debug("Job started: dest=%s, count=%i", ac->destination.c_str(), ac->files.size()); if (!tof.exists()) { tof.createDirectory(); } int c = 0; while (!ac->stopped && iter!=ac->files.end()) { bool err_copy = false; std::string file = (*iter++); c++; logger->Debug("File: path=%s, count=%i\n", file.c_str(), c); try { Poco::Path from(file); Poco::File f(file); if (f.isDirectory()) { ac->Copy(from,to); } else { Poco::Path dest(to,from.getFileName()); ac->Copy(from,dest); } logger->Debug("File copied"); KValueRef value = Value::NewString(file); ValueList args; args.push_back(value); args.push_back(Value::NewInt(c)); args.push_back(Value::NewInt(ac->files.size())); args.push_back(Value::NewBool(true)); RunOnMainThread(ac->callback, args, false); logger->Debug("Callback executed"); } catch (ValueException &ex) { err_copy = true; SharedString ss = ex.DisplayString(); logger->Error(std::string("Error: ") + *ss + " for file: " + file); } catch (Poco::Exception &ex) { err_copy = true; logger->Error(std::string("Error: ") + ex.displayText() + " for file: " + file); } catch (std::exception &ex) { err_copy = true; logger->Error(std::string("Error: ") + ex.what() + " for file: " + file); } catch (...) { err_copy = true; logger->Error(std::string("Unknown error during copy: ") + file); } try { if(err_copy) { KValueRef value = Value::NewString(file); ValueList args; args.push_back(value); args.push_back(Value::NewInt(c)); args.push_back(Value::NewInt(ac->files.size())); args.push_back(Value::NewBool(false)); RunOnMainThread(ac->callback, args, false); } } catch(...) { err_copy = true; logger->Error(std::string("Unknown error during copy: ") + file); } } ac->Set("running",Value::NewBool(false)); ac->stopped = true; logger->Debug(std::string("Job finished")); END_KROLL_THREAD; }
int main(int argc, char** argv) { if(!parseOption(argc, argv)) { fprintf(stderr, "failed to parse option\n"); return 1; } const char *bitcode = NULL; size_t bitcodeSize = readBitcode(&bitcode); unsigned int version = 0; bcinfo::BitcodeWrapper bcWrapper((const char *)bitcode, bitcodeSize); if (bcWrapper.getBCFileType() == bcinfo::BC_WRAPPER) { version = bcWrapper.getTargetAPI(); if (verbose) { printf("Found bitcodeWrapper\n"); } } else if (translateFlag) { version = 12; } if (verbose) { printf("targetAPI: %u\n", version); printf("compilerVersion: %u\n", bcWrapper.getCompilerVersion()); printf("optimizationLevel: %u\n\n", bcWrapper.getOptimizationLevel()); } llvm::OwningPtr<bcinfo::BitcodeTranslator> BT; BT.reset(new bcinfo::BitcodeTranslator(bitcode, bitcodeSize, version)); if (!BT->translate()) { fprintf(stderr, "failed to translate bitcode\n"); return 3; } llvm::OwningPtr<bcinfo::MetadataExtractor> ME; ME.reset(new bcinfo::MetadataExtractor(BT->getTranslatedBitcode(), BT->getTranslatedBitcodeSize())); if (!ME->extract()) { fprintf(stderr, "failed to get metadata\n"); return 4; } if (verbose) { dumpMetadata(ME.get()); const char *translatedBitcode = BT->getTranslatedBitcode(); size_t translatedBitcodeSize = BT->getTranslatedBitcodeSize(); llvm::LLVMContext &ctx = llvm::getGlobalContext(); llvm::llvm_shutdown_obj called_on_exit; llvm::OwningPtr<llvm::MemoryBuffer> mem; mem.reset(llvm::MemoryBuffer::getMemBuffer( llvm::StringRef(translatedBitcode, translatedBitcodeSize), inFile.c_str(), false)); llvm::OwningPtr<llvm::Module> module; std::string errmsg; module.reset(llvm::ParseBitcodeFile(mem.get(), ctx, &errmsg)); if (module.get() != 0 && module->MaterializeAllPermanently(&errmsg)) { module.reset(); } if (module.get() == 0) { if (errmsg.size()) { fprintf(stderr, "error: %s\n", errmsg.c_str()); } else { fprintf(stderr, "error: failed to parse bitcode file\n"); } return 5; } llvm::OwningPtr<llvm::tool_output_file> tof( new llvm::tool_output_file(outFile.c_str(), errmsg, llvm::sys::fs::F_Binary)); llvm::OwningPtr<llvm::AssemblyAnnotationWriter> ann; module->print(tof->os(), ann.get()); tof->keep(); } if (infoFlag) { if (dumpInfo(ME.get()) != 0) { fprintf(stderr, "Error dumping info file\n"); return 6; } } releaseBitcode(&bitcode); return 0; }
int init(CSOUND *csound) { int result = OK; #pragma omp critical (critical_section_fluid_engine) { fluid_synth_t *fluidSynth = 0; fluid_settings_t *fluidSettings = 0; chorusEnabled = (int) *iChorusEnabled; reverbEnabled = (int) *iReverbEnabled; channelCount = (int) *iChannelCount; voiceCount = (int) *iVoiceCount; if (channelCount <= 0) { channelCount = 256; } else if (channelCount < 16) { channelCount = 16; } else if (channelCount > 256) { channelCount = 256; } if (voiceCount <= 0) { voiceCount = 4096; } else if (voiceCount < 16) { voiceCount = 16; } else if (voiceCount > 4096) { voiceCount = 4096; } //csound_global_mutex_lock(); fluidSettings = new_fluid_settings(); if (fluidSettings != NULL) { fluid_settings_setnum(fluidSettings, (char *)"synth.sample-rate", (double) csound->GetSr(csound)); fluid_settings_setint(fluidSettings, (char *)"synth.midi-channels", channelCount); fluid_settings_setint(fluidSettings, (char *)"synth.polyphony", voiceCount); fluidSynth = new_fluid_synth(fluidSettings); } //csound_global_mutex_unlock(); if (!fluidSynth) { if (fluidSettings) { delete_fluid_settings(fluidSettings); } result = csound->InitError(csound, Str("error allocating fluid engine\n")); } else { //csound_global_mutex_lock(); fluid_synth_set_chorus_on(fluidSynth, chorusEnabled); fluid_synth_set_reverb_on(fluidSynth, reverbEnabled); //csound_global_mutex_unlock(); log(csound, "Created fluidEngine 0x%p with sampling rate = %f, " "chorus %s, reverb %s, channels %d, voices %d.\n", fluidSynth, (double) csound->GetSr(csound), chorusEnabled ? "on" : "off", reverbEnabled ? "on" : "off", channelCount, voiceCount); tof(fluidSynth, iFluidSynth); getFluidSynthsForCsoundInstances()[csound].push_back(fluidSynth); } } return result; }
void AlignChimeLocal3(const string &Q3, const string &A3, const string &B3, const string &QLabel, const string &ALabel, const string &BLabel, ChimeHit2 &Hit) { Hit.Clear(); const byte *Q3Seq = (const byte *) Q3.c_str(); const byte *A3Seq = (const byte *) A3.c_str(); const byte *B3Seq = (const byte *) B3.c_str(); const unsigned ColCount = SIZE(Q3); asserta(SIZE(A3) == ColCount && SIZE(B3) == ColCount); vector<float> ColScoresA(ColCount, 0.0f); vector<float> ColScoresB(ColCount, 0.0f); float ScoreN = -(float) opt_xn; unsigned QL = 0; for (unsigned Col = 0; Col < ColCount; ++Col) { char q = Q3Seq[Col]; char a = A3Seq[Col]; char b = B3Seq[Col]; if (!isgap(q)) ++QL; if (q == a && q == b && a == b) continue; if (isgap(q) || isgap(a) || isgap(b)) continue; if (Col > 0 && (isgap(Q3Seq[Col-1]) || isgap(A3Seq[Col-1]) || isgap(B3Seq[Col-1]))) continue; if (Col + 1 < ColCount && (isgap(Q3Seq[Col+1]) || isgap(A3Seq[Col+1]) || isgap(B3Seq[Col+1]))) continue; if (q == a && q != b) ColScoresA[Col] = 1; else ColScoresA[Col] = ScoreN; if (q == b && q != a) ColScoresB[Col] = 1; else ColScoresB[Col] = ScoreN; } vector<float> LVA(ColCount, 0.0f); vector<float> LVB(ColCount, 0.0f); LVA[0] = ColScoresA[0]; LVB[0] = ColScoresB[0]; for (unsigned Col = 1; Col < ColCount; ++Col) { LVA[Col] = max(LVA[Col-1], 0.0f) + ColScoresA[Col]; LVB[Col] = max(LVB[Col-1], 0.0f) + ColScoresB[Col]; } vector<float> RVA(ColCount, 0.0f); vector<float> RVB(ColCount, 0.0f); RVA[ColCount-1] = ColScoresA[ColCount-1]; RVB[ColCount-1] = ColScoresB[ColCount-1]; for (int Col = ColCount-2; Col >= 0; --Col) { RVA[Col] = max(RVA[Col+1], 0.0f) + ColScoresA[Col]; RVB[Col] = max(RVB[Col+1], 0.0f) + ColScoresB[Col]; } bool FirstA = true; float MaxSum = 0.0; unsigned ColX = UINT_MAX; for (unsigned Col = 1; Col < ColCount-1; ++Col) { float Sum = LVA[Col] + RVB[Col+1]; if (Sum > MaxSum) { FirstA = true; MaxSum = Sum; ColX = Col; } } for (unsigned Col = 1; Col < ColCount-1; ++Col) { float Sum = LVB[Col] + RVA[Col+1]; if (Sum > MaxSum) { FirstA = false; MaxSum = Sum; ColX = Col; } } if (ColX == UINT_MAX) return; unsigned ColLo = UINT_MAX; unsigned ColHi = UINT_MAX; if (FirstA) { float Sum = 0.0f; for (int Col = ColX; Col >= 0; --Col) { Sum += ColScoresA[Col]; if (Sum >= LVA[ColX]) { ColLo = Col; break; } } asserta(Sum >= LVA[ColX]); Sum = 0.0f; for (unsigned Col = ColX+1; Col < ColCount; ++Col) { Sum += ColScoresB[Col]; if (Sum >= RVB[ColX]) { ColHi = Col; break; } } asserta(Sum >= RVB[ColX]); } else { float Sum = 0.0f; for (int Col = ColX; Col >= 0; --Col) { Sum += ColScoresB[Col]; if (Sum >= LVB[ColX]) { ColLo = Col; break; } } asserta(Sum >= LVB[ColX]); Sum = 0.0f; for (unsigned Col = ColX+1; Col < ColCount; ++Col) { Sum += ColScoresA[Col]; if (Sum >= RVA[ColX]) { ColHi = Col; break; } } asserta(Sum >= RVA[ColX]); } unsigned ColXHi = ColX; for (unsigned Col = ColX + 1; Col < ColCount; ++Col) { char q = Q3Seq[Col]; char a = A3Seq[Col]; char b = B3Seq[Col]; if (q == a && q == b && !isgap(q)) ColXHi = Col; else break; } unsigned ColXLo = ColX; for (int Col = (int) ColX - 1; Col >= 0; --Col) { char q = Q3Seq[Col]; char a = A3Seq[Col]; char b = B3Seq[Col]; if (q == a && q == b && !isgap(q)) ColXLo = Col; else break; } unsigned IdQA = 0; unsigned IdQB = 0; unsigned IdAB = 0; unsigned NQA = 0; unsigned NQB = 0; unsigned NAB = 0; for (unsigned Col = 0; Col < ColCount; ++Col) { char q = Q3Seq[Col]; char a = A3Seq[Col]; char b = B3Seq[Col]; if (!isgap(q) && !isgap(a)) { ++NQA; if (q == a) ++IdQA; } if (!isgap(q) && !isgap(b)) { ++NQB; if (q == b) ++IdQB; } if (!isgap(a) && !isgap(b)) { ++NAB; if (a == b) ++IdAB; } } Hit.PctIdQA = Pct(IdQA, NQA); Hit.PctIdQB = Pct(IdQB, NQB); Hit.PctIdAB = Pct(IdAB, NAB); unsigned LIdQA = 0; unsigned LIdQB = 0; for (unsigned Col = ColLo; Col < ColXLo; ++Col) { char q = Q3Seq[Col]; char a = A3Seq[Col]; char b = B3Seq[Col]; if (!isgap(q) && !isgap(a)) { if (q == a) ++LIdQA; } if (!isgap(q) && !isgap(b)) { if (q == b) ++LIdQB; } } unsigned RIdQA = 0; unsigned RIdQB = 0; for (unsigned Col = ColXHi+1; Col <= ColHi; ++Col) { char q = Q3Seq[Col]; char a = A3Seq[Col]; char b = B3Seq[Col]; if (!isgap(q) && !isgap(a)) { if (q == a) ++RIdQA; } if (!isgap(q) && !isgap(b)) { if (q == b) ++RIdQB; } } unsigned IdDiffL = max(LIdQA, LIdQB) - min(LIdQA, LIdQB); unsigned IdDiffR = max(RIdQA, RIdQB) - min(RIdQA, RIdQB); unsigned MinIdDiff = min(IdDiffL, IdDiffR); unsigned ColRange = ColHi - ColLo + 1; if (opt_queryfract > 0.0f && float(ColRange)/float(QL) < opt_queryfract) return; // double Div = Pct(MinIdDiff, QSD.L); #if TRACE { Log(" Col A Q B ScoreA ScoreB LVA LVB RVA RVB\n"); Log("----- - - - ------- ------- ------- ------- ------- -------\n"); for (unsigned Col = 0; Col < ColCount; ++Col) { if (ColScoresA[Col] == 0.0 && ColScoresB[Col] == 0.0) continue; char q = Q3Seq[Col]; char a = A3Seq[Col]; char b = B3Seq[Col]; Log("%5u %c %c %c", Col, a, q, b); if (ColScoresA[Col] == 0.0) Log(" %7.7s", ""); else Log(" %7.1f", ColScoresA[Col]); if (ColScoresB[Col] == 0.0) Log(" %7.7s", ""); else Log(" %7.1f", ColScoresB[Col]); Log(" %7.1f %7.1f %7.1f %7.1f", LVA[Col], LVB[Col], RVA[Col], RVB[Col]); Log("\n"); } Log("\n"); Log("MaxSum %.1f, ColLo %u, ColXLo %u, ColX %u, ColXHi %u, ColHi %u, AF %c\n", MaxSum, ColLo, ColXLo, ColX, ColXHi, ColHi, tof(FirstA)); Log(" LIdQA %u, LIdQB %u, RIdQA %u, RIdQB %u\n", LIdQA, LIdQB, RIdQA, RIdQB); } #endif string Q3L; string A3L; string B3L; for (unsigned Col = ColLo; Col <= ColHi; ++Col) { char q = Q3[Col]; char a = A3[Col]; char b = B3[Col]; Q3L += q; A3L += a; B3L += b; } AlignChimeGlobal3(Q3L, A3L, B3L, QLabel, ALabel, BLabel, Hit); #if 0 // CS SNPs Hit.CS_LY = 0; Hit.CS_LN = 0; Hit.CS_RY = 0; Hit.CS_RN = 0; Hit.CS_LA = 0; Hit.CS_RA = 0; for (unsigned Col = ColLo; Col <= ColHi; ++Col) { char q = Q3Seq[Col]; char a = A3Seq[Col]; char b = B3Seq[Col]; if (q == a && q == b && a == b) continue; if (isgap(q) || isgap(a) || isgap(b)) continue; if (Col > 0 && (isgap(Q3Seq[Col-1]) || isgap(A3Seq[Col-1]) || isgap(B3Seq[Col-1]))) continue; if (Col + 1 < ColCount && (isgap(Q3Seq[Col+1]) || isgap(A3Seq[Col+1]) || isgap(B3Seq[Col+1]))) continue; if (!FirstA) swap(a, b); if (Col < ColXLo) { if (q == a && q != b) ++Hit.CS_LY; else if (q == b && q != a) ++Hit.CS_LN; else ++Hit.CS_LA; } else if (Col > ColXHi) { if (q == b && q != a) ++Hit.CS_RY; else if (q == a && q != b) ++Hit.CS_RN; else ++Hit.CS_RA; } } double ScoreL = GetScore2(Hit.CS_LY, Hit.CS_LN, Hit.CS_LA); double ScoreR = GetScore2(Hit.CS_RY, Hit.CS_RN, Hit.CS_RA); Hit.Score = ScoreL*ScoreR; //Hit.QSD = QSD; //if (FirstA) // { // Hit.ASD = ASD; // Hit.BSD = BSD; // Hit.PathQA = PathQA; // Hit.PathQB = PathQB; // } //else // { // Hit.ASD = BSD; // Hit.BSD = ASD; // } //Hit.ColLo = ColLo; //Hit.ColXLo = ColXLo; //Hit.ColXHi = ColXHi; //Hit.ColHi = ColHi; //Hit.Div = Div; // Hit.LogMe(); #endif }