MCPcopy Create free account
hub / github.com/AMReX-Codes/amrex / start

Method start

Src/Base/AMReX_TinyProfiler.cpp:98–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

96}
97
98void
99TinyProfiler::start ()
100{
101 if (!enabled) { return; }
102
103 memory_start();
104
105#ifdef AMREX_USE_OMP
106#pragma omp master
107#endif
108 {
109 AMREX_ALWAYS_ASSERT_WITH_MESSAGE(stats.empty(), "TinyProfiler cannot be started twice");
110 }
111
112#ifdef AMREX_USE_OMP
113#pragma omp master
114#endif
115 if (!regionstack.empty()) {
116
117#ifdef AMREX_USE_GPU
118 if (device_synchronize_around_region) {
119 amrex::Gpu::streamSynchronize();
120 }
121#endif
122
123 const double t = amrex::second();
124
125 ttstack.emplace_back(t, 0.0, &fname);
126 global_depth = static_cast<int>(ttstack.size());
127#ifdef AMREX_USE_OMP
128 in_parallel_region = omp_in_parallel();
129#else
130 in_parallel_region = false;
131#endif
132
133#ifdef AMREX_USE_CUDA
134 nvtxRangePush(fname.c_str());
135#elif defined(AMREX_USE_HIP) && defined(AMREX_USE_ROCTX)
136 roctxRangePush(fname.c_str());
137#endif
138
139 for (auto const& region : regionstack)
140 {
141 Stats& st = statsmap[region][fname];
142 ++st.depth;
143 stats.push_back(&st);
144 }
145
146 if (verbose) {
147 ++n_print_tabs;
148 std::string whitespace;
149 for (int itab = 0; itab < n_print_tabs; ++itab) {
150 whitespace += " ";
151 }
152 // If we try to print to output_file here, it may not be thread
153 // safe. Also note that this is controlled by verbose already.
154 amrex::Print() << whitespace << "TP: Entering " << fname << '\n';
155 }

Callers 1

TinyProfileRegionMethod · 0.45

Calls 6

streamSynchronizeFunction · 0.85
secondFunction · 0.85
PrintClass · 0.85
emptyMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected