22#include <unordered_map>
36 std::unordered_map<int32_t, struct sigaction>
oldActions;
49 static std::mutex initMutex;
51 std::lock_guard<std::mutex> guard(initMutex);
53 GPUFatal(
"Error handlers for debug dumps already set, cannot set them again");
55 mDebugData = std::make_unique<debugInternal>();
59 struct sigaction sa, oldsa;
60 memset(&sa, 0,
sizeof(sa));
62 sa.sa_flags = SA_SIGINFO;
66 if (
mask & (1 <<
i)) {
67 if (sigaction(
i, &sa, &oldsa)) {
68 GPUFatal(
"Error installing signal handler for error dump on signal %d",
i);
75 mDebugData->signalCallback = [
this, &oldActions =
mDebugData->oldActions, myAction = std::move(sa)](
int32_t signal, siginfo_t* info,
void* ucontext) {
76 static std::mutex callbackMutex;
77 std::lock_guard<std::mutex> guard(callbackMutex);
79 GPUInfo(
"Running debug callback for signal %d", signal);
85 sigaction(signal, &oldActions[signal],
nullptr);
87 mDebugData->reinstallCallback = [signal, myAction]() { sigaction(signal, &myAction,
nullptr); };
101 if (sigaction(it.first, &it.second,
nullptr)) {
102 GPUFatal(
"Error restoring signal handler for signal %d", it.first);
126 std::size_t total_size = 0;
127 std::size_t subfolder_count = 0;
129 if (!std::filesystem::exists(target_dir) || !std::filesystem::is_directory(target_dir)) {
130 GPUError(
"Invalid debugOnFailureDirectory %s",
GetProcessingSettings().debugOnFailureDirectory.c_str());
134 for (
const auto&
entry : std::filesystem::directory_iterator(target_dir)) {
135 if (
entry.is_directory()) {
138 for (
const auto& subentry : std::filesystem::directory_iterator(
entry.path())) {
139 if (subentry.is_regular_file()) {
141 auto size = std::filesystem::file_size(subentry.path(), ec);
151 GPUError(
"Cannot store debug dump files, target storage exceeded: %zu dumps, %zu bytes", subfolder_count, total_size);
155 auto currentTime = std::chrono::system_clock::to_time_t(std::chrono::system_clock::now());
156 std::ostringstream dateTime;
157 dateTime << std::put_time(std::localtime(¤tTime),
"%Y-%m-%d_%H-%M-%S");
162 if (attempt++ >= 512) {
163 GPUError(
"Error creating debug dump folder");
169 bool created = std::filesystem::create_directory(outname, ec);
170 if (!ec && created) {
175 GPUInfo(
"Debug dump to %s", outname.c_str());
184 GPUInfo(
"Running triggered debug callback");
193GPUReconstructionCPU::debugWriter::debugWriter(std::string filenameCSV,
bool markdown,
uint32_t statNEvents) : mMarkdown{markdown}, mStatNEvents{statNEvents}
195 if (!filenameCSV.empty()) {
196 streamCSV.open(filenameCSV, std::ios::out | std::ios::app);
200void GPUReconstructionCPU::debugWriter::header()
202 if (streamCSV.is_open() && !streamCSV.tellp()) {
203 streamCSV <<
"type,count,name,gpu (us),cpu (us),cpu/total,total (us),GB/s,bytes,bytes/call\n";
207 std::cout <<
"| | count | name | gpu (us) | cpu (us) | cpu/tot | tot (us) | GB/s | bytes | bytes/call |\n";
208 std::cout <<
"|---|--------|-------------------------------------------|-----------|-----------|---------|-----------|-----------|---------------|---------------|\n";
212void GPUReconstructionCPU::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)
214 double scale = 1000000.0 / mStatNEvents;
216 if (streamCSV.is_open()) {
217 streamCSV <<
type <<
",";
221 streamCSV <<
"," <<
name <<
",";
222 if (gpu_time != -1.0) {
223 streamCSV << std::format(
"{:.0f}", gpu_time * scale);
226 if (cpu_time != -1.0) {
227 streamCSV << std::format(
"{:.0f}", cpu_time * scale);
230 if (cpu_time != -1.0 && total_time != -1.0) {
231 streamCSV << std::format(
"{:.2f}", cpu_time / total_time);
234 if (total_time != -1.0) {
235 streamCSV << std::format(
"{:.0f}", total_time * scale);
238 if (memSize != 0 &&
count != 0) {
239 streamCSV << std::format(
"{:.3f},{},{}", memSize / gpu_time * 1
e-9, memSize / mStatNEvents, memSize / mStatNEvents /
count);
243 streamCSV << std::endl;
247 std::cout <<
"| " <<
type <<
" | ";
249 std::cout << std::format(
"{:6} |",
count);
253 std::cout << std::format(
" {:42}|",
name);
254 if (gpu_time != -1.0) {
255 std::cout << std::format(
"{:10.0f} |", gpu_time * scale);
259 if (cpu_time != -1.0) {
260 std::cout << std::format(
"{:10.0f} |", cpu_time * scale);
264 if (cpu_time != -1.0 && total_time != -1.0) {
265 std::cout << std::format(
"{:8.2f} |", cpu_time / total_time);
269 if (total_time != -1.0) {
270 std::cout << std::format(
"{:10.0f} |", total_time * scale);
274 if (memSize != 0 &&
count != 0) {
275 std::cout << std::format(
"{:10.3f} |{:14} |{:14} |", memSize / gpu_time * 1
e-9, memSize / mStatNEvents, memSize / mStatNEvents /
count);
277 std::cout <<
" | | |";
279 std::cout << std::endl;
281 if (
name.substr(0, 3) ==
"GPU") {
282 char bandwidth[256] =
"";
283 if (memSize && mStatNEvents && gpu_time != 0.0) {
284 snprintf(bandwidth, 256,
" (%8.3f GB/s - %'14zu bytes - %'14zu per call)", memSize / gpu_time * 1
e-9, memSize / mStatNEvents, memSize / mStatNEvents /
count);
286 printf(
"Execution Time: Task (%c %8ux): %50s Time: %'10.0f us%s\n",
type,
count,
name.c_str(), gpu_time * scale, bandwidth);
287 }
else if (
name.substr(0, 3) ==
"TPC") {
288 std::size_t
n =
name.find(
'(');
289 std::string basename =
name.substr(0,
n - 1);
290 std::string postfix =
name.substr(
n + 1,
name.size() -
n - 2);
291 if (total_time != -1.0) {
292 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(),
293 basename.c_str(), gpu_time * scale,
"", total_time * scale, cpu_time * scale, cpu_time / total_time);
295 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,
296 memSize / gpu_time * 1
e-9, memSize / mStatNEvents, memSize / mStatNEvents /
count);
298 }
else if (
name ==
"Prepare") {
299 printf(
"Execution Time: General Step : %50s Time: %'10.0f us\n",
name.c_str(), gpu_time * scale);
300 }
else if (
name ==
"Wall") {
301 if (gpu_time != -1.0) {
302 printf(
"Execution Time: Total : %50s Time: %'10.0f us%s\n",
"Total Kernel", gpu_time * scale, nEventReport.c_str());
304 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());
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char e
configStandalone Reconstruction rec_tpc multiplier for the combined cluster track error during track following area in cm for the search of for z only used if decrease removal by when above this local occupancy rowx Shift of TPC revert cluster flag edge bit distance to edge exceeds this ZOffset for secondary multiple of radius max P of electron K BB bands crossing max P of electron p BB bands crossing max P of electron d BB bands crossing max P of electron t BB bands crossing min accepted dEdxMaxTPC of the track Additive extra cluster error for Y2 if edge flag set Additive extra cluster error for Y2 if single set Additive extra cluster error for Y2 if or single set Additive extra cluster error for Z2 if or single set Extra errors to add to track when crossing depending on addErrorsCECrossing Inner portion of y range in sector that is not used in searching for extrapolated track candidates factor2YS for track merging factor2K for track merging Margin in cm of Y position when rejecting edge clusters based on uncorrected track Y Max fraction of shared clusters for tracklet Except pad from cluster finding if total number of charges in a fragment is above this Except pad from cluster finding if number of consecutive charges in a fragment is above this Threshold where a timebin is considered disabling the noisy pad check for that pad Treat signal above this minimum as saturated Smoothing factor for the exponential Highly Ionising Particle tail filter Number of timebins to use for the averaging Add additional custom track errors when crossing relative as fraction of Do N fit passes in final fit of< 0:reject at max -n hits") AddOptionRTC(rejectIFCLowRadiusCluster, uint8_t, 1, "", 0, "Reject clusters that get the IFC mask error during refit") AddOptionRTC(dEdxTruncLow, uint8_t, 2, "", 0, "Low truncation threshold, fraction of 128") AddOptionRTC(dEdxTruncHigh, uint8_t, 77, "", 0, "High truncation threshold, fraction of 128") AddOptionRTC(extrapolationTracking, int8_t, 1, "", 0, "Enable Extrapolation Tracking(prolong tracks to adjacent sectors to find short segments)") AddOptionRTC(disableRefitAttachment, uint8_t, 0, "", 0, "Bitmask to disable certain attachment steps during refit(1:attachment, 2:propagation, 4:loop following, 8:mirroring)") AddOptionRTC(rejectionStrategy, uint8_t, o2::gpu::GPUSettings::RejectionStrategyA, "", 0, "Enable rejection of TPC clusters for compression(0=no, 1=strategy A, 2=strategy B)") AddOptionRTC(mergeLoopersAfterburner, uint8_t, 1, "", 0, "Run afterburner for additional looper merging") AddOptionRTC(compressionTypeMask, uint8_t, o2::gpu::GPUSettings::CompressionFull, "", 0, "TPC Compression mode bits(1=truncate charge/width LSB, 2=differences, 4=track-model)") AddOptionRTC(compressionSortOrder, uint8_t, o2::gpu::GPUSettings::SortTime, "", 0, "Sort order of TPC compression(0=time, 1=pad, 2=Z-time-pad, 3=Z-pad-time, 4=no sorting(use incoming order))") AddOptionRTC(sigBitsCharge, uint8_t, 4, "", 0, "Number of significant bits for TPC cluster charge in compression mode 1") AddOptionRTC(sigBitsWidth, uint8_t, 3, "", 0, "Number of significant bits for TPC cluster width in compression mode 1") AddOptionRTC(dropLoopers, uint8_t, 0, "", 0, "Drop looping tracks starting from second loop") AddOptionRTC(mergerInterpolateErrors, uint8_t, 1, "", 0, "Use interpolation instead of extrapolation for chi2 based cluster rejection") AddOptionRTC(mergerInterpolateRejectAlsoOnCurrentPosition, uint8_t, 1, "", 0, "When using mergerInterpolateErrors, reject based on chi2 twice computed with interpolated and current track position starting from NDF > mergerNonInterpolateRejectMinNDF Merge tracks accross the central electrode Enable PID response Add sub threshold clusters in TPC dEdx computation OR mask of TPC flags that will reject the cluster in alternative dEdx Reject edge clusters based on uncorrected track Y during track fit Increase decrease removal by when on this number of pads from the edge h configStandalone Reconstruction rec_trd Max chi2 for TRD tracklets to be matched to a track Chi2 cut for strict matching mode Number of sigmas for ITS TPC track time error estimate Addition to search road around track prolongation along Y in cm Optimal tracklet rphi resolution in maximum chi2 per attached tracklet for TRD tracks take into account the full likelihood of the slope including exponential tails Tracks with less attached tracklets are discarded after the tracking Post trigger Pile up integration time in BCs fits all iterations but the last one in projections Use material lookup table for TPC refit Apply workarounds to avoid cyclic merge should not be needed tpc dyn configStandalone Processing proc_rtc Replace constant variables static by constexpr expressions Compile RTC in deterministic with NO_FAST_MATH flags and GPUCA_DETERMINISTIC_MODE define Use RTC to optimize GPU code h configStandalone Processing proc_rtctech Use a file lock to serialize access to the cache folder int32_t
GPUReconstruction * mMaster
std::string getDebugFolder(const std::string &prefix="")
void setDebugDumpCallback(std::function< void()> &&callback=std::function< void()>(nullptr))
static std::unique_ptr< debugInternal > mDebugData
const GPUSettingsProcessing & GetProcessingSettings() const
GLuint const GLchar * name
GLint GLint GLsizei GLint GLenum GLenum type
typedef void(APIENTRYP PFNGLCULLFACEPROC)(GLenum mode)
std::string to_string(gsl::span< T, Size > span)
std::function< void()> debugCallback
std::function< void(int32_t, siginfo_t *, void *)> signalCallback
static void globalCallback(int32_t signal, siginfo_t *info, void *ucontext)
std::unordered_map< int32_t, struct sigaction > oldActions
std::function< void()> reinstallCallback