@@ -215,6 +215,7 @@ int32_t GPUReconstructionCPU::ExitDevice()
215215 return 0 ;
216216}
217217
218+ <<<<<<< Updated upstream
218219namespace
219220{
220221void writeHeaderMarkdown (std::ostream& stream)
@@ -298,6 +299,8 @@ struct Row {
298299};
299300} // namespace
300301
302+ =======
303+ >>>>>>> Stashed changes
301304int32_t GPUReconstructionCPU::RunChains ()
302305{
303306 mMemoryScalers ->temporaryFactor = 1 .;
@@ -342,26 +345,17 @@ int32_t GPUReconstructionCPU::RunChains()
342345 PrintMemoryOverview ();
343346 }
344347
345- mStatWallTime = mTimerTotal .GetElapsedTime ();
346348 std::string nEventReport;
347349 if (GetProcessingSettings ().debugLevel >= 0 && mStatNEvents > 1 ) {
348350 nEventReport += " (avergage of " + std::to_string (mStatNEvents ) + " runs)" ;
349351 }
350352 double kernelTotal = 0 ;
351353 std::vector<double > kernelStepTimes (gpudatatypes::N_RECO_STEPS, 0 .);
352354
353- std::ofstream benchmarkCSV;
354- if (!GetProcessingSettings ().timingCSV .empty ()) {
355- benchmarkCSV.open (GetProcessingSettings ().timingCSV , std::ios::out | std::ios::app);
356- if (!benchmarkCSV.is_open ()) {
357- GPUError (" Could not open timing CSV file '%s' for writing" , GetProcessingSettings ().timingCSV .c_str ());
358- } else if (mNEventsProcessed == 1 ) {
359- writeHeaderCSV (benchmarkCSV);
360- }
361- }
355+ debugWriter writer (GetProcessingSettings ().debugCSV , GetProcessingSettings ().debugMarkdown , mStatNEvents );
362356
363357 if (GetProcessingSettings ().debugLevel >= 1 ) {
364- writeHeaderMarkdown (std::cout );
358+ writer. header ( );
365359 for (uint32_t i = 0 ; i < mTimers .size (); i++) {
366360 double time = 0 ;
367361 if (mTimers [i] == nullptr ) {
@@ -381,19 +375,7 @@ int32_t GPUReconstructionCPU::RunChains()
381375 int32_t stepNum = getRecoStepNum (mTimers [i]->step );
382376 kernelStepTimes[stepNum] += time;
383377 }
384- Row task_row;
385- task_row.type = ' K' ;
386- task_row.name = mTimers [i]->name .c_str ();
387- task_row.gpu_time = time;
388- task_row.count = mTimers [i]->count ;
389- task_row.statNEvents = mStatNEvents ;
390- if (mTimers [i]->memSize && mStatNEvents && time != 0 .) {
391- task_row.memSize = mTimers [i]->memSize ;
392- }
393- if (benchmarkCSV.is_open ()) {
394- task_row.writeCSV (benchmarkCSV);
395- }
396- task_row.writeMarkdown (std::cout);
378+ writer.row (' K' , mTimers [i]->count , mTimers [i]->name .c_str (), time, -1.0 , -1.0 , mTimers [i]->memSize );
397379 if (GetProcessingSettings ().resetTimers ) {
398380 mTimers [i]->count = 0 ;
399381 mTimers [i]->memSize = 0 ;
@@ -403,42 +385,13 @@ int32_t GPUReconstructionCPU::RunChains()
403385 if (GetProcessingSettings ().recoTaskTiming ) {
404386 for (int32_t i = 0 ; i < gpudatatypes::N_RECO_STEPS; i++) {
405387 if (kernelStepTimes[i] != 0 . || mTimersRecoSteps [i].timerTotal .GetElapsedTime () != 0 .) {
406- Row reco_step_row;
407- reco_step_row.name = std::string (gpudatatypes::RECO_STEP_NAMES[i]) + " (Tasks)" ;
408- reco_step_row.gpu_time = kernelStepTimes[i];
409- reco_step_row.cpu_time = mTimersRecoSteps [i].timerCPU ;
410- reco_step_row.total_time = mTimersRecoSteps [i].timerTotal .GetElapsedTime ();
411- reco_step_row.statNEvents = mStatNEvents ;
412- if (benchmarkCSV.is_open ()) {
413- reco_step_row.writeCSV (benchmarkCSV);
414- }
415- reco_step_row.writeMarkdown (std::cout);
388+ writer.row (' ' , 0 , std::string (gpudatatypes::RECO_STEP_NAMES[i]) + " (Tasks)" , kernelStepTimes[i], mTimersRecoSteps [i].timerCPU , mTimersRecoSteps [i].timerTotal .GetElapsedTime (), 0 );
416389 }
417390 if (mTimersRecoSteps [i].bytesToGPU ) {
418- Row reco_step_row;
419- reco_step_row.type = ' D' ;
420- reco_step_row.name = std::string (gpudatatypes::RECO_STEP_NAMES[i]) + " (DMA to GPU)" ;
421- reco_step_row.gpu_time = mTimersRecoSteps [i].timerToGPU .GetElapsedTime ();
422- reco_step_row.memSize = mTimersRecoSteps [i].bytesToGPU ;
423- reco_step_row.count = mTimersRecoSteps [i].countToGPU ;
424- reco_step_row.statNEvents = mStatNEvents ;
425- if (benchmarkCSV.is_open ()) {
426- reco_step_row.writeCSV (benchmarkCSV);
427- }
428- reco_step_row.writeMarkdown (std::cout);
391+ writer.row (' D' , mTimersRecoSteps [i].countToGPU , std::string (gpudatatypes::RECO_STEP_NAMES[i]) + " (DMA to GPU)" , mTimersRecoSteps [i].timerToGPU .GetElapsedTime (), -1.0 , -1.0 , mTimersRecoSteps [i].bytesToGPU );
429392 }
430393 if (mTimersRecoSteps [i].bytesToHost ) {
431- Row reco_step_row;
432- reco_step_row.type = ' D' ;
433- reco_step_row.name = std::string (gpudatatypes::RECO_STEP_NAMES[i]) + " (DMA to Host)" ;
434- reco_step_row.gpu_time = mTimersRecoSteps [i].timerToHost .GetElapsedTime ();
435- reco_step_row.memSize = mTimersRecoSteps [i].bytesToHost ;
436- reco_step_row.count = mTimersRecoSteps [i].countToHost ;
437- reco_step_row.statNEvents = mStatNEvents ;
438- if (benchmarkCSV.is_open ()) {
439- reco_step_row.writeCSV (benchmarkCSV);
440- }
441- reco_step_row.writeMarkdown (std::cout);
394+ writer.row (' D' , mTimersRecoSteps [i].countToHost , std::string (gpudatatypes::RECO_STEP_NAMES[i]) + " (DMA to Host)" , mTimersRecoSteps [i].timerToHost .GetElapsedTime (), -1.0 , -1.0 , mTimersRecoSteps [i].bytesToHost );
442395 }
443396 if (GetProcessingSettings ().resetTimers ) {
444397 mTimersRecoSteps [i].bytesToGPU = mTimersRecoSteps [i].bytesToHost = 0 ;
@@ -452,30 +405,13 @@ int32_t GPUReconstructionCPU::RunChains()
452405 }
453406 for (int32_t i = 0 ; i < gpudatatypes::N_GENERAL_STEPS; i++) {
454407 if (mTimersGeneralSteps [i].GetElapsedTime () != 0 .) {
455- Row general_step_row;
456- general_step_row.name = gpudatatypes::GENERAL_STEP_NAMES[i];
457- general_step_row.gpu_time = mTimersGeneralSteps [i].GetElapsedTime ();
458- general_step_row.statNEvents = mStatNEvents ;
459- if (benchmarkCSV.is_open ()) {
460- general_step_row.writeCSV (benchmarkCSV);
461- }
462- general_step_row.writeMarkdown (std::cout);
408+ writer.row (' ' , 0 , gpudatatypes::GENERAL_STEP_NAMES[i], mTimersGeneralSteps [i].GetElapsedTime (), -1.0 , -1.0 , 0 );
463409 }
464410 }
465- Row wall_row;
466- wall_row.name = " Wall" ;
467- if (GetProcessingSettings ().debugLevel >= 1 ) {
468- wall_row.gpu_time = kernelTotal;
469- }
470- wall_row.cpu_time = mStatCPUTime ;
471- wall_row.total_time = mStatWallTime ;
472- wall_row.statNEvents = mStatNEvents ;
473- if (benchmarkCSV.is_open ()) {
474- wall_row.writeCSV (benchmarkCSV);
475- }
476- wall_row.writeMarkdown (std::cout);
411+ double gpu_time = GetProcessingSettings ().debugLevel >= 1 ? kernelTotal : -1.0 ;
412+ writer.row (' ' , 0 , " Wall" , gpu_time, mStatCPUTime , mTimerTotal .GetElapsedTime (), 0 , nEventReport);
477413 } else if (GetProcessingSettings ().debugLevel >= 0 ) {
478- GPUInfo (" Total Wall Time: %10.0f us%s" , mStatWallTime * 1000000 / mStatNEvents , nEventReport.c_str ());
414+ GPUInfo (" Total Wall Time: %10.0f us%s" , mTimerTotal . GetElapsedTime () * 1000000 / mStatNEvents , nEventReport.c_str ());
479415 }
480416 if (GetProcessingSettings ().resetTimers ) {
481417 mStatNEvents = 0 ;
0 commit comments