int plotprofile(char *command, int xspin[4]) { int nplots = 0; FILE *unit33; /* Open gnu file and load with plot commands */ unit33 = openGnufile(zlabel, dlabel); /* Generate nuclear, magnetic, or spin profiles */ if (command[3] == 0 || command[3] == 'N') { /* Generate nuclear profile and place in plot array */ ngenlayers(qcsq, d, rough, mu, nlayer, zint, rufint, nrough, proftyp); dumpProfile('n', nglayn, gqcnsq, gdn); addThickLabels(unit33, "N", .05, d, vacThick(rough, zint, nrough), nlayer); addLinePlot(unit33, profile, NULL, nplots++); } if ( command[3] == 0 || command[3] == 'M' || command[3] == 'T' ) { char xsec; /* Generate magnetic profile and save in plot array */ xsec = (command[3] == 0) ? 'm' : tolower(command[3]); mgenlayers(qcmsq, dm, mrough, the, nlayer, zint, rufint, nrough, proftyp); dumpProfile(xsec, nglaym, (xsec == 'm' ? gqcmsq : gthem), gdm); addThickLabels(unit33, "M", .10, dm, vacThick(mrough, zint, nrough), nlayer); addLinePlot(unit33, profile, NULL, nplots++); } if (command[3] == 'S' || (command[3] >= 'A' && command[3] <= 'D')) { int n; addThickLabels(unit33, "N", .05, d, vacThick(rough, zint, nrough), nlayer); addThickLabels(unit33, "M", .10, dm, vacThick(mrough, zint, nrough), nlayer); ngenlayers(qcsq, d, rough, mu, nlayer, zint, rufint, nrough, proftyp); mgenlayers(qcmsq, dm, mrough, the, nlayer, zint, rufint, nrough, proftyp); gmagpro4(); /* Read in data */ if (command[3] == 'S') { for (n = 0; n < 4; n++) if (xspin[n]) addLinePlot(unit33, dumpSDensity((char) n + 'a'), NULL, nplots++); } else { for (n = 3; command[n] >= 'A' && command[n] <= 'D'; n++) addLinePlot(unit33, dumpSDensity(tolower(command[n])), NULL, nplots++); } } closeGnufile(unit33); runGnufile(command); return FALSE; }
STATIC void firstProfileFrame(FILE *gnuPipe, int xspin[4], int pspin[4]) { ngenlayers(qcsq, d, rough, mu, nlayer, zint, rufint, nrough, proftyp); mgenlayers(qcmsq, dm, mrough, the, nlayer, zint, rufint, nrough, proftyp); addThickLabels(gnuPipe, "N", .05, d, vacThick(rough, zint, nrough), nlayer); addThickLabels(gnuPipe, "M", .10, dm, vacThick(mrough, zint, nrough), nlayer); fputs("set ytics nomirror; set y2tics\n", gnuPipe); /* fputs("set y2range [0:360]\n", gnuPipe); */ dumpProfile('n', nglayn, gqcnsq, gdn); addLinePlot(gnuPipe, profile, "axes x1y1", 0); dumpProfile('m', nglaym, gqcmsq, gdm); addLinePlot(gnuPipe, profile, "axes x1y1", 1); dumpProfile('t', nglaym, gthem, gdm); addLinePlot(gnuPipe, profile, "axes x1y2", 1); }
ParseTree* parseFile(ParserContext& context) { gUniqueNames.clear(); gUniqueTypes.clear(); gUniqueExpressions.clear(); SemaContext& globals = *new SemaContext(context, getAllocator(context)); SemaNamespace& walker = *new SemaNamespace(globals); ParserGeneric<SemaNamespace> parser(context, walker); cpp::symbol_sequence<cpp::declaration_seq> result(NULL); try { ProfileScope profile(gProfileParser); PROFILESCOPE_ENABLECOLLECTION(profile2); PARSE_SEQUENCE(parser, result); } catch(ParseError&) { } catch(SemanticError&) { printPosition(parser.context.getErrorPosition()); std::cout << "caught SemanticError" << std::endl; throw; } catch(SymbolsError&) { printPosition(parser.context.getErrorPosition()); std::cout << "caught SymbolsError" << std::endl; throw; } catch(TypeError& e) { e.report(); } if(!context.finished()) { printError(parser); } dumpProfile(gProfileIo); dumpProfile(gProfileWave); dumpProfile(gProfileParser); dumpProfile(gProfileLookup); dumpProfile(gProfileDiagnose); dumpProfile(gProfileAllocator); dumpProfile(gProfileIdentifier); dumpProfile(gProfileTemplateId); return result.get(); }
/** * Write out profile for all processors for requested title * @param idx category title */ void gridpack::utility::LocalTimer::dumpProfile(const std::string title) { MPI_Comm comm = static_cast<MPI_Comm>(this->communicator()); std::map<std::string, int>::iterator it; it = p_title_map.find(title); if (it != p_title_map.end()) { int idx = it->second; dumpProfile(idx); } else { int me; MPI_Comm_rank(comm, &me); if (me == 0) { printf("No statistics for:%s\n",title.c_str()); } } }
STATIC void profileFrame(FILE *gnuPipe, int xspin[4], int pspin[4]) { dumpProfile('n', nglayn, gqcnsq, gdn); dumpProfile('m', nglaym, gqcmsq, gdm); dumpProfile('t', nglaym, gthem, gdm); }
//Data output and erase bool NuPlayer::Renderer::onDrainAudioQueue() { uint32_t numFramesPlayed; #ifndef ANDROID_DEFAULT_CODE //flush mutex Mutex::Autolock autoLock(mFlushLock); #endif if (mAudioSink->getPosition(&numFramesPlayed) != OK) { #ifndef ANDROID_DEFAULT_CODE // mtk80902: ALPS00504270 // ACodec got an error at the beginning, if here returned // false directly then NuPlayer would never receive // audio renderer EOS anymore. ALOGD("audio sink get position false."); if (!mAudioQueue.empty()) { QueueEntry *entry = &*mAudioQueue.begin(); if (entry->mBuffer == NULL) { // EOS if(entry->mFinalResult!=OK) { ALOGE("err %d, Line:%d", entry->mFinalResult,__LINE__); } notifyEOS(true /* audio */, entry->mFinalResult); mAudioQueue.erase(mAudioQueue.begin()); entry = NULL; mNeedNewAudioAnchorTime = false; mHasAudio = false; ALOGD("audio position EOS at the beginning."); } } #endif return false; } ssize_t numFramesAvailableToWrite = mAudioSink->frameCount() - (mNumFramesWritten - numFramesPlayed); #ifndef ANDROID_DEFAULT_CODE if (numFramesPlayed > mNumFramesWritten) ALOGW("numFramesPlayed(%d) > mNumFramesWritten(%d), no reset @ onDrainAudioQueue", numFramesPlayed, mNumFramesWritten); if (numFramesAvailableToWrite > mAudioSink->frameCount()*3/4 || mAudioQueue.size() <= 3) ALOGW("numFramesAvailableToWrite(%d), mAudioSink frameCount(%d), mAudioQueue size(%d), numFramesPlayed(%d), mNumFramesWritten(%d)", numFramesAvailableToWrite, mAudioSink->frameCount(), mAudioQueue.size(), numFramesPlayed, mNumFramesWritten); #endif size_t numBytesAvailableToWrite = numFramesAvailableToWrite * mAudioSink->frameSize(); while (numBytesAvailableToWrite > 0 && !mAudioQueue.empty()) { QueueEntry *entry = &*mAudioQueue.begin(); if (entry->mBuffer == NULL) { // EOS if(entry->mFinalResult!=OK) { ALOGE("err %d, Line:%d", entry->mFinalResult,__LINE__); } notifyEOS(true /* audio */, entry->mFinalResult); mAudioQueue.erase(mAudioQueue.begin()); entry = NULL; #ifndef ANDROID_DEFAULT_CODE mNeedNewAudioAnchorTime = false; // mtk80902: i cant find out who set the last damn timeUs to 0.. mHasAudio = false; ALOGD("audio position EOS"); #endif return false; } if (entry->mOffset == 0) { int64_t mediaTimeUs; CHECK(entry->mBuffer->meta()->findInt64("timeUs", &mediaTimeUs)); int64_t TimeMin=mediaTimeUs/(1000000ll * 60ll); int64_t TimeSec=(mediaTimeUs/1000000ll)%60; ALOGV("rendering audio at media time %.2f secs.(%lld m: %lld s)", mediaTimeUs / 1E6,TimeMin, TimeSec); #if DUMP_PROFILE dumpProfile("render", mediaTimeUs); #endif #ifndef ANDROID_DEFAULT_CODE // mtk80902: for ALPS00456468 & avoid ALPS00457437 CTS fail if (entry->mBuffer->size() != 0) { mNeedNewAudioAnchorTime = false; mAnchorTimeMediaUs = mediaTimeUs; } #else mAnchorTimeMediaUs = mediaTimeUs; #endif uint32_t numFramesPlayed; CHECK_EQ(mAudioSink->getPosition(&numFramesPlayed), (status_t)OK); #ifndef ANDROID_DEFAULT_CODE // after flush several secs. numFramesPlayed is not zero ?? if (numFramesPlayed > mNumFramesWritten) mNumFramesWritten = numFramesPlayed; #endif uint32_t numFramesPendingPlayout = mNumFramesWritten - numFramesPlayed; #ifndef ANDROID_DEFAULT_CODE int64_t realTimeOffsetUs = (numFramesPendingPlayout * mAudioSink->msecsPerFrame()) * 1000ll; #else int64_t realTimeOffsetUs = (mAudioSink->latency() / 2 /* XXX */ + numFramesPendingPlayout * mAudioSink->msecsPerFrame()) * 1000ll; #endif { int64_t TimeMin=realTimeOffsetUs/(1000000ll * 60ll); int64_t TimeSec=(realTimeOffsetUs/1000000ll)%60; // ALOGI("realTimeOffsetUs = %lld us.(%lld m: %lld s)", realTimeOffsetUs,TimeMin, TimeSec); } #ifndef ANDROID_DEFAULT_CODE // mtk80902: for ALPS00456468 & avoid ALPS00457437 CTS fail if (entry->mBuffer->size() != 0) #endif mAnchorTimeRealUs = ALooper::GetNowUs() + realTimeOffsetUs; } size_t copy = entry->mBuffer->size() - entry->mOffset; if (copy > numBytesAvailableToWrite) { copy = numBytesAvailableToWrite; } #ifndef ANDROID_DEFAULT_CODE if ((ssize_t)copy != mAudioSink->write( entry->mBuffer->data() + entry->mOffset, copy)){ ALOGE("NuPlayer::Renderer::onDrainAudioQueue audio sink write maybe fail"); break; } #else CHECK_EQ(mAudioSink->write( entry->mBuffer->data() + entry->mOffset, copy), (ssize_t)copy); #endif entry->mOffset += copy; if (entry->mOffset == entry->mBuffer->size()) { entry->mNotifyConsumed->post(); mAudioQueue.erase(mAudioQueue.begin()); entry = NULL; } numBytesAvailableToWrite -= copy; size_t copiedFrames = copy / mAudioSink->frameSize(); mNumFramesWritten += copiedFrames; notifyIfMediaRenderingStarted(); } #ifndef ANDROID_DEFAULT_CODE notifyPosition(true/*audio*/); #else notifyPosition(); #endif return !mAudioQueue.empty(); }