Skip to content

Commit 37873b7

Browse files
committed
Fix printf syntax / improve printf(size_t) usage / simplify syntax for MacOS
1 parent e4c0849 commit 37873b7

File tree

9 files changed

+33
-30
lines changed

9 files changed

+33
-30
lines changed

Detectors/TPC/workflow/readers/include/TPCReaderWorkflow/TPCSectorCompletionPolicy.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ class TPCSectorCompletionPolicy
228228
mExternalInputMatchers = arg;
229229
} else if constexpr (std::is_same_v<Type, std::function<bool(o2::framework::DataProcessingHeader::StartTime)>**>) {
230230
mOrderCheck = arg;
231-
} else if constexpr (std::is_same_v<Type, unsigned long*> || std::is_same_v<Type, const unsigned long*>) {
231+
} else if constexpr (std::is_same_v<Type, uint64_t*> || std::is_same_v<Type, const uint64_t*>) {
232232
mTpcSectorMask = arg;
233233
} else {
234234
static_assert(framework::always_static_assert_v<Type>);
@@ -245,7 +245,7 @@ class TPCSectorCompletionPolicy
245245
// - They are controlled externally and the external entity can modify them, e.g. after parsing command line arguments.
246246
// - They are all matched independently, it is not sufficient that one of them is present for all sectors
247247
const std::vector<framework::InputSpec>* mExternalInputMatchers = nullptr;
248-
const unsigned long* mTpcSectorMask = nullptr;
248+
const uint64_t* mTpcSectorMask = nullptr;
249249
bool mRequireAll = false;
250250
};
251251
} // namespace tpc

Detectors/TPC/workflow/src/ZSSpec.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ DataProcessorSpec getZSEncoderSpec(std::vector<int> const& tpcSectors, bool outR
6666
using DigitArray = std::array<gsl::span<const o2::tpc::Digit>, NSectors>;
6767

6868
struct ProcessAttributes {
69-
std::unique_ptr<unsigned long[]> zsoutput;
69+
std::unique_ptr<uint64_t[]> zsoutput;
7070
std::unique_ptr<IonTailCorrection> itcorr;
7171
std::vector<unsigned int> sizes;
7272
std::vector<int> tpcSectors;

Detectors/TPC/workflow/src/tpc-occupancy-filter.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <vector>
1414
#include <string>
1515
#include <unordered_map>
16+
#include <cstdint>
1617

1718
#include "Algorithm/RangeTokenizer.h"
1819
#include "Framework/WorkflowSpec.h"
@@ -37,8 +38,8 @@ using namespace o2::framework;
3738
using namespace o2::tpc;
3839

3940
// Global variable used to transport data to the completion policy
40-
std::vector<InputSpec> gPolicyData;
41-
unsigned long gTpcSectorMask = 0xFFFFFFFFF;
41+
static std::vector<InputSpec> gPolicyData;
42+
static uint64_t gTpcSectorMask = 0xFFFFFFFFF;
4243

4344
// customize the completion policy
4445
void customize(std::vector<o2::framework::CompletionPolicy>& policies)

Detectors/TPC/workflow/src/tpc-reco-workflow.cxx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,14 +35,15 @@
3535
#include <stdexcept>
3636
#include <unordered_map>
3737
#include <regex>
38+
#include <cstdint>
3839

3940
// we need a global variable to propagate the type the message dispatching of the
4041
// publisher will trigger on. This is dependent on the input type
4142
static o2::framework::Output gDispatchTrigger{"", ""};
4243

4344
// Global variable used to transport data to the completion policy
4445
static o2::tpc::reco_workflow::CompletionPolicyData gPolicyData;
45-
static unsigned long gTpcSectorMask = 0xFFFFFFFFF;
46+
static uint64_t gTpcSectorMask = 0xFFFFFFFFF;
4647

4748
void customize(std::vector<o2::framework::CallbacksPolicy>& policies)
4849
{

GPU/GPUTracking/Base/GPUReconstruction.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ constexpr const char* const GPUReconstruction::GEOMETRY_TYPE_NAMES[];
7474
constexpr const char* const GPUReconstruction::IOTYPENAMES[];
7575
constexpr GPUReconstruction::GeometryType GPUReconstruction::geometryType;
7676

77-
static int64_t ptrDiff(void* a, void* b) { return (int64_t)((char*)a - (char*)b); }
77+
static ptrdiff_t ptrDiff(void* a, void* b) { return (char*)a - (char*)b; }
7878

7979
GPUReconstruction::GPUReconstruction(const GPUSettingsDeviceBackend& cfg) : mHostConstantMem(new GPUConstantMem), mDeviceBackendSettings(cfg)
8080
{
@@ -834,9 +834,9 @@ void GPUReconstruction::PopNonPersistentMemory(RecoStep step, uint64_t tag)
834834
}
835835
if ((mProcessingSettings.debugLevel >= 3 || mProcessingSettings.allocDebugLevel) && (IsGPU() || mProcessingSettings.forceHostMemoryPoolSize)) {
836836
if (IsGPU()) {
837-
printf("Allocated Device memory after %30s (%8s): %'13ld (non temporary %'13ld, blocked %'13ld)\n", GPUDataTypes::RECO_STEP_NAMES[getRecoStepNum(step, true)], qTag2Str(std::get<3>(mNonPersistentMemoryStack.back())).c_str(), ptrDiff(mDeviceMemoryPool, mDeviceMemoryBase) + ptrDiff((char*)mDeviceMemoryBase + mDeviceMemorySize, mDeviceMemoryPoolEnd), ptrDiff(mDeviceMemoryPool, mDeviceMemoryBase), mDeviceMemoryPoolBlocked == nullptr ? 0l : ptrDiff((char*)mDeviceMemoryBase + mDeviceMemorySize, mDeviceMemoryPoolBlocked));
837+
printf("Allocated Device memory after %30s (%8s): %'13zd (non temporary %'13zd, blocked %'13zd)\n", GPUDataTypes::RECO_STEP_NAMES[getRecoStepNum(step, true)], qTag2Str(std::get<3>(mNonPersistentMemoryStack.back())).c_str(), ptrDiff(mDeviceMemoryPool, mDeviceMemoryBase) + ptrDiff((char*)mDeviceMemoryBase + mDeviceMemorySize, mDeviceMemoryPoolEnd), ptrDiff(mDeviceMemoryPool, mDeviceMemoryBase), mDeviceMemoryPoolBlocked ? ptrDiff((char*)mDeviceMemoryBase + mDeviceMemorySize, mDeviceMemoryPoolBlocked) : 0);
838838
}
839-
printf("Allocated Host memory after %30s (%8s): %'13ld (non temporary %'13ld, blocked %'13ld)\n", GPUDataTypes::RECO_STEP_NAMES[getRecoStepNum(step, true)], qTag2Str(std::get<3>(mNonPersistentMemoryStack.back())).c_str(), ptrDiff(mHostMemoryPool, mHostMemoryBase) + ptrDiff((char*)mHostMemoryBase + mHostMemorySize, mHostMemoryPoolEnd), ptrDiff(mHostMemoryPool, mHostMemoryBase), mHostMemoryPoolBlocked == nullptr ? 0l : ptrDiff((char*)mHostMemoryBase + mHostMemorySize, mHostMemoryPoolBlocked));
839+
printf("Allocated Host memory after %30s (%8s): %'13zd (non temporary %'13zd, blocked %'13zd)\n", GPUDataTypes::RECO_STEP_NAMES[getRecoStepNum(step, true)], qTag2Str(std::get<3>(mNonPersistentMemoryStack.back())).c_str(), ptrDiff(mHostMemoryPool, mHostMemoryBase) + ptrDiff((char*)mHostMemoryBase + mHostMemorySize, mHostMemoryPoolEnd), ptrDiff(mHostMemoryPool, mHostMemoryBase), mHostMemoryPoolBlocked ? ptrDiff((char*)mHostMemoryBase + mHostMemorySize, mHostMemoryPoolBlocked) : 0);
840840
printf("%16s", "");
841841
PrintMemoryMax();
842842
}
@@ -904,15 +904,15 @@ void GPUReconstruction::UpdateMaxMemoryUsed()
904904

905905
void GPUReconstruction::PrintMemoryMax()
906906
{
907-
printf("Maximum Memory Allocation: Host %'ld / Device %'ld\n", (int64_t)mHostMemoryUsedMax, (int64_t)mDeviceMemoryUsedMax);
907+
printf("Maximum Memory Allocation: Host %'zu / Device %'zu\n", mHostMemoryUsedMax, mDeviceMemoryUsedMax);
908908
}
909909

910910
void GPUReconstruction::PrintMemoryOverview()
911911
{
912912
if (mProcessingSettings.memoryAllocationStrategy == GPUMemoryResource::ALLOCATION_GLOBAL) {
913-
printf("Memory Allocation: Host %'ld / %'ld (Permanent %'ld), Device %'ld / %'ld, (Permanent %'ld) %d chunks\n",
914-
ptrDiff(mHostMemoryPool, mHostMemoryBase) + ptrDiff((char*)mHostMemoryBase + mHostMemorySize, mHostMemoryPoolEnd), (int64_t)mHostMemorySize, ptrDiff(mHostMemoryPermanent, mHostMemoryBase),
915-
ptrDiff(mDeviceMemoryPool, mDeviceMemoryBase) + ptrDiff((char*)mDeviceMemoryBase + mDeviceMemorySize, mDeviceMemoryPoolEnd), (int64_t)mDeviceMemorySize, ptrDiff(mDeviceMemoryPermanent, mDeviceMemoryBase), (int32_t)mMemoryResources.size());
913+
printf("Memory Allocation: Host %'zd / %'zu (Permanent %'zd), Device %'zd / %'zu, (Permanent %'zd) %zu chunks\n",
914+
ptrDiff(mHostMemoryPool, mHostMemoryBase) + ptrDiff((char*)mHostMemoryBase + mHostMemorySize, mHostMemoryPoolEnd), mHostMemorySize, ptrDiff(mHostMemoryPermanent, mHostMemoryBase),
915+
ptrDiff(mDeviceMemoryPool, mDeviceMemoryBase) + ptrDiff((char*)mDeviceMemoryBase + mDeviceMemorySize, mDeviceMemoryPoolEnd), mDeviceMemorySize, ptrDiff(mDeviceMemoryPermanent, mDeviceMemoryBase), mMemoryResources.size());
916916
}
917917
}
918918

@@ -937,7 +937,7 @@ void GPUReconstruction::PrintMemoryStatistics()
937937
}
938938
printf("%59s CPU / %9s GPU\n", "", "");
939939
for (auto it = sizes.begin(); it != sizes.end(); it++) {
940-
printf("Allocation %30s %s: Size %'14ld / %'14ld\n", it->first.c_str(), it->second[2] ? "P" : " ", (int64_t)it->second[0], (int64_t)it->second[1]);
940+
printf("Allocation %30s %s: Size %'14zu / %'14zu\n", it->first.c_str(), it->second[2] ? "P" : " ", it->second[0], it->second[1]);
941941
}
942942
PrintMemoryOverview();
943943
for (uint32_t i = 0; i < mChains.size(); i++) {

GPU/GPUTracking/Base/GPUReconstructionCPU.cxx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -268,24 +268,24 @@ int32_t GPUReconstructionCPU::RunChains()
268268
}
269269
char bandwidth[256] = "";
270270
if (mTimers[i]->memSize && mStatNEvents && time != 0.) {
271-
snprintf(bandwidth, 256, " (%6.3f GB/s - %'14lu bytes)", mTimers[i]->memSize / time * 1e-9, (uint64_t)(mTimers[i]->memSize / mStatNEvents));
271+
snprintf(bandwidth, 256, " (%8.3f GB/s - %'14zu bytes - %'14zu per call)", mTimers[i]->memSize / time * 1e-9, mTimers[i]->memSize / mStatNEvents, mTimers[i]->memSize / mStatNEvents / mTimers[i]->count);
272272
}
273-
printf("Execution Time: Task (%c %8ux): %50s Time: %'10lu us%s\n", type == 0 ? 'K' : 'C', mTimers[i]->count, mTimers[i]->name.c_str(), (uint64_t)(time * 1000000 / mStatNEvents), bandwidth);
273+
printf("Execution Time: Task (%c %8ux): %50s Time: %'10.0f us%s\n", type == 0 ? 'K' : 'C', mTimers[i]->count, mTimers[i]->name.c_str(), time * 1000000 / mStatNEvents, bandwidth);
274274
if (mProcessingSettings.resetTimers) {
275275
mTimers[i]->count = 0;
276276
mTimers[i]->memSize = 0;
277277
}
278278
}
279279
for (int32_t i = 0; i < GPUDataTypes::N_RECO_STEPS; i++) {
280280
if (kernelStepTimes[i] != 0. || mTimersRecoSteps[i].timerTotal.GetElapsedTime() != 0.) {
281-
printf("Execution Time: Step : %11s %38s Time: %'10lu us ( Total Time : %'14lu us)\n", "Tasks", GPUDataTypes::RECO_STEP_NAMES[i], (uint64_t)(kernelStepTimes[i] * 1000000 / mStatNEvents), (uint64_t)(mTimersRecoSteps[i].timerTotal.GetElapsedTime() * 1000000 / mStatNEvents));
281+
printf("Execution Time: Step : %11s %38s Time: %'10.0f us %64s ( Total Time : %'14.0f us)\n", "Tasks", GPUDataTypes::RECO_STEP_NAMES[i], kernelStepTimes[i] * 1000000 / mStatNEvents, "", mTimersRecoSteps[i].timerTotal.GetElapsedTime() * 1000000 / mStatNEvents);
282282
}
283283
if (mTimersRecoSteps[i].bytesToGPU) {
284-
printf("Execution Time: Step (D %8ux): %11s %38s Time: %'10lu us (%6.3f GB/s - %'14lu bytes - %'14lu per call)\n", mTimersRecoSteps[i].countToGPU, "DMA to GPU", GPUDataTypes::RECO_STEP_NAMES[i], (uint64_t)(mTimersRecoSteps[i].timerToGPU.GetElapsedTime() * 1000000 / mStatNEvents),
284+
printf("Execution Time: Step (D %8ux): %11s %38s Time: %'10.0f us (%8.3f GB/s - %'14zu bytes - %'14zu per call)\n", mTimersRecoSteps[i].countToGPU, "DMA to GPU", GPUDataTypes::RECO_STEP_NAMES[i], mTimersRecoSteps[i].timerToGPU.GetElapsedTime() * 1000000 / mStatNEvents,
285285
mTimersRecoSteps[i].bytesToGPU / mTimersRecoSteps[i].timerToGPU.GetElapsedTime() * 1e-9, mTimersRecoSteps[i].bytesToGPU / mStatNEvents, mTimersRecoSteps[i].bytesToGPU / mTimersRecoSteps[i].countToGPU);
286286
}
287287
if (mTimersRecoSteps[i].bytesToHost) {
288-
printf("Execution Time: Step (D %8ux): %11s %38s Time: %'10lu us (%6.3f GB/s - %'14lu bytes - %'14lu per call)\n", mTimersRecoSteps[i].countToHost, "DMA to Host", GPUDataTypes::RECO_STEP_NAMES[i], (uint64_t)(mTimersRecoSteps[i].timerToHost.GetElapsedTime() * 1000000 / mStatNEvents),
288+
printf("Execution Time: Step (D %8ux): %11s %38s Time: %'10.0f us (%8.3f GB/s - %'14zu bytes - %'14zu per call)\n", mTimersRecoSteps[i].countToHost, "DMA to Host", GPUDataTypes::RECO_STEP_NAMES[i], mTimersRecoSteps[i].timerToHost.GetElapsedTime() * 1000000 / mStatNEvents,
289289
mTimersRecoSteps[i].bytesToHost / mTimersRecoSteps[i].timerToHost.GetElapsedTime() * 1e-9, mTimersRecoSteps[i].bytesToHost / mStatNEvents, mTimersRecoSteps[i].bytesToHost / mTimersRecoSteps[i].countToHost);
290290
}
291291
if (mProcessingSettings.resetTimers) {
@@ -299,12 +299,12 @@ int32_t GPUReconstructionCPU::RunChains()
299299
}
300300
for (int32_t i = 0; i < GPUDataTypes::N_GENERAL_STEPS; i++) {
301301
if (mTimersGeneralSteps[i].GetElapsedTime() != 0.) {
302-
printf("Execution Time: General Step : %50s Time: %'10lu us\n", GPUDataTypes::GENERAL_STEP_NAMES[i], (uint64_t)(mTimersGeneralSteps[i].GetElapsedTime() * 1000000 / mStatNEvents));
302+
printf("Execution Time: General Step : %50s Time: %'10.0f us\n", GPUDataTypes::GENERAL_STEP_NAMES[i], mTimersGeneralSteps[i].GetElapsedTime() * 1000000 / mStatNEvents);
303303
}
304304
}
305305
mStatKernelTime = kernelTotal * 1000000 / mStatNEvents;
306-
printf("Execution Time: Total : %50s Time: %'10lu us%s\n", "Total Kernel", (uint64_t)mStatKernelTime, nEventReport.c_str());
307-
printf("Execution Time: Total : %50s Time: %'10lu us%s\n", "Total Wall", (uint64_t)mStatWallTime, nEventReport.c_str());
306+
printf("Execution Time: Total : %50s Time: %'10.0f us%s\n", "Total Kernel", mStatKernelTime, nEventReport.c_str());
307+
printf("Execution Time: Total : %50s Time: %'10.0f us%s\n", "Total Wall", mStatWallTime, nEventReport.c_str());
308308
} else if (GetProcessingSettings().debugLevel >= 0) {
309309
GPUInfo("Total Wall Time: %lu us%s", (uint64_t)mStatWallTime, nEventReport.c_str());
310310
}

GPU/GPUTracking/DataCompression/GPUTPCClusterStatistics.cxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ void GPUTPCClusterStatistics::Finish()
225225
GPUInfo("Combined Sigma: %6.4f --> %6.4f (%6.4f%%)", eSigma, eSigmaCombined, eSigma > 1e-3 ? (100. * (eSigma - eSigmaCombined) / eSigma) : 0.f);
226226
GPUInfo("Combined Q: %6.4f --> %6.4f (%6.4f%%)", eQ, eQCombined, eQ > 1e-3 ? (100. * (eQ - eQCombined) / eQ) : 0.f);
227227

228-
printf("\nCombined Entropy: %7.4f (Size %'13.0f, %'ld clusters)\nCombined Huffman: %7.4f (Size %'13.0f, %f%%)\n\n", mEntropy / mNTotalClusters, mEntropy, (int64_t)mNTotalClusters, mHuffman / mNTotalClusters, mHuffman, 100. * (mHuffman - mEntropy) / mHuffman);
228+
printf("\nCombined Entropy: %7.4f (Size %'13.0f, %'zu clusters)\nCombined Huffman: %7.4f (Size %'13.0f, %f%%)\n\n", mEntropy / mNTotalClusters, mEntropy, mNTotalClusters, mHuffman / mNTotalClusters, mHuffman, 100. * (mHuffman - mEntropy) / mHuffman);
229229
}
230230

231231
float GPUTPCClusterStatistics::Analyze(std::vector<int32_t>& p, const char* name, bool count)

GPU/GPUTracking/Global/GPUChainTrackingDebugAndProfiling.cxx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -111,17 +111,17 @@ int32_t GPUChainTracking::DoProfile()
111111
namespace
112112
{
113113
struct GPUChainTrackingMemUsage {
114-
void add(uint64_t n, uint64_t bound)
114+
void add(size_t n, size_t bound)
115115
{
116116
nMax = std::max(nMax, n);
117117
maxUse = std::max(n / std::max<double>(bound, 1.), maxUse);
118118
nSum += n;
119119
nBoundSum += bound;
120120
count++;
121121
}
122-
uint64_t nMax;
123-
uint64_t nSum = 0;
124-
uint64_t nBoundSum = 0;
122+
size_t nMax;
123+
size_t nSum = 0;
124+
size_t nBoundSum = 0;
125125
double maxUse = 0.;
126126
uint32_t count = 0;
127127
};
@@ -163,7 +163,7 @@ void GPUChainTracking::PrintMemoryStatistics()
163163
#endif
164164

165165
for (auto& elem : usageMap) {
166-
printf("Mem Usage %-30s : %'14lu / %'14lu (%3.0f%% / %3.0f%% / count %3u / max %'14lu)\n", elem.first.c_str(), elem.second.nSum, elem.second.nBoundSum, 100. * elem.second.nSum / std::max(1lu, elem.second.nBoundSum), 100. * elem.second.maxUse, elem.second.count, elem.second.nMax);
166+
printf("Mem Usage %-30s : %'14zu / %'14zu (%3.0f%% / %3.0f%% / count %3u / max %'14zu)\n", elem.first.c_str(), elem.second.nSum, elem.second.nBoundSum, 100. * elem.second.nSum / std::max<size_t>(1, elem.second.nBoundSum), 100. * elem.second.maxUse, elem.second.count, elem.second.nMax);
167167
}
168168
}
169169

GPU/GPUTracking/qa/GPUQA.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@
7373
#include "GPUQAHelper.h"
7474
#include <algorithm>
7575
#include <cstdio>
76+
#include <cinttypes>
7677

7778
#include "utils/qconfig.h"
7879
#include "utils/timer.h"
@@ -2796,10 +2797,10 @@ void GPUQA::PrintClusterCount(int32_t mode, int32_t& num, const char* name, uint
27962797
createHist(mHistClusterCount[num], name2, name, 1000, 0, mConfig.histMaxNClusters, 1000, 0, 100);
27972798
} else if (mode == 0) {
27982799
if (normalization && mConfig.enableLocalOutput) {
2799-
printf("\t%35s: %'12lu (%6.2f%%)\n", name, n, 100.f * n / normalization);
2800+
printf("\t%35s: %'12" PRIu64 " (%6.2f%%)\n", name, n, 100.f * n / normalization);
28002801
}
28012802
if (mConfig.clusterRejectionHistograms) {
2802-
float ratio = 100.f * n / std::max(normalization, 1lu);
2803+
float ratio = 100.f * n / std::max<uint64_t>(normalization, 1);
28032804
mHistClusterCount[num]->Fill(normalization, ratio, 1);
28042805
}
28052806
}

0 commit comments

Comments
 (0)