void mozilla_sampler_stop() { if (!stack_key_initialized) profiler_init(); TableTicker *t = tlsTicker.get(); if (!t) { return; } bool disableJS = t->ProfileJS(); t->Stop(); delete t; tlsTicker.set(NULL); PseudoStack *stack = tlsPseudoStack.get(); ASSERT(stack != NULL); if (disableJS) stack->disableJSSampling(); sIsProfiling = false; nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); if (os) os->NotifyObservers(nullptr, "profiler-stopped", nullptr); }
int main( int argc, const char* argv[] ) { int i,j,iret; double first[SIZE][SIZE]; double second[SIZE][SIZE]; double multiply[SIZE][SIZE]; double dtime; for (i = 0; i < SIZE; i++) { //rows in first for (j = 0; j < SIZE; j++) { //columns in first first[i][j]=i+j; second[j][i]=i-j; multiply[i][j]=0.0; } } profiler_init(); dtime = dclock(); profiler_start(); iret=mm(first,second,multiply); profiler_stop(); dtime = dclock()-dtime; profiler_print(); printf( "Time: %le \n", dtime); fflush( stdout ); double check=0.0; for(i=0;i<SIZE;i++){ for(j=0;j<SIZE;j++){ check+=multiply[i][j]; } } printf("check %le \n",check); return iret; }
// Values are only honored on the first start void mozilla_sampler_start(int aProfileEntries, int aInterval, const char** aFeatures, uint32_t aFeatureCount) { if (!stack_key_initialized) profiler_init(); /* If the sampling interval was set using env vars, use that in preference to anything else. */ if (sUnwindInterval > 0) aInterval = sUnwindInterval; PseudoStack *stack = tlsPseudoStack.get(); if (!stack) { ASSERT(false); return; } // Reset the current state if the profiler is running profiler_stop(); TableTicker* t; if (sps_version2()) { t = new BreakpadSampler(aInterval ? aInterval : PROFILE_DEFAULT_INTERVAL, aProfileEntries ? aProfileEntries : PROFILE_DEFAULT_ENTRY, aFeatures, aFeatureCount); } else { t = new TableTicker(aInterval ? aInterval : PROFILE_DEFAULT_INTERVAL, aProfileEntries ? aProfileEntries : PROFILE_DEFAULT_ENTRY, aFeatures, aFeatureCount); } tlsTicker.set(t); t->Start(); if (t->ProfileJS()) { mozilla::MutexAutoLock lock(*Sampler::sRegisteredThreadsMutex); std::vector<ThreadInfo*> threads = t->GetRegisteredThreads(); for (uint32_t i = 0; i < threads.size(); i++) { ThreadInfo* info = threads[i]; ThreadProfile* thread_profile = info->Profile(); if (!thread_profile) { continue; } thread_profile->GetPseudoStack()->enableJSSampling(); } } sIsProfiling = true; nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); if (os) os->NotifyObservers(nullptr, "profiler-started", nullptr); }
void mozilla_sampler_stop() { if (!stack_key_initialized) profiler_init(nullptr); TableTicker *t = tlsTicker.get(); if (!t) { return; } bool disableJS = t->ProfileJS(); bool unwinderThreader = t->HasUnwinderThread(); // Shut down and reap the unwinder thread. We have to do this // before stopping the sampler, so as to guarantee that the unwinder // thread doesn't try to access memory that the subsequent call to // mozilla_sampler_stop causes to be freed. if (unwinderThreader) { uwt__stop(); } t->Stop(); delete t; tlsTicker.set(nullptr); if (disableJS) { PseudoStack *stack = tlsPseudoStack.get(); ASSERT(stack != nullptr); stack->disableJSSampling(); } if (unwinderThreader) { uwt__deinit(); } mozilla::IOInterposer::Unregister(mozilla::IOInterposeObserver::OpAll, sInterposeObserver); sIsProfiling = false; nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); if (os) os->NotifyObservers(nullptr, "profiler-stopped", nullptr); }
// Values are only honored on the first start void mozilla_sampler_start(int aProfileEntries, double aInterval, const char** aFeatures, uint32_t aFeatureCount, const char** aThreadNameFilters, uint32_t aFilterCount) { LOG("BEGIN mozilla_sampler_start"); if (!stack_key_initialized) profiler_init(nullptr); /* If the sampling interval was set using env vars, use that in preference to anything else. */ if (sUnwindInterval > 0) aInterval = sUnwindInterval; /* If the entry count was set using env vars, use that, too: */ if (sProfileEntries > 0) aProfileEntries = sProfileEntries; // Reset the current state if the profiler is running profiler_stop(); GeckoSampler* t; t = new GeckoSampler(aInterval ? aInterval : PROFILE_DEFAULT_INTERVAL, aProfileEntries ? aProfileEntries : PROFILE_DEFAULT_ENTRY, aFeatures, aFeatureCount, aThreadNameFilters, aFilterCount); tlsTicker.set(t); t->Start(); if (t->ProfileJS() || t->InPrivacyMode()) { ::MutexAutoLock lock(*Sampler::sRegisteredThreadsMutex); std::vector<ThreadInfo*> threads = t->GetRegisteredThreads(); for (uint32_t i = 0; i < threads.size(); i++) { ThreadInfo* info = threads[i]; if (info->IsPendingDelete()) { continue; } ThreadProfile* thread_profile = info->Profile(); if (!thread_profile) { continue; } thread_profile->GetPseudoStack()->reinitializeOnResume(); #ifndef SPS_STANDALONE if (t->ProfileJS()) { thread_profile->GetPseudoStack()->enableJSSampling(); } if (t->InPrivacyMode()) { thread_profile->GetPseudoStack()->mPrivacyMode = true; } #endif } } #if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK) if (t->ProfileJava()) { int javaInterval = aInterval; // Java sampling doesn't accuratly keep up with 1ms sampling if (javaInterval < 10) { aInterval = 10; } mozilla::widget::GeckoJavaSampler::StartJavaProfiling(javaInterval, 1000); } #endif #ifndef SPS_STANDALONE if (t->AddMainThreadIO()) { if (!sInterposeObserver) { // Lazily create IO interposer observer sInterposeObserver = new mozilla::ProfilerIOInterposeObserver(); } mozilla::IOInterposer::Register(mozilla::IOInterposeObserver::OpAll, sInterposeObserver); } #endif sIsProfiling = true; #ifndef SPS_STANDALONE sIsGPUProfiling = t->ProfileGPU(); sIsLayersDump = t->LayersDump(); sIsDisplayListDump = t->DisplayListDump(); sIsRestyleProfiling = t->ProfileRestyle(); if (Sampler::CanNotifyObservers()) { nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); if (os) { nsTArray<nsCString> featuresArray; nsTArray<nsCString> threadNameFiltersArray; for (size_t i = 0; i < aFeatureCount; ++i) { featuresArray.AppendElement(aFeatures[i]); } for (size_t i = 0; i < aFilterCount; ++i) { threadNameFiltersArray.AppendElement(aThreadNameFilters[i]); } nsCOMPtr<nsIProfilerStartParams> params = new nsProfilerStartParams(aProfileEntries, aInterval, featuresArray, threadNameFiltersArray); os->NotifyObservers(params, "profiler-started", nullptr); } } #endif LOG("END mozilla_sampler_start"); }
// --------------------------------------------------------------------------- /// Mandor2 core. // --------------------------------------------------------------------------- int main (int argc, char **argv) { time_get (&stopFlag_startTime); cl_import ("./source/import.pl", argc, argv, 0); parameter_enterMPI (argc, argv, 1); parameter_load (); // Initializes profiler. profiler_init (_("output/prof_core_%03d.txt", cpu_here)); units_load (); // Configures all modules. main_startUp (); em_init (&E, &H); plasma_init (); for (int tmp = 0; tmp < 100; tmp++) tmp_gamma[tmp] = 0.0; // TEMP say ("System is initialized successfully."); // Total time of the work stage - starts here. int stopFlag = 0; double computTime = MPI_Wtime (), oldTime = -1; for (int t = 1 ; t <= totalSteps && !stopFlag ; t++) { double W_E, W_M, WTx = 0, WTy = 0, WTz = 0; profiler_startLoop (); // XXX Add it to the timing counter. comm_plasma_start (); // Reads data from external file (works as mailbox).. profiler_begin (mc_prof_throwStopFlag); if (chPoint_stopRequest > 0 && t%chPoint_stopRequest == 0) main_throwStopFlag (); // H^(n-1/2) -> H^n. profiler_endBegin (mc_prof_emh1); em_HHalfStep (mcast_meshVec_RO (&E), &H); // Energy density of the field at t = n*tau. profiler_endBegin (mc_prof_EMenergy); em_energy (mcast_meshVec_RO(&E), mcast_meshVec_RO(&H), &W_E, &W_M); profiler_endBegin (mc_prof_probes); probe_postData (Time, mcast_meshVec_RO(&E), mcast_meshVec_RO(&H)); // Gauss law test beginning (profiler call is inside). gauss_before (); profiler_endBegin (mc_prof_plasma_move); plasma_move (mcast_meshVec_RO(&E), mcast_meshVec_RO(&H), &J); // Energy density: gets plasma termal energy. profiler_endBegin (mc_prof_plasma_Txyz); plasma_temperature (&WTx, &WTy, &WTz); // Tecplot's diagnostic check-pointing. if (chPoint_tecplot > 0 && t%chPoint_tecplot == 0) { say_doing ("writing tecplot mesh..."); profiler_endBegin (mc_prof_tecRho); plasma_rho (&rho); profiler_endBegin (mc_prof_tecEH); tecIO_saveFields (Time, mcast_meshVec_RO(&E), mcast_meshVec_RO(&H)); } // Spectral energy density diagnostic. if (chPoint_spectr > 0 && t%chPoint_spectr == 0) { say_doing ("writing spectral energy density dump..."); profiler_endBegin (mc_prof_spectr); reg_t reg = {{cpu_min[0], cpu_min[1], cpu_min[2]}, {cpu_max[0] - mc_have_x, cpu_max[1] - mc_have_y, cpu_max[2] - mc_have_z}}; reg_t map = {{E.imin, E.jmin, E.kmin}, {E.imax, E.jmax, E.kmax}}; spectr_dump (Time, cpu_here, cpu_total, ®, &map, E.storage, H.storage); } // Saves local energies to the buffer. profiler_endBegin (mc_prof_wDensity); wDensity_addPoint (W_E, W_M, WTx, WTy, WTz); // H^n -> H^(n+1/2). profiler_endBegin (mc_prof_emh2); em_HStep (mcast_meshVec_RO(&E), &H); // E^n -> E^(n+1). profiler_endBegin (mc_prof_eme); em_EStep_start (&E, mcast_meshVec_RO(&H)); // Gets full picture of the currents. profiler_endBegin (mc_prof_jbcFinish); jbc_finish (&J); profiler_endBegin (mc_prof_plasma_pbcRecv); comm_plasma_complete (1000); profiler_endBegin (mc_prof_EFinish); em_EStep_finish (&E, &H, mcast_meshVec_RO(&J)); // Gauss law test ending. gauss_after (mcast_meshVec_RO(&J), mcast_meshVec_RO(&E)); // Tecplot's diagnostic check-pointing. if (chPoint_tecplot > 0 && t%chPoint_tecplot == 0) { say_doing ("writing tecplot mesh..."); profiler_endBegin (mc_prof_tecRhoJ); tecIO_saveCurrents (mcast_meshVec_RO(&J), mcast_meshDouble_RO(&rho)); } // Updates time after successful time step. parameter_setTime (Time + tau); tmp_update_gamma(countCore, countAll); // TEMP tmp_update_gamma(0, countShell); // TEMP // System check-point. if (t && t%chPoint_full == 0) { tmp_save_gamma(sysNum, cpu_here); // TEMP timeTick_t startWrite; time_get (&startWrite); say_doing ("writing check-point..."); profiler_endBegin (mc_prof_sysSave); plasma_save (sysNum, cpu_here); sysIO_save (Time, mcast_meshVec_RO(&E), mcast_meshVec_RO(&H)); profiler_endBegin (mc_prof_wDensityFlush); // WARNING: barrier-type calls inside. wDensity_flushData (); oldTime = Time; // Updates estimate of saving time. timeTick_t endWrite; time_get (&endWrite); stopFlag_saveTime = time_elapsed (&startWrite, &endWrite); } profiler_endBegin (mc_prof_catchStop); // Gets data sent earlier. if (chPoint_stopRequest > 0 && t % chPoint_stopRequest == 0) { stopFlag = main_catchStopFlag (); } profiler_end (); say_doing ("time=%.4f (%.2f %%) ", Time, 100.0*t/(double) totalSteps); // say ("step %d: time=%.4f (%.2f %%)", t, Time // , 100.0*t/(double) totalSteps); profiler_finishLoop (); } computTime = MPI_Wtime () - computTime; say ("main: main loop have taken %f sec.", computTime); // System check-point. if (oldTime != Time) { say ("Addional check-point to save the final state."); plasma_save (sysNum, cpu_here); sysIO_save (Time, mcast_meshVec_RO(&E), mcast_meshVec_RO(&H)); } say ("Final barrier."); MPI_Barrier (MPI_COMM_WORLD); // Removes tmp file to signal the end of run. if (!cpu_here) remove ("tmp/stop.flag"); return EXIT_SUCCESS; }
// Values are only honored on the first start void mozilla_sampler_start(int aProfileEntries, double aInterval, const char** aFeatures, uint32_t aFeatureCount, const char** aThreadNameFilters, uint32_t aFilterCount) { if (!stack_key_initialized) profiler_init(nullptr); /* If the sampling interval was set using env vars, use that in preference to anything else. */ if (sUnwindInterval > 0) aInterval = sUnwindInterval; /* If the entry count was set using env vars, use that, too: */ if (sProfileEntries > 0) aProfileEntries = sProfileEntries; // Reset the current state if the profiler is running profiler_stop(); TableTicker* t; t = new TableTicker(aInterval ? aInterval : PROFILE_DEFAULT_INTERVAL, aProfileEntries ? aProfileEntries : PROFILE_DEFAULT_ENTRY, aFeatures, aFeatureCount, aThreadNameFilters, aFilterCount); if (t->HasUnwinderThread()) { // Create the unwinder thread. ATM there is only one. uwt__init(); } tlsTicker.set(t); t->Start(); if (t->ProfileJS() || t->InPrivacyMode()) { mozilla::MutexAutoLock lock(*Sampler::sRegisteredThreadsMutex); std::vector<ThreadInfo*> threads = t->GetRegisteredThreads(); for (uint32_t i = 0; i < threads.size(); i++) { ThreadInfo* info = threads[i]; ThreadProfile* thread_profile = info->Profile(); if (!thread_profile) { continue; } if (t->ProfileJS()) { thread_profile->GetPseudoStack()->enableJSSampling(); } if (t->InPrivacyMode()) { thread_profile->GetPseudoStack()->mPrivacyMode = true; } } } #if defined(SPS_OS_android) && !defined(MOZ_WIDGET_GONK) if (t->ProfileJava()) { int javaInterval = aInterval; // Java sampling doesn't accuratly keep up with 1ms sampling if (javaInterval < 10) { aInterval = 10; } mozilla::AndroidBridge::Bridge()->StartJavaProfiling(javaInterval, 1000); } #endif if (t->AddMainThreadIO()) { if (!sInterposeObserver) { // Lazily create IO interposer observer sInterposeObserver = new mozilla::ProfilerIOInterposeObserver(); } mozilla::IOInterposer::Register(mozilla::IOInterposeObserver::OpAll, sInterposeObserver); } sIsProfiling = true; nsCOMPtr<nsIObserverService> os = mozilla::services::GetObserverService(); if (os) os->NotifyObservers(nullptr, "profiler-started", nullptr); }