3939#include < format>
4040#include < string>
4141
42-
4342#ifndef _WIN32
4443#include < unistd.h>
4544#endif
@@ -216,14 +215,17 @@ int32_t GPUReconstructionCPU::ExitDevice()
216215 return 0 ;
217216}
218217
219- namespace {
220- void writeHeaderMarkdown (std::ostream& stream) {
221- stream << " | | count | name | gpu (us) | cpu (us) | cpu/tot | tot (us) | GB/s | bytes | bytes/call |\n " ;
222- stream << " |---|--------|-------------------------------------------|-----------|-----------|---------|-----------|-----------|---------------|---------------|\n " ;
218+ namespace
219+ {
220+ void writeHeaderMarkdown (std::ostream& stream)
221+ {
222+ stream << " | | count | name | gpu (us) | cpu (us) | cpu/tot | tot (us) | GB/s | bytes | bytes/call |\n " ;
223+ stream << " |---|--------|-------------------------------------------|-----------|-----------|---------|-----------|-----------|---------------|---------------|\n " ;
223224}
224225
225- void writeHeaderCSV (std::ostream& stream) {
226- stream << " type,count,name,gpu (us),cpu (us),cpu/total,total (us),GB/s,bytes,bytes/call\n " ;
226+ void writeHeaderCSV (std::ostream& stream)
227+ {
228+ stream << " type,count,name,gpu (us),cpu (us),cpu/total,total (us),GB/s,bytes,bytes/call\n " ;
227229}
228230
229231struct Row {
@@ -236,44 +238,65 @@ struct Row {
236238 uint32_t memSize = 0 ;
237239 uint32_t statNEvents;
238240
239- void writeMarkdown (std::ostream& stream) {
241+ void writeMarkdown (std::ostream& stream)
242+ {
240243 double scale = 1000000.0 / statNEvents;
241244 stream << " | " << type << " | " ;
242- if (count != 0 ) stream << std::format (" {:6} |" , count);
243- else stream << " |" ;
245+ if (count != 0 )
246+ stream << std::format (" {:6} |" , count);
247+ else
248+ stream << " |" ;
244249 stream << std::format (" {:42}|" , name);
245- if (gpu_time != -1.0 ) stream << std::format (" {:10.0f} |" , gpu_time * scale);
246- else stream << " |" ;
247- if (cpu_time != -1.0 ) stream << std::format (" {:10.0f} |" , cpu_time * scale);
248- else stream << " |" ;
249- if (cpu_time != -1.0 && total_time != -1.0 ) stream << std::format (" {:8.2f} |" , cpu_time / total_time);
250- else stream << " |" ;
251- if (total_time != -1.0 ) stream << std::format (" {:10.0f} |" , total_time * scale);
252- else stream << " |" ;
253- if (memSize != 0 && count != 0 ) stream << std::format (" {:10.3f} |{:14} |{:14} |" , memSize / gpu_time * 1e-9 , memSize / statNEvents, memSize / statNEvents / count);
254- else stream << " | | |" ;
250+ if (gpu_time != -1.0 )
251+ stream << std::format (" {:10.0f} |" , gpu_time * scale);
252+ else
253+ stream << " |" ;
254+ if (cpu_time != -1.0 )
255+ stream << std::format (" {:10.0f} |" , cpu_time * scale);
256+ else
257+ stream << " |" ;
258+ if (cpu_time != -1.0 && total_time != -1.0 )
259+ stream << std::format (" {:8.2f} |" , cpu_time / total_time);
260+ else
261+ stream << " |" ;
262+ if (total_time != -1.0 )
263+ stream << std::format (" {:10.0f} |" , total_time * scale);
264+ else
265+ stream << " |" ;
266+ if (memSize != 0 && count != 0 )
267+ stream << std::format (" {:10.3f} |{:14} |{:14} |" , memSize / gpu_time * 1e-9 , memSize / statNEvents, memSize / statNEvents / count);
268+ else
269+ stream << " | | |" ;
255270 stream << std::endl;
256271 }
257272
258- void writeCSV (std::ostream& stream) {
273+ void writeCSV (std::ostream& stream)
274+ {
259275 double scale = 1000000.0 / statNEvents;
260276 stream << type << " ," ;
261- if (count != 0 ) stream << count;
277+ if (count != 0 )
278+ stream << count;
262279 stream << " ," << name << " ," ;
263- if (gpu_time != -1.0 ) stream << std::format (" {:.0f}" , gpu_time * scale);
280+ if (gpu_time != -1.0 )
281+ stream << std::format (" {:.0f}" , gpu_time * scale);
264282 stream << " ," ;
265- if (cpu_time != -1.0 ) stream << std::format (" {:.0f}" , cpu_time * scale);
283+ if (cpu_time != -1.0 )
284+ stream << std::format (" {:.0f}" , cpu_time * scale);
266285 stream << " ," ;
267- if (cpu_time != -1.0 && total_time != -1.0 ) stream << std::format (" {:.2f}" , cpu_time / total_time);
286+ if (cpu_time != -1.0 && total_time != -1.0 )
287+ stream << std::format (" {:.2f}" , cpu_time / total_time);
268288 stream << " ," ;
269- if (total_time != -1.0 ) stream << std::format (" {:.0f}" , total_time * scale);
289+ if (total_time != -1.0 )
290+ stream << std::format (" {:.0f}" , total_time * scale);
270291 stream << " ," ;
271- if (memSize != 0 && count != 0 ) stream << std::format (" {:.3f},{},{}" , memSize / gpu_time * 1e-9 , memSize / statNEvents, memSize / statNEvents / count);
272- else stream << " ,," ;
292+ if (memSize != 0 && count != 0 )
293+ stream << std::format (" {:.3f},{},{}" , memSize / gpu_time * 1e-9 , memSize / statNEvents, memSize / statNEvents / count);
294+ else
295+ stream << " ,," ;
273296 stream << std::endl;
274297 }
275298};
276- }
299+ } // namespace
277300
278301int32_t GPUReconstructionCPU::RunChains ()
279302{
0 commit comments