diff --git a/DataFormats/Detectors/TPC/include/DataFormatsTPC/ClusterNative.h b/DataFormats/Detectors/TPC/include/DataFormatsTPC/ClusterNative.h index 54dbb559709fa..ead1694b63afb 100644 --- a/DataFormats/Detectors/TPC/include/DataFormatsTPC/ClusterNative.h +++ b/DataFormats/Detectors/TPC/include/DataFormatsTPC/ClusterNative.h @@ -53,7 +53,7 @@ namespace tpc * Not for permanent storage. */ struct ClusterNative { - // NOTE: These states must match those from GPUTPCGMMergedTrackHit! + // NOTE: These states must match those from GPUTPCGMMergedTrackHit, and we must not add a state beyond 0x8, since 0x10 is already used enum clusterState { flagSplitPad = 0x1, // Split in pad direction flagSplitTime = 0x2, // Split in time direction flagEdge = 0x4, // At edge of TPC sector diff --git a/GPU/Common/GPUCommonConstants.h b/GPU/Common/GPUCommonConstants.h index 95cf89cc6d0a7..fb30ea129f818 100644 --- a/GPU/Common/GPUCommonConstants.h +++ b/GPU/Common/GPUCommonConstants.h @@ -16,10 +16,11 @@ #define GPUCOMMONCONSTANTS_H #include "GPUCommonDef.h" +#include "CommonConstants/MathConstants.h" namespace o2::gpu::gpu_common_constants { -static GPUglobalconstexpr() const float kCLight = 0.000299792458f; // TODO: Duplicate of MathConstants, fix this now that we use only OpenCL CPP +static GPUglobalconstexpr() const float kCLight = -o2::constants::math::B2C; static GPUglobalconstexpr() const float kZeroFieldCut = 0.013f; } // namespace o2::gpu::gpu_common_constants diff --git a/GPU/Common/GPUCommonDefAPI.h b/GPU/Common/GPUCommonDefAPI.h index faddcb027e0c5..07543797f55b9 100644 --- a/GPU/Common/GPUCommonDefAPI.h +++ b/GPU/Common/GPUCommonDefAPI.h @@ -189,15 +189,7 @@ #define GPUhdni() __host__ __device__ #define GPUg() __global__ #define GPUshared() __shared__ - #if defined(GPUCA_GPUCODE_DEVICE) && 0 // TODO: Fix for HIP - #define GPUCA_USE_TEMPLATE_ADDRESS_SPACES - #define GPUglobal() __attribute__((address_space(1))) - #define GPUglobalref() GPUglobal() - #define GPUconstantref() __attribute__((address_space(4))) - #define GPUsharedref() __attribute__((address_space(3))) - #else - #define GPUglobal() - #endif + #define GPUglobal() #define GPUconstant() __constant__ #define GPUconstexpr() constexpr __constant__ #define GPUprivate() diff --git a/GPU/Common/GPUCommonMath.h b/GPU/Common/GPUCommonMath.h index 2e542d027307f..e7ccf1e5c166f 100644 --- a/GPU/Common/GPUCommonMath.h +++ b/GPU/Common/GPUCommonMath.h @@ -64,8 +64,6 @@ class GPUCommonMath using half_t = _Float16; #endif - GPUd() static float2 MakeFloat2(float x, float y); // TODO: Find better appraoch that is constexpr - template GPUhd() constexpr static T Min(const T x, const T y) { @@ -289,17 +287,6 @@ GPUdi() constexpr T GPUCommonMath::nextMultipleOf(T val) } else { return (val + I - 1) & ~(T)(I - 1); } - return 0; // BUG: Cuda complains about missing return value with constexpr if -} - -GPUdi() float2 GPUCommonMath::MakeFloat2(float x, float y) -{ -#if !defined(GPUCA_GPUCODE) || defined(__OPENCL__) || defined(__OPENCL_HOST__) || defined(__METAL__) || defined(__METAL_HOST__) || defined(__CPUDEVICE__) - float2 ret = {x, y}; - return ret; -#else - return make_float2(x, y); -#endif // GPUCA_GPUCODE } GPUdi() constexpr float GPUCommonMath::Modf(float x, float y) { return GPUCA_CHOICE(fmodf(x, y), fmodf(x, y), fmod(x, y)); } @@ -442,7 +429,7 @@ GPUdi() constexpr uint32_t GPUCommonMath::Ctz(uint32_t x) GPUdi() constexpr uint32_t GPUCommonMath::Popcount(uint32_t x) { -#if (defined(__GNUC__) || defined(__clang__) || defined(__CUDACC__) || defined(__HIPCC__)) && !defined(__OPENCL__) // TODO: remove OPENCL when reported SPIR-V bug is fixed +#if (defined(__GNUC__) || defined(__clang__) || defined(__CUDACC__) || defined(__HIPCC__)) // use builtin if available return GPUCA_CHOICE(__builtin_popcount(x), __popc(x), __builtin_popcount(x)); #else @@ -482,7 +469,7 @@ GPUdi() constexpr uint32_t GPUCommonMath::Ctz64(uint64_t x) GPUdi() constexpr uint32_t GPUCommonMath::Popcount64(uint64_t x) { -#if (defined(__GNUC__) || defined(__clang__) || defined(__CUDACC__) || defined(__HIPCC__)) && !defined(__OPENCL__) // TODO: remove OPENCL when reported SPIR-V bug is fixed +#if (defined(__GNUC__) || defined(__clang__) || defined(__CUDACC__) || defined(__HIPCC__)) // use builtin if available return GPUCA_CHOICE(__builtin_popcountll(x), __popcll(x), __builtin_popcountll(x)); #else diff --git a/GPU/GPUTracking/Base/GPUConstantMem.h b/GPU/GPUTracking/Base/GPUConstantMem.h index 05547262ce100..b18382e976f62 100644 --- a/GPU/GPUTracking/Base/GPUConstantMem.h +++ b/GPU/GPUTracking/Base/GPUConstantMem.h @@ -91,12 +91,12 @@ union GPUConstantMemCopyable { #if defined(GPUCA_GPUCODE) static GPUglobalconstexpr() size_t gGPUConstantMemBufferSize = (sizeof(GPUConstantMem) + sizeof(uint4) - 1); #endif -} // namespace o2::gpu + #if defined(GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM) -GPUconstant() o2::gpu::GPUConstantMemCopyable gGPUConstantMemBuffer; // TODO: This should go into o2::gpu namespace, but then CUDA or HIP would not find the symbol -#endif // GPUCA_HAS_GLOBAL_SYMBOL_CONSTANT_MEM -namespace o2::gpu -{ +extern "C" { // C linkage for the unmangled symbol name that the RTC looks up, the braces make it a definition, not a declaration +GPUconstant() GPUConstantMemCopyable gGPUConstantMemBuffer; +} +#endif // Must be placed here, to avoid circular header dependency GPUdi() GPUconstantref() const GPUConstantMem* GPUProcessor::GetConstantMem() const diff --git a/GPU/GPUTracking/Base/GPUParam.cxx b/GPU/GPUTracking/Base/GPUParam.cxx index b7f8ccb9fa668..d5bcd098a877c 100644 --- a/GPU/GPUTracking/Base/GPUParam.cxx +++ b/GPU/GPUTracking/Base/GPUParam.cxx @@ -34,9 +34,9 @@ void GPUParam::SetDefaults(float solenoidBz, bool assumeConstantBz) { memset((void*)this, 0, sizeof(*this)); new (&rec) GPUSettingsRec; - occupancyMap = nullptr; - occupancyMapSize = 0; - occupancyTotal = 0; + occupancy.map = nullptr; + occupancy.mapSize = 0; + occupancy.total = 0; #ifndef GPUCA_RUN2 const float kErrorsY[4] = {0.06, 0.24, 0.12, 0.1}; diff --git a/GPU/GPUTracking/Base/GPUParam.h b/GPU/GPUTracking/Base/GPUParam.h index 5fab4b5e0fb54..90531bef8cece 100644 --- a/GPU/GPUTracking/Base/GPUParam.h +++ b/GPU/GPUTracking/Base/GPUParam.h @@ -56,9 +56,12 @@ struct GPUParam_t { int32_t tpcCutTimeBin; GPUTPCGMPolynomialField polynomialField; // Polynomial approx. of magnetic field for TPC GM - const uint32_t* occupancyMap; // Ptr to TPC occupancy map - uint32_t occupancyTotal; // Total occupancy in the TPC (nCl / nHbf) - uint32_t occupancyMapSize; // Size of occupancy map + + struct occupancyStruct { + const uint32_t* map; // Ptr to TPC occupancy map + uint32_t total; // Total occupancy in the TPC (nCl / nHbf) + uint32_t mapSize; // Size of occupancy map + } occupancy; protected: #ifndef GPUCA_RUN2 diff --git a/GPU/GPUTracking/Base/GPUParam.inc b/GPU/GPUTracking/Base/GPUParam.inc index 566592bdd8d61..762afc0ce0968 100644 --- a/GPU/GPUTracking/Base/GPUParam.inc +++ b/GPU/GPUTracking/Base/GPUParam.inc @@ -112,12 +112,12 @@ GPUdi() float GPUParam::GetSystematicClusterErrorIFC2(float x, float y, float z, GPUdi() float GPUParam::GetSystematicClusterErrorC122(float x, float y, uint8_t sector) const { const float dx = x - 83.f; - if (dx > occupancyTotal * rec.tpc.sysClusErrorC12Box) { + if (dx > occupancy.total * rec.tpc.sysClusErrorC12Box) { return 0.f; } constexpr float dEdgeInv = 18.f / CAMath::Pi(); const float dy = (sector == (GPUTPCGeometry::NSECTORS / 2 + 1) ? 0.5f : -0.5f) * (y / x) * dEdgeInv + 0.5f; - const float errC12 = rec.tpc.sysClusErrorC12Norm * occupancyTotal * dy; + const float errC12 = rec.tpc.sysClusErrorC12Norm * occupancy.total * dy; return errC12 * errC12; } @@ -210,11 +210,11 @@ GPUdi() void GPUParam::UpdateClusterError2ByState(int16_t clusterState, float& E GPUdi() float GPUParam::GetUnscaledMult(float time) const { - if (!occupancyMap) { + if (!occupancy.map) { return 0.f; } - const uint32_t bin = CAMath::Min(occupancyMapSize - 1, CAMath::Max(0.f, time / rec.tpc.occupancyMapTimeBins)); - return occupancyMap[bin]; + const uint32_t bin = CAMath::Min(occupancy.mapSize - 1, CAMath::Max(0.f, time / rec.tpc.occupancyMapTimeBins)); + return occupancy.map[bin]; } GPUdi() bool GPUParam::rejectEdgeClusterByY(float uncorrectedY, int32_t iRow, float trackSigmaY) const diff --git a/GPU/GPUTracking/Base/GPUReconstruction.cxx b/GPU/GPUTracking/Base/GPUReconstruction.cxx index fbb8cfb5ff77e..4370102a201af 100644 --- a/GPU/GPUTracking/Base/GPUReconstruction.cxx +++ b/GPU/GPUTracking/Base/GPUReconstruction.cxx @@ -95,11 +95,6 @@ GPUReconstruction::GPUReconstruction(const GPUSettingsDeviceBackend& cfg) : mHos param().SetDefaults(mGRPSettings.get()); mMemoryScalers.reset(new GPUMemorySizeScalers); for (uint32_t i = 0; i < NSECTORS; i++) { - processors()->tpcTrackers[i].SetSector(i); // TODO: Move to a better place - processors()->tpcClusterer[i].mISector = i; -#ifdef GPUCA_HAS_ONNX - processors()->tpcNNClusterer[i].mISector = i; -#endif } } @@ -438,7 +433,7 @@ int32_t GPUReconstruction::InitPhaseAfterDevice() void GPUReconstruction::WriteConstantParams(int32_t stream) { if (IsGPU()) { - const auto threadContext = GetThreadContext(); + const auto holdContext = GetThreadContext(); WriteToConstantMemory(ptrDiff(&processors()->param, processors()), ¶m(), sizeof(param()), stream); } } @@ -753,20 +748,23 @@ void* GPUReconstruction::AllocateDirectMemory(size_t size, int32_t type) void*& pool = (type & GPUMemoryResource::MEMORY_GPU) ? mDeviceMemoryPool : mHostMemoryPool; void*& poolend = (type & GPUMemoryResource::MEMORY_GPU) ? mDeviceMemoryPoolEnd : mHostMemoryPoolEnd; char* retVal; - if ((type & GPUMemoryResource::MEMORY_STACK)) { - poolend = (char*)poolend - size; // TODO: Implement overflow check + if (size > (size_t)((char*)poolend - (char*)pool)) { + GPUError("Insufficient direct memory: requested %zd, required %td bytes", size, ptrDiff(pool, poolend)); + throw std::bad_alloc(); + } else if ((type & GPUMemoryResource::MEMORY_STACK)) { + poolend = (char*)poolend - size; poolend = (char*)poolend - GPUProcessor::getAlignmentMod(poolend); retVal = (char*)poolend; } else { GPUProcessor::computePointerWithAlignment(pool, retVal, size); } if (pool > poolend) { - GPUError("Insufficient unmanaged memory: missing %ld bytes", ptrDiff(pool, poolend)); + GPUError("Insufficient direct memory: missing %td bytes", ptrDiff(pool, poolend)); throw std::bad_alloc(); } UpdateMaxMemoryUsed(); if (GetProcessingSettings().allocDebugLevel >= 2) { - std::cout << "Allocated (unmanaged " << ((type & GPUMemoryResource::MEMORY_GPU) ? "gpu" : "host") << "): " << size << " - available: " << ptrDiff(poolend, pool) << "\n"; + std::cout << "Allocated (direct " << ((type & GPUMemoryResource::MEMORY_GPU) ? "gpu" : "host") << "): " << size << " - available: " << ptrDiff(poolend, pool) << "\n"; } return retVal; } diff --git a/GPU/GPUTracking/Base/GPUReconstruction.h b/GPU/GPUTracking/Base/GPUReconstruction.h index 3a2d644ac71f1..1a23c67add845 100644 --- a/GPU/GPUTracking/Base/GPUReconstruction.h +++ b/GPU/GPUTracking/Base/GPUReconstruction.h @@ -62,12 +62,6 @@ struct GPUSettingsRec; struct GPUSettingsRecDynamic; struct GPUMemoryReuse; -namespace gpu_reconstruction_kernels -{ -struct deviceEvent; -class threadContext; -} // namespace gpu_reconstruction_kernels - class GPUReconstruction { protected: @@ -140,6 +134,9 @@ class GPUReconstruction Device = 1, Auto = -1 }; + struct deviceEvent; + struct threadContext; + // Global steering functions template T* AddChain(Args... args); @@ -278,7 +275,7 @@ class GPUReconstruction int32_t InitPhaseAfterDevice(); void WriteConstantParams(int32_t stream = -1); virtual int32_t ExitDevice() = 0; - virtual size_t WriteToConstantMemory(size_t offset, const void* src, size_t size, int32_t stream = -1, gpu_reconstruction_kernels::deviceEvent* ev = nullptr) = 0; + virtual size_t WriteToConstantMemory(size_t offset, const void* src, size_t size, int32_t stream = -1, deviceEvent* ev = nullptr) = 0; void UpdateMaxMemoryUsed(); int32_t EnqueuePipeline(bool terminate = false); GPUChain* GetNextChainInQueue(); @@ -288,7 +285,7 @@ class GPUReconstruction virtual int32_t unregisterMemoryForGPU_internal(const void* ptr) = 0; // Management for GPU thread contexts - virtual std::unique_ptr GetThreadContext() = 0; + virtual std::unique_ptr GetThreadContext() = 0; // Private helpers for library loading static std::shared_ptr* GetLibraryInstance(DeviceType type, bool verbose); diff --git a/GPU/GPUTracking/Base/GPUReconstructionCPU.cxx b/GPU/GPUTracking/Base/GPUReconstructionCPU.cxx index b7983a8c81ec1..dfec97fe1a158 100644 --- a/GPU/GPUTracking/Base/GPUReconstructionCPU.cxx +++ b/GPU/GPUTracking/Base/GPUReconstructionCPU.cxx @@ -359,20 +359,12 @@ void GPUReconstructionCPU::UpdateParamOccupancyMap(const uint32_t* mapHost, cons if (mapHost && mapSize != GPUTPCClusterOccupancyMapBin::getNBins(param())) { throw std::runtime_error("Updating occupancy map with object of invalid size"); } - param().occupancyMap = mapHost; - param().occupancyMapSize = mapSize; - param().occupancyTotal = occupancyTotal; + param().occupancy.map = mapHost; + param().occupancy.total = occupancyTotal; + param().occupancy.mapSize = mapSize; if (IsGPU()) { - if (!((size_t)¶m().occupancyMapSize - (size_t)¶m().occupancyMap == sizeof(param().occupancyMap) + sizeof(param().occupancyTotal) && sizeof(param().occupancyMap) == sizeof(void*) && sizeof(param().occupancyTotal) == sizeof(uint32_t))) { // TODO: Make static assert, and check alignment - throw std::runtime_error("occupancy data not consecutive in GPUParam"); - } - struct tmpOccuapncyParam { - const void* ptr; - uint32_t total; - uint32_t size; - }; - tmpOccuapncyParam tmp = {mapGPU, occupancyTotal, mapSize}; + GPUParam::occupancyStruct tmp = {mapGPU, occupancyTotal, mapSize}; const auto holdContext = GetThreadContext(); - WriteToConstantMemory((char*)&processors()->param.occupancyMap - (char*)processors(), &tmp, sizeof(tmp), stream, ev); + WriteToConstantMemory((char*)&processors()->param.occupancy - (char*)processors(), &tmp, sizeof(tmp), stream, ev); } } diff --git a/GPU/GPUTracking/Base/GPUReconstructionConvert.cxx b/GPU/GPUTracking/Base/GPUReconstructionConvert.cxx index 0b5e15303f22a..441c15de289cb 100644 --- a/GPU/GPUTracking/Base/GPUReconstructionConvert.cxx +++ b/GPU/GPUTracking/Base/GPUReconstructionConvert.cxx @@ -1064,9 +1064,8 @@ inline uint32_t zsEncoderRun::run(std::vector* buffer, std::vectorbc : 0; int32_t orbitShift = ir ? ir->orbit : 0; - int32_t rawcru = 0; - int32_t rawendpoint = 0; - (void)(rawcru + rawendpoint); // avoid compiler warning + [[maybe_unused]] int32_t rawcru = 0; + [[maybe_unused]] int32_t rawendpoint = 0; encodeBitsFactor = (1 << (encodeBits - 10)); std::sort(tmpBuffer.begin(), tmpBuffer.end(), [this](const o2::tpc::Digit a, const o2::tpc::Digit b) { return sort(a, b); }); diff --git a/GPU/GPUTracking/Base/GPUReconstructionIO.h b/GPU/GPUTracking/Base/GPUReconstructionIO.h index 494e1cc308ed7..c1a656e9f61d3 100644 --- a/GPU/GPUTracking/Base/GPUReconstructionIO.h +++ b/GPU/GPUTracking/Base/GPUReconstructionIO.h @@ -81,7 +81,8 @@ inline size_t GPUReconstruction::ReadData(FILE* fp, const T** entries, S* num, s return 0; } InOutPointerType inType; - size_t r, pos = ftell(fp); + [[maybe_unused]] size_t r; + size_t pos = ftell(fp); r = fread(&inType, sizeof(inType), 1, fp); if (r != 1 || inType != type) { fseek(fp, pos, SEEK_SET); @@ -101,7 +102,6 @@ inline size_t GPUReconstruction::ReadData(FILE* fp, const T** entries, S* num, s } numTotal += num[i]; } - (void)r; if (GetProcessingSettings().debugLevel >= 2) { GPUInfo("Read %zu %s", numTotal, IOTYPENAMES[type]); } diff --git a/GPU/GPUTracking/Base/GPUReconstructionProcessing.cxx b/GPU/GPUTracking/Base/GPUReconstructionProcessing.cxx index a511102a492ef..935db0e640857 100644 --- a/GPU/GPUTracking/Base/GPUReconstructionProcessing.cxx +++ b/GPU/GPUTracking/Base/GPUReconstructionProcessing.cxx @@ -140,8 +140,8 @@ std::unique_ptr GPUReconstructionPro return std::make_unique(); } -gpu_reconstruction_kernels::threadContext::threadContext() = default; -gpu_reconstruction_kernels::threadContext::~threadContext() = default; +GPUReconstruction::threadContext::threadContext() = default; +GPUReconstruction::threadContext::~threadContext() = default; const std::vector GPUReconstructionProcessing::mKernelNames = { #define GPUCA_KRNL(x_class, ...) GPUCA_M_STR(GPUCA_M_KRNL_NAME(x_class)), diff --git a/GPU/GPUTracking/Base/GPUReconstructionProcessing.h b/GPU/GPUTracking/Base/GPUReconstructionProcessing.h index 3d9507e48e292..1c4c45f410410 100644 --- a/GPU/GPUTracking/Base/GPUReconstructionProcessing.h +++ b/GPU/GPUTracking/Base/GPUReconstructionProcessing.h @@ -31,9 +31,7 @@ namespace o2::gpu struct GPUDefParameters; -namespace gpu_reconstruction_kernels // TODO: Get rid of this namespace -{ -struct deviceEvent { +struct GPUReconstruction::deviceEvent { constexpr deviceEvent() = default; constexpr deviceEvent(std::nullptr_t p) : v(nullptr) {}; template @@ -57,23 +55,16 @@ struct deviceEvent { void* v = nullptr; // We use only pointers anyway, and since cl_event and cudaEvent_t and hipEvent_t are actually pointers, we can cast them to deviceEvent (void*) this way. }; -class threadContext -{ - public: +struct GPUReconstruction::threadContext { threadContext(); virtual ~threadContext(); }; -} // namespace gpu_reconstruction_kernels - class GPUReconstructionProcessing : public GPUReconstruction { public: ~GPUReconstructionProcessing() override; - using deviceEvent = gpu_reconstruction_kernels::deviceEvent; - using threadContext = gpu_reconstruction_kernels::threadContext; - struct RecoStepTimerMeta { HighResTimer timerToGPU; HighResTimer timerToHost; diff --git a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu index d81b1e2cdfb4a..574e9acdd1d31 100644 --- a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu +++ b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDA.cu @@ -331,11 +331,7 @@ int32_t GPUReconstructionCUDA::InitDevice_Runtime() } } -#ifndef __HIPCC__ // CUDA - dummyInitKernel<<>>(mDeviceMemoryBase); // TODO: Can't we just use the CUDA version and hipify will take care of the rest? -#else // HIP - hipLaunchKernelGGL(HIP_KERNEL_NAME(dummyInitKernel), dim3(mMultiprocessorCount), dim3(256), 0, 0, mDeviceMemoryBase); -#endif + dummyInitKernel<<>>(mDeviceMemoryBase); if (GetProcessingSettings().rtc.enable) { genAndLoadRTC(); diff --git a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAIncludesSystem.h b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAIncludesSystem.h index 263d6939909c8..90a674d203778 100644 --- a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAIncludesSystem.h +++ b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAIncludesSystem.h @@ -22,14 +22,11 @@ #include #include #include -#pragma GCC diagnostic push // FIXME: Is this still needed? -#pragma GCC diagnostic ignored "-Wshadow" #include #include #include #include #include -#pragma GCC diagnostic pop #include #include diff --git a/GPU/GPUTracking/DataCompression/GPUTPCClusterRejection.h b/GPU/GPUTracking/DataCompression/GPUTPCClusterRejection.h index 8ec8c85c4c73f..2ac38ae236ba0 100644 --- a/GPU/GPUTracking/DataCompression/GPUTPCClusterRejection.h +++ b/GPU/GPUTracking/DataCompression/GPUTPCClusterRejection.h @@ -28,10 +28,8 @@ struct GPUTPCClusterRejection { } template - GPUdi() static constexpr bool GetRejectionStatus(int32_t attach, bool& physics, T* counts = nullptr, S* mev200 = nullptr) + GPUdi() static constexpr bool GetRejectionStatus(int32_t attach, bool& physics, [[maybe_unused]] T* counts = nullptr, [[maybe_unused]] S* mev200 = nullptr) { - (void)counts; // FIXME: Avoid incorrect -Wunused-but-set-parameter warning - (void)mev200; bool retVal = false; if (attach == 0) { retVal = false; diff --git a/GPU/GPUTracking/DataCompression/GPUTPCCompression.cxx b/GPU/GPUTracking/DataCompression/GPUTPCCompression.cxx index 00f1f6500e9f0..fac4c4854c565 100644 --- a/GPU/GPUTracking/DataCompression/GPUTPCCompression.cxx +++ b/GPU/GPUTracking/DataCompression/GPUTPCCompression.cxx @@ -17,7 +17,6 @@ #include "GPUO2DataTypes.h" #include "GPUMemorySizeScalers.h" #include "GPUDefParametersRuntime.h" -#include "GPUConstantMem.h" using namespace o2::gpu; @@ -124,7 +123,7 @@ void GPUTPCCompression::SetMaxData(const GPUTrackingInOutPointers& io) mMaxClusters = io.clustersNative->nClustersTotal; mMaxClusterFactorBase1024 = mMaxClusters > 100000000 ? mRec->MemoryScalers()->NTPCUnattachedHitsBase1024(mRec->GetParam().rec.tpc.rejectionStrategy) : 1024; mMaxClustersInCache = mMaxClusters * mMaxClusterFactorBase1024 / 1024; - mMaxTrackClusters = mRec->GetConstantMem().tpcMerger.NMergedTrackClusters(); // TODO: Why is this not using ioPtrs? Could remove GPUConstantMem.h include + mMaxTrackClusters = io.nMergedTrackHits; mMaxTracks = mRec->GetConstantMem().tpcMerger.NMergedTracks(); if (mMaxClusters % 16) { mMaxClusters += 16 - (mMaxClusters % 16); diff --git a/GPU/GPUTracking/DataCompression/GPUTPCCompressionTrackModel.cxx b/GPU/GPUTracking/DataCompression/GPUTPCCompressionTrackModel.cxx index 1fe22e0e88137..961a77c76c2e2 100644 --- a/GPU/GPUTracking/DataCompression/GPUTPCCompressionTrackModel.cxx +++ b/GPU/GPUTracking/DataCompression/GPUTPCCompressionTrackModel.cxx @@ -542,7 +542,7 @@ GPUd() int32_t GPUTPCCompressionTrackModel::rotateToAlpha(float newAlpha) GPUd() int32_t GPUTPCCompressionTrackModel::propagateToXBzLightNoUpdate(PhysicalTrackModel& t, float x, float Bz, float& dLp) { // - // transport the track to X=x in magnetic field B = ( 0, 0, Bz[kG*0.000299792458] ) + // transport the track to X=x in magnetic field B = ( 0, 0, Bz[kG*kClight] ) // dLp is a return value == path length / track momentum [cm/(GeV/c)] // the method returns error code (0 == no error) // diff --git a/GPU/GPUTracking/DataTypes/GPUTPCGMMergedTrackHit.h b/GPU/GPUTracking/DataTypes/GPUTPCGMMergedTrackHit.h index 789c1f00262f8..6d2e3977b347b 100644 --- a/GPU/GPUTracking/DataTypes/GPUTPCGMMergedTrackHit.h +++ b/GPU/GPUTracking/DataTypes/GPUTPCGMMergedTrackHit.h @@ -16,6 +16,7 @@ #define GPUTPCGMMERGEDTRACKHIT_H #include "GPUCommonDef.h" +#include "DataFormatsTPC/ClusterNative.h" namespace o2::gpu { @@ -23,13 +24,11 @@ struct GPUTPCGMMergedTrackHit { uint32_t num; uint8_t sector, row, state; - // NOTE: the lower states must match those from ClusterNative! - // TODO: take them directly from clusterNative header. - enum hitState { flagSplitPad = 0x1, - flagSplitTime = 0x2, - flagSplit = 0x3, - flagEdge = 0x4, - flagSingle = 0x8, + enum hitState { flagSplitPad = o2::tpc::ClusterNative::clusterState::flagSplitPad, + flagSplitTime = o2::tpc::ClusterNative::clusterState::flagSplitTime, + flagEdge = o2::tpc::ClusterNative::clusterState::flagEdge, + flagSingle = o2::tpc::ClusterNative::clusterState::flagSingle, + flagSplit = flagSplitPad | flagSplitTime, flagShared = 0x10, clustererAndSharedFlags = 0x1F, flagRejectDistance = 0x20, diff --git a/GPU/GPUTracking/Global/GPUChainTracking.cxx b/GPU/GPUTracking/Global/GPUChainTracking.cxx index b66cc7d49dcc9..5f1b7a6f28ae9 100644 --- a/GPU/GPUTracking/Global/GPUChainTracking.cxx +++ b/GPU/GPUTracking/Global/GPUChainTracking.cxx @@ -84,10 +84,19 @@ void GPUChainTracking::RegisterPermanentMemoryAndProcessors() } mRec->RegisterGPUProcessor(mInputsHost.get(), mRec->IsGPU()); - if (GetRecoSteps() & RecoStep::TPCSectorTracking) { - for (uint32_t i = 0; i < NSECTORS; i++) { + for (uint32_t i = 0; i < NSECTORS; i++) { + if (GetRecoSteps() & RecoStep::TPCSectorTracking) { + processors()->tpcTrackers[i].SetSector(i); mRec->RegisterGPUProcessor(&processors()->tpcTrackers[i], GetRecoStepsGPU() & RecoStep::TPCSectorTracking); } + if (GetRecoSteps() & RecoStep::TPCClusterFinding) { + processors()->tpcClusterer[i].mISector = i; + mRec->RegisterGPUProcessor(&processors()->tpcClusterer[i], GetRecoStepsGPU() & RecoStep::TPCClusterFinding); +#ifdef GPUCA_HAS_ONNX + processors()->tpcNNClusterer[i].mISector = i; + mRec->RegisterGPUProcessor(&processors()->tpcNNClusterer[i], GetRecoStepsGPU() & RecoStep::TPCClusterFinding); +#endif + } } if (GetRecoSteps() & RecoStep::TPCMerging) { mRec->RegisterGPUProcessor(&processors()->tpcMerger, GetRecoStepsGPU() & RecoStep::TPCMerging); @@ -104,14 +113,6 @@ void GPUChainTracking::RegisterPermanentMemoryAndProcessors() if (GetRecoSteps() & RecoStep::TPCDecompression) { mRec->RegisterGPUProcessor(&processors()->tpcDecompressor, GetRecoStepsGPU() & RecoStep::TPCDecompression); } - if (GetRecoSteps() & RecoStep::TPCClusterFinding) { - for (uint32_t i = 0; i < NSECTORS; i++) { - mRec->RegisterGPUProcessor(&processors()->tpcClusterer[i], GetRecoStepsGPU() & RecoStep::TPCClusterFinding); -#ifdef GPUCA_HAS_ONNX - mRec->RegisterGPUProcessor(&processors()->tpcNNClusterer[i], GetRecoStepsGPU() & RecoStep::TPCClusterFinding); -#endif - } - } if (GetRecoSteps() & RecoStep::Refit) { mRec->RegisterGPUProcessor(&processors()->trackingRefit, GetRecoStepsGPU() & RecoStep::Refit); } @@ -334,7 +335,7 @@ bool GPUChainTracking::ValidateSettings() int32_t GPUChainTracking::Init() { - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); if (GetProcessingSettings().debugLevel >= 1) { printf("Enabled Reconstruction Steps: 0x%x (on GPU: 0x%x)", (int32_t)GetRecoSteps().get(), (int32_t)GetRecoStepsGPU().get()); for (uint32_t i = 0; i < sizeof(gpudatatypes::RECO_STEP_NAMES) / sizeof(gpudatatypes::RECO_STEP_NAMES[0]); i++) { @@ -686,7 +687,7 @@ int32_t GPUChainTracking::RunChain() if (GetProcessingSettings().autoAdjustHostThreads && !mRec->IsGPU()) { mRec->SetNActiveThreads(-1); } - const auto threadContext = GetThreadContext(); + const auto holdContext = GetThreadContext(); if (GetProcessingSettings().runCompressionStatistics && mCompressionStatistics == nullptr) { mCompressionStatistics.reset(new GPUTPCClusterStatistics); } @@ -908,7 +909,7 @@ int32_t GPUChainTracking::CheckErrorCodes(bool cpuOnly, bool forceShowErrors, st bool hasDebugError = false; for (int32_t i = 0; i < 1 + (!cpuOnly && mRec->IsGPU()); i++) { if (i) { - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); if (GetProcessingSettings().doublePipeline) { TransferMemoryResourceLinkToHost(RecoStep::NoRecoStep, mInputsHost->mResourceErrorCodes, 0); SynchronizeStream(0); @@ -974,7 +975,7 @@ void GPUChainTracking::ClearErrorCodes(bool cpuOnly) { processors()->errorCodes.clear(); if (mRec->IsGPU() && !cpuOnly) { - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); WriteToConstantMemory(RecoStep::NoRecoStep, (char*)&processors()->errorCodes - (char*)processors(), &processorsShadow()->errorCodes, sizeof(processorsShadow()->errorCodes), 0); TransferMemoryResourceLinkToGPU(RecoStep::NoRecoStep, mInputsHost->mResourceErrorCodes, 0); } diff --git a/GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx b/GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx index 7d76c5abbe421..fc10e672b5264 100644 --- a/GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx +++ b/GPU/GPUTracking/Global/GPUChainTrackingClusterizer.cxx @@ -655,7 +655,7 @@ int32_t GPUChainTracking::RunTPCClusterizer_prepare(bool restorePointers, const processorsShadow()->ioPtrs.clustersNative = mCFContext->ptrClusterNativeSave; return 0; } - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); mRec->MemoryScalers()->nTPCdigits = 0; if (mCFContext == nullptr) { mCFContext.reset(new GPUTPCCFChainContext); @@ -763,7 +763,7 @@ int32_t GPUChainTracking::RunTPCClusterizer(bool synchronizeOutput) int32_t tpcTimeBinCut = (mUpdateNewCalibObjects && mNewCalibValues->newTPCTimeBinCut) ? mNewCalibValues->tpcTimeBinCut : param().tpcCutTimeBin; mRec->PushNonPersistentMemory(qStr2Tag("TPCCLUST")); - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); const bool doGPU = GetRecoStepsGPU() & RecoStep::TPCClusterFinding; GPUTPCExtraADC extraADCs; diff --git a/GPU/GPUTracking/Global/GPUChainTrackingCompression.cxx b/GPU/GPUTracking/Global/GPUChainTrackingCompression.cxx index 5d7a785b7a25e..2caf7b3df4e54 100644 --- a/GPU/GPUTracking/Global/GPUChainTrackingCompression.cxx +++ b/GPU/GPUTracking/Global/GPUChainTrackingCompression.cxx @@ -41,7 +41,7 @@ int32_t GPUChainTracking::RunTPCCompression() int32_t gatherMode = mRec->GetProcessingSettings().tpcCompressionGatherMode == -1 ? mRec->getGPUParameters(doGPU).par_COMP_GATHER_MODE : mRec->GetProcessingSettings().tpcCompressionGatherMode; GPUTPCCompression& Compressor = processors()->tpcCompressor; GPUTPCCompression& CompressorShadow = doGPU ? processorsShadow()->tpcCompressor : Compressor; - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); if (mPipelineFinalizationCtx && GetProcessingSettings().doublePipelineClusterizer) { RecordMarker(&mEvents->single, 0); } @@ -239,7 +239,7 @@ int32_t GPUChainTracking::RunTPCDecompression() } if (GetProcessingSettings().tpcUseOldCPUDecoding) { const bool runFiltering = needFullFiltering || runTimeBinCutFiltering; - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); TPCClusterDecompressor decomp; auto allocatorFinal = [this](size_t size) { this->mInputsHost->mNClusterNative = this->mInputsShadow->mNClusterNative = size; @@ -279,7 +279,7 @@ int32_t GPUChainTracking::RunTPCDecompression() bool doGPU = GetRecoStepsGPU() & RecoStep::TPCDecompression; GPUTPCDecompression& Decompressor = processors()->tpcDecompressor; GPUTPCDecompression& DecompressorShadow = doGPU ? processorsShadow()->tpcDecompressor : Decompressor; - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); CompressedClusters& inputGPU = Decompressor.mInputGPU; CompressedClusters& inputGPUShadow = DecompressorShadow.mInputGPU; diff --git a/GPU/GPUTracking/Global/GPUChainTrackingDebugAndProfiling.cxx b/GPU/GPUTracking/Global/GPUChainTrackingDebugAndProfiling.cxx index 13369405ac519..9f4600211450f 100644 --- a/GPU/GPUTracking/Global/GPUChainTrackingDebugAndProfiling.cxx +++ b/GPU/GPUTracking/Global/GPUChainTrackingDebugAndProfiling.cxx @@ -195,7 +195,7 @@ void GPUChainTracking::PrintMemoryRelations() void GPUChainTracking::PrepareKernelDebugOutput() { #ifdef GPUCA_KERNEL_DEBUGGER_OUTPUT - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); if (mRec->IsGPU()) { SetupGPUProcessor(&processors()->debugOutput, false); WriteToConstantMemory(RecoStep::NoRecoStep, (char*)&processors()->debugOutput - (char*)processors(), &processorsShadow()->debugOutput, sizeof(processors()->debugOutput), -1); @@ -208,7 +208,7 @@ void GPUChainTracking::PrepareKernelDebugOutput() void GPUChainTracking::PrintKernelDebugOutput() { #ifdef GPUCA_KERNEL_DEBUGGER_OUTPUT - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); TransferMemoryResourcesToHost(RecoStep::NoRecoStep, &processors()->debugOutput, -1); processors()->debugOutput.Print(); #endif @@ -216,11 +216,13 @@ void GPUChainTracking::PrintKernelDebugOutput() void GPUChainTracking::PrintOutputStat() { - int32_t nTracks = 0, nAttachedClusters = 0, nAttachedClustersFitted = 0, nAdjacentClusters = 0; + int32_t nTracks = 0, nAttachedClusters = 0, nAttachedClustersFitted = 0, nAdjacentClusters = 0, nCompressedClusters = 0; uint32_t nCls = GetProcessingSettings().doublePipeline ? mIOPtrs.clustersNative->nClustersTotal : processors()->tpcMerger.NClusters(); + const char* outputType = ""; if (GetProcessingSettings().createO2Output > 1) { nTracks = mIOPtrs.nOutputTracksTPCO2; nAttachedClusters = mIOPtrs.nMergedTrackHits; + outputType = "O2"; } else { for (uint32_t k = 0; k < mIOPtrs.nMergedTracks; k++) { if (mIOPtrs.mergedTracks[k].OK()) { @@ -237,6 +239,11 @@ void GPUChainTracking::PrintOutputStat() nAdjacentClusters++; } } + outputType = "GPU"; + } + if (mIOPtrs.tpcCompressedClusters) { + o2::tpc::CompressedClusters c = *mIOPtrs.tpcCompressedClusters; + nCompressedClusters = c.nAttachedClusters + c.nUnattachedClusters; } char trdText[1024] = ""; @@ -256,7 +263,7 @@ void GPUChainTracking::PrintOutputStat() } snprintf(trdText, 1024, " - TRD Tracker reconstructed %d tracks (%d tracklets)", nTRDTracks, nTRDTracklets); } - GPUInfo("Output Tracks: %d (%d / %d / %d / %d clusters (fitted / attached / adjacent / total) - %s format)%s", nTracks, nAttachedClustersFitted, nAttachedClusters, nAdjacentClusters, nCls, GetProcessingSettings().createO2Output > 1 ? "O2" : "GPU", trdText); + GPUInfo("Output Tracks (%s): %d - Clusters: %d / %d / %d / %d / %d (attached / total / compressed / fitted / adjacent) )%s", outputType, nTracks, nAttachedClusters, nCls, nCompressedClusters, nAttachedClustersFitted, nAdjacentClusters, trdText); } void GPUChainTracking::OutputSanityCheck() diff --git a/GPU/GPUTracking/Global/GPUChainTrackingIO.cxx b/GPU/GPUTracking/Global/GPUChainTrackingIO.cxx index ac8cb2ba11736..c7aa8768cea4c 100644 --- a/GPU/GPUTracking/Global/GPUChainTrackingIO.cxx +++ b/GPU/GPUTracking/Global/GPUChainTrackingIO.cxx @@ -168,7 +168,7 @@ int32_t GPUChainTracking::ReadData(const char* filename) } char buf[DUMP_HEADER_SIZE + 1] = ""; - size_t r = fread(buf, 1, DUMP_HEADER_SIZE, fp); + [[maybe_unused]] size_t r = fread(buf, 1, DUMP_HEADER_SIZE, fp); if (strncmp(DUMP_HEADER, buf, DUMP_HEADER_SIZE)) { GPUError("Invalid file header"); fclose(fp); @@ -265,7 +265,6 @@ int32_t GPUChainTracking::ReadData(const char* filename) GPUError("Error reading data file, reading incomplete"); return 1; } - (void)r; for (uint32_t i = 0; i < NSECTORS; i++) { for (uint32_t j = 0; j < mIOPtrs.nClusterData[i]; j++) { ptrClusterData[i][j].id = nClustersTotal++; diff --git a/GPU/GPUTracking/Global/GPUChainTrackingMerger.cxx b/GPU/GPUTracking/Global/GPUChainTrackingMerger.cxx index 32cad4d62b82c..ef549fda636cb 100644 --- a/GPU/GPUTracking/Global/GPUChainTrackingMerger.cxx +++ b/GPU/GPUTracking/Global/GPUChainTrackingMerger.cxx @@ -101,7 +101,7 @@ int32_t GPUChainTracking::RunTPCTrackingMerger(bool synchronizeOutput) if (GetProcessingSettings().debugLevel >= 2) { GPUInfo("Running TPC Merger"); } - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); SynchronizeGPU(); // Need to know the full number of sector tracks SetupGPUProcessor(&Merger, true); diff --git a/GPU/GPUTracking/Global/GPUChainTrackingRefit.cxx b/GPU/GPUTracking/Global/GPUChainTrackingRefit.cxx index eeabab6ed395f..62d35df61414c 100644 --- a/GPU/GPUTracking/Global/GPUChainTrackingRefit.cxx +++ b/GPU/GPUTracking/Global/GPUChainTrackingRefit.cxx @@ -28,7 +28,7 @@ int32_t GPUChainTracking::RunRefit() GPUTrackingRefitProcessor& Refit = processors()->trackingRefit; GPUTrackingRefitProcessor& RefitShadow = doGPU ? processorsShadow()->trackingRefit : Refit; - [[maybe_unused]] const auto& threadContext = GetThreadContext(); + [[maybe_unused]] const auto& holdContext = GetThreadContext(); SetupGPUProcessor(&Refit, false); RefitShadow.SetPtrsFromGPUConstantMem(processorsShadow(), doGPU ? &processorsDevice()->param : nullptr); RefitShadow.SetPropagator(doGPU ? processorsShadow()->calibObjects.o2Propagator : GetO2Propagator()); diff --git a/GPU/GPUTracking/Global/GPUChainTrackingSectorTracker.cxx b/GPU/GPUTracking/Global/GPUChainTrackingSectorTracker.cxx index bcaaa92bddb12..b2fd37f0d2c94 100644 --- a/GPU/GPUTracking/Global/GPUChainTrackingSectorTracker.cxx +++ b/GPU/GPUTracking/Global/GPUChainTrackingSectorTracker.cxx @@ -58,7 +58,7 @@ int32_t GPUChainTracking::RunTPCTrackingSectors() return (1); } - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); int32_t retVal = RunTPCTrackingSectors_internal(); if (retVal) { diff --git a/GPU/GPUTracking/Global/GPUChainTrackingTRD.cxx b/GPU/GPUTracking/Global/GPUChainTrackingTRD.cxx index ca47d65b32cd4..7489f9eb87c09 100644 --- a/GPU/GPUTracking/Global/GPUChainTrackingTRD.cxx +++ b/GPU/GPUTracking/Global/GPUChainTrackingTRD.cxx @@ -150,7 +150,7 @@ int32_t GPUChainTracking::DoTRDGPUTracking(T* externalInstance) int32_t useStream = 0; - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); SetupGPUProcessor(Tracker, false); if (doGPU) { TrackerShadow->OverrideGPUGeometry(reinterpret_cast(mFlatObjectsDevice.mCalibObjects.trdGeometry)); diff --git a/GPU/GPUTracking/Global/GPUChainTrackingTransformation.cxx b/GPU/GPUTracking/Global/GPUChainTrackingTransformation.cxx index 46bcd6931c302..be73dfab87faa 100644 --- a/GPU/GPUTracking/Global/GPUChainTrackingTransformation.cxx +++ b/GPU/GPUTracking/Global/GPUChainTrackingTransformation.cxx @@ -38,7 +38,7 @@ bool GPUChainTracking::NeedTPCClustersOnGPU() int32_t GPUChainTracking::ConvertNativeToClusterData() { mRec->PushNonPersistentMemory(qStr2Tag("TPCTRANS")); - const auto& threadContext = GetThreadContext(); + const auto& holdContext = GetThreadContext(); bool transferClusters = false; if (mRec->IsGPU() && !(mRec->GetRecoStepsGPU() & gpudatatypes::RecoStep::TPCClusterFinding) && NeedTPCClustersOnGPU()) { diff --git a/GPU/GPUTracking/Interface/GPUO2InterfaceUtils.cxx b/GPU/GPUTracking/Interface/GPUO2InterfaceUtils.cxx index f0efaf48c8725..b96ff6fa0beaa 100644 --- a/GPU/GPUTracking/Interface/GPUO2InterfaceUtils.cxx +++ b/GPU/GPUTracking/Interface/GPUO2InterfaceUtils.cxx @@ -132,8 +132,8 @@ void GPUO2InterfaceUtils::paramUseExternalOccupancyMap(GPUParam* param, uint32_t if (occupancymap) { param->occupancyTotal = *occupancymap; if (param->rec.tpc.occupancyMapTimeBins) { - param->occupancyMap = occupancymap + 2; - param->occupancyMapSize = GPUTPCClusterOccupancyMapBin::getNBins(*param); + param->occupancy.map = occupancymap + 2; + param->occupancy.mapSize = GPUTPCClusterOccupancyMapBin::getNBins(*param); } } } diff --git a/GPU/GPUTracking/Merger/GPUTPCGMMergerDump.cxx b/GPU/GPUTracking/Merger/GPUTPCGMMergerDump.cxx index cabe3eb7db923..ef5c3e598896b 100644 --- a/GPU/GPUTracking/Merger/GPUTPCGMMergerDump.cxx +++ b/GPU/GPUTracking/Merger/GPUTPCGMMergerDump.cxx @@ -381,7 +381,7 @@ std::vector GPUTPCGMMerger::StreamerOccupancyBin(int32_t iSector, int3 const int32_t bin = CAMath::Max(0.f, time / Param().rec.tpc.occupancyMapTimeBins); for (int32_t i = 0; i < 1 + 2 * size; i++) { const int32_t mybin = bin + i - size; - retVal[i] = (mybin >= 0 && mybin < (int32_t)GPUTPCClusterOccupancyMapBin::getNBins(Param())) ? Param().occupancyMap[mybin] : 0; + retVal[i] = (mybin >= 0 && mybin < (int32_t)GPUTPCClusterOccupancyMapBin::getNBins(Param())) ? Param().occupancy.map[mybin] : 0; } #endif return retVal; diff --git a/GPU/GPUTracking/Merger/GPUTPCGMPhysicalTrackModel.cxx b/GPU/GPUTracking/Merger/GPUTPCGMPhysicalTrackModel.cxx index ed60f2d86f63c..c942f5214ce5b 100644 --- a/GPU/GPUTracking/Merger/GPUTPCGMPhysicalTrackModel.cxx +++ b/GPU/GPUTracking/Merger/GPUTPCGMPhysicalTrackModel.cxx @@ -35,7 +35,7 @@ GPUd() int32_t GPUTPCGMPhysicalTrackModel::PropagateToXBzLight(float x, float Bz GPUd() int32_t GPUTPCGMPhysicalTrackModel::PropagateToXBzLightNoUpdate(float x, float Bz, float& GPUrestrict() dLp) { // - // transport the track to X=x in magnetic field B = ( 0, 0, Bz[kG*0.000299792458f] ) + // transport the track to X=x in magnetic field B = ( 0, 0, Bz[kG*kClight] ) // dLp is a return value == path length / track momentum [cm/(GeV/c)] // the method returns error code (0 == no error) // @@ -89,7 +89,7 @@ GPUd() int32_t GPUTPCGMPhysicalTrackModel::PropagateToXBzLightNoUpdate(float x, GPUd() int32_t GPUTPCGMPhysicalTrackModel::PropagateToXBxByBz(float x, float Bx, float By, float Bz, float& GPUrestrict() dLp) { // - // transport the track to X=x in magnetic field B = ( Bx, By, Bz )[kG*0.000299792458f] + // transport the track to X=x in magnetic field B = ( Bx, By, Bz )[kG*kClight] // xyzPxPyPz as well as all the additional values will change. No need to call UpdateValues() afterwards. // the method returns error code (0 == no error) // diff --git a/GPU/GPUTracking/SectorTracker/GPUTPCStartHitsSorter.cxx b/GPU/GPUTracking/SectorTracker/GPUTPCStartHitsSorter.cxx index 8918c6cab5604..aeb101ffe469d 100644 --- a/GPU/GPUTracking/SectorTracker/GPUTPCStartHitsSorter.cxx +++ b/GPU/GPUTracking/SectorTracker/GPUTPCStartHitsSorter.cxx @@ -42,11 +42,7 @@ GPUdii() void GPUTPCStartHitsSorter::Thread<0>(int32_t nBlocks, int32_t nThreads GPUbarrier(); int32_t startOffset = s.mStartOffset; -#ifdef __HIPCC__ // TODO: Fixme - for (int32_t ir = -1; ++ir < (int32_t)s.mNRows;) { -#else for (uint32_t ir = 0; ir < s.mNRows; ir++) { -#endif GPUglobalref() GPUTPCHitId* const GPUrestrict() startHits = tracker.mTrackletStartHits; GPUglobalref() GPUTPCHitId* const GPUrestrict() tmpStartHits = tracker.mTrackletTmpStartHits + (s.mStartRow + ir) * tracker.mNMaxRowStartHits; diff --git a/GPU/GPUTracking/SectorTracker/GPUTPCTrackParam.cxx b/GPU/GPUTracking/SectorTracker/GPUTPCTrackParam.cxx index 774bcfb54b6a5..5c31d509f8a5a 100644 --- a/GPU/GPUTracking/SectorTracker/GPUTPCTrackParam.cxx +++ b/GPU/GPUTracking/SectorTracker/GPUTPCTrackParam.cxx @@ -21,7 +21,6 @@ using namespace o2::gpu; // // Circle in XY: // -// kCLight = 0.000299792458f; // Kappa = -Bz*kCLight*QPt; // R = 1/CAMath::Abs(Kappa); // Xc = X - CAMath::Sin(Phi)/Kappa; diff --git a/GPU/GPUTracking/SectorTracker/GPUTPCTrackingData.cxx b/GPU/GPUTracking/SectorTracker/GPUTPCTrackingData.cxx index 9324198753a44..468ac8ed19504 100644 --- a/GPU/GPUTracking/SectorTracker/GPUTPCTrackingData.cxx +++ b/GPU/GPUTracking/SectorTracker/GPUTPCTrackingData.cxx @@ -213,7 +213,7 @@ GPUdii() int32_t GPUTPCTrackingData::InitFromClusterData(int32_t nBlocks, int32_ float x, y, z; GPUTPCConvertImpl::convert(*mem, iSector, rowIndex, mem->ioPtrs.clustersNative->clusters[iSector][rowIndex][i].getPad(), mem->ioPtrs.clustersNative->clusters[iSector][rowIndex][i].getTime(), x, y, z); UpdateMinMaxYZ(yMin, yMax, zMin, zMax, y, z); - YZData[RowOffset + i] = CAMath::MakeFloat2(y, z); + YZData[RowOffset + i] = float2{y, z}; } if (iThread == 0) { diff --git a/GPU/GPUTracking/SectorTracker/GPUTPCTrackletConstructor.cxx b/GPU/GPUTracking/SectorTracker/GPUTPCTrackletConstructor.cxx index 2f89a998f8e9f..b076a0a9c0417 100644 --- a/GPU/GPUTracking/SectorTracker/GPUTPCTrackletConstructor.cxx +++ b/GPU/GPUTracking/SectorTracker/GPUTPCTrackletConstructor.cxx @@ -88,11 +88,7 @@ GPUd() void GPUTPCTrackletConstructor::StoreTracklet(int32_t /*nBlocks*/, int32_ tracklet.SetParam(tParam.GetParam()); int32_t w = tracker.CalculateHitWeight(r.mNHits, tParam.GetChi2()); tracklet.SetHitWeight(w); -#ifdef __HIPCC__ // Todo: fixme! - for (int32_t iRow = r.mFirstRow - 1; ++iRow <= (int32_t)r.mLastRow; /*iRow++*/) { -#else for (uint32_t iRow = r.mFirstRow; iRow <= r.mLastRow; iRow++) { -#endif calink ih = rowHits[iRow]; tracker.TrackletRowHits()[hitout + (iRow - r.mFirstRow)] = ih; if (ih != CALINK_INVAL && ih != CALINK_DEAD_CHANNEL) { @@ -313,20 +309,12 @@ GPUdic(2, 1) void GPUTPCTrackletConstructor::UpdateTracklet(int32_t /*nBlocks*/, row.Grid().GetBinArea(yUncorrected, zUncorrected + tParam.ZOffset(), CAMath::Sqrt(sy2), CAMath::Sqrt(sz2), bin, ny, nz); float ds = 1e6f; -#ifdef __HIPCC__ // Todo: fixme! - for (int32_t k = -1; ++k <= nz; /*k++*/) { -#else for (int32_t k = 0; k <= nz; k++) { -#endif int32_t nBinsY = row.Grid().Ny(); int32_t mybin = bin + k * nBinsY; uint32_t hitFst = firsthit[mybin]; uint32_t hitLst = firsthit[mybin + ny + 1]; -#ifdef __HIPCC__ // Todo: fixme! - for (uint32_t ih = hitFst - 1; ++ih < hitLst; /*ih++*/) { -#else for (uint32_t ih = hitFst; ih < hitLst; ih++) { -#endif cahit2 hh = hits[ih]; float y = y0 + hh.x * stepY; float z = z0 + hh.y * stepZ; @@ -420,11 +408,7 @@ GPUdic(2, 1) void GPUTPCTrackletConstructor::DoTracklet(GPUconstantref() GPUTPCT r.mNHits = 0; CADEBUG(printf("Start tracklet\n")); -#ifdef __HIPCC__ // Todo: fixme! - for (int32_t iStage = -1; ++iStage < 2; /*iStage++*/) { -#else for (int32_t iStage = 0; iStage < 2; iStage++) { -#endif for (; iRow != iRowEnd; iRow += r.mStage == 2 ? -1 : 1) { if (!r.mGo) { break; diff --git a/GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizer.cxx b/GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizer.cxx index c041cfcc10121..5edc3afbc75e4 100644 --- a/GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizer.cxx +++ b/GPU/GPUTracking/TPCClusterFinder/GPUTPCNNClusterizer.cxx @@ -70,8 +70,7 @@ void* GPUTPCNNClusterizer::setIOPointers(void* mem) auto fmt = [](size_t bytes) -> const char* { static char buf[64]; double mb = (double)bytes / (1024.0 * 1024.0); - int n = snprintf(buf, sizeof(buf), "%zu bytes (%.3f MB)", bytes, mb); - (void)n; + [[maybe_unused]] int n = snprintf(buf, sizeof(buf), "%zu bytes (%.3f MB)", bytes, mb); return buf; }; @@ -136,10 +135,9 @@ void* GPUTPCNNClusterizer::setIOPointers(void* mem) double allocatedMB = static_cast(allocatedBytes) / (1024.0 * 1024.0); { char allocMsg[256]; - int nn = snprintf(allocMsg, sizeof(allocMsg), - "(NNCLUS, GPUTPCNNClusterizer, this=%p) Total scratch allocation in setIOPointers: %zu bytes (%.3f MB)", - (void*)this, (size_t)allocatedBytes, allocatedMB); - (void)nn; + [[maybe_unused]] int nn = snprintf(allocMsg, sizeof(allocMsg), + "(NNCLUS, GPUTPCNNClusterizer, this=%p) Total scratch allocation in setIOPointers: %zu bytes (%.3f MB)", + (void*)this, (size_t)allocatedBytes, allocatedMB); LOG(info) << allocMsg; } } diff --git a/dependencies/FindO2GPU.cmake b/dependencies/FindO2GPU.cmake index a8a2924872bf0..0ca99a346d2ca 100644 --- a/dependencies/FindO2GPU.cmake +++ b/dependencies/FindO2GPU.cmake @@ -10,7 +10,7 @@ # or submit itself to any jurisdiction. # NOTE!!!! - Whenever this file is changed, move it over to alidist/resources -# FindO2GPU.cmake Version 25 +# FindO2GPU.cmake Version 26 set(CUDA_COMPUTETARGET_DEFAULT_FULL 80-real;86-real;89-real;120-real;75-virtual) set(HIP_AMDGPUTARGET_DEFAULT_FULL gfx906;gfx908) @@ -349,34 +349,18 @@ if(ENABLE_HIP) endif() if (DEFINED ENV{O2_GPU_ROCM_HOME}) list(PREPEND CMAKE_PREFIX_PATH "$ENV{O2_GPU_ROCM_HOME}/lib/cmake") + elseif (DEFINED ENV{ROCM_PATH}) list(PREPEND CMAKE_PREFIX_PATH "$ENV{ROCM_PATH}/lib/cmake") + set(CMAKE_HIP_COMPILER "$ENV{ROCM_PATH}/llvm/bin/clang++") elseif(NOT "$ENV{CMAKE_PREFIX_PATH}" MATCHES "rocm|ROCm" AND NOT CMAKE_PREFIX_PATH MATCHES "rocm|ROCm" AND EXISTS "/opt/rocm/lib/cmake/") list(APPEND CMAKE_PREFIX_PATH "/opt/rocm/lib/cmake") endif() - # TODO: Use ROCm folder as provided by alidist-gpu recipe - if("$ENV{CMAKE_PREFIX_PATH}" MATCHES "rocm|ROCm" OR CMAKE_PREFIX_PATH MATCHES "rocm|ROCm") - if (DEFINED ENV{O2_GPU_ROCM_HOME}) - set(CMAKE_HIP_COMPILER "$ENV{O2_GPU_ROCM_HOME}/llvm/bin/clang++") - set(TMP_ROCM_DIR "$ENV{O2_GPU_ROCM_HOME}") - elseif (DEFINED ENV{ROCM_PATH}) - set(CMAKE_HIP_COMPILER "$ENV{ROCM_PATH}/llvm/bin/clang++") - set(TMP_ROCM_DIR "$ENV{ROCM_PATH}") - else() - set(TMP_ROCM_DIR_LIST "${CMAKE_PREFIX_PATH}:$ENV{CMAKE_PREFIX_PATH}") - string(REPLACE ":" ";" TMP_ROCM_DIR_LIST "${TMP_ROCM_DIR_LIST}") - list(FILTER TMP_ROCM_DIR_LIST INCLUDE REGEX /rocm/lib/cmake|/ROCm/lib/cmake) - list(POP_FRONT TMP_ROCM_DIR_LIST TMP_ROCM_DIR) - get_filename_component(TMP_ROCM_DIR ${TMP_ROCM_DIR}/../../ ABSOLUTE) - endif() + find_package(rocm-core CONFIG) + if(rocm-core_FOUND) + set(CMAKE_HIP_COMPILER "${ROCM_PATH}/llvm/bin/clang++") set(CMAKE_HIP_STANDARD ${CMAKE_CXX_STANDARD}) set(CMAKE_HIP_STANDARD_REQUIRED TRUE) - if (NOT DEFINED CMAKE_HIP_COMPILER) - set(CMAKE_HIP_COMPILER "${TMP_ROCM_DIR}/llvm/bin/clang++") - if(NOT EXISTS ${CMAKE_HIP_COMPILER}) - unset(CMAKE_HIP_COMPILER) - endif() - endif() include(CheckLanguage) check_language(HIP) find_package(hip) @@ -385,7 +369,7 @@ if(ENABLE_HIP) find_package(rocthrust) find_program(hip_HIPIFY_PERL_EXECUTABLE "hipify-perl") if(NOT hip_HIPIFY_PERL_EXECUTABLE) - find_program(hip_HIPIFY_PERL_EXECUTABLE "hipify-perl" HINTS "${TMP_ROCM_DIR}/bin") + find_program(hip_HIPIFY_PERL_EXECUTABLE "hipify-perl" HINTS "${ROCM_PATH}/bin") endif() if(ENABLE_HIP STREQUAL "AUTO") set_package_properties(hip PROPERTIES TYPE OPTIONAL) @@ -411,12 +395,13 @@ if(ENABLE_HIP) enable_language(HIP) endif() elseif(NOT ENABLE_HIP STREQUAL "AUTO") - message(FATAL_ERROR "HIP requested, but CMAKE_PREFIX_PATH (${CMAKE_PREFIX_PATH}) env variable does not contain rocm folder!") + message(FATAL_ERROR "HIP requested, but not found. Perhaps need to set CMAKE_PREFIX_PATH (currently ${CMAKE_PREFIX_PATH})") endif() - if(hip_FOUND AND NOT hip_VERSION VERSION_GREATER_EQUAL "6.3") + if((hip_FOUND AND NOT hip_VERSION VERSION_GREATER_EQUAL "7.15") OR (hip_FOUND AND NOT rocm-core_VERSION VERSION_GREATER_EQUAL "10.1")) + message(${FAILURE_SEVERITY} "ROCm too old: HIP ${hip_VERSION}, 7.15 required, ROCm: ${rocm-core_VERSION}, 10.1 required") set(hip_FOUND 0) endif() - if(hip_FOUND AND hipcub_FOUND AND rocthrust_FOUND AND rocprim_FOUND AND hip_HIPCC_EXECUTABLE AND hip_HIPIFY_PERL_EXECUTABLE) + if(rocm-core_FOUND AND hip_FOUND AND hipcub_FOUND AND rocthrust_FOUND AND rocprim_FOUND AND hip_HIPCC_EXECUTABLE AND hip_HIPIFY_PERL_EXECUTABLE) set(HIP_ENABLED ON) set_target_properties(roc::rocthrust PROPERTIES IMPORTED_GLOBAL TRUE) set(CMAKE_HIP_FLAGS "${O2_GPU_CMAKE_CXX_FLAGS_NOSTD} ${CMAKE_HIP_FLAGS} ${GPUCA_HIP_DENORMALS_FLAGS}") @@ -434,7 +419,7 @@ if(ENABLE_HIP) if(HIP_AMDGPUTARGET) set(CMAKE_HIP_ARCHITECTURES "${HIP_AMDGPUTARGET}") endif() - message(STATUS "HIP Found (${hip_HIPCC_EXECUTABLE}, ${CMAKE_HIP_COMPILER}, Version ${hip_VERSION}, Architectures ${CMAKE_HIP_ARCHITECTURES})") + message(STATUS "HIP Found (${hip_HIPCC_EXECUTABLE}, ${CMAKE_HIP_COMPILER} ${CMAKE_HIP_COMPILER_VERSION}, Version ${hip_VERSION}, Architectures ${CMAKE_HIP_ARCHITECTURES})") else() set(HIP_ENABLED OFF) endif()