Skip to content

Commit 5b8151f

Browse files
authored
Merge branch 'dev' into add-df-offset-option
2 parents baed16b + 91d4cee commit 5b8151f

File tree

554 files changed

+12841
-10264
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

554 files changed

+12841
-10264
lines changed

CCDB/include/CCDB/BasicCCDBManager.h

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ class CCDBManagerInstance
102102
template <typename T>
103103
T* getForTimeStamp(std::string const& path, long timestamp);
104104

105+
/// retrieve an object of type T from CCDB as stored under path and using the timestamp in the middle of the run
106+
template <typename T>
107+
T* getForRun(std::string const& path, int runNumber, bool setRunMetadata = false);
108+
105109
/// retrieve an object of type T from CCDB as stored under path, timestamp and metaData
106110
template <typename T>
107111
T* getSpecific(std::string const& path, long timestamp = -1, MD metaData = MD())
@@ -111,6 +115,10 @@ class CCDBManagerInstance
111115
return getForTimeStamp<T>(path, timestamp);
112116
}
113117

118+
/// retrieve an object of type T from CCDB as stored under path and using the timestamp in the middle of the run + metadata. The run number is provided separately to conform to typical analysis use (in which case metadata does not include runNumber)
119+
template <typename T>
120+
T* getSpecificForRun(std::string const& path, int runNumber, MD metaData = MD());
121+
114122
/// detect online processing modes (i.e. CCDB objects may be updated in the lifetime of the manager)
115123
bool isOnline() const { return mDeplMode == o2::framework::DeploymentMode::OnlineAUX || mDeplMode == o2::framework::DeploymentMode::OnlineDDS || mDeplMode == o2::framework::DeploymentMode::OnlineECS; }
116124

@@ -186,7 +194,7 @@ class CCDBManagerInstance
186194
/// On error it fatals (if fatal == true) or else returns the pair -1, -1.
187195
std::pair<int64_t, int64_t> getRunDuration(int runnumber, bool fatal = true);
188196
static std::pair<int64_t, int64_t> getRunDuration(o2::ccdb::CcdbApi const& api, int runnumber, bool fatal = true);
189-
197+
static std::pair<int64_t, int64_t> getRunDuration(const MD& headers);
190198
std::string getSummaryString() const;
191199

192200
size_t getFetchedSize() const { return mFetchedSize; }
@@ -311,6 +319,27 @@ T* CCDBManagerInstance::getForTimeStamp(std::string const& path, long timestamp)
311319
return ptr;
312320
}
313321

322+
template <typename T>
323+
T* CCDBManagerInstance::getForRun(std::string const& path, int runNumber, bool setRunMetadata)
324+
{
325+
auto metaData = setRunMetadata ? MD{{"runNumber", std::to_string(runNumber)}} : MD{};
326+
mMetaData = metaData;
327+
return getSpecificForRun<T>(path, runNumber, metaData);
328+
}
329+
330+
template <typename T>
331+
T* CCDBManagerInstance::getSpecificForRun(std::string const& path, int runNumber, MD metaData)
332+
{
333+
auto [start, stop] = getRunDuration(runNumber);
334+
if (start < 0 || stop < 0) {
335+
if (mFatalWhenNull) {
336+
reportFatal(std::string("Failed to get run duration for run ") + std::to_string(runNumber));
337+
}
338+
return nullptr;
339+
}
340+
return getSpecific<T>(path, start / 2 + stop / 2, metaData);
341+
}
342+
314343
class BasicCCDBManager : public CCDBManagerInstance
315344
{
316345
public:

CCDB/include/CCDB/CcdbApi.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,9 @@ class CcdbApi //: public DatabaseInterface
392392
// Loads files from alien and cvmfs into given destination.
393393
bool loadLocalContentToMemory(o2::pmr::vector<char>& dest, std::string& url) const;
394394

395+
// add annotated flattened headers in the end of the blob
396+
static void appendFlatHeader(o2::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers);
397+
395398
// the failure to load the file to memory is signaled by 0 size and non-0 capacity
396399
static bool isMemoryFileInvalid(const o2::pmr::vector<char>& v) { return v.size() == 0 && v.capacity() > 0; }
397400
template <typename T>
@@ -610,6 +613,16 @@ class CcdbApi //: public DatabaseInterface
610613
return getSnapshotDir(topdir, path) + '/' + sfile;
611614
}
612615

616+
template <typename MAP> // can be either std::map or std::multimap
617+
static size_t getFlatHeaderSize(const MAP& Headers)
618+
{
619+
size_t hsize = sizeof(int) + sizeof(FlatHeaderAnnot); // annotation size
620+
for (auto& h : Headers) {
621+
hsize += h.first.length() + h.second.length() + 2; // 2*(string_buffer + terminating null character)
622+
}
623+
return hsize;
624+
}
625+
613626
// tmp helper and single point of entry for a CURL perform call
614627
// helps to switch between easy handle perform and multi handles in a single place
615628
CURLcode CURL_perform(CURL* handle) const;
@@ -632,6 +645,8 @@ class CcdbApi //: public DatabaseInterface
632645
size_t mCurlTimeoutDownload = 15; // download timeout in seconds, can be configured via ALICEO2_CCDB_CURL_TIMEOUT_DOWNLOAD, updated according to the deployment mode
633646
size_t mCurlTimeoutUpload = 15; // upload timeout in seconds, can be configured via ALICEO2_CCDB_CURL_TIMEOUT_UPLOAD, updated according to the deployment mode
634647

648+
static constexpr char FlatHeaderAnnot[] = "$HEADER$"; // annotation for flat header
649+
635650
ClassDefNV(CcdbApi, 1);
636651
};
637652

CCDB/src/BasicCCDBManager.cxx

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -32,44 +32,47 @@ void CCDBManagerInstance::reportFatal(std::string_view err)
3232
LOG(fatal) << err;
3333
}
3434

35-
std::pair<int64_t, int64_t> CCDBManagerInstance::getRunDuration(o2::ccdb::CcdbApi const& api, int runnumber, bool fatal)
35+
std::pair<int64_t, int64_t> CCDBManagerInstance::getRunDuration(const std::map<std::string, std::string>& headers)
3636
{
37-
auto response = api.retrieveHeaders("RCT/Info/RunInformation", std::map<std::string, std::string>(), runnumber);
38-
if (response.size() != 0) {
37+
if (headers.size() != 0) {
3938
std::string report{};
40-
auto strt = response.find("STF");
41-
auto stop = response.find("ETF");
42-
long valStrt = (strt == response.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
43-
long valStop = (stop == response.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
39+
auto strt = headers.find("STF");
40+
auto stop = headers.find("ETF");
41+
long valStrt = (strt == headers.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
42+
long valStop = (stop == headers.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
4443
if (valStrt < 0 || valStop < 0) {
4544
report += "Missing STF/EFT -> use SOX/EOX;";
46-
strt = response.find("SOX");
47-
valStrt = (strt == response.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
45+
strt = headers.find("SOX");
46+
valStrt = (strt == headers.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
4847
if (valStrt < 1) {
4948
report += fmt::format(" Missing/invalid SOX -> use SOR");
50-
strt = response.find("SOR");
51-
valStrt = (strt == response.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
49+
strt = headers.find("SOR");
50+
valStrt = (strt == headers.end()) ? -1L : boost::lexical_cast<int64_t>(strt->second);
5251
}
53-
stop = response.find("EOX");
54-
valStop = (stop == response.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
52+
stop = headers.find("EOX");
53+
valStop = (stop == headers.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
5554
if (valStop < 1) {
5655
report += fmt::format(" | Missing/invalid EOX -> use EOR");
57-
stop = response.find("EOR");
58-
valStop = (stop == response.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
56+
stop = headers.find("EOR");
57+
valStop = (stop == headers.end()) ? -1L : boost::lexical_cast<int64_t>(stop->second);
5958
}
6059
if (!report.empty()) {
6160
LOGP(warn, "{}", report);
6261
}
6362
}
64-
if (valStrt > 0 && valStop >= valStrt) {
65-
return std::make_pair(valStrt, valStop);
66-
}
63+
return std::make_pair(valStrt, valStop);
6764
}
68-
// failure
69-
if (fatal) {
65+
return std::make_pair(-1L, -1L);
66+
}
67+
68+
std::pair<int64_t, int64_t> CCDBManagerInstance::getRunDuration(o2::ccdb::CcdbApi const& api, int runnumber, bool fatal)
69+
{
70+
auto headers = api.retrieveHeaders("RCT/Info/RunInformation", std::map<std::string, std::string>(), runnumber);
71+
auto response = getRunDuration(headers);
72+
if ((response.first <= 0 || response.second < response.first) && fatal) {
7073
LOG(fatal) << "Empty, missing or invalid response from query to RCT/Info/RunInformation for run " << runnumber;
7174
}
72-
return std::make_pair(-1L, -1L);
75+
return response;
7376
}
7477

7578
std::pair<int64_t, int64_t> CCDBManagerInstance::getRunDuration(int runnumber, bool fatal)

CCDB/src/CcdbApi.cxx

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1687,12 +1687,15 @@ void CcdbApi::scheduleDownload(RequestContext& requestContext, size_t* requestCo
16871687
ho.counter++;
16881688
try {
16891689
if (chunk.capacity() < chunk.size() + realsize) {
1690+
// estimate headers size when converted to annotated text string
1691+
const char hannot[] = "header";
1692+
size_t hsize = getFlatHeaderSize(ho.header);
16901693
auto cl = ho.header.find("Content-Length");
16911694
if (cl != ho.header.end()) {
16921695
size_t sizeFromHeader = std::stol(cl->second);
1693-
sz = std::max(chunk.size() * (sizeFromHeader ? 1 : 2) + realsize, sizeFromHeader);
1696+
sz = hsize + std::max(chunk.size() * (sizeFromHeader ? 1 : 2) + realsize, sizeFromHeader);
16941697
} else {
1695-
sz = std::max(chunk.size() * 2, chunk.size() + realsize);
1698+
sz = hsize + std::max(chunk.size() * 2, chunk.size() + realsize);
16961699
// LOGP(debug, "SIZE IS NOT IN HEADER, allocate {}", sz);
16971700
}
16981701
chunk.reserve(sz);
@@ -1885,6 +1888,25 @@ void CcdbApi::loadFileToMemory(o2::pmr::vector<char>& dest, std::string const& p
18851888
vectoredLoadFileToMemory(contexts);
18861889
}
18871890

1891+
void CcdbApi::appendFlatHeader(o2::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers)
1892+
{
1893+
size_t hsize = getFlatHeaderSize(headers), cnt = dest.size();
1894+
dest.resize(cnt + hsize);
1895+
auto addString = [&dest, &cnt](const std::string& s) {
1896+
for (char c : s) {
1897+
dest[cnt++] = c;
1898+
}
1899+
dest[cnt++] = 0;
1900+
};
1901+
1902+
for (auto& h : headers) {
1903+
addString(h.first);
1904+
addString(h.second);
1905+
}
1906+
*reinterpret_cast<int*>(&dest[cnt]) = hsize; // store size
1907+
std::memcpy(&dest[cnt + sizeof(int)], FlatHeaderAnnot, sizeof(FlatHeaderAnnot)); // annotate the flattened headers map
1908+
}
1909+
18881910
void CcdbApi::navigateSourcesAndLoadFile(RequestContext& requestContext, int& fromSnapshot, size_t* requestCounter) const
18891911
{
18901912
LOGP(debug, "loadFileToMemory {} ETag=[{}]", requestContext.path, requestContext.etag);

Common/Constants/include/CommonConstants/PhysicsConstants.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ enum Pdg {
4848
kDPlus = 411,
4949
kDS = 431,
5050
kDSBar = -431,
51+
kDSStar = 433,
5152
kDS1 = 10433,
5253
kDS2Star = 435,
5354
kDStar = 413,
@@ -95,6 +96,7 @@ constexpr double MassDMinus = 1.86966;
9596
constexpr double MassDPlus = 1.86966;
9697
constexpr double MassDS = 1.96835;
9798
constexpr double MassDSBar = 1.96835;
99+
constexpr double MassDSStar = 2.1122;
98100
constexpr double MassDS1 = 2.53511;
99101
constexpr double MassDS2Star = 2.5691;
100102
constexpr double MassDStar = 2.01026;

Common/Constants/include/CommonConstants/make_pdg_header.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ class Pdg(Enum):
103103
kDPlus = 411
104104
kDS = 431
105105
kDSBar = -431
106+
kDSStar = 433
106107
kDS1 = 10433
107108
kDS2Star = 435
108109
kDStar = 413
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
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+
/// \brief Helper interface to the GPU device, meant to be compatible with manual allocation/streams and GPUReconstruction ones.
13+
/// \author matteo.concas@cern.ch
14+
15+
#ifndef DCAFITTER_GPU_INTERFACE
16+
#define DCAFITTER_GPU_INTERFACE
17+
18+
#include <thread>
19+
#include <vector>
20+
#include <atomic>
21+
22+
namespace o2
23+
{
24+
namespace vertexing
25+
{
26+
namespace device
27+
{
28+
29+
#if !defined(__HIPCC__) && !defined(__CUDACC__)
30+
typedef struct _dummyStream {
31+
} Stream;
32+
#else
33+
#ifdef __HIPCC__
34+
typedef hipStream_t Stream;
35+
#else
36+
typedef cudaStream_t Stream;
37+
#endif
38+
#endif
39+
40+
class GPUInterface
41+
{
42+
public:
43+
GPUInterface(GPUInterface& other) = delete;
44+
void operator=(const GPUInterface&) = delete;
45+
46+
static GPUInterface* Instance();
47+
48+
// APIs
49+
void registerBuffer(void*, size_t);
50+
void unregisterBuffer(void* addr);
51+
void allocDevice(void**, size_t);
52+
void freeDevice(void*);
53+
Stream& getStream(unsigned short N = 0);
54+
Stream& getNextStream();
55+
56+
protected:
57+
GPUInterface(size_t N = 1);
58+
~GPUInterface();
59+
60+
void resize(size_t);
61+
62+
std::atomic<unsigned short> mLastUsedStream{0};
63+
static GPUInterface* sGPUInterface;
64+
std::vector<std::thread> mPool{};
65+
std::vector<Stream> mStreams{};
66+
};
67+
68+
} // namespace device
69+
} // namespace vertexing
70+
} // namespace o2
71+
#endif

Common/DCAFitter/GPU/cuda/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,15 @@
1212
o2_add_library(DCAFitterCUDA
1313
TARGETVARNAME targetName
1414
SOURCES DCAFitterN.cu
15+
GPUInterface.cu
1516
PUBLIC_INCLUDE_DIRECTORIES ../../include
17+
PUBLIC_INCLUDE_DIRECTORIES ../
1618
PUBLIC_LINK_LIBRARIES O2::MathUtils
1719
O2::ReconstructionDataFormats
1820
O2::DetectorsBase
1921
PRIVATE_LINK_LIBRARIES O2::GPUTrackingCUDAExternalProvider)
2022
set_property(TARGET ${targetName} PROPERTY CUDA_SEPARABLE_COMPILATION ON)
23+
# add_compile_options(-lineinfo)
2124

2225
o2_add_test(DCAFitterNCUDA
2326
SOURCES test/testDCAFitterNGPU.cxx

0 commit comments

Comments
 (0)