diff --git a/GPU/Common/GPUCommonMath.h b/GPU/Common/GPUCommonMath.h index e7ccf1e5c166f..eb0fd6f11dee1 100644 --- a/GPU/Common/GPUCommonMath.h +++ b/GPU/Common/GPUCommonMath.h @@ -130,7 +130,7 @@ class GPUCommonMath GPUhdi() static float Remainderf(float x, float y); GPUd() constexpr static bool Finite(float x); GPUd() constexpr static bool IsNaN(float x); -#ifndef __FAST_MATH__ +#if !defined(__FAST_MATH__) && !defined(GPUCA_GPUCODE_GENRTC) GPUd() constexpr static float QuietNaN() { return GPUCA_CHOICE(std::numeric_limits::quiet_NaN(), __builtin_nanf(""), NAN); } #endif GPUd() constexpr static uint32_t Clz(uint32_t val); diff --git a/GPU/GPUTracking/Base/GPUReconstruction.cxx b/GPU/GPUTracking/Base/GPUReconstruction.cxx index 904db3c9c0065..31ff906a19490 100644 --- a/GPU/GPUTracking/Base/GPUReconstruction.cxx +++ b/GPU/GPUTracking/Base/GPUReconstruction.cxx @@ -226,6 +226,10 @@ int32_t GPUReconstruction::InitPhaseBeforeDevice() } GPUConfigDump::dumpConfig(¶m().rec, mProcessingSettings.get(), chTrk ? chTrk->GetQAConfig() : nullptr, chTrk ? chTrk->GetEventDisplayConfig() : nullptr, mDeviceBackendSettings.get(), &mRecoSteps); } + if (GPUConfigDump::checkConfig(GetProcessingSettings(), *mDeviceBackendSettings)) { + GPUError("Invalid settings"); + return 1; + } mRecoSteps.stepsGPUMask &= mRecoSteps.steps; mRecoSteps.stepsGPUMask &= AvailableGPURecoSteps(); if (!IsGPU()) { diff --git a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAGenRTC.cxx b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAGenRTC.cxx index aa820357d92e7..0ac63608f0c84 100644 --- a/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAGenRTC.cxx +++ b/GPU/GPUTracking/Base/cuda/GPUReconstructionCUDAGenRTC.cxx @@ -45,10 +45,10 @@ int32_t GPUReconstructionCUDA::genRTC(std::string& filename, uint32_t& nCompile) rtchelpers::loadLaunchBounds(proc, *mParDevice); if constexpr (std::string_view("CUDA") == "HIP") { // Check if we are RTC-compiling for HIP - if (proc.hipOverrideAMDEUSperCU > 0) { - mParDevice->par_AMD_EUS_PER_CU = proc.hipOverrideAMDEUSperCU; + if (proc.backend.overrideEUSperCU > 0) { + mParDevice->par_AMD_EUS_PER_CU = proc.backend.overrideEUSperCU; } else if (mParDevice->par_AMD_EUS_PER_CU <= 0) { - GPUFatal("AMD_EUS_PER_CU not set in the parameters provided for the AMD GPU, you can override this via --PROChipOverrideAMDEUSperCU [n]"); + GPUFatal("AMD_EUS_PER_CU not set in the parameters provided for the AMD GPU, you can override this via --BACKENDbackendOverrideEUSperCU [n]"); } } for (uint32_t i = 0; i < GetNKernels(); i++) { diff --git a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cxx b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cxx index 316daa63542cf..a093f10bf3d2e 100644 --- a/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cxx +++ b/GPU/GPUTracking/Base/opencl/GPUReconstructionOCL.cxx @@ -126,17 +126,17 @@ int32_t GPUReconstructionOCL::InitDevice_Runtime() cl_uint deviceCount, bestDevice = (cl_uint)-1, bestPlatform = (cl_uint)-1; for (uint32_t iPlatform = 0; iPlatform < num_platforms; iPlatform++) { - if (GetProcessingSettings().oclPlatformNum >= 0) { - if (GetProcessingSettings().oclPlatformNum >= (int32_t)num_platforms) { + if (GetProcessingSettings().backend.platformNum >= 0) { + if (GetProcessingSettings().backend.platformNum >= (int32_t)num_platforms) { GPUErrorReturn("Invalid platform specified"); } - iPlatform = GetProcessingSettings().oclPlatformNum; + iPlatform = GetProcessingSettings().backend.platformNum; } std::string platformUsageInfo; bool platformCompatible = false; queryPlatform(platforms[iPlatform]); if (clGetDeviceIDs(platforms[iPlatform], CL_DEVICE_TYPE_ALL, 0, nullptr, &deviceCount) != CL_SUCCESS) { - if (GetProcessingSettings().oclPlatformNum >= 0) { + if (GetProcessingSettings().backend.platformNum >= 0) { GPUErrorReturn("No device in requested platform or error obtaining device count"); } platformUsageInfo += " - no devices"; @@ -147,16 +147,16 @@ int32_t GPUReconstructionOCL::InitDevice_Runtime() } } - if (GetProcessingSettings().oclPlatformNum >= 0 || GetProcessingSettings().debugLevel >= 2) { - GPUInfo("%s Platform %d: (%s %s) %s %s (Compatible: %s)%s", GetProcessingSettings().oclPlatformNum >= 0 ? "Enforced" : "Available", iPlatform, platform_profile.c_str(), platform_version.c_str(), platform_vendor.c_str(), platform_name.c_str(), platformCompatible ? "yes" : "no", GetProcessingSettings().debugLevel >= 2 ? platformUsageInfo.c_str() : ""); + if (GetProcessingSettings().backend.platformNum >= 0 || GetProcessingSettings().debugLevel >= 2) { + GPUInfo("%s Platform %d: (%s %s) %s %s (Compatible: %s)%s", GetProcessingSettings().backend.platformNum >= 0 ? "Enforced" : "Available", iPlatform, platform_profile.c_str(), platform_version.c_str(), platform_vendor.c_str(), platform_name.c_str(), platformCompatible ? "yes" : "no", GetProcessingSettings().debugLevel >= 2 ? platformUsageInfo.c_str() : ""); } - if (platformCompatible || GetProcessingSettings().oclPlatformNum >= 0 || (GetProcessingSettings().oclPlatformNum == -2 && deviceCount)) { + if (platformCompatible || GetProcessingSettings().backend.platformNum >= 0 || (GetProcessingSettings().backend.platformNum == -2 && deviceCount)) { if (deviceCount > devices.size()) { devices.resize(deviceCount); } if (clGetDeviceIDs(platforms[iPlatform], CL_DEVICE_TYPE_ALL, deviceCount, devices.data(), nullptr) != CL_SUCCESS) { - if (GetProcessingSettings().oclPlatformNum >= 0) { + if (GetProcessingSettings().backend.platformNum >= 0) { GPUErrorReturn("Error getting OpenCL devices"); } continue; @@ -184,7 +184,7 @@ int32_t GPUReconstructionOCL::InitDevice_Runtime() deviceOK = false; deviceFailure += " - No Little Endian Mode"; } - if (!GetProcessingSettings().oclCompileFromSources) { + if (!GetProcessingSettings().backend.compileFromSources) { size_t pos = 0; while ((pos = device_il_version.find("SPIR-V", pos)) != std::string::npos) { float spirvVersion; @@ -222,7 +222,7 @@ int32_t GPUReconstructionOCL::InitDevice_Runtime() } } } - if (GetProcessingSettings().oclPlatformNum >= 0) { + if (GetProcessingSettings().backend.platformNum >= 0) { break; } } @@ -521,10 +521,10 @@ int32_t GPUReconstructionOCL::GetOCLPrograms() { cl_int ocl_error; - const char* oclBuildFlags = GetProcessingSettings().oclOverrideSourceBuildFlags != "" ? GetProcessingSettings().oclOverrideSourceBuildFlags.c_str() : GPUCA_M_STR(GPUCA_OCL_BUILD_FLAGS); + const char* oclBuildFlags = GetProcessingSettings().backend.overrideSourceBuildFlags != "" ? GetProcessingSettings().backend.overrideSourceBuildFlags.c_str() : GPUCA_M_STR(GPUCA_OCL_BUILD_FLAGS); #ifdef OPENCL_ENABLED_SPIRV // clang-format off - if (mOclVersion >= 2.1f && !GetProcessingSettings().oclCompileFromSources) { + if (mOclVersion >= 2.1f && !GetProcessingSettings().backend.compileFromSources) { GPUInfo("Reading OpenCL program from SPIR-V IL (Platform version %4.2f)", mOclVersion); mInternals->program = clCreateProgramWithIL(mInternals->context, _binary_GPUReconstructionOCLCode_spirv_start, _binary_GPUReconstructionOCLCode_spirv_len, &ocl_error); oclBuildFlags = ""; diff --git a/GPU/GPUTracking/CMakeLists.txt b/GPU/GPUTracking/CMakeLists.txt index 6993bbae056e1..a21608ba8c247 100644 --- a/GPU/GPUTracking/CMakeLists.txt +++ b/GPU/GPUTracking/CMakeLists.txt @@ -69,6 +69,9 @@ set(SRCS_DATATYPES DataTypes/GPUDataTypesConfig.cxx DataTypes/GPUConfigDump.cxx set(ON_THE_FLY_DIR ${CMAKE_CURRENT_BINARY_DIR}/include_gpu_onthefly) file(MAKE_DIRECTORY ${ON_THE_FLY_DIR}) +file(TOUCH ${ON_THE_FLY_DIR}/.cmake_stamp) +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${ON_THE_FLY_DIR}) # Files are generated at configure time, remove them with "make / ninja clean" +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${ON_THE_FLY_DIR}/.cmake_stamp) # and rerun CMake afterwards to regenerate them, since the stamp is gone include(cmake/gpu_settings_list_generator.cmake) foreach(GPU_SETTINGS_LIST GPUSettingsList GPUSettingsListDisplay GPUSettingsListStandalone) generate_gpu_settings_list(${CMAKE_CURRENT_SOURCE_DIR}/Definitions/${GPU_SETTINGS_LIST}.template ${ON_THE_FLY_DIR}/${GPU_SETTINGS_LIST}.h) @@ -116,7 +119,6 @@ set(SRCS_NO_H SectorTracker/GPUTPCTrackerDump.cxx Global/GPUChainTrackingIO.cxx) set(HDRS_INSTALL - ${GPU_SETTINGS_LIST_HEADERS} ${HDRS_CINT_O2} ${HDRS_CINT_DATATYPES} ${HDRS_CINT_O2_ADDITIONAL} @@ -248,7 +250,7 @@ set(TEMPLATE_HEADER_LIST Base/GPUReconstructionKernelList.template.h cmake/GPUNoFastMathKernels.template.h Definitions/GPUDefParametersRuntime.template.h Definitions/GPUDefParametersLoad.template.inc) -set(GENERATED_HEADERS_LIST "") +set(GENERATED_HEADERS_LIST ${GPU_SETTINGS_LIST_HEADERS}) foreach(TEMPLATE_FILE ${TEMPLATE_HEADER_LIST}) get_filename_component(OUTPUT_FILE_NAME ${TEMPLATE_FILE} NAME) @@ -262,6 +264,7 @@ string(APPEND GPUDEFPARAMETERSLBLIST "$ ${ON_THE_FLY_DIR}/GPUDefParametersLoadPrepare.h @@ -296,6 +299,7 @@ foreach(GPU_PARAM_JSON_FILE IN LISTS GPU_PARAM_JSON) COMMAND_ERROR_IS_FATAL ANY ) message(STATUS "Converted ${GPU_PARAM_JSON_FILE} to ${CONVOUTFILE}") + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/${CONVOUTFILE}) list(APPEND GPU_PARAM_JSON_FILES ${CMAKE_CURRENT_BINARY_DIR}/${CONVOUTFILE}) else() list(APPEND GPU_PARAM_JSON_FILES ${GPU_PARAM_JSON_FILE}) @@ -315,6 +319,12 @@ file(GENERATE list(APPEND GENERATED_HEADERS_LIST ${GPU_DEFAULT_PARAMS_HEADER} ${ON_THE_FLY_DIR}/GPUKernelsWith1Warp.inc) set(HDRS_INSTALL ${HDRS_INSTALL} ${GENERATED_HEADERS_LIST}) +file(GLOB GPU_STALE_GENERATED_HEADERS LIST_DIRECTORIES false ${ON_THE_FLY_DIR}/*.h ${ON_THE_FLY_DIR}/*.inc) # Remove headers of previous configurations, which are no longer generated +list(REMOVE_ITEM GPU_STALE_GENERATED_HEADERS ${GENERATED_HEADERS_LIST}) +if(GPU_STALE_GENERATED_HEADERS) + message(STATUS "Removing stale generated GPU headers: ${GPU_STALE_GENERATED_HEADERS}") + file(REMOVE ${GPU_STALE_GENERATED_HEADERS}) +endif() include(kernels.cmake) # Optional sources depending on optional dependencies @@ -455,6 +465,7 @@ endif() # GPUReconstructionLibrary needs to know which GPU backends are enabled for proper error messages configure_file(Base/GPUReconstructionAvailableBackends.template.h ${CMAKE_CURRENT_BINARY_DIR}/GPUReconstructionAvailableBackends.h) +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/GPUReconstructionAvailableBackends.h) set_source_files_properties(Base/GPUReconstructionLibrary.cxx PROPERTIES INCLUDE_DIRECTORIES "${CMAKE_CURRENT_BINARY_DIR}") diff --git a/GPU/GPUTracking/DataTypes/GPUConfigDump.cxx b/GPU/GPUTracking/DataTypes/GPUConfigDump.cxx index 6fd2a0acda6ef..2a338cc53fce5 100644 --- a/GPU/GPUTracking/DataTypes/GPUConfigDump.cxx +++ b/GPU/GPUTracking/DataTypes/GPUConfigDump.cxx @@ -17,11 +17,17 @@ #define GPUSETTINGS_ALL #include "GPUSettings.h" +#include #include +#include #include #include +#include +#include +#include #include "utils/qconfig_helpers.h" +#include "utils/qconfig_internal_helpers.h" using namespace o2::gpu; @@ -29,6 +35,7 @@ namespace { GPUSettingsStandalone configStandalone; #include "utils/qconfig_print.inc" +#include "utils/qconfig_check.inc" } // namespace void GPUConfigDump::dumpConfig(const GPUSettingsRec* rec, const GPUSettingsProcessing* proc, const GPUSettingsQA* qa, const GPUSettingsDisplay* display, const GPUSettingsDeviceBackend* device, const GPURecoStepConfiguration* workflow) @@ -55,3 +62,8 @@ void GPUConfigDump::dumpConfig(const GPUSettingsRec* rec, const GPUSettingsProce printf("\n\tReconstruction steps / inputs / outputs:\n\tReco Steps = 0x%08x\n\tReco Steps GPU = 0x%08x\n\tInputs = 0x%08x\n\tOutputs = 0x%08x\n", (uint32_t)workflow->steps, (uint32_t)workflow->stepsGPUMask, (uint32_t)workflow->inputs, (uint32_t)workflow->outputs); } } + +int32_t GPUConfigDump::checkConfig(const GPUSettingsProcessing& proc, const GPUSettingsDeviceBackend& device) +{ + return qConfigCheck(device, proc, proc.rtc, proc.rtctech, proc.param, proc.nn, proc.scaling, proc.debug, proc.backend); +} diff --git a/GPU/GPUTracking/DataTypes/GPUConfigDump.h b/GPU/GPUTracking/DataTypes/GPUConfigDump.h index b0c0a6d73a109..5a9daea544d8b 100644 --- a/GPU/GPUTracking/DataTypes/GPUConfigDump.h +++ b/GPU/GPUTracking/DataTypes/GPUConfigDump.h @@ -30,6 +30,7 @@ class GPUConfigDump { public: static void dumpConfig(const GPUSettingsRec* rec, const GPUSettingsProcessing* proc, const GPUSettingsQA* qa, const GPUSettingsDisplay* display, const GPUSettingsDeviceBackend* device, const GPURecoStepConfiguration* workflow); + static int32_t checkConfig(const GPUSettingsProcessing& proc, const GPUSettingsDeviceBackend& device); // Evaluate the qcheck settings, returns the number of failed checks }; } // namespace o2::gpu diff --git a/GPU/GPUTracking/Definitions/GPUSettingsList.template b/GPU/GPUTracking/Definitions/GPUSettingsList.template index 9c744433877fb..94b25b32cf734 100644 --- a/GPU/GPUTracking/Definitions/GPUSettingsList.template +++ b/GPU/GPUTracking/Definitions/GPUSettingsList.template @@ -357,6 +357,15 @@ AddOption(mergerDumpTrackNCl, bool, false, "", 0, "Dump file with nCl per merged AddHelp("help", 0) EndConfig() +// Backend Settings +BeginSubConfig(GPUSettingsProcessingBackend, backend, configStandalone.proc, "BACKEND", 0, "Backend Settings", proc_backend) +AddOption(platformNum, int32_t, -1, "", 0, "Platform to use, in case the backend provides multiple platforms (OpenCL only, -1 = auto-select, -2 query all platforms (also incompatible))", qcheck(get().deviceType == gpudatatypes::DeviceType::OCL)) +AddOption(compileFromSources, bool, false, "", 0, "Compile OpenCL binary from included source code instead of using included spirv code (OpenCL only)", qcheck(get().deviceType == gpudatatypes::DeviceType::OCL)) +AddOption(overrideSourceBuildFlags, std::string, "", "", 0, "Override Backend build flags for compilation from source, put a space for empty options (OpenCL and Metal only)", qcheck(get().deviceType == gpudatatypes::DeviceType::OCL || get().deviceType == gpudatatypes::DeviceType::METAL)) +AddOption(overrideEUSperCU, int32_t, -1, "", 0, "Override AMD_EUS_PER_CU setting (HIP only)", qcheck(get().deviceType == gpudatatypes::DeviceType::HIP)) +AddHelp("help", 0) +EndConfig() + // Settings steering the processing once the device was selected, only available on the host BeginSubConfig(GPUSettingsProcessing, proc, configStandalone, "PROC", 0, "Processing settings", proc) AddOption(deviceNum, int32_t, -1, "gpuDevice", 0, "Set GPU device to use (-1: automatic, -2: for round-robin usage in timeslice-pipeline)") @@ -432,11 +441,6 @@ AddOption(tpcApplyCFCutsAtDecoding, bool, false, "", 0, "Apply cluster cuts from AddOption(tpcApplyClusterFilterOnCPU, uint8_t, 0, "", 0, "Apply custom cluster filter of GPUTPCClusterFilter class, 0: off, 1: debug, 2: PbPb23") AddOption(tpcWriteClustersAfterRejection, bool, false, "", 0, "Apply TPC rejection strategy before writing clusters") AddOption(tpcSortClusters, bool, false, "", 0, "Enforce sorting TPC clusters") -AddOption(oclPlatformNum, int32_t, -1, "", 0, "Platform to use, in case the backend provides multiple platforms (OpenCL only, -1 = auto-select, -2 query all platforms (also incompatible))") // TODO: Create some backend-specific options -AddOption(oclCompileFromSources, bool, false, "", 0, "Compile OpenCL binary from included source code instead of using included spirv code") -AddOption(oclOverrideSourceBuildFlags, std::string, "", "", 0, "Override OCL build flags for compilation from source, put a space for empty options") -AddOption(metalOverrideSourceBuildFlags, std::string, "", "", 0, "Override Metal build flags for compilation from source, put a space for empty options") -AddOption(hipOverrideAMDEUSperCU, int32_t, -1, "", 0, "Override AMD_EUS_PER_CU setting") AddOption(printSettings, bool, false, "", 0, "Print all settings when initializing") AddOption(tpcFreeAllocatedMemoryAfterProcessing, bool, false, "", 0, "Clean all memory allocated by TPC when TPC processing done, only data written to external output resources will remain") AddOption(debugOnFailure, int32_t, 0, "", 0, "Dump raw data in case an error occured, bit 1 enables all dumps, otherwise bitmask for: 2 = signal, 3 = GPUErrorCode", def(1)) @@ -458,6 +462,7 @@ AddSubConfig(GPUSettingsProcessingParam, param) AddSubConfig(GPUSettingsProcessingNNclusterizer, nn) AddSubConfig(GPUSettingsProcessingScaling, scaling) AddSubConfig(GPUSettingsProcessingDebug, debug) +AddSubConfig(GPUSettingsProcessingBackend, backend) AddHelp("help", 0) EndConfig() #endif // !__OPENCL__ && !__METAL__ diff --git a/GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx b/GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx index 3d57a1470636a..9f57b08e5263e 100644 --- a/GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx +++ b/GPU/GPUTracking/Merger/GPUTPCGMMerger.cxx @@ -190,7 +190,7 @@ int64_t GPUTPCGMMerger::GetTrackLabelA(const S& trk) const int32_t nClusters = 0; if constexpr (std::is_same_v) { sectorTrack = &mSectorTrackInfos[trk.TrackID()]; - nClusters = sectorTrack->OrigTrack()->NHits(); + nClusters = sectorTrack->OrigTrack(this)->NHits(); } else { nClusters = trk.NClusters(); } @@ -199,7 +199,7 @@ int64_t GPUTPCGMMerger::GetTrackLabelA(const S& trk) const int32_t id; if constexpr (std::is_same_v) { const GPUTPCTracker& tracker = GetConstantMem()->tpcTrackers[sectorTrack->Sector()]; - const GPUTPCHitId& ic = tracker.TrackHits()[sectorTrack->OrigTrack()->FirstHitID() + i]; + const GPUTPCHitId& ic = tracker.TrackHits()[sectorTrack->OrigTrack(this)->FirstHitID() + i]; id = tracker.Data().ClusterDataIndex(tracker.Data().Row(ic.RowIndex()), ic.HitIndex()) + GetConstantMem()->ioPtrs.clustersNative->clusterOffset[sectorTrack->Sector()][0]; } else { id = mClusters[trk.FirstClusterRef() + i].num; @@ -667,7 +667,7 @@ GPUd() int32_t GPUTPCGMMerger::RefitSectorTrack(GPUTPCGMSectorTrack& sectorTrack if (way) { sectorTrack.SetParam2(trk); } else { - sectorTrack.Set(trk, inTrack, alpha, sector); + sectorTrack.Set(this, trk, inTrack, alpha, sector); } } return 0; @@ -802,7 +802,7 @@ GPUd() void GPUTPCGMMerger::MergeSectorsPrepareStep2(int32_t nBlocks, int32_t nT const GPUTPCGMSectorTrack* trackMin = track; while (track->NextSegmentNeighbour() >= 0 && track->Sector() == mSectorTrackInfos[track->NextSegmentNeighbour()].Sector()) { track = &mSectorTrackInfos[track->NextSegmentNeighbour()]; - if (track->OrigTrack()->Param().X() < trackMin->OrigTrack()->Param().X()) { + if (track->OrigTrack(this)->Param().X() < trackMin->OrigTrack(this)->Param().X()) { trackMin = track; } } @@ -811,7 +811,7 @@ GPUd() void GPUTPCGMMerger::MergeSectorsPrepareStep2(int32_t nBlocks, int32_t nT if (trackTmp.X2() != 0.f) { trackTmp.UseParam2(); } else { - trackTmp.Set(this, trackMin->OrigTrack(), trackMin->Alpha(), trackMin->Sector()); + trackTmp.Set(this, trackMin->OrigTrack(this), trackMin->Alpha(), trackMin->Sector()); } } else { if (CAMath::Abs(track->QPt()) * Param().qptB5Scaler < Param().rec.tpc.mergerLooperSecondHorizontalQPtB5Limit) { @@ -1630,9 +1630,9 @@ GPUd() void GPUTPCGMMerger::CollectMergedTracks(int32_t nBlocks, int32_t nThread const GPUTPCGMSectorTrack* trchk = &mSectorTrackInfos[ichk]; const GPUTPCGMSectorTrack* longest = trchk; while (true) { - if (trchk->OrigTrack()->NHits() > length) { + if (trchk->OrigTrack(this)->NHits() > length) { longest = trchk; - length = trchk->OrigTrack()->NHits(); + length = trchk->OrigTrack(this)->NHits(); } int32_t next = trchk->NextSegmentNeighbour(); if (next < 0 || (Param().rec.enableCyclicGraphWorkarounds && next == ichk)) { @@ -1717,7 +1717,7 @@ GPUd() void GPUTPCGMMerger::CollectMergedTracks(int32_t nBlocks, int32_t nThread trackCluster* c2 = trackClusters + nHits + nTrackHits - 1; for (int32_t i = 0; i < nTrackHits; i++, c2--) { const GPUTPCTracker& trk = GetConstantMem()->tpcTrackers[t->Sector()]; - const GPUTPCHitId& ic = trk.TrackHits()[t->OrigTrack()->FirstHitID() + i]; + const GPUTPCHitId& ic = trk.TrackHits()[t->OrigTrack(this)->FirstHitID() + i]; uint32_t id = trk.Data().ClusterDataIndex(trk.Data().Row(ic.RowIndex()), ic.HitIndex()) + GetConstantMem()->ioPtrs.clustersNative->clusterOffset[t->Sector()][0]; *c2 = trackCluster{id, (uint8_t)ic.RowIndex(), t->Sector()}; } diff --git a/GPU/GPUTracking/Merger/GPUTPCGMMergerDump.cxx b/GPU/GPUTracking/Merger/GPUTPCGMMergerDump.cxx index ac25a25426a01..496d70b745bb3 100644 --- a/GPU/GPUTracking/Merger/GPUTPCGMMergerDump.cxx +++ b/GPU/GPUTracking/Merger/GPUTPCGMMergerDump.cxx @@ -311,7 +311,7 @@ inline void GPUTPCGMMerger::MergedTrackStreamerInternal(const GPUTPCGMBorderTrac } const GPUTPCTracker& tracker1 = GetConstantMem()->tpcTrackers[sector1]; const GPUTPCGMSectorTrack& sectorTrack1 = mSectorTrackInfos[b1.TrackID()]; - const GPUTPCTrack& inTrack1 = *sectorTrack1.OrigTrack(); + const GPUTPCTrack& inTrack1 = *sectorTrack1.OrigTrack(this); for (int32_t i = 0; i < inTrack1.NHits(); i++) { const GPUTPCHitId& ic1 = tracker1.TrackHits()[inTrack1.FirstHitID() + i]; int32_t clusterIndex = tracker1.Data().ClusterDataIndex(tracker1.Data().Row(ic1.RowIndex()), ic1.HitIndex()); @@ -319,7 +319,7 @@ inline void GPUTPCGMMerger::MergedTrackStreamerInternal(const GPUTPCGMBorderTrac } const GPUTPCTracker& tracker2 = GetConstantMem()->tpcTrackers[sector2]; const GPUTPCGMSectorTrack& sectorTrack2 = mSectorTrackInfos[b2.TrackID()]; - const GPUTPCTrack& inTrack2 = *sectorTrack2.OrigTrack(); + const GPUTPCTrack& inTrack2 = *sectorTrack2.OrigTrack(this); for (int32_t i = 0; i < inTrack2.NHits(); i++) { const GPUTPCHitId& ic2 = tracker2.TrackHits()[inTrack2.FirstHitID() + i]; int32_t clusterIndex = tracker2.Data().ClusterDataIndex(tracker2.Data().Row(ic2.RowIndex()), ic2.HitIndex()); diff --git a/GPU/GPUTracking/Merger/GPUTPCGMSectorTrack.cxx b/GPU/GPUTracking/Merger/GPUTPCGMSectorTrack.cxx index 8a9669a28143b..e488666288c84 100644 --- a/GPU/GPUTracking/Merger/GPUTPCGMSectorTrack.cxx +++ b/GPU/GPUTracking/Merger/GPUTPCGMSectorTrack.cxx @@ -26,7 +26,7 @@ using namespace o2::tpc; GPUd() void GPUTPCGMSectorTrack::Set(const GPUTPCGMMerger* merger, const GPUTPCTrack* sectorTr, float alpha, int32_t sector) { const GPUTPCBaseTrackParam& t = sectorTr->Param(); - mOrigTrack = sectorTr; + mOrigTrackId = sectorTr - merger->GetConstantMem()->tpcTrackers[sector].Tracks(); mParam.mX = t.GetX(); mParam.mY = t.GetY(); mParam.mZ = t.GetZ(); @@ -41,9 +41,9 @@ GPUd() void GPUTPCGMSectorTrack::Set(const GPUTPCGMMerger* merger, const GPUTPCT mNClusters = sectorTr->NHits(); } -GPUd() void GPUTPCGMSectorTrack::Set(const GPUTPCGMTrackParam& trk, const GPUTPCTrack* sectorTr, float alpha, int32_t sector) +GPUd() void GPUTPCGMSectorTrack::Set(const GPUTPCGMMerger* merger, const GPUTPCGMTrackParam& trk, const GPUTPCTrack* sectorTr, float alpha, int32_t sector) { - mOrigTrack = sectorTr; + mOrigTrackId = sectorTr - merger->GetConstantMem()->tpcTrackers[sector].Tracks(); mParam.mX = trk.GetX(); mParam.mY = trk.GetY(); mParam.mZ = trk.GetZ(); @@ -91,11 +91,11 @@ GPUd() void GPUTPCGMSectorTrack::SetParam2(const GPUTPCGMTrackParam& trk) GPUd() bool GPUTPCGMSectorTrack::FilterErrors(const GPUTPCGMMerger* merger, int32_t iSector, float maxSinPhi, float sinPhiMargin) { float lastX; - // float lastX = GPUTPCGeometry::Row2X(mOrigTrack->Cluster(mOrigTrack->NClusters() - 1).GetRow()); // TODO: Why is this needed to be set below, Row2X should work, but looses some tracks + // float lastX = GPUTPCGeometry::Row2X(OrigTrack(merger)->Cluster(OrigTrack(merger)->NClusters() - 1).GetRow()); // TODO: Why is this needed to be set below, Row2X should work, but looses some tracks float y, z; int32_t row, index; const GPUTPCTracker& trk = merger->GetConstantMem()->tpcTrackers[iSector]; - const GPUTPCHitId& ic = trk.TrackHits()[mOrigTrack->FirstHitID() + mOrigTrack->NHits() - 1]; + const GPUTPCHitId& ic = trk.TrackHits()[OrigTrack(merger)->FirstHitID() + OrigTrack(merger)->NHits() - 1]; index = trk.Data().ClusterDataIndex(trk.Data().Row(ic.RowIndex()), ic.HitIndex()) + merger->GetConstantMem()->ioPtrs.clustersNative->clusterOffset[iSector][0]; row = ic.RowIndex(); const ClusterNative& cl = merger->GetConstantMem()->ioPtrs.clustersNative->clustersLinear[index]; @@ -493,9 +493,9 @@ GPUd() bool GPUTPCGMSectorTrack::TransportToXAlpha(GPUTPCGMMerger* merger, float return 1; } -GPUd() void GPUTPCGMSectorTrack::CopyBaseTrackCov() +GPUd() void GPUTPCGMSectorTrack::CopyBaseTrackCov(const GPUTPCGMMerger* merger) { - const float* GPUrestrict() cov = mOrigTrack->Param().mC; + const float* GPUrestrict() cov = OrigTrack(merger)->Param().mC; mParam.mC0 = cov[0]; mParam.mC2 = cov[2]; mParam.mC3 = cov[3]; diff --git a/GPU/GPUTracking/Merger/GPUTPCGMSectorTrack.h b/GPU/GPUTracking/Merger/GPUTPCGMSectorTrack.h index 2c340bf9ad49b..c0f807e635fa4 100644 --- a/GPU/GPUTracking/Merger/GPUTPCGMSectorTrack.h +++ b/GPU/GPUTracking/Merger/GPUTPCGMSectorTrack.h @@ -45,7 +45,12 @@ class GPUTPCGMSectorTrack { return (i < 2) ? mSegmentNeighbour[i] : mNeighbour[i - 2]; } - GPUd() const GPUTPCTrack* OrigTrack() const { return mOrigTrack; } + GPUd() int32_t OrigTrackId() const { return mOrigTrackId; } + template + GPUdi() const GPUTPCTrack* OrigTrack(const T* merger) const // T = GPUTPCGMMerger, template since it is incomplete here + { + return &merger->GetConstantMem()->tpcTrackers[mSector].Tracks()[mOrigTrackId]; + } GPUd() float X() const { return mParam.mX; } GPUd() float Y() const { return mParam.mY; } GPUd() float Z() const { return mParam.mZ; } @@ -73,7 +78,7 @@ class GPUTPCGMSectorTrack mClusterT[1] = v2; } - GPUd() void Set(const GPUTPCGMTrackParam& trk, const GPUTPCTrack* sectorTr, float alpha, int32_t sector); + GPUd() void Set(const GPUTPCGMMerger* merger, const GPUTPCGMTrackParam& trk, const GPUTPCTrack* sectorTr, float alpha, int32_t sector); GPUd() void SetParam2(const GPUTPCGMTrackParam& trk); GPUd() void Set(const GPUTPCGMMerger* merger, const GPUTPCTrack* sectorTr, float alpha, int32_t sector); GPUd() void UseParam2() { mParam = mParam2; } // TODO: Clean this up! @@ -117,24 +122,24 @@ class GPUTPCGMSectorTrack template GPUd() bool TransportToX(GPUTPCGMMerger* merger, float x, float Bz, GPUTPCGMBorderTrack& b, float maxSinPhi, bool doCov = true) const; GPUd() bool TransportToXAlpha(GPUTPCGMMerger* merger, float x, float sinAlpha, float cosAlpha, float Bz, GPUTPCGMBorderTrack& b, float maxSinPhi) const; - GPUd() void CopyBaseTrackCov(); + GPUd() void CopyBaseTrackCov(const GPUTPCGMMerger* merger); struct sectorTrackParam { float mX, mY, mZ, mSinPhi, mDzDs, mQPt, mCosPhi, mSecPhi; // parameters float mC0, mC2, mC3, mC5, mC7, mC9, mC10, mC12, mC14; // covariances }; private: - const GPUTPCTrack* mOrigTrack; // pointer to original sector track + int32_t mOrigTrackId; // index of the original sector track in the tracker of mSector sectorTrackParam mParam; // Track parameters sectorTrackParam mParam2; // Parameters at other side float mTOffset; // Z offset with early transform, T offset otherwise float mAlpha; // alpha angle float mClusterT[2]; // Minimum maximum cluster T - int32_t mNClusters; // N clusters int32_t mNeighbour[2]; // int32_t mSegmentNeighbour[2]; // int32_t mLocalTrackId; // Corrected local track id in terms of GMSectorTracks array for extrapolated tracks, UNDEFINED for local tracks! int32_t mExtrapolatedTrackIds[2]; // IDs of associated extrapolated tracks + int16_t mNClusters; // N clusters uint8_t mSector; // sector of this track segment ClassDefNV(GPUTPCGMSectorTrack, 1); diff --git a/GPU/GPUTracking/Merger/GPUTPCGMTrackParam.cxx b/GPU/GPUTracking/Merger/GPUTPCGMTrackParam.cxx index 028293eaa1f29..e42750e3c4712 100644 --- a/GPU/GPUTracking/Merger/GPUTPCGMTrackParam.cxx +++ b/GPU/GPUTracking/Merger/GPUTPCGMTrackParam.cxx @@ -411,9 +411,9 @@ GPUd() bool GPUTPCGMTrackParam::Fit(GPUTPCGMMerger& GPUrestrict() merger, GPUTPC revert = true; break; } - const float time = merger.GetConstantMem()->ioPtrs.clustersNative ? cl.getTime() : -1.f; // TODO: When is it possible that we do not have clusterNative? - const float invSqrtCharge = merger.GetConstantMem()->ioPtrs.clustersNative ? CAMath::InvSqrt(cl.qMax) : 0.f; - const float invCharge = merger.GetConstantMem()->ioPtrs.clustersNative ? (1.f / cl.qMax) : 0.f; + const float time = cl.getTime(); + const float invSqrtCharge = CAMath::InvSqrt(cl.qMax); + const float invCharge = 1.f / cl.qMax; float invAvgCharge = (sumInvSqrtCharge += invSqrtCharge) / ++nAvgCharge; invAvgCharge *= invAvgCharge; const uint8_t clusterState = cl.getFlags(); @@ -607,9 +607,10 @@ GPUdii() int32_t GPUTPCGMTrackParam::FitHit(GPUTPCGMMerger& GPUrestrict() merger } } else { float err2Y, err2Z; - const float time = merger.GetConstantMem()->ioPtrs.clustersNative ? merger.GetConstantMem()->ioPtrs.clustersNative->clustersLinear[cluster.num].getTime() : -1.f; - const float invSqrtCharge = merger.GetConstantMem()->ioPtrs.clustersNative ? CAMath::InvSqrt(merger.GetConstantMem()->ioPtrs.clustersNative->clustersLinear[cluster.num].qMax) : 0.f; - const float invCharge = merger.GetConstantMem()->ioPtrs.clustersNative ? (1.f / merger.GetConstantMem()->ioPtrs.clustersNative->clustersLinear[cluster.num].qMax) : 0.f; + const ClusterNative& GPUrestrict() cl = merger.GetConstantMem()->ioPtrs.clustersNative->clustersLinear[cluster.num]; + const float time = cl.getTime(); + const float invSqrtCharge = CAMath::InvSqrt(cl.qMax); + const float invCharge = 1.f / cl.qMax; float invAvgCharge = (sumInvSqrtCharge += invSqrtCharge) / ++nAvgCharge; invAvgCharge *= invAvgCharge; @@ -877,7 +878,7 @@ GPUdii() float GPUTPCGMTrackParam::FindBestInterpolatedHit(GPUTPCGMMerger& GPUre if (insert < param.rec.tpc.rebuildTrackInFitClusterCandidates) { for (int32_t c = CAMath::Min(nCandidates, param.rec.tpc.rebuildTrackInFitClusterCandidates - 1); c > insert; c--) { merger.ClusterCandidates(iTrk, row, tmpRows)[c] = merger.ClusterCandidates(iTrk, row, tmpRows)[c - 1]; - } // TODO: Downweight non-interpolated candidates + } merger.ClusterCandidates(iTrk, row, tmpRows)[insert].set(merger.CandidateId(idOffset + ids[ih], sector, row), sector, (CAMath::half_t)err); nCandidates += (nCandidates < param.rec.tpc.rebuildTrackInFitClusterCandidates); } @@ -887,7 +888,7 @@ GPUdii() float GPUTPCGMTrackParam::FindBestInterpolatedHit(GPUTPCGMMerger& GPUre } CADEBUG(const auto* dbgCand = merger.ClusterCandidates(iTrk, row, tmpRows); for (int dbgi = 0; dbgi < nCandidates; dbgi++) { if (dbgCand[dbgi].hasCluster()) printf("\t\t\tiTrk %d Row %d Candidate %d hit %d err %f\n", iTrk, (int)row, dbgi, merger.CandidateClusterId(dbgCand[dbgi], row), dbgCand[dbgi].error); else break; }); } - if (nCandidates == 0 && !interOnly) { // TODO: remove the interOnly here when rebuilding is fully working + if (nCandidates == 0 && !interOnly) { merger.ClusterCandidates(iTrk, row, tmpRows)[0].setNoCandidate(); } } else if (doAttach && (!interOnly || inter.isValid())) { diff --git a/GPU/GPUTracking/Merger/GPUTPCGlobalDebugSortKernels.cxx b/GPU/GPUTracking/Merger/GPUTPCGlobalDebugSortKernels.cxx index 83781998e2806..9a8367fefe40e 100644 --- a/GPU/GPUTracking/Merger/GPUTPCGlobalDebugSortKernels.cxx +++ b/GPU/GPUTracking/Merger/GPUTPCGlobalDebugSortKernels.cxx @@ -52,7 +52,7 @@ GPUdii() void GPUTPCGlobalDebugSortKernels::ThreadLocalTrackId()] = j; + merger.TrackIDs()[tracks[j].Sector() * merger.NMaxSingleSectorTracks() + tracks[j].OrigTrack(&merger)->LocalTrackId()] = j; } } diff --git a/GPU/GPUTracking/SectorTracker/GPUTPCTrack.h b/GPU/GPUTracking/SectorTracker/GPUTPCTrack.h index d67903f00acfa..1243595579b8c 100644 --- a/GPU/GPUTracking/SectorTracker/GPUTPCTrack.h +++ b/GPU/GPUTracking/SectorTracker/GPUTPCTrack.h @@ -50,7 +50,7 @@ class GPUTPCTrack private: int32_t mFirstHitID; // index of the first track cell in the track->cell pointer array - int32_t mNHits; // number of track cells + int16_t mNHits; // number of track cells int32_t mLocalTrackId; // Id of local track this extrapolated track belongs to, index of this track itself if it is a local track GPUTPCBaseTrackParam mParam; // track parameters diff --git a/GPU/GPUTracking/SectorTracker/GPUTPCTracklet.h b/GPU/GPUTracking/SectorTracker/GPUTPCTracklet.h index d614b98ecb81f..6981ce3d888ff 100644 --- a/GPU/GPUTracking/SectorTracker/GPUTPCTracklet.h +++ b/GPU/GPUTracking/SectorTracker/GPUTPCTracklet.h @@ -46,8 +46,8 @@ class GPUTPCTracklet GPUhd() void SetHitWeight(const int32_t w) { mHitWeight = w; } private: - uint32_t mFirstRow; // first TPC row // TODO: We can use smaller data format here! - uint32_t mLastRow; // last TPC row + uint8_t mFirstRow; // first TPC row + uint8_t mLastRow; // last TPC row GPUTPCBaseTrackParam mParam; // tracklet parameters int32_t mHitWeight; // Hit Weight of Tracklet uint32_t mFirstHit; // first hit in row hit array diff --git a/GPU/GPUTracking/Standalone/Benchmark/standalone.cxx b/GPU/GPUTracking/Standalone/Benchmark/standalone.cxx index 94939dab2a2f1..e22704c37d4b9 100644 --- a/GPU/GPUTracking/Standalone/Benchmark/standalone.cxx +++ b/GPU/GPUTracking/Standalone/Benchmark/standalone.cxx @@ -312,8 +312,8 @@ int32_t ReadConfiguration(int argc, char** argv) configStandalone.gpuType = "HIP"; } else if (GPUReconstruction::CheckInstanceAvailable(GPUReconstruction::DeviceType::OCL, configStandalone.proc.debugLevel >= 2)) { configStandalone.gpuType = "OCL"; - } else if (GPUReconstruction::CheckInstanceAvailable(GPUReconstruction::DeviceType::OCL, configStandalone.proc.debugLevel >= 2)) { - configStandalone.gpuType = "OCL"; + } else if (GPUReconstruction::CheckInstanceAvailable(GPUReconstruction::DeviceType::METAL, configStandalone.proc.debugLevel >= 2)) { + configStandalone.gpuType = "METAL"; } else { if (configStandalone.runGPU > 1 && configStandalone.runGPUforce) { printf("No GPU backend / device found, running on CPU is disabled due to runGPUforce\n"); diff --git a/GPU/GPUTracking/TPCClusterFinder/GPUTPCCFNoiseSuppression.cxx b/GPU/GPUTracking/TPCClusterFinder/GPUTPCCFNoiseSuppression.cxx index cbe13c33ccaba..a0b55f007be3d 100644 --- a/GPU/GPUTracking/TPCClusterFinder/GPUTPCCFNoiseSuppression.cxx +++ b/GPU/GPUTracking/TPCClusterFinder/GPUTPCCFNoiseSuppression.cxx @@ -107,7 +107,7 @@ GPUdi() void GPUTPCCFNoiseSuppression::checkForMinima( { float r = other.unpack(); - uint64_t isMinima = (q - r > epsilon) && (float)CAMath::Abs(q - r) / (float)CAMath::Max(q, r) > epsilonRelative; // TODO: Can we assume q > r and get rid of Max/Abs? + uint64_t isMinima = (q - r > epsilon) && (q - r) / q > epsilonRelative; *minimas |= (isMinima << pos); uint64_t lq = (r > q); diff --git a/GPU/GPUTracking/cmake/kernel_helpers.cmake b/GPU/GPUTracking/cmake/kernel_helpers.cmake index 459165d86cf5d..f19f92a45c922 100644 --- a/GPU/GPUTracking/cmake/kernel_helpers.cmake +++ b/GPU/GPUTracking/cmake/kernel_helpers.cmake @@ -23,6 +23,9 @@ define_property(TARGET PROPERTY O2_GPU_KERNEL_STRING_PARAMS) define_property(TARGET PROPERTY O2_GPU_KERNELS_FORCE_1_WARP) set(O2_GPU_KERNEL_WRAPPER_FOLDER "${CMAKE_CURRENT_BINARY_DIR}/GPU/include_gpu_onthefly") file(MAKE_DIRECTORY ${O2_GPU_KERNEL_WRAPPER_FOLDER}) +file(TOUCH ${O2_GPU_KERNEL_WRAPPER_FOLDER}/.cmake_stamp) +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${O2_GPU_KERNEL_WRAPPER_FOLDER}) # Kernel wrappers are generated at configure time, remove them with "make / ninja clean" +set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${O2_GPU_KERNEL_WRAPPER_FOLDER}/.cmake_stamp) # and rerun CMake afterwards to regenerate them, since the stamp is gone set(O2_GPU_BASE_DIR "${CMAKE_CURRENT_LIST_DIR}/../") function(o2_gpu_add_kernel kernel_name kernel_files) list(LENGTH ARGV n) diff --git a/GPU/GPUTracking/display/CMakeLists.txt b/GPU/GPUTracking/display/CMakeLists.txt index 682dfbe60c61c..4d4b743b9783f 100644 --- a/GPU/GPUTracking/display/CMakeLists.txt +++ b/GPU/GPUTracking/display/CMakeLists.txt @@ -226,6 +226,7 @@ install(FILES ${HDRS} ${HDRS_INSTALL} DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/GP install(DIRECTORY filterMacros/ DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/GPU/displayTrackFilter FILES_MATCHING PATTERN "*.C") get_property(GPU_DISPLAY_INCLUDE_PATH DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) configure_file(filterMacros/setinclude.sh.in setinclude.sh @ONLY) +set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/setinclude.sh) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/setinclude.sh PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/GPU/displayTrackFilter) target_compile_definitions(${targetName} PRIVATE $) diff --git a/GPU/GPUTracking/display/shaders.cmake b/GPU/GPUTracking/display/shaders.cmake index 2c232672115ef..89dcd86182155 100644 --- a/GPU/GPUTracking/display/shaders.cmake +++ b/GPU/GPUTracking/display/shaders.cmake @@ -64,5 +64,6 @@ function(write_glslc_shader_header TARGET HEADER) endif() string(APPEND content "#else\n#error GPUCA_DISPLAY_SHADER_TYPE_[VULKAN|OPENGL] undefined, or shaders not compiled for this type\n#endif\n") file(CONFIGURE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${HEADER} CONTENT "${content}" @ONLY) # Only rewritten if changed + set_property(DIRECTORY APPEND PROPERTY ADDITIONAL_CLEAN_FILES ${CMAKE_CURRENT_BINARY_DIR}/${HEADER}) target_include_directories(${TARGET} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) endfunction(write_glslc_shader_header) diff --git a/GPU/GPUTracking/utils/qconfig_check.inc b/GPU/GPUTracking/utils/qconfig_check.inc new file mode 100644 index 0000000000000..e8c9e38fdcdf8 --- /dev/null +++ b/GPU/GPUTracking/utils/qconfig_check.inc @@ -0,0 +1,93 @@ +// Copyright 2019-2026 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file qconfig_check.inc +/// \author David Rohr + +// Provides static inline qConfigCheck(objs...) in the namespace it is included in: evaluates the qcheck(...) settings of all options of the passed config objects, returns the number of failed checks. +// Requires , , , , , , "qconfig_helpers.h", "qconfig_internal_helpers.h" to be included before (outside of the namespace), and the config structs to be visible unqualified. +// Options with the default value are not checked. Each type may be passed only once, sub configs are not included automatically and must be passed explicitly. Objects of other types can be passed to be used in the checks via get(). + +#ifndef QCONFIG_CHECK_INC +#define QCONFIG_CHECK_INC + +template +static inline bool qConfigCheckIsDefault(const T& val, const T& def) +{ + if constexpr (std::is_array_v) { + return std::equal(std::begin(val), std::end(val), std::begin(def)); + } else { + return val == def; + } +} + +template +static inline int32_t qConfigCheckOption([[maybe_unused]] const char* configStruct, [[maybe_unused]] const char* name, [[maybe_unused]] const T& val, [[maybe_unused]] const T& def, const char* /*help*/, const Args&... args) // Evaluate the qcheck_result settings of one option, if its value differs from the default +{ + int32_t retVal = 0; + if constexpr (sizeof...(Args) > 0) { + if (qConfigCheckIsDefault(val, def)) { + return 0; + } + } + ( + [&](const auto& arg) { + if constexpr (std::is_same_v, ::qConfig::qcheck_result>) { + if (!arg.ok) { + std::string value = ""; + if constexpr (std::is_arithmetic_v || std::is_enum_v || std::is_same_v) { + value = " = " + ::qConfig::print_type(val); + } + printf("Invalid setting %s.%s%s, check failed: %s\n", configStruct, name, value.c_str(), arg.expression); + retVal++; + } + } + }(args), + ...); + return retVal; +} + +template +class qConfigChecker +{ + public: + qConfigChecker(const Args&... objs) : mObjs{objs...} {} + int32_t check() const + { + using namespace ::qConfig; // For the settings helpers (min, max, ...) used in the settings lists + int32_t retVal = 0; +#define QCONFIG_CHECK +#include "qconfig_internal.h" +#undef QCONFIG_CHECK + return retVal; + } + + private: + template + const T& get() const + { + static_assert((std::is_same_v || ...), "qcheck uses get() with a type not passed to qConfigCheck"); + return std::get(mObjs); + } + std::tuple mObjs; +}; + +template +constexpr int32_t qConfigCheckTypeCount = (std::is_same_v + ... + 0); + +template +static inline int32_t qConfigCheck(const Args&... objs) +{ + static_assert(((qConfigCheckTypeCount == 1) && ...), "qConfigCheck: each type may be passed only once"); + return qConfigChecker(objs...).check(); +} + +#endif // QCONFIG_CHECK_INC diff --git a/GPU/GPUTracking/utils/qconfig_internal.h b/GPU/GPUTracking/utils/qconfig_internal.h index dbdb5180f28e5..5437382813ec2 100644 --- a/GPU/GPUTracking/utils/qconfig_internal.h +++ b/GPU/GPUTracking/utils/qconfig_internal.h @@ -18,6 +18,14 @@ #include "qconfig_general.h" #include "qconfig_helpers.h" +#ifdef QCONFIG_CHECK // qcheck(expression) as additional setting of an option: expression is evaluated by qConfigCheck if the option has not the default value (qconfig_check.inc), can use val (value of the option) and get() (object of type T passed to qConfigCheck) +#define qcheck(...) \ + ::qConfig::qcheck_result { static_cast(__VA_ARGS__), #__VA_ARGS__ } +#else +#define qcheck(...) \ + ::qConfig::qcheck_ignore {} +#endif + #ifdef QCONFIG_PARSE // Included in the constructor of qConfigOptionRegistry: registers the names and the handler of each option #define AddOption(name, type, default, optname, optnameshort, ...) \ @@ -271,6 +279,25 @@ void qConfigPrint(const T& qconfig_tmp_object, const std::string& blockName); // } // End QCONFIG_GEN_RTTI +#elif defined(QCONFIG_CHECK) // Included in qConfigChecker::check(), blocks of config structs not passed to qConfigCheck are discarded +#define AddOption(name, type, default, optname, optnameshort, ...) \ + { \ + [[maybe_unused]] const auto& val = qConfigObj.name; \ + retVal += qConfigCheckOption(qConfigStruct, qon_mxstr(name), val, qConfigDefault.name, __VA_ARGS__); \ + } +#define AddOptionVec(name, type, optname, optnameshort, ...) AddOption(name, type, , optname, optnameshort, __VA_ARGS__) +#define AddOptionArray(name, type, count, default, optname, optnameshort, ...) AddOption(name, type, , optname, optnameshort, __VA_ARGS__) +#define AddOptionSet(...) +#define AddSubConfig(name, instance) +#define BeginConfig(name, instance) \ + if constexpr ((std::is_same_v || ...)) { \ + [[maybe_unused]] const name& qConfigObj = get(); \ + [[maybe_unused]] const name qConfigDefault{}; \ + [[maybe_unused]] constexpr const char* qConfigStruct = qon_mxstr(name); +#define BeginSubConfig(name, instance, parent, preoptname, preoptnameshort, descr, ...) BeginConfig(name, instance) +#define EndConfig() } + +// End QCONFIG_CHECK #else // Define structures #error Internal error, qconfig_internal called with action type @@ -280,3 +307,4 @@ void qConfigPrint(const T& qconfig_tmp_object, const std::string& blockName); // #define QCONFIG_INTERNAL #include "qconfig_wrapinclude.h" #undef QCONFIG_INTERNAL +#undef qcheck diff --git a/GPU/GPUTracking/utils/qconfig_internal_helpers.h b/GPU/GPUTracking/utils/qconfig_internal_helpers.h index 0eb16d22d60f0..527653b1eef27 100644 --- a/GPU/GPUTracking/utils/qconfig_internal_helpers.h +++ b/GPU/GPUTracking/utils/qconfig_internal_helpers.h @@ -46,6 +46,13 @@ QCONFIG_SETTING_TEMPLATE(max) QCONFIG_SETTING_TEMPLATE(set) QCONFIG_SETTING_TEMPLATE(def) +struct qcheck_ignore { +}; +struct qcheck_result { + bool ok; + const char* expression; +}; + template struct qConfigSettings { qConfigSettings() : checkMin(false), checkMax(false), doSet(false), doDefault(false), min(), max(), set(), message(nullptr), allowEmpty(false) {}; @@ -84,6 +91,7 @@ struct qConfigSettingsParser { // Parse the additional settings (min, max, set, settings.max = maxval.v; } static inline void qProcessSetting(qConfigSettings& settings, qmessage_t msg) { settings.message = msg.v; } + static inline void qProcessSetting(qConfigSettings& /*settings*/, qcheck_ignore) {} template static inline void qProcessSetting(qConfigSettings& settings, qset_t set) { diff --git a/GPU/documentation/GPUSettings.md b/GPU/documentation/GPUSettings.md new file mode 100644 index 0000000000000..fe39f0f781a91 --- /dev/null +++ b/GPU/documentation/GPUSettings.md @@ -0,0 +1,52 @@ +The settings of the GPU reconstruction are defined once in macro lists, from which the structs, the command line options of the standalone benchmark, the O2 `ConfigurableParam`s, the help, and the RTC code are generated (`GPU/GPUTracking/utils/qconfig*`). + +# Settings lists + +- [GPUSettingsList.template](https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/GPUTracking/Definitions/GPUSettingsList.template): all settings of the reconstruction, available in O2 and in the standalone benchmark: `rec` (reconstruction parameters, in GPU constant memory, with the sub-structs `rec.tpc`, `rec.trd`, `rec.dyn`), `proc` (processing, host only, with `proc.rtc`, `proc.rtctech`, `proc.param`, `proc.nn`, `proc.scaling`, `proc.debug`, `proc.backend`), `QA`, and `global` (O2 workflow settings). +- [GPUSettingsListDisplay.template](https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/GPUTracking/Definitions/GPUSettingsListDisplay.template): event display settings (`display`, with `light`, `heavy`, `renderer`, `vulkan`, `internal`). +- [GPUSettingsListStandalone.template](https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/GPUTracking/Definitions/GPUSettingsListStandalone.template): options only for the standalone benchmark (`configStandalone`, e.g. `--runs`, `--gpuType`, `--syncAsync`), not available in O2. +- [GPUDisplayControl.h](https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/GPUTracking/display/GPUDisplayControl.h): display state without command line options (`GPUDisplayOptions`, saved / reset with the display settings, and `GPUDisplayControl`, transient control state). + +CMake generates `GPUSettingsList*.h` from the templates into `include_gpu_onthefly` in the build folder, sorting the members of each struct by alignment. `rec` structs must not contain `bool` (CMake error), since they are copied to the GPU: use `int8_t` / `uint8_t`. + +# Option names + +- Standalone benchmark: `--[PREFIX][name]`, with the prefix of the block (`BeginSubConfig(..., "PREFIX", ...)`), e.g. `--RECTPCrejectQPtB5 20`, `--PROCdebugLevel 1`, `--RTCenable 1`, `--QAnoMC 1`. Options with an explicit name have it in addition, e.g. `--debug` / `-d` for `proc.debugLevel`. Standalone-only options have no prefix. `./ca --help`, `--helpall`, and `--[PREFIX]help` list the options, `--printSettings` prints all values. +- O2: each block is an O2 `ConfigurableParam` named `GPU_[o2prefix]` (last argument of `BeginSubConfig`), set via `--configKeyValues`, e.g. `--configKeyValues "GPU_rec_tpc.rejectQPtB5=20;GPU_proc.debugLevel=1;GPU_proc_rtc.enable=1"`. + +# Macros + +``` +BeginSubConfig(StructName, instance, parent, "PREFIX", 'p', "description", o2prefix) +AddOption(name, type, default, "optname", 'o', "help", modifiers...) +EndConfig() +``` + +- `AddOption`: a setting with command line option and O2 key. `optname` `""` uses no extra name, `'o'` is an optional short name (0 for none). +- `AddVariable(name, type, default)`: struct member without option, e.g. for values derived from options (`GPUParam::UpdateSettings`). Any type is allowed. +- `AddOptionArray(name, type, count, (v0, v1, ...), ...)`: fixed-size array, the values are given space-separated on the command line, or as `GPU_x.name[i]=...` in O2. +- `AddOptionVec(name, type, ...)`: `std::vector`, standalone only (not in O2, not in device structs). +- `AddOptionSet(name, type, value, "optname", 'o', "help")`: additional option which sets an existing member to a fixed value, e.g. `-c` sets `runGPU = 0`. +- `AddSubConfig(Struct, instance)`, `AddHelp`, `AddHelpAll`, `AddShortcut`, `AddCommand`, `AddHelpText`, `AddCustomCPP` (code added to the struct). +- Entries must not end with `;`. + +Supported types of options: `bool`, `int8_t` ... `int64_t`, `uint8_t` ... `uint64_t`, `float`, `double`, `std::string` (not for `...RTC` entries). + +## RTC and non-RTC + +`AddOptionRTC`, `AddVariableRTC`, `AddOptionArrayRTC` mark values read in GPU device code. With run time compilation and `--RTCoptConstexpr`, their current values are compiled in as `static constexpr` constants (see [run-time-compilation.md](https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/documentation/run-time-compilation.md)). Otherwise they behave like the non-RTC versions. Use them only for values used in device code. + +## Modifiers + +Additional arguments after the help text: +- `def(x)`: value if the option is given without argument (e.g. `--display` = `--display 1`). +- `min(x)`, `max(x)`: range checked by the command line parser (standalone only). +- `set(x)`: the option takes no argument and sets `x`. +- `message("text %s")`: printed by the parser when the option is set, `%s` is the value. +- `qcheck(expression)`: checked at the initialization of `GPUReconstruction`, in O2 and standalone, if the value differs from the default; the initialization fails if `expression` is false. `val` is the value of the option, `get()` gives another passed settings object, e.g. `qcheck(get().deviceType == gpudatatypes::DeviceType::OCL)`. The objects are passed in `GPUConfigDump::checkConfig`. + +# Validation and derived values + +- `GPUParam::UpdateSettings`: values derived from options. +- `GPUChainTracking::ValidateSettings`: consistency checks. +- `GPUChainTracking::ApplySyncSettings`: differences between synchronous and asynchronous reconstruction. diff --git a/GPU/documentation/README.md b/GPU/documentation/README.md index 0f6ba79df63ce..59dc9bf6ad82d 100644 --- a/GPU/documentation/README.md +++ b/GPU/documentation/README.md @@ -14,3 +14,6 @@ [tpc-tracking-qa.md](https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/documentation/tpc-tracking-qa.md) : - Instructions how to run the QA for TPC tracking (efficiency, resolution, etc.). + +[GPUSettings.md](https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/documentation/GPUSettings.md) : +- Description of the GPU reconstruction settings, how they are defined, and how to set them in the standalone benchmark and in O2. diff --git a/GPU/documentation/build-O2.md b/GPU/documentation/build-O2.md index b04fe562b8c2f..27a9e06de39c9 100644 --- a/GPU/documentation/build-O2.md +++ b/GPU/documentation/build-O2.md @@ -3,7 +3,9 @@ This ticket will serve as documentation how to enable which GPU features and col So far, the following features exist: * GPU Tracking with CUDA * GPU Tracking with HIP - * GPU Tracking with OpenCL (>= 2.1) + * GPU Tracking with OpenCL (>= 2.2) + * GPU Tracking with Metal (macOS) + * CPUDevice debug backend: runs the CPU kernels on the host, but behaves like a GPU device (standalone benchmark only, `ENABLE_CPUDEVICE` in `config.cmake`, `--gpuType CPUDEVICE`) * OpenGL visualization of the tracking * ITS GPU tracking @@ -56,7 +58,7 @@ Disadvantages: * It may be that some patches must be applied to ROCm after the installation. You find the details in the provisioning script of the GPU CI container below. *GPU Tracking with OpenCL (Needs Clang >= 18 for compilation)* - * Needs OpenCL library with version >= 2.1, detectable via CMake find_package(OpenCL). + * Needs OpenCL library with version >= 2.2, detectable via CMake find_package(OpenCL). * Needs the SPIR-V LLVM translator together with LLVM to create the SPIR-V binaries, also detectable via CMake. *OpenGL visualization of TPC tracking* @@ -66,7 +68,10 @@ Disadvantages: * CMake will report "Building GPU Event Display" when enabled. *Vulkan visualization* - * similar to OpenCL visualization, but with Vulkan. + * similar to OpenGL visualization, but with Vulkan. + +*GPU Tracking with Metal* + * The CMake option `-DENABLE_METAL=ON/OFF/AUTO`, needs a Metal toolchain with MSL 4.1 (macOS 27), which CMake checks by compiling a probe kernel. *ITS GPU Tracking* * So far supports only CUDA and HIP, support for OpenCL might come. diff --git a/GPU/documentation/build-standalone.md b/GPU/documentation/build-standalone.md index cedb7463214d6..6a29fc103ded9 100644 --- a/GPU/documentation/build-standalone.md +++ b/GPU/documentation/build-standalone.md @@ -27,11 +27,14 @@ mkdir -p ~/standalone/build cd ~/standalone/build cmake -DCMAKE_INSTALL_PREFIX=../ ~/alice/O2/GPU/GPUTracking/Standalone/ nano config.cmake # edit config file to enable / disable dependencies as needed. In case cmake failed, and you disabled the dependency, just rerun the above command. -make install -j32 +make install -j$(nproc) ``` You can edit certain build settings in `config.cmake`. Some of them are identical to the GPU build settings for O2, as described in [build-O2.md](https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/documentation/build-O2.md). And there are plenty of additional settings to enable/disable event display, qa, usage of ROOT, FMT, etc. libraries. +`GPUCA_BUILD_DEBUG 1` gives a debug build (-O0, asserts), which compiles fast but runs slowly: use it only for small datasets. + +Some headers are generated by CMake into `GPU/GPUTracking/include_gpu_onthefly` in the build folder; `make` reruns CMake when their inputs change. Generated headers that are no longer produced (e.g. after a revert) are removed when CMake runs, and `make clean` removes all generated files. This will create the `ca` binary in `~/standalone`, which is basically the same as the `o2-gpu-standalone-benchmark`, but built outside of O2. @@ -41,13 +44,13 @@ As an exacmple you can also have a look at [build.sh](https://github.com/AliceO2 The following command lines will use `./ca`, in case you use the executable from the O2 build, please replace by `o2-gpu-standalone-benchmark`. -You can get a list of command line options by `./ca --help` and `./ca --helpall`. +You can get a list of command line options by `./ca --help` and `./ca --helpall`. The options and their names are explained in [GPUSettings.md](https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/documentation/GPUSettings.md). In order to run, you need a dataset. See the next section for how to create a dataset. Datasets are stored in `~/standalone/events`, and are identified by their folder names. The following commands assume a testdataset of name `o2-pbpb-100`. To run on that data, the simpled command is `./ca -e o2-pbpb-100`. This will automatically use a GPU if available, trying all backends, otherwise fall back to CPU. You can force using GPU or CPU with `-g` and `-c`. -You can select the backend via `--gpuType CUDA|HIP|OCL|OCL2`, and inside the backend you can select the device number, if multiple devices exist, via `--gpuDevice i`. +You can select the backend via `--gpuType CUDA|HIP|OCL|METAL|CPUDEVICE`, and inside the backend you can select the device number, if multiple devices exist, via `--gpuDevice i`. The flag `--debug` (-2 to 6) enables increasingly extensive debug output, and `--debug 6` stores full data dumpts of all intermediate steps to files. >= `--debug 1` has a performance impact since it adds serialization points for debugging. For timing individual kernels, `--debug 1` prints timing information for all kernels. diff --git a/GPU/documentation/deterministic-mode.md b/GPU/documentation/deterministic-mode.md index 4a9647a4d3bc1..43a80558644cd 100644 --- a/GPU/documentation/deterministic-mode.md +++ b/GPU/documentation/deterministic-mode.md @@ -9,13 +9,13 @@ It uses a combination of This is steered by 3 options: - The `-DGPUCA_DETERMINISTIC_MODE` Cmake setting : Compile-time setting. -- The `--PROCdeterministicGPUReconstruction` command line option / `GPU_proc.deterministicGPUReconstruction` `--configKeyValue` setting : Run time setting. +- The `--PROCdeterministicGPUReconstruction` command line option / `GPU_proc.deterministicGPUReconstruction` `--configKeyValue` setting : Run time setting. (Default -1: enabled automatically if the deterministic compile-time setting is active or with `--debug 6`.) - The `--RTCdeterministic` command line option / `GPU_proc_rtc.deterministic` `--configKeyValue` setting. (Auto-enabled by the `deterministicGPUReconstruction` setting.) : Compile-time setting for RTC code. Note that enabling a single setting will not result in fully deterministic behavior! Each setting enables different deterministic aspects! In order to be fully deterministic, all settings must be enabled, where the RTC setting is automatically enabled if not explicitly disabled. -`GPUCA_DETERMINISTIC_MODE` has multiple levels, which are described here: [FindO2GPU.cmake](https://github.com/AliceO2Group/AliceO2/blob/80a80a17f5a1d9cb77743e2a39b15b653fe1a4f9/dependencies/FindO2GPU.cmake#L72). +`GPUCA_DETERMINISTIC_MODE` has multiple levels, which are described here: [FindO2GPU.cmake](https://github.com/AliceO2Group/AliceO2/blob/dev/dependencies/FindO2GPU.cmake): `OFF`, `NO_FAST_MATH`, `OPTO2`, `GPU` (synonym `ON`), `WHOLEO2`. The value `1` is invalid on purpose, use the names. - In order to have fully deterministic GPUReconstruction (i.e. all algorithms that come with the GPUTracking library, like TPC tracking), the level `GPUCA_DETERMINISTIC_MODE=GPU` is needed. - In order to apply it to all of O2, e.g. for ITS tracking, please use `GPUCA_DETERMINISTIC_MODE=WHOLEO2` @@ -30,9 +30,13 @@ Beyond comparing only the number of clusters and number of tracks, it is also po It will create a dump container all (most) intermediate results in text form, which can be compared. The output files is called `CPU.out` if using the CPU backend, and `GPU.out` for the GPU backend. Note that the dump files will be huge and the processing will be slow and consume much more memory than normal with `--debug 6 . It has been tested with datasets containing up to 50 Pb-Pb collisions, and might fail for larger data. The dump files (if the deterministic mode is used with both compile- and runtime-activation), the files should be 100% identical and can just be compared with `diff`. +- `--PROCdebugDumpChecksum 1` writes no file, but prints a hash of the dump (`Debug hash: ...`), which is much faster for a first comparison. +- `--PROCdebugMask` selects the dumped sections, `--PROCdebugLogSuffix` adds a suffix to the file name. +- `--debug >= 4` also sets `--PROCkeepAllMemory` (no memory reuse), so bugs from reused, uninitialized memory may disappear in the dump. +- The `CPUDEVICE` backend (`--gpuType CPUDEVICE`, standalone build with `ENABLE_CPUDEVICE`) runs the GPU code path on the CPU, and its results can be compared with the CPU backend without a GPU. By default, the deterministic mode will apply flush-to-zero and denormals-are-zero to denormal floats. -This can be disabled bia `-DDGPUCA_DETERMINISTIC_MODE`. +This can be disabled via `-DGPUCA_DETERMINISTIC_NO_FTZ=1` (`GPUCA_DETERMINISTIC_NO_FTZ` in `config.cmake` for the standalone benchmark). Note that some GPUs cannot do precise float computation with denormals flushed to zero, while other GPUs do not support denormals at all. Thus, comparison between CPU and GPU deterministic results might require that this setting is either set or not set. CPU results for the 2 cases will always differ, since the floating point math will be slightly different. diff --git a/GPU/documentation/run-time-compilation.md b/GPU/documentation/run-time-compilation.md index f4693171e1360..3c63a64da24dc 100644 --- a/GPU/documentation/run-time-compilation.md +++ b/GPU/documentation/run-time-compilation.md @@ -1,4 +1,4 @@ -Run time compilation is a feature of the GPUReconstruction library, which can recompile the GPU code for HIP and for CUDA at runtime, and apply some optimizations and changes. It is planned to add support for CPU code and OpenCL code in the future. +Run time compilation is a feature of the GPUReconstruction library, which can recompile the GPU code for HIP and for CUDA at runtime, and apply some optimizations and changes. The CPUDevice debug backend (`--gpuType CPUDEVICE`) supports RTC as well, compiling the device code with the host compiler. It is planned to add support for OpenCL code in the future. The changes that can be applied are: - `constexpr` optimization: configuration values that are constant during the processing are replaced by `constexpr` expressions, which allows the compiler to optimize the code better. Benchmarks in 2024 habe shown 5% performance improvement with CUDA and 2% improvement with HIP. @@ -18,4 +18,6 @@ It is possible to select a different target architecture for the compilation via `--RTCdeterministic` enables the [Deterministic Mode](https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/documentation/deterministic-mode.md) (compile-time setting) for RTC. Usually you don't need to bother, as for the deterministic mode it is autoenabled from `--PROCdeterministicGPUReconstruction`, but the explicit `--RTCdeterministic` is available for tests. +For testing and debugging: `--RTCTECHrunTest 1` / `2` runs the compilation as test (2: exit afterwards), `--RTCTECHkeepTempFiles 1` keeps the generated source and binary files (e.g. for gdb), and the environment variable `O2_GPU_RTC_OVERRIDE_CMD` replaces the compiler command. + Finally, `--RTCoptConstexpr` and `--RTCoptSpecialCode` enable the constexpr and code removal optimizations. For an example how the TPC V/M shape corrections are removed, see [TPCFastTransform.h](https://github.com/AliceO2Group/AliceO2/blob/fc3ace17eca580c338751163ef4528e3ec47f9d6/GPU/TPCFastTransformation/TPCFastTransform.h#L445). diff --git a/GPU/documentation/tpc-tracking-qa.md b/GPU/documentation/tpc-tracking-qa.md index 4487d10d0fe70..7742c3c404f56 100644 --- a/GPU/documentation/tpc-tracking-qa.md +++ b/GPU/documentation/tpc-tracking-qa.md @@ -27,22 +27,27 @@ Remark on the *Cluster Rejection count histograms* for the *online QC*: Running the TPC QA standalone: * It must be enabled via the configKeyValue GPU_proc.runQA in the o2-tpc-reco-workflow. The QA will run as part of the normal TPC tracking and will have access to all data structures of the tracking. Otherwise, the normal settings for the o2-tpc-reco-workflow apply. * Example to run on digits: -{code}o2-tpc-reco-workflow -b --infile tpcdigits.root --configKeyValues "GPU_proc.runQA=1;" --output-type clusters,tracks{code} +```o2-tpc-reco-workflow -b --infile tpcdigits.root --configKeyValues "GPU_proc.runQA=1;" --output-type clusters,tracks``` * Example to run on clusters: -{code}o2-tpc-reco-workflow --input-type clusters --infile tpc-native-clusters.root --output-type tracks --configKeyValues "GPU_proc.runQA=1"{code} +```o2-tpc-reco-workflow --input-type clusters --infile tpc-native-clusters.root --output-type tracks --configKeyValues "GPU_proc.runQA=1"``` + +Running the TPC QA in the standalone benchmark: +* `./ca -e [dataset] --qa` runs the QA on a dataset with MC labels, prints the efficiency / clone / fake rates (`QA Stats` lines) and the cluster attachment statistics, and writes the plots to the `plots` folder. Use a build without `GPUCA_BUILD_DEBUG`, the QA is slow. +* `--QAoutput file.root` stores the histograms, `--QAinput file.root` overlays them in the plots of a new run. +* QA options are set with `--QA[option]` (`GPU_QA.[option]` in O2), see [GPUSettings.md](https://github.com/AliceO2Group/AliceO2/blob/dev/GPU/documentation/GPUSettings.md). Running the TPC QA inside the o2-tpc-reco-workflow as external source for qc: * As in the standalone mode, the TPC Tracking QA will run as part of the o2-tpc-reco-workflow with full access to the tracking data structures. * The output is shipped to QC as external qc-input in the form of ROOT histograms, which disables some subtasks that do not produce ROOT histograms (such as the cluster counts (32)). * A merged workflow of the o2-tpc-reco-workflow and qc must be configures, such as: -{code}o2-tpc-reco-workflow --input-type clusters --infile tpc-native-clusters.root --output-type tracks,qa | o2-qc --config json:/${QUALITYCONTROL_ROOT}/etc/tpcQCTrackingFromExternal_direct.json{code} +```o2-tpc-reco-workflow --input-type clusters --infile tpc-native-clusters.root --output-type tracks,qa | o2-qc --config json:/${QUALITYCONTROL_ROOT}/etc/tpcQCTrackingFromExternal_direct.json``` (Note that by default, the output will be uploaded and visible at https://qcg-test.cern.ch/) * By default, this will create postprocessed histograms, and it can be switched via configKeyValues to layouts output via: -{code}o2-tpc-reco-workflow --input-type clusters --infile tpc-native-clusters.root --output-type tracks,qa --configKeyValues "GPU_QA.shipToQCAsCanvas=true" | o2-qc --config json:/${QUALITYCONTROL_ROOT}/etc/tpcQCTrackingFromExternal_direct.json{code} +```o2-tpc-reco-workflow --input-type clusters --infile tpc-native-clusters.root --output-type tracks,qa --configKeyValues "GPU_QA.shipToQCAsCanvas=true" | o2-qc --config json:/${QUALITYCONTROL_ROOT}/etc/tpcQCTrackingFromExternal_direct.json``` * This mode can be combined with the standalone QA mode. * Running the *online cluster rejection histogram QA*: ** This mode works also without MC information, it must be enabled explicitly. Irrespective of the output mode, it will always furnish the same mergeable histograms, since there is no postprocessing. An example to run them on ROOT files: -{code}o2-tpc-reco-workflow --input-type clusters --infile tpc-native-clusters.root --output-type tracks,qa --disable-mc --configKeyValues "GPU_QA.clusterRejectionHistograms=1" | o2-qc --config json:/${QUALITYCONTROL_ROOT}/etc/tpcQCTrackingFromExternal_direct.json{code} +```o2-tpc-reco-workflow --input-type clusters --infile tpc-native-clusters.root --output-type tracks,qa --disable-mc --configKeyValues "GPU_QA.clusterRejectionHistograms=1" | o2-qc --config json:/${QUALITYCONTROL_ROOT}/etc/tpcQCTrackingFromExternal_direct.json``` ** In order to set the x-axis scale (number of clusters), use the configKeyValue GPU_QA.histMaxNClusters. Running the QA as independent QC task: @@ -51,7 +56,7 @@ Running the QA as independent QC task: * This mode is mostly foreseen for the mergeble output. In this way, many instance can run in parallel and the output can be merged before being postprocessed. * Currently, the mergeble output is hardcoded, but the task could easily be extended for other outputs (see below). * To run the tasks on ROOT file input, you can use the following example: -{code}o2-tpc-track-reader | o2-tpc-reco-workflow --input-type clusters --infile tpc-native-clusters.root --output-type disable-writer | o2-qc --config json:/${QUALITYCONTROL_ROOT}/etc/tpcQCTracking_direct.json{code} +```o2-tpc-track-reader | o2-tpc-reco-workflow --input-type clusters --infile tpc-native-clusters.root --output-type disable-writer | o2-qc --config json:/${QUALITYCONTROL_ROOT}/etc/tpcQCTracking_direct.json``` Postprocessing the mergeble output: * The o2::tpc::qc::Tracking class can be used for the postprocessing in a standalone way. @@ -60,7 +65,7 @@ Postprocessing the mergeble output: * Depending on the outputMode setting, the class will fill the out object witl either the postprocessed histograms or the canvas layouts. The following classes in O2 / QC belong to the TPC tracking QA: -* o2::gpu::GPUQA (O2/GPU/GPUTracking/Standalone/qa/GPUQA.cxx): The main QA class, which can produce the standalone output, or can run with external input driven from the o2::gpu::GPUO2InterfaceQA. +* o2::gpu::GPUQA (O2/GPU/GPUTracking/qa/GPUQA.cxx): The main QA class, which can produce the standalone output, or can run with external input driven from the o2::gpu::GPUO2InterfaceQA. * o2::gpu::GPUO2InterfaceQA (O2/GPU/GPUTracking/Interface/GPUO2InterfaceQA.cxx): Internal interface class, uses o2::gpu::GPUQA. * o2::tpc::qc::Tracking (O2/Detectors/TPC/qc/src/Tracking.cxx): The main QC class for running the TPC QA independent from the o2-tpc-reco-workflow, uses o2::gpu::GPUO2InterfaceQA. ** Can produce all output types from tracks / clusters as input.