Skip to content

Commit 10f5c38

Browse files
committed
GPU: Split of ROOT dictionary for GPU ConfigKeyValues into GPUDataTypes library
1 parent aea1ca1 commit 10f5c38

8 files changed

Lines changed: 78 additions & 52 deletions

File tree

GPU/GPUTracking/Base/GPUReconstruction.cxx

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ struct GPUReconstructionPipelineContext {
7676

7777
using namespace GPUCA_NAMESPACE::gpu;
7878

79-
constexpr const char* const GPUReconstruction::DEVICE_TYPE_NAMES[];
8079
constexpr const char* const GPUReconstruction::GEOMETRY_TYPE_NAMES[];
8180
constexpr const char* const GPUReconstruction::IOTYPENAMES[];
8281
constexpr GPUReconstruction::GeometryType GPUReconstruction::geometryType;
@@ -1121,40 +1120,30 @@ GPUReconstruction* GPUReconstruction::CreateInstance(const GPUSettingsDeviceBack
11211120

11221121
if (retVal == nullptr) {
11231122
if (cfg.forceDeviceType) {
1124-
GPUError("Error: Could not load GPUReconstruction for specified device: %s (%u)", DEVICE_TYPE_NAMES[type], type);
1123+
GPUError("Error: Could not load GPUReconstruction for specified device: %s (%u)", GPUDataTypes::DEVICE_TYPE_NAMES[type], type);
11251124
} else {
1126-
GPUError("Could not load GPUReconstruction for device type %s (%u), falling back to CPU version", DEVICE_TYPE_NAMES[type], type);
1125+
GPUError("Could not load GPUReconstruction for device type %s (%u), falling back to CPU version", GPUDataTypes::DEVICE_TYPE_NAMES[type], type);
11271126
GPUSettingsDeviceBackend cfg2 = cfg;
11281127
cfg2.deviceType = DeviceType::CPU;
11291128
retVal = CreateInstance(cfg2);
11301129
}
11311130
} else {
1132-
GPUInfo("Created GPUReconstruction instance for device type %s (%u) %s", DEVICE_TYPE_NAMES[type], type, cfg.master ? " (slave)" : "");
1131+
GPUInfo("Created GPUReconstruction instance for device type %s (%u) %s", GPUDataTypes::DEVICE_TYPE_NAMES[type], type, cfg.master ? " (slave)" : "");
11331132
}
11341133

11351134
return retVal;
11361135
}
11371136

11381137
GPUReconstruction* GPUReconstruction::CreateInstance(const char* type, bool forceType, GPUReconstruction* master)
11391138
{
1140-
DeviceType t = GetDeviceType(type);
1139+
DeviceType t = GPUDataTypes::GetDeviceType(type);
11411140
if (t == DeviceType::INVALID_DEVICE) {
11421141
GPUError("Invalid device type: %s", type);
11431142
return nullptr;
11441143
}
11451144
return CreateInstance(t, forceType, master);
11461145
}
11471146

1148-
GPUReconstruction::DeviceType GPUReconstruction::GetDeviceType(const char* type)
1149-
{
1150-
for (unsigned int i = 1; i < sizeof(DEVICE_TYPE_NAMES) / sizeof(DEVICE_TYPE_NAMES[0]); i++) {
1151-
if (strcmp(DEVICE_TYPE_NAMES[i], type) == 0) {
1152-
return (DeviceType)i;
1153-
}
1154-
}
1155-
return DeviceType::INVALID_DEVICE;
1156-
}
1157-
11581147
#ifdef _WIN32
11591148
#define LIBRARY_EXTENSION ".dll"
11601149
#define LIBRARY_TYPE HMODULE

GPU/GPUTracking/Base/GPUReconstruction.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ class GPUReconstruction
8484
static constexpr GeometryType geometryType = GeometryType::ALIROOT;
8585
#endif
8686

87-
static constexpr const char* const DEVICE_TYPE_NAMES[] = {"INVALID", "CPU", "CUDA", "HIP", "OCL", "OCL2"};
8887
static DeviceType GetDeviceType(const char* type);
8988
enum InOutPointerType : unsigned int { CLUSTER_DATA = 0,
9089
SLICE_OUT_TRACK = 1,

GPU/GPUTracking/Benchmark/standalone.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -723,14 +723,14 @@ int main(int argc, char** argv)
723723
return 1;
724724
}
725725

726-
recUnique.reset(GPUReconstruction::CreateInstance(configStandalone.runGPU ? configStandalone.gpuType.c_str() : GPUReconstruction::DEVICE_TYPE_NAMES[GPUReconstruction::DeviceType::CPU], configStandalone.runGPUforce));
726+
recUnique.reset(GPUReconstruction::CreateInstance(configStandalone.runGPU ? configStandalone.gpuType.c_str() : GPUDataTypes::DEVICE_TYPE_NAMES[GPUDataTypes::DeviceType::CPU], configStandalone.runGPUforce));
727727
rec = recUnique.get();
728728
if (configStandalone.testSyncAsync) {
729-
recUniqueAsync.reset(GPUReconstruction::CreateInstance(configStandalone.runGPU ? configStandalone.gpuType.c_str() : GPUReconstruction::DEVICE_TYPE_NAMES[GPUReconstruction::DeviceType::CPU], configStandalone.runGPUforce, rec));
729+
recUniqueAsync.reset(GPUReconstruction::CreateInstance(configStandalone.runGPU ? configStandalone.gpuType.c_str() : GPUDataTypes::DEVICE_TYPE_NAMES[GPUDataTypes::DeviceType::CPU], configStandalone.runGPUforce, rec));
730730
recAsync = recUniqueAsync.get();
731731
}
732732
if (configStandalone.proc.doublePipeline) {
733-
recUniquePipeline.reset(GPUReconstruction::CreateInstance(configStandalone.runGPU ? configStandalone.gpuType.c_str() : GPUReconstruction::DEVICE_TYPE_NAMES[GPUReconstruction::DeviceType::CPU], configStandalone.runGPUforce, rec));
733+
recUniquePipeline.reset(GPUReconstruction::CreateInstance(configStandalone.runGPU ? configStandalone.gpuType.c_str() : GPUDataTypes::DEVICE_TYPE_NAMES[GPUDataTypes::DeviceType::CPU], configStandalone.runGPUforce, rec));
734734
recPipeline = recUniquePipeline.get();
735735
}
736736
if (rec == nullptr || (configStandalone.testSyncAsync && recAsync == nullptr)) {

GPU/GPUTracking/CMakeLists.txt

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,16 @@ set(SRCS
6262
TRDTracking/GPUTRDTrackerKernels.cxx
6363
Base/GPUParam.cxx)
6464

65-
set(SRCS_O2_DATATYPES
65+
set(SRCS_O2_DATATYPE_HEADERS
6666
DataTypes/GPUTRDTrackO2.cxx)
67+
set(SRCS_O2_DATATYPES
68+
DataTypes/GPUDataTypes.cxx
69+
Interface/GPUO2InterfaceConfigurableParam.cxx)
70+
set(HDRS_CINT_O2 DataTypes/TPCdEdxCalibrationSplines.h Merger/GPUTPCGMMergedTrack.h)
71+
set(HDRS_CINT_O2_DATATYPES DataTypes/GPUDataTypes.h Interface/GPUO2InterfaceConfigurableParam.h)
72+
set(HDRS_CINT_O2_ADDITIONAL DataTypes/GPUSettings.h Definitions/GPUSettingsList.h DataTypes/GPUDataTypes.h DataTypes/GPUTRDTrack.h) # Manual dependencies for ROOT dictionary generation
6773

6874
set(SRCS_NO_CINT
69-
DataTypes/GPUDataTypes.cxx
7075
DataTypes/GPUMemorySizeScalers.cxx
7176
Base/GPUReconstruction.cxx
7277
Base/GPUReconstructionCPU.cxx
@@ -153,13 +158,6 @@ set(HDRS_INSTALL
153158
Debug/GPUROOTDump.h
154159
)
155160

156-
# Sources only for O2
157-
if(ALIGPU_BUILD_TYPE STREQUAL "O2")
158-
set(SRCS ${SRCS} Interface/GPUO2InterfaceConfigurableParam.cxx)
159-
set(HDRS_CINT_O2 ${HDRS_CINT_O2} DataTypes/TPCdEdxCalibrationSplines.h Interface/GPUO2InterfaceConfigurableParam.h)
160-
set(HDRS_CINT_O2_ADDITIONAL DataTypes/GPUSettings.h Definitions/GPUSettingsList.h DataTypes/GPUDataTypes.h DataTypes/GPUTRDTrack.h Merger/GPUTPCGMMergedTrack.h) # Manual dependencies for ROOT dictionary generation
161-
endif()
162-
163161
# Sources for O2 and for Standalone if requested in config file
164162
if(ALIGPU_BUILD_TYPE STREQUAL "O2" OR ALIGPU_BUILD_TYPE STREQUAL "Standalone")
165163
set(SRCS_NO_CINT ${SRCS_NO_CINT} display/GPUDisplayBackend.cxx)
@@ -283,16 +281,24 @@ if(ALIGPU_BUILD_TYPE STREQUAL "O2")
283281
PUBLIC_LINK_LIBRARIES O2::GPUCommon
284282
O2::ReconstructionDataFormats
285283
PRIVATE_LINK_LIBRARIES O2::DataFormatsTPC
286-
SOURCES ${SRCS_O2_DATATYPES})
287-
target_compile_definitions(${targetName} PRIVATE GPUCA_O2_LIB
288-
GPUCA_TPC_GEOMETRY_O2 GPUCA_HAVE_O2HEADERS)
284+
SOURCES ${SRCS_O2_DATATYPE_HEADERS})
285+
target_compile_definitions(${targetName} PRIVATE GPUCA_O2_LIB GPUCA_TPC_GEOMETRY_O2 GPUCA_HAVE_O2HEADERS)
289286

287+
o2_add_library(GPUDataTypes
288+
TARGETVARNAME targetName
289+
PUBLIC_LINK_LIBRARIES O2::GPUDataTypeHeaders O2::GPUUtils
290+
PRIVATE_LINK_LIBRARIES O2::DataFormatsTPC
291+
SOURCES ${SRCS_O2_DATATYPES})
292+
target_compile_definitions(${targetName} PRIVATE GPUCA_O2_LIB GPUCA_TPC_GEOMETRY_O2 GPUCA_HAVE_O2HEADERS)
293+
o2_target_root_dictionary(GPUDataTypes
294+
HEADERS ${HDRS_CINT_O2_DATATYPES} ${HDRS_CINT_O2_ADDITIONAL}
295+
LINKDEF GPUTrackingLinkDef_O2_DataTypes.h)
290296

291297
o2_add_library(${MODULE}
292298
TARGETVARNAME targetName
293299
PUBLIC_LINK_LIBRARIES O2::GPUCommon
294300
O2::GPUUtils
295-
O2::GPUDataTypeHeaders
301+
O2::GPUDataTypes
296302
O2::DataFormatsTPC
297303
O2::DataFormatsTOF
298304
O2::TPCBase
@@ -330,14 +336,14 @@ target_compile_definitions(${targetName} PRIVATE GPUCA_O2_LIB
330336
${targetName}
331337
PRIVATE $<TARGET_PROPERTY:O2::Framework,INTERFACE_INCLUDE_DIRECTORIES>)
332338

339+
target_compile_definitions(${targetName} PRIVATE GPUCA_O2_LIB
340+
GPUCA_TPC_GEOMETRY_O2 GPUCA_HAVE_O2HEADERS)
341+
333342
o2_target_root_dictionary(${MODULE}
334343
HEADERS ${HDRS_CINT_O2} ${HDRS_CINT_O2_ADDITIONAL}
335344
LINKDEF GPUTrackingLinkDef_O2.h)
336345

337-
target_compile_definitions(${targetName} PRIVATE GPUCA_O2_LIB
338-
GPUCA_TPC_GEOMETRY_O2 GPUCA_HAVE_O2HEADERS)
339-
340-
install(FILES ${HDRS_CINT_ALIROOT} ${HDRS_CINT_O2} ${HDRS_INSTALL}
346+
install(FILES ${HDRS_CINT_ALIROOT} ${HDRS_CINT_O2} ${HDRS_CINT_O2_DATATYPES} ${HDRS_INSTALL}
341347
DESTINATION include/GPU)
342348
install(DIRECTORY utils
343349
DESTINATION include/GPU

GPU/GPUTracking/DataTypes/GPUDataTypes.cxx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,20 @@
1313
/// \author David Rohr
1414

1515
#include "GPUDataTypes.h"
16-
#include "GPUReconstruction.h"
16+
#include <cstring>
1717

1818
using namespace GPUCA_NAMESPACE::gpu;
1919

20+
constexpr const char* const GPUDataTypes::DEVICE_TYPE_NAMES[];
2021
constexpr const char* const GPUDataTypes::RECO_STEP_NAMES[];
2122
constexpr const char* const GPUDataTypes::GENERAL_STEP_NAMES[];
2223

23-
GPUDataTypes::DeviceType GPUDataTypes::GetDeviceType(const char* type) { return GPUReconstruction::GetDeviceType(type); }
24+
GPUDataTypes::DeviceType GPUDataTypes::GetDeviceType(const char* type)
25+
{
26+
for (unsigned int i = 1; i < sizeof(DEVICE_TYPE_NAMES) / sizeof(DEVICE_TYPE_NAMES[0]); i++) {
27+
if (strcmp(DEVICE_TYPE_NAMES[i], type) == 0) {
28+
return (DeviceType)i;
29+
}
30+
}
31+
return DeviceType::INVALID_DEVICE;
32+
}

GPU/GPUTracking/DataTypes/GPUDataTypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@ class GPUDataTypes
171171
TPCRaw = 64 };
172172

173173
#ifdef GPUCA_NOCOMPAT_ALLOPENCL
174+
static constexpr const char* const DEVICE_TYPE_NAMES[] = {"INVALID", "CPU", "CUDA", "HIP", "OCL", "OCL2"};
174175
static constexpr const char* const RECO_STEP_NAMES[] = {"TPC Transformation", "TPC Sector Tracking", "TPC Track Merging and Fit", "TPC Compression", "TRD Tracking", "ITS Tracking", "TPC dEdx Computation", "TPC Cluster Finding", "TPC Decompression", "Global Refit"};
175176
static constexpr const char* const GENERAL_STEP_NAMES[] = {"Prepare", "QA"};
176177
typedef bitfield<RecoStep, unsigned int> RecoStepField;

GPU/GPUTracking/GPUTrackingLinkDef_O2.h

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,19 +20,5 @@
2020

2121
#pragma link C++ class o2::gpu::TPCdEdxCalibrationSplines + ;
2222
#pragma link C++ class o2::gpu::GPUTPCGMMergedTrack + ;
23-
#pragma link C++ class o2::gpu::trackInterface < o2::track::TrackParCov> + ;
24-
#pragma link C++ class o2::gpu::GPUTRDTrack_t < o2::gpu::trackInterface < o2::track::TrackParCov>> + ;
25-
#pragma link C++ class std::vector < o2::gpu::GPUTRDTrack_t < o2::gpu::trackInterface < o2::track::TrackParCov>>> + ;
26-
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsO2 + ;
27-
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsRec + ;
28-
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsRecTPC + ;
29-
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsRecTRD + ;
30-
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsProcessing + ;
31-
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsProcessingRTC + ;
32-
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsDisplay + ;
33-
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsDisplayLight + ;
34-
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsDisplayHeavy + ;
35-
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsDisplayRenderer + ;
36-
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsQA + ;
3723

3824
#endif
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+
// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+
// All rights not expressly granted are reserved.
4+
//
5+
// This software is distributed under the terms of the GNU General Public
6+
// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+
//
8+
// In applying this license CERN does not waive the privileges and immunities
9+
// granted to it by virtue of its status as an Intergovernmental Organization
10+
// or submit itself to any jurisdiction.
11+
12+
/// \file GPUTrackingLinkDef_O2_DataTypes.h
13+
/// \author David Rohr
14+
15+
#ifdef __CLING__
16+
17+
#pragma link off all globals;
18+
#pragma link off all classes;
19+
#pragma link off all functions;
20+
21+
#pragma link C++ class o2::gpu::trackInterface < o2::track::TrackParCov> + ;
22+
#pragma link C++ class o2::gpu::GPUTRDTrack_t < o2::gpu::trackInterface < o2::track::TrackParCov>> + ;
23+
#pragma link C++ class std::vector < o2::gpu::GPUTRDTrack_t < o2::gpu::trackInterface < o2::track::TrackParCov>>> + ;
24+
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsO2 + ;
25+
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsRec + ;
26+
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsRecTPC + ;
27+
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsRecTRD + ;
28+
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsProcessing + ;
29+
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsProcessingRTC + ;
30+
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsDisplay + ;
31+
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsDisplayLight + ;
32+
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsDisplayHeavy + ;
33+
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsDisplayRenderer + ;
34+
#pragma link C++ class o2::gpu::GPUConfigurableParamGPUSettingsQA + ;
35+
36+
#endif

0 commit comments

Comments
 (0)