Skip to content

Commit 38568a6

Browse files
clang-format
1 parent 5c23211 commit 38568a6

File tree

2 files changed

+87
-64
lines changed

2 files changed

+87
-64
lines changed

GPU/GPUTracking/Base/GPUReconstruction.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,7 @@ class GPUReconstruction
428428
debugWriter(std::string filenameCSV, bool markdown, uint32_t statNEvents);
429429
void header();
430430
void 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 = "");
431+
431432
private:
432433
std::ofstream streamCSV;
433434
bool mMarkdown;

GPU/GPUTracking/Base/GPUReconstructionDebug.cxx

Lines changed: 86 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -189,84 +189,106 @@ bool GPUReconstruction::triggerDebugDump()
189189
return false;
190190
}
191191

192-
GPUReconstruction::debugWriter::debugWriter(std::string filenameCSV, bool markdown, uint32_t statNEvents) : mMarkdown{markdown}, mStatNEvents{statNEvents} {
192+
GPUReconstruction::debugWriter::debugWriter(std::string filenameCSV, bool markdown, uint32_t statNEvents) : mMarkdown{markdown}, mStatNEvents{statNEvents}
193+
{
193194
if (!filenameCSV.empty()) {
194195
streamCSV.open(filenameCSV, std::ios::out | std::ios::app);
195196
}
196197
}
197198

198-
void GPUReconstruction::debugWriter::header() {
199+
void GPUReconstruction::debugWriter::header()
200+
{
199201
if (streamCSV.is_open() && !streamCSV.tellp()) {
200-
streamCSV << "type,count,name,gpu (us),cpu (us),cpu/total,total (us),GB/s,bytes,bytes/call\n";
202+
streamCSV << "type,count,name,gpu (us),cpu (us),cpu/total,total (us),GB/s,bytes,bytes/call\n";
201203
}
202204

203205
if (mMarkdown) {
204-
std::cout << "| | count | name | gpu (us) | cpu (us) | cpu/tot | tot (us) | GB/s | bytes | bytes/call |\n";
205-
std::cout << "|---|--------|-------------------------------------------|-----------|-----------|---------|-----------|-----------|---------------|---------------|\n";
206+
std::cout << "| | count | name | gpu (us) | cpu (us) | cpu/tot | tot (us) | GB/s | bytes | bytes/call |\n";
207+
std::cout << "|---|--------|-------------------------------------------|-----------|-----------|---------|-----------|-----------|---------------|---------------|\n";
206208
}
207209
}
208210

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;
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;
211214

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-
}
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+
}
228238

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());
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);
270272
}
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());
290+
}
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());
271292
}
293+
}
272294
}

0 commit comments

Comments
 (0)