Skip to content

Commit 5ca0fd3

Browse files
authored
Merge 5a5d53d into sapling-pr-archive-ktf
2 parents 39ae108 + 5a5d53d commit 5ca0fd3

File tree

90 files changed

+1227
-559
lines changed

Some content is hidden

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

90 files changed

+1227
-559
lines changed

CCDB/include/CCDB/CCDBDownloader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ namespace o2::ccdb
4141
#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
4242
struct HeaderObjectPair_t {
4343
std::multimap<std::string, std::string> header;
44-
o2::pmr::vector<char>* object = nullptr;
44+
std::pmr::vector<char>* object = nullptr;
4545
int counter = 0;
4646
};
4747

CCDB/include/CCDB/CcdbApi.h

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -355,7 +355,7 @@ class CcdbApi //: public DatabaseInterface
355355

356356
#if !defined(__CINT__) && !defined(__MAKECINT__) && !defined(__ROOTCLING__) && !defined(__CLING__)
357357
typedef struct RequestContext {
358-
o2::pmr::vector<char>& dest;
358+
std::pmr::vector<char>& dest;
359359
std::string path;
360360
std::map<std::string, std::string> const& metadata;
361361
long timestamp;
@@ -365,7 +365,7 @@ class CcdbApi //: public DatabaseInterface
365365
std::string createdNotBefore;
366366
bool considerSnapshot;
367367

368-
RequestContext(o2::pmr::vector<char>& d,
368+
RequestContext(std::pmr::vector<char>& d,
369369
std::map<std::string, std::string> const& m,
370370
std::map<std::string, std::string>& h)
371371
: dest(d), metadata(m), headers(h) {}
@@ -379,7 +379,7 @@ class CcdbApi //: public DatabaseInterface
379379

380380
void getFromSnapshot(bool createSnapshot, std::string const& path,
381381
long timestamp, std::map<std::string, std::string>& headers,
382-
std::string& snapshotpath, o2::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const;
382+
std::string& snapshotpath, std::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const;
383383
void releaseNamedSemaphore(boost::interprocess::named_semaphore* sem, std::string const& path) const;
384384
boost::interprocess::named_semaphore* createNamedSemaphore(std::string const& path) const;
385385
static std::string determineSemaphoreName(std::string const& basedir, std::string const& objectpath);
@@ -388,22 +388,22 @@ class CcdbApi //: public DatabaseInterface
388388
static bool removeSemaphore(std::string const& name, bool remove = false);
389389
static void removeLeakingSemaphores(std::string const& basedir, bool remove = false);
390390

391-
void loadFileToMemory(o2::pmr::vector<char>& dest, const std::string& path, std::map<std::string, std::string>* localHeaders = nullptr, bool fetchLocalMetaData = true) const;
392-
void loadFileToMemory(o2::pmr::vector<char>& dest, std::string const& path,
391+
void loadFileToMemory(std::pmr::vector<char>& dest, const std::string& path, std::map<std::string, std::string>* localHeaders = nullptr, bool fetchLocalMetaData = true) const;
392+
void loadFileToMemory(std::pmr::vector<char>& dest, std::string const& path,
393393
std::map<std::string, std::string> const& metadata, long timestamp,
394394
std::map<std::string, std::string>* headers, std::string const& etag,
395395
const std::string& createdNotAfter, const std::string& createdNotBefore, bool considerSnapshot = true) const;
396396

397397
// Loads files from alien and cvmfs into given destination.
398-
bool loadLocalContentToMemory(o2::pmr::vector<char>& dest, std::string& url) const;
398+
bool loadLocalContentToMemory(std::pmr::vector<char>& dest, std::string& url) const;
399399

400400
// add annotated flattened headers in the end of the blob
401-
static void appendFlatHeader(o2::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers);
401+
static void appendFlatHeader(std::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers);
402402

403403
// the failure to load the file to memory is signaled by 0 size and non-0 capacity
404-
static bool isMemoryFileInvalid(const o2::pmr::vector<char>& v) { return v.size() == 0 && v.capacity() > 0; }
404+
static bool isMemoryFileInvalid(const std::pmr::vector<char>& v) { return v.size() == 0 && v.capacity() > 0; }
405405
template <typename T>
406-
static T* extractFromMemoryBlob(o2::pmr::vector<char>& blob)
406+
static T* extractFromMemoryBlob(std::pmr::vector<char>& blob)
407407
{
408408
auto obj = static_cast<T*>(interpretAsTMemFileAndExtract(blob.data(), blob.size(), typeid(T)));
409409
if constexpr (std::is_base_of<o2::conf::ConfigurableParam, T>::value) {
@@ -576,9 +576,6 @@ class CcdbApi //: public DatabaseInterface
576576
// convert type_info to TClass, throw on failure
577577
static TClass* tinfo2TClass(std::type_info const& tinfo);
578578

579-
// split string on delimiters and return tokens as vector
580-
std::vector<std::string> splitString(const std::string& str, const char* delimiters);
581-
582579
typedef size_t (*CurlWriteCallback)(void*, size_t, size_t, void*);
583580

584581
void initCurlOptionsForRetrieve(CURL* curlHandle, void* pointer, CurlWriteCallback writeCallback, bool followRedirect = true) const;

CCDB/src/CcdbApi.cxx

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "Framework/DataTakingContext.h"
2525
#include <chrono>
2626
#include <memory>
27+
#include <ranges>
2728
#include <sstream>
2829
#include <TFile.h>
2930
#include <TGrid.h>
@@ -843,7 +844,7 @@ bool CcdbApi::retrieveBlob(std::string const& path, std::string const& targetdir
843844
return false;
844845
}
845846

846-
o2::pmr::vector<char> buff;
847+
std::pmr::vector<char> buff;
847848
std::map<std::string, std::string> headers;
848849
// avoid creating snapshot via loadFileToMemory itself
849850
loadFileToMemory(buff, path, metadata, timestamp, &headers, "", createdNotAfter, createdNotBefore, false);
@@ -1665,22 +1666,11 @@ int CcdbApi::updateMetadata(std::string const& path, std::map<std::string, std::
16651666
return ret;
16661667
}
16671668

1668-
std::vector<std::string> CcdbApi::splitString(const std::string& str, const char* delimiters)
1669-
{
1670-
std::vector<std::string> tokens;
1671-
char stringForStrTok[str.length() + 1];
1672-
strcpy(stringForStrTok, str.c_str());
1673-
char* token = strtok(stringForStrTok, delimiters);
1674-
while (token != nullptr) {
1675-
tokens.emplace_back(token);
1676-
token = strtok(nullptr, delimiters);
1677-
}
1678-
return tokens;
1679-
}
1680-
16811669
void CcdbApi::initHostsPool(std::string hosts)
16821670
{
1683-
hostsPool = splitString(hosts, ",;");
1671+
for (auto host : std::views::split(hosts, ",;")) {
1672+
hostsPool.emplace_back(&*host.begin(), std::ranges::distance(host));
1673+
}
16841674
}
16851675

16861676
std::string CcdbApi::getHostUrl(int hostIndex) const
@@ -1838,7 +1828,7 @@ void CcdbApi::removeLeakingSemaphores(std::string const& snapshotdir, bool remov
18381828

18391829
void CcdbApi::getFromSnapshot(bool createSnapshot, std::string const& path,
18401830
long timestamp, std::map<std::string, std::string>& headers,
1841-
std::string& snapshotpath, o2::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const
1831+
std::string& snapshotpath, std::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const
18421832
{
18431833
if (createSnapshot) { // create named semaphore
18441834
std::string logfile = mSnapshotCachePath + "/log";
@@ -1892,7 +1882,7 @@ void CcdbApi::loadFileToMemory(std::vector<char>& dest, std::string const& path,
18921882
std::map<std::string, std::string>* headers, std::string const& etag,
18931883
const std::string& createdNotAfter, const std::string& createdNotBefore, bool considerSnapshot) const
18941884
{
1895-
o2::pmr::vector<char> destP;
1885+
std::pmr::vector<char> destP;
18961886
destP.reserve(dest.size());
18971887
loadFileToMemory(destP, path, metadata, timestamp, headers, etag, createdNotAfter, createdNotBefore, considerSnapshot);
18981888
dest.clear();
@@ -1902,7 +1892,7 @@ void CcdbApi::loadFileToMemory(std::vector<char>& dest, std::string const& path,
19021892
}
19031893
}
19041894

1905-
void CcdbApi::loadFileToMemory(o2::pmr::vector<char>& dest, std::string const& path,
1895+
void CcdbApi::loadFileToMemory(std::pmr::vector<char>& dest, std::string const& path,
19061896
std::map<std::string, std::string> const& metadata, long timestamp,
19071897
std::map<std::string, std::string>* headers, std::string const& etag,
19081898
const std::string& createdNotAfter, const std::string& createdNotBefore, bool considerSnapshot) const
@@ -1920,7 +1910,7 @@ void CcdbApi::loadFileToMemory(o2::pmr::vector<char>& dest, std::string const& p
19201910
vectoredLoadFileToMemory(contexts);
19211911
}
19221912

1923-
void CcdbApi::appendFlatHeader(o2::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers)
1913+
void CcdbApi::appendFlatHeader(std::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers)
19241914
{
19251915
size_t hsize = getFlatHeaderSize(headers), cnt = dest.size();
19261916
dest.resize(cnt + hsize);
@@ -1985,7 +1975,7 @@ void CcdbApi::vectoredLoadFileToMemory(std::vector<RequestContext>& requestConte
19851975
}
19861976
}
19871977

1988-
bool CcdbApi::loadLocalContentToMemory(o2::pmr::vector<char>& dest, std::string& url) const
1978+
bool CcdbApi::loadLocalContentToMemory(std::pmr::vector<char>& dest, std::string& url) const
19891979
{
19901980
if (url.find("alien:/", 0) != std::string::npos) {
19911981
std::map<std::string, std::string> localHeaders;
@@ -2013,7 +2003,7 @@ bool CcdbApi::loadLocalContentToMemory(o2::pmr::vector<char>& dest, std::string&
20132003
return false;
20142004
}
20152005

2016-
void CcdbApi::loadFileToMemory(o2::pmr::vector<char>& dest, const std::string& path, std::map<std::string, std::string>* localHeaders, bool fetchLocalMetaData) const
2006+
void CcdbApi::loadFileToMemory(std::pmr::vector<char>& dest, const std::string& path, std::map<std::string, std::string>* localHeaders, bool fetchLocalMetaData) const
20172007
{
20182008
// Read file to memory as vector. For special case of the locally cached file retriev metadata stored directly in the file
20192009
constexpr size_t MaxCopySize = 0x1L << 25;

CCDB/test/testCcdbApi.cxx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,7 @@ BOOST_AUTO_TEST_CASE(multi_host_test)
560560
api.init("http://bogus-host.cern.ch,http://ccdb-test.cern.ch:8080");
561561
std::map<std::string, std::string> metadata;
562562
std::map<std::string, std::string> headers;
563-
o2::pmr::vector<char> dst;
563+
std::pmr::vector<char> dst;
564564
std::string url = "Analysis/ALICE3/Centrality";
565565
api.loadFileToMemory(dst, url, metadata, 1645780010602, &headers, "", "", "", true);
566566
BOOST_CHECK(dst.size() != 0);
@@ -572,7 +572,7 @@ BOOST_AUTO_TEST_CASE(vectored)
572572
api.init("http://ccdb-test.cern.ch:8080");
573573

574574
int TEST_SAMPLE_SIZE = 5;
575-
std::vector<o2::pmr::vector<char>> dests(TEST_SAMPLE_SIZE);
575+
std::vector<std::pmr::vector<char>> dests(TEST_SAMPLE_SIZE);
576576
std::vector<std::map<std::string, std::string>> metadatas(TEST_SAMPLE_SIZE);
577577
std::vector<std::map<std::string, std::string>> headers(TEST_SAMPLE_SIZE);
578578

CCDB/test/testCcdbApiDownloader.cxx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,12 +116,12 @@ size_t writeCallbackNoLambda(void* contents, size_t size, size_t nmemb, void* ch
116116
return realsize;
117117
}
118118

119-
std::vector<CURL*> prepareAsyncHandles(size_t num, std::vector<o2::pmr::vector<char>*>& dests)
119+
std::vector<CURL*> prepareAsyncHandles(size_t num, std::vector<std::pmr::vector<char>*>& dests)
120120
{
121121
std::vector<CURL*> handles;
122122

123123
for (int i = 0; i < num; i++) {
124-
auto dest = new o2::pmr::vector<char>();
124+
auto dest = new std::pmr::vector<char>();
125125
dests.push_back(dest);
126126
CURL* curl_handle = curl_easy_init();
127127
handles.push_back(curl_handle);
@@ -154,7 +154,7 @@ BOOST_AUTO_TEST_CASE(asynch_schedule_test)
154154
}
155155

156156
CCDBDownloader downloader;
157-
std::vector<o2::pmr::vector<char>*> dests;
157+
std::vector<std::pmr::vector<char>*> dests;
158158
auto handles = prepareAsyncHandles(TRANSFERS, dests);
159159
size_t transfersLeft = 0;
160160

Common/ML/include/ML/OrtInterface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ class OrtModel
116116
int32_t mInputsTotal = 0, mOutputsTotal = 0; // Total number of inputs and outputs
117117

118118
// Environment settings
119-
bool mInitialized = false;
119+
bool mInitialized = false, mDeterministicMode = false;
120120
std::string mModelPath, mEnvName = "", mDeviceType = "CPU", mThreadAffinity = ""; // device options should be cpu, rocm, migraphx, cuda
121121
int32_t mIntraOpNumThreads = 1, mInterOpNumThreads = 1, mDeviceId = -1, mEnableProfiling = 0, mLoggingLevel = 0, mAllocateDeviceMemory = 0, mEnableOptimizations = 0;
122122

Common/ML/src/OrtInterface.cxx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ void OrtModel::initOptions(std::unordered_map<std::string, std::string> optionsM
6868
mEnableProfiling = (optionsMap.contains("enable-profiling") ? std::stoi(optionsMap["enable-profiling"]) : 0);
6969
mEnableOptimizations = (optionsMap.contains("enable-optimizations") ? std::stoi(optionsMap["enable-optimizations"]) : 0);
7070
mEnvName = (optionsMap.contains("onnx-environment-name") ? optionsMap["onnx-environment-name"] : "onnx_model_inference");
71+
mDeterministicMode = (optionsMap.contains("deterministic-compute") ? std::stoi(optionsMap["deterministic-compute"]) : 0);
7172

7273
if (mDeviceType == "CPU") {
7374
(mPImplOrt->sessionOptions).SetIntraOpNumThreads(mIntraOpNumThreads);
@@ -99,6 +100,10 @@ void OrtModel::initOptions(std::unordered_map<std::string, std::string> optionsM
99100
(mPImplOrt->sessionOptions).DisableProfiling();
100101
}
101102

103+
if (mDeterministicMode > 0) {
104+
(mPImplOrt->sessionOptions).AddConfigEntry("session_options.use_deterministic_compute", "1");
105+
}
106+
102107
(mPImplOrt->sessionOptions).SetGraphOptimizationLevel(GraphOptimizationLevel(mEnableOptimizations));
103108
(mPImplOrt->sessionOptions).SetLogSeverityLevel(OrtLoggingLevel(mLoggingLevel));
104109

DataFormats/Detectors/TOF/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ o2_add_library(DataFormatsTOF
1616
src/CalibLHCphaseTOF.cxx
1717
src/CalibTimeSlewingParamTOF.cxx
1818
src/CTF.cxx
19-
src/ParameterContainers.cxx
2019
src/CalibInfoCluster.cxx
2120
src/CosmicInfo.cxx
2221
src/Diagnostic.cxx

DataFormats/Detectors/TOF/include/DataFormatsTOF/ParameterContainers.h

Lines changed: 38 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class Parameters
3737
Parameters(std::array<std::string, nPar> parNames, std::string name) : mName{name}, mPar{}, mParNames{parNames} {};
3838

3939
/// Default destructor
40-
~Parameters() = default;
40+
virtual ~Parameters() = default; // Ensure proper cleanup in derived classes
4141

4242
/// Setter for the parameter at position iparam
4343
/// \param iparam index in the array of the parameters
@@ -183,10 +183,27 @@ class ParameterCollection : public TNamed
183183
/// @param value parameter to add to the stored information
184184
/// @param pass key to look for in the stored information e.g. pass
185185
/// @return true if found and configured false if not fully configured
186-
bool addParameter(const std::string& pass, const std::string& parName, float value);
186+
bool addParameter(const std::string& pass, const std::string& parName, float value)
187+
{
188+
const bool alreadyPresent = hasKey(pass);
189+
if (alreadyPresent) {
190+
LOG(debug) << "Changing parametrization corresponding to key " << pass << " from size " << mParameters[pass].size() << " to " << parName;
191+
} else {
192+
mParameters[pass] = std::unordered_map<std::string, paramvar_t>{};
193+
LOG(debug) << "Adding new parametrization corresponding to key " << pass << ": " << parName;
194+
}
195+
mParameters[pass][parName] = value;
196+
return true;
197+
}
187198

188199
/// @return the size of the container i.e. the number of stored keys (or passes)
189-
int getSize(const std::string& pass) const;
200+
int getSize(const std::string& pass) const
201+
{
202+
if (!hasKey(pass)) {
203+
return -1;
204+
}
205+
return mParameters.at(pass).size();
206+
}
190207

191208
/// @brief Function to push the parameters from the sub container into the collection and store it under a given key
192209
/// @tparam ParType type of the parameter container
@@ -214,10 +231,26 @@ class ParameterCollection : public TNamed
214231

215232
/// @brief printing function for the content of the pass
216233
/// @param pass pass to print
217-
void print(const std::string& pass) const;
234+
void print(const std::string& pass) const
235+
{
236+
const auto& size = getSize(pass);
237+
if (size < 0) {
238+
LOG(info) << "empty pass: " << pass;
239+
return;
240+
}
241+
LOG(info) << "Pass \"" << pass << "\" with size " << size;
242+
for (const auto& [par, value] : mParameters.at(pass)) {
243+
LOG(info) << "par name = " << par << ", value = " << value;
244+
}
245+
}
218246

219247
/// @brief printing function for the full content of the container
220-
void print() const;
248+
void print() const
249+
{
250+
for (const auto& [pass, pars] : mParameters) {
251+
print(pass);
252+
}
253+
}
221254

222255
/// @brief Getter of the full map of parameters stored in the container
223256
/// @return returns the full map of parameters

DataFormats/Detectors/TOF/src/ParameterContainers.cxx

Lines changed: 0 additions & 62 deletions
This file was deleted.

0 commit comments

Comments
 (0)