@@ -189,106 +189,84 @@ bool GPUReconstruction::triggerDebugDump()
189189 return false ;
190190}
191191
192- GPUReconstruction::debugWriter::debugWriter (std::string filenameCSV, bool markdown, uint32_t statNEvents) : mMarkdown{markdown}, mStatNEvents {statNEvents}
193- {
192+ GPUReconstruction::debugWriter::debugWriter (std::string filenameCSV, bool markdown, uint32_t statNEvents) : mMarkdown{markdown}, mStatNEvents {statNEvents} {
194193 if (!filenameCSV.empty ()) {
195194 streamCSV.open (filenameCSV, std::ios::out | std::ios::app);
196195 }
197196}
198197
199- void GPUReconstruction::debugWriter::header ()
200- {
198+ void GPUReconstruction::debugWriter::header () {
201199 if (streamCSV.is_open () && !streamCSV.tellp ()) {
202- streamCSV << " type,count,name,gpu (us),cpu (us),cpu/total,total (us),GB/s,bytes,bytes/call\n " ;
200+ streamCSV << " type,count,name,gpu (us),cpu (us),cpu/total,total (us),GB/s,bytes,bytes/call\n " ;
203201 }
204202
205203 if (mMarkdown ) {
206- std::cout << " | | count | name | gpu (us) | cpu (us) | cpu/tot | tot (us) | GB/s | bytes | bytes/call |\n " ;
207- std::cout << " |---|--------|-------------------------------------------|-----------|-----------|---------|-----------|-----------|---------------|---------------|\n " ;
204+ std::cout << " | | count | name | gpu (us) | cpu (us) | cpu/tot | tot (us) | GB/s | bytes | bytes/call |\n " ;
205+ std::cout << " |---|--------|-------------------------------------------|-----------|-----------|---------|-----------|-----------|---------------|---------------|\n " ;
208206 }
209207}
210208
211- void GPUReconstruction::debugWriter::row (char type, uint32_t count, std::string name, double gpu_time, double cpu_time, double total_time, std::size_t memSize, std::string nEventReport)
212- {
213- double scale = 1000000.0 / mStatNEvents ;
209+ void GPUReconstruction::debugWriter::row (char type, uint32_t count, std::string name, double gpu_time, double cpu_time, double total_time, std::size_t memSize, std::string nEventReport) {
210+ double scale = 1000000.0 / mStatNEvents ;
214211
215- if (streamCSV.is_open ()) {
216- streamCSV << type << " ," ;
217- if (count != 0 )
218- streamCSV << count;
219- streamCSV << " ," << name << " ," ;
220- if (gpu_time != -1.0 )
221- streamCSV << std::format (" {:.0f}" , gpu_time * scale);
222- streamCSV << " ," ;
223- if (cpu_time != -1.0 )
224- streamCSV << std::format (" {:.0f}" , cpu_time * scale);
225- streamCSV << " ," ;
226- if (cpu_time != -1.0 && total_time != -1.0 )
227- streamCSV << std::format (" {:.2f}" , cpu_time / total_time);
228- streamCSV << " ," ;
229- if (total_time != -1.0 )
230- streamCSV << std::format (" {:.0f}" , total_time * scale);
231- streamCSV << " ," ;
232- if (memSize != 0 && count != 0 )
233- streamCSV << std::format (" {:.3f},{},{}" , memSize / gpu_time * 1e-9 , memSize / mStatNEvents , memSize / mStatNEvents / count);
234- else
235- streamCSV << " ,," ;
236- streamCSV << std::endl;
237- }
212+ if (streamCSV.is_open ()) {
213+ streamCSV << type << " ," ;
214+ if (count != 0 ) streamCSV << count;
215+ streamCSV << " ," << name << " ," ;
216+ if (gpu_time != -1.0 ) streamCSV << std::format (" {:.0f}" , gpu_time * scale);
217+ streamCSV << " ," ;
218+ if (cpu_time != -1.0 ) streamCSV << std::format (" {:.0f}" , cpu_time * scale);
219+ streamCSV << " ," ;
220+ if (cpu_time != -1.0 && total_time != -1.0 ) streamCSV << std::format (" {:.2f}" , cpu_time / total_time);
221+ streamCSV << " ," ;
222+ if (total_time != -1.0 ) streamCSV << std::format (" {:.0f}" , total_time * scale);
223+ streamCSV << " ," ;
224+ if (memSize != 0 && count != 0 ) streamCSV << std::format (" {:.3f},{},{}" , memSize / gpu_time * 1e-9 , memSize / mStatNEvents , memSize / mStatNEvents / count);
225+ else streamCSV << " ,," ;
226+ streamCSV << std::endl;
227+ }
238228
239- if (mMarkdown ) {
240- std::cout << " | " << type << " | " ;
241- if (count != 0 )
242- std::cout << std::format (" {:6} |" , count);
243- else
244- std::cout << " |" ;
245- std::cout << std::format (" {:42}|" , name);
246- if (gpu_time != -1.0 )
247- std::cout << std::format (" {:10.0f} |" , gpu_time * scale);
248- else
249- std::cout << " |" ;
250- if (cpu_time != -1.0 )
251- std::cout << std::format (" {:10.0f} |" , cpu_time * scale);
252- else
253- std::cout << " |" ;
254- if (cpu_time != -1.0 && total_time != -1.0 )
255- std::cout << std::format (" {:8.2f} |" , cpu_time / total_time);
256- else
257- std::cout << " |" ;
258- if (total_time != -1.0 )
259- std::cout << std::format (" {:10.0f} |" , total_time * scale);
260- else
261- std::cout << " |" ;
262- if (memSize != 0 && count != 0 )
263- std::cout << std::format (" {:10.3f} |{:14} |{:14} |" , memSize / gpu_time * 1e-9 , memSize / mStatNEvents , memSize / mStatNEvents / count);
264- else
265- std::cout << " | | |" ;
266- std::cout << std::endl;
267- } else {
268- if (name.substr (0 , 3 ) == " GPU" ) {
269- char bandwidth[256 ] = " " ;
270- if (memSize && mStatNEvents && gpu_time != 0.0 ) {
271- snprintf (bandwidth, 256 , " (%8.3f GB/s - %'14zu bytes - %'14zu per call)" , memSize / gpu_time * 1e-9 , memSize / mStatNEvents , memSize / mStatNEvents / count);
272- }
273- printf (" Execution Time: Task (%c %8ux): %50s Time: %'10.0f us%s\n " , type, count, name.c_str (), gpu_time * scale, bandwidth);
274- } else if (name.substr (0 , 3 ) == " TPC" ) {
275- std::size_t n = name.find (' (' );
276- std::string basename = name.substr (0 , n - 1 );
277- std::string postfix = name.substr (n + 1 , name.size () - n - 2 );
278- if (total_time != -1.0 ) {
279- printf (" Execution Time: Step : %11s %38s Time: %'10.0f us %64s ( Total Time : %'14.0f us, CPU Time : %'14.0f us, %'7.2fx )\n " , postfix.c_str (),
280- basename.c_str (), gpu_time * scale, " " , total_time * scale, cpu_time * scale, cpu_time / total_time);
281- } else {
282- printf (" Execution Time: Step (D %8ux): %11s %38s Time: %'10.0f us (%8.3f GB/s - %'14zu bytes - %'14zu per call)\n " , count, postfix.c_str (), basename.c_str (), gpu_time * scale,
283- memSize / gpu_time * 1e-9 , memSize / mStatNEvents , memSize / mStatNEvents / count);
284- }
285- } else if (name == " Prepare" ) {
286- printf (" Execution Time: General Step : %50s Time: %'10.0f us\n " , name.c_str (), gpu_time * scale);
287- } else if (name == " Wall" ) {
288- if (gpu_time != -1.0 ) {
289- printf (" Execution Time: Total : %50s Time: %'10.0f us%s\n " , " Total Kernel" , gpu_time * scale, nEventReport.c_str ());
229+ if (mMarkdown ) {
230+ std::cout << " | " << type << " | " ;
231+ if (count != 0 ) std::cout << std::format (" {:6} |" , count);
232+ else std::cout << " |" ;
233+ std::cout << std::format (" {:42}|" , name);
234+ if (gpu_time != -1.0 ) std::cout << std::format (" {:10.0f} |" , gpu_time * scale);
235+ else std::cout << " |" ;
236+ if (cpu_time != -1.0 ) std::cout << std::format (" {:10.0f} |" , cpu_time * scale);
237+ else std::cout << " |" ;
238+ if (cpu_time != -1.0 && total_time != -1.0 ) std::cout << std::format (" {:8.2f} |" , cpu_time / total_time);
239+ else std::cout << " |" ;
240+ if (total_time != -1.0 ) std::cout << std::format (" {:10.0f} |" , total_time * scale);
241+ else std::cout << " |" ;
242+ if (memSize != 0 && count != 0 ) std::cout << std::format (" {:10.3f} |{:14} |{:14} |" , memSize / gpu_time * 1e-9 , memSize / mStatNEvents , memSize / mStatNEvents / count);
243+ else std::cout << " | | |" ;
244+ std::cout << std::endl;
245+ } else {
246+ if (name.substr (0 , 3 ) == " GPU" ) {
247+ char bandwidth[256 ] = " " ;
248+ if (memSize && mStatNEvents && gpu_time != 0.0 ) {
249+ snprintf (bandwidth, 256 , " (%8.3f GB/s - %'14zu bytes - %'14zu per call)" , memSize / gpu_time * 1e-9 , memSize / mStatNEvents , memSize / mStatNEvents / count);
250+ }
251+ printf (" Execution Time: Task (%c %8ux): %50s Time: %'10.0f us%s\n " , type, count, name.c_str (), gpu_time * scale, bandwidth);
252+ } else if (name.substr (0 , 3 ) == " TPC" ) {
253+ std::size_t n = name.find (' (' );
254+ std::string basename = name.substr (0 , n - 1 );
255+ std::string postfix = name.substr (n + 1 , name.size () - n - 2 );
256+ if (total_time != -1.0 ) {
257+ printf (" Execution Time: Step : %11s %38s Time: %'10.0f us %64s ( Total Time : %'14.0f us, CPU Time : %'14.0f us, %'7.2fx )\n " , postfix.c_str (),
258+ basename.c_str (), gpu_time * scale, " " , total_time * scale, cpu_time * scale, cpu_time / total_time);
259+ } else {
260+ printf (" Execution Time: Step (D %8ux): %11s %38s Time: %'10.0f us (%8.3f GB/s - %'14zu bytes - %'14zu per call)\n " , count, postfix.c_str (), basename.c_str (), gpu_time * scale,
261+ memSize / gpu_time * 1e-9 , memSize / mStatNEvents , memSize / mStatNEvents / count);
262+ }
263+ } else if (name == " Prepare" ) {
264+ printf (" Execution Time: General Step : %50s Time: %'10.0f us\n " , name.c_str (), gpu_time * scale);
265+ } else if (name == " Wall" ) {
266+ if (gpu_time != -1.0 ) {
267+ printf (" Execution Time: Total : %50s Time: %'10.0f us%s\n " , " Total Kernel" , gpu_time * scale, nEventReport.c_str ());
268+ }
269+ printf (" Execution Time: Total : %50s Time: %'10.0f us ( CPU Time : %'10.0f us, %7.2fx ) %s\n " , " Total Wall" , total_time * scale, cpu_time * scale, cpu_time / total_time, nEventReport.c_str ());
290270 }
291- printf (" Execution Time: Total : %50s Time: %'10.0f us ( CPU Time : %'10.0f us, %7.2fx ) %s\n " , " Total Wall" , total_time * scale, cpu_time * scale, cpu_time / total_time, nEventReport.c_str ());
292271 }
293- }
294272}
0 commit comments