Skip to content

Commit 3ae40d7

Browse files
committed
Revert "DPL: move to std::pmr where possible"
This reverts commit 83467b3.
1 parent 6fe38af commit 3ae40d7

File tree

37 files changed

+128
-115
lines changed

37 files changed

+128
-115
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-
std::pmr::vector<char>* object = nullptr;
44+
o2::pmr::vector<char>* object = nullptr;
4545
int counter = 0;
4646
};
4747

CCDB/include/CCDB/CcdbApi.h

Lines changed: 9 additions & 9 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-
std::pmr::vector<char>& dest;
358+
o2::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(std::pmr::vector<char>& d,
368+
RequestContext(o2::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, std::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const;
382+
std::string& snapshotpath, o2::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(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,
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,
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(std::pmr::vector<char>& dest, std::string& url) const;
398+
bool loadLocalContentToMemory(o2::pmr::vector<char>& dest, std::string& url) const;
399399

400400
// add annotated flattened headers in the end of the blob
401-
static void appendFlatHeader(std::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers);
401+
static void appendFlatHeader(o2::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 std::pmr::vector<char>& v) { return v.size() == 0 && v.capacity() > 0; }
404+
static bool isMemoryFileInvalid(const o2::pmr::vector<char>& v) { return v.size() == 0 && v.capacity() > 0; }
405405
template <typename T>
406-
static T* extractFromMemoryBlob(std::pmr::vector<char>& blob)
406+
static T* extractFromMemoryBlob(o2::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) {

CCDB/src/CcdbApi.cxx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -844,7 +844,7 @@ bool CcdbApi::retrieveBlob(std::string const& path, std::string const& targetdir
844844
return false;
845845
}
846846

847-
std::pmr::vector<char> buff;
847+
o2::pmr::vector<char> buff;
848848
std::map<std::string, std::string> headers;
849849
// avoid creating snapshot via loadFileToMemory itself
850850
loadFileToMemory(buff, path, metadata, timestamp, &headers, "", createdNotAfter, createdNotBefore, false);
@@ -1830,7 +1830,7 @@ void CcdbApi::removeLeakingSemaphores(std::string const& snapshotdir, bool remov
18301830

18311831
void CcdbApi::getFromSnapshot(bool createSnapshot, std::string const& path,
18321832
long timestamp, std::map<std::string, std::string>& headers,
1833-
std::string& snapshotpath, std::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const
1833+
std::string& snapshotpath, o2::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const
18341834
{
18351835
if (createSnapshot) { // create named semaphore
18361836
std::string logfile = mSnapshotCachePath + "/log";
@@ -1884,7 +1884,7 @@ void CcdbApi::loadFileToMemory(std::vector<char>& dest, std::string const& path,
18841884
std::map<std::string, std::string>* headers, std::string const& etag,
18851885
const std::string& createdNotAfter, const std::string& createdNotBefore, bool considerSnapshot) const
18861886
{
1887-
std::pmr::vector<char> destP;
1887+
o2::pmr::vector<char> destP;
18881888
destP.reserve(dest.size());
18891889
loadFileToMemory(destP, path, metadata, timestamp, headers, etag, createdNotAfter, createdNotBefore, considerSnapshot);
18901890
dest.clear();
@@ -1894,7 +1894,7 @@ void CcdbApi::loadFileToMemory(std::vector<char>& dest, std::string const& path,
18941894
}
18951895
}
18961896

1897-
void CcdbApi::loadFileToMemory(std::pmr::vector<char>& dest, std::string const& path,
1897+
void CcdbApi::loadFileToMemory(o2::pmr::vector<char>& dest, std::string const& path,
18981898
std::map<std::string, std::string> const& metadata, long timestamp,
18991899
std::map<std::string, std::string>* headers, std::string const& etag,
19001900
const std::string& createdNotAfter, const std::string& createdNotBefore, bool considerSnapshot) const
@@ -1912,7 +1912,7 @@ void CcdbApi::loadFileToMemory(std::pmr::vector<char>& dest, std::string const&
19121912
vectoredLoadFileToMemory(contexts);
19131913
}
19141914

1915-
void CcdbApi::appendFlatHeader(std::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers)
1915+
void CcdbApi::appendFlatHeader(o2::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers)
19161916
{
19171917
size_t hsize = getFlatHeaderSize(headers), cnt = dest.size();
19181918
dest.resize(cnt + hsize);
@@ -1977,7 +1977,7 @@ void CcdbApi::vectoredLoadFileToMemory(std::vector<RequestContext>& requestConte
19771977
}
19781978
}
19791979

1980-
bool CcdbApi::loadLocalContentToMemory(std::pmr::vector<char>& dest, std::string& url) const
1980+
bool CcdbApi::loadLocalContentToMemory(o2::pmr::vector<char>& dest, std::string& url) const
19811981
{
19821982
if (url.find("alien:/", 0) != std::string::npos) {
19831983
std::map<std::string, std::string> localHeaders;
@@ -2005,7 +2005,7 @@ bool CcdbApi::loadLocalContentToMemory(std::pmr::vector<char>& dest, std::string
20052005
return false;
20062006
}
20072007

2008-
void CcdbApi::loadFileToMemory(std::pmr::vector<char>& dest, const std::string& path, std::map<std::string, std::string>* localHeaders, bool fetchLocalMetaData) const
2008+
void CcdbApi::loadFileToMemory(o2::pmr::vector<char>& dest, const std::string& path, std::map<std::string, std::string>* localHeaders, bool fetchLocalMetaData) const
20092009
{
20102010
// Read file to memory as vector. For special case of the locally cached file retriev metadata stored directly in the file
20112011
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-
std::pmr::vector<char> dst;
563+
o2::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<std::pmr::vector<char>> dests(TEST_SAMPLE_SIZE);
575+
std::vector<o2::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<std::pmr::vector<char>*>& dests)
119+
std::vector<CURL*> prepareAsyncHandles(size_t num, std::vector<o2::pmr::vector<char>*>& dests)
120120
{
121121
std::vector<CURL*> handles;
122122

123123
for (int i = 0; i < num; i++) {
124-
auto dest = new std::pmr::vector<char>();
124+
auto dest = new o2::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<std::pmr::vector<char>*> dests;
157+
std::vector<o2::pmr::vector<char>*> dests;
158158
auto handles = prepareAsyncHandles(TRANSFERS, dests);
159159
size_t transfersLeft = 0;
160160

DataFormats/Headers/include/Headers/Stack.h

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@
1111
#ifndef O2_HEADERS_STACK_H
1212
#define O2_HEADERS_STACK_H
1313

14+
#include "MemoryResources/MemoryResources.h"
1415
#include "Headers/DataHeader.h"
1516

16-
#include <memory_resource>
17-
1817
namespace o2::header
1918
{
2019
//__________________________________________________________________________________________________
@@ -33,7 +32,7 @@ namespace o2::header
3332
/// - returns a Stack ready to be shipped.
3433
struct Stack {
3534

36-
using memory_resource = std::pmr::memory_resource;
35+
using memory_resource = o2::pmr::memory_resource;
3736

3837
private:
3938
struct freeobj {
@@ -43,7 +42,7 @@ struct Stack {
4342
};
4443

4544
public:
46-
using allocator_type = std::pmr::polymorphic_allocator<std::byte>;
45+
using allocator_type = fair::mq::pmr::polymorphic_allocator<std::byte>;
4746
using value_type = std::byte;
4847
using BufferType = std::unique_ptr<value_type[], freeobj>; // this gives us proper default move semantics for free
4948

@@ -88,9 +87,9 @@ struct Stack {
8887
/// all headers must derive from BaseHeader, in addition also other stacks can be passed to ctor.
8988
template <typename FirstArgType, typename... Headers,
9089
typename std::enable_if_t<
91-
!std::is_convertible<FirstArgType, std::pmr::polymorphic_allocator<std::byte>>::value, int> = 0>
90+
!std::is_convertible<FirstArgType, fair::mq::pmr::polymorphic_allocator<std::byte>>::value, int> = 0>
9291
Stack(FirstArgType&& firstHeader, Headers&&... headers)
93-
: Stack(std::pmr::new_delete_resource(), std::forward<FirstArgType>(firstHeader),
92+
: Stack(fair::mq::pmr::new_delete_resource(), std::forward<FirstArgType>(firstHeader),
9493
std::forward<Headers>(headers)...)
9594
{
9695
}
@@ -141,7 +140,7 @@ struct Stack {
141140
constexpr static size_t calculateSize() { return 0; }
142141

143142
private:
144-
allocator_type allocator{std::pmr::new_delete_resource()};
143+
allocator_type allocator{fair::mq::pmr::new_delete_resource()};
145144
size_t bufferSize{0};
146145
BufferType buffer{nullptr, freeobj{allocator.resource()}};
147146

DataFormats/Headers/test/testDataHeader.cxx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ BOOST_AUTO_TEST_CASE(headerStack_test)
314314
BOOST_CHECK(h3->secret == 42);
315315

316316
// test constructing from a buffer and an additional header
317-
Stack s5(std::pmr::new_delete_resource(), s1.data(), Stack{}, meta);
317+
using namespace fair::mq::pmr;
318+
Stack s5(new_delete_resource(), s1.data(), Stack{}, meta);
318319
BOOST_CHECK(s5.size() == s1.size() + sizeof(meta));
319320
// check if we can find the header even though there was an empty stack in the middle
320321
h3 = get<test::MetaHeader*>(s5.data());
@@ -328,7 +329,7 @@ BOOST_AUTO_TEST_CASE(headerStack_test)
328329
BOOST_CHECK(h4 == h3);
329330

330331
// let's assume we have some stack that is missing the required DataHeader at the beginning:
331-
Stack s6{std::pmr::new_delete_resource(), DataHeader{}, s1.data()};
332+
Stack s6{new_delete_resource(), DataHeader{}, s1.data()};
332333
BOOST_CHECK(s6.size() == sizeof(DataHeader) + s1.size());
333334
}
334335

DataFormats/MemoryResources/include/MemoryResources/MemoryResources.h

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@
2828
#ifndef ALICEO2_MEMORY_RESOURCES_
2929
#define ALICEO2_MEMORY_RESOURCES_
3030

31+
#include <boost/container/pmr/memory_resource.hpp>
32+
#include <boost/container/pmr/monotonic_buffer_resource.hpp>
33+
#include <boost/container/pmr/polymorphic_allocator.hpp>
3134
#include <cstring>
3235
#include <string>
3336
#include <type_traits>
@@ -42,8 +45,12 @@
4245
namespace o2::pmr
4346
{
4447

48+
using FairMQMemoryResource = fair::mq::MemoryResource;
49+
using ChannelResource = fair::mq::ChannelResource;
50+
using namespace fair::mq::pmr;
51+
4552
template <typename ContainerT>
46-
fair::mq::MessagePtr getMessage(ContainerT&& container, fair::mq::MemoryResource* targetResource = nullptr)
53+
fair::mq::MessagePtr getMessage(ContainerT&& container, FairMQMemoryResource* targetResource = nullptr)
4754
{
4855
return fair::mq::getMessage(std::forward<ContainerT>(container), targetResource);
4956
}
@@ -53,7 +60,7 @@ fair::mq::MessagePtr getMessage(ContainerT&& container, fair::mq::MemoryResource
5360
/// Ownership of hte message is taken. Meant to be used for transparent data adoption in containers.
5461
/// In combination with the SpectatorAllocator this is an alternative to using span, as raw memory
5562
/// (e.g. an existing buffer message) will be accessible with appropriate container.
56-
class MessageResource : public fair::mq::MemoryResource
63+
class MessageResource : public FairMQMemoryResource
5764
{
5865

5966
public:
@@ -75,7 +82,7 @@ class MessageResource : public fair::mq::MemoryResource
7582
size_t getNumberOfMessages() const noexcept override { return mMessageData ? 1 : 0; }
7683

7784
protected:
78-
fair::mq::MemoryResource* mUpstream{nullptr};
85+
FairMQMemoryResource* mUpstream{nullptr};
7986
size_t mMessageSize{0};
8087
void* mMessageData{nullptr};
8188
bool initialImport{true};
@@ -106,14 +113,14 @@ class MessageResource : public fair::mq::MemoryResource
106113

107114
// The NoConstructAllocator behaves like the normal pmr vector but does not call constructors / destructors
108115
template <typename T>
109-
class NoConstructAllocator : public std::pmr::polymorphic_allocator<T>
116+
class NoConstructAllocator : public fair::mq::pmr::polymorphic_allocator<T>
110117
{
111118
public:
112-
using std::pmr::polymorphic_allocator<T>::polymorphic_allocator;
119+
using fair::mq::pmr::polymorphic_allocator<T>::polymorphic_allocator;
113120
using propagate_on_container_move_assignment = std::true_type;
114121

115122
template <typename... Args>
116-
NoConstructAllocator(Args&&... args) : std::pmr::polymorphic_allocator<T>(std::forward<Args>(args)...)
123+
NoConstructAllocator(Args&&... args) : fair::mq::pmr::polymorphic_allocator<T>(std::forward<Args>(args)...)
117124
{
118125
}
119126

@@ -138,13 +145,13 @@ class NoConstructAllocator : public std::pmr::polymorphic_allocator<T>
138145
//__________________________________________________________________________________________________
139146
//__________________________________________________________________________________________________
140147

141-
using BytePmrAllocator = std::pmr::polymorphic_allocator<std::byte>;
148+
using BytePmrAllocator = fair::mq::pmr::polymorphic_allocator<std::byte>;
142149
template <class T>
143-
using vector = std::vector<T, std::pmr::polymorphic_allocator<T>>;
150+
using vector = std::vector<T, fair::mq::pmr::polymorphic_allocator<T>>;
144151

145152
//__________________________________________________________________________________________________
146153
/// Get the allocator associated to a transport factory
147-
inline static fair::mq::MemoryResource* getTransportAllocator(fair::mq::TransportFactory* factory)
154+
inline static FairMQMemoryResource* getTransportAllocator(fair::mq::TransportFactory* factory)
148155
{
149156
return *factory;
150157
}

DataFormats/MemoryResources/test/testMemoryResources.cxx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include <fairmq/ProgOptions.h>
2020
#include <vector>
2121
#include <cstring>
22-
#include <memory_resource>
2322

2423
namespace o2::pmr
2524
{
@@ -61,6 +60,8 @@ BOOST_AUTO_TEST_CASE(transportallocatormap_test)
6160
BOOST_CHECK(_tmp == allocZMQ);
6261
}
6362

63+
using namespace fair::mq::pmr;
64+
6465
BOOST_AUTO_TEST_CASE(allocator_test)
6566
{
6667
size_t session{(size_t)getpid() * 1000 + 1};
@@ -75,7 +76,7 @@ BOOST_AUTO_TEST_CASE(allocator_test)
7576
testData::nconstructions = 0;
7677

7778
{
78-
std::vector<testData, std::pmr::polymorphic_allocator<testData>> v(std::pmr::polymorphic_allocator<testData>{allocZMQ});
79+
std::vector<testData, polymorphic_allocator<testData>> v(polymorphic_allocator<testData>{allocZMQ});
7980
v.reserve(3);
8081
BOOST_CHECK(v.capacity() == 3);
8182
BOOST_CHECK(allocZMQ->getNumberOfMessages() == 1);
@@ -109,7 +110,7 @@ BOOST_AUTO_TEST_CASE(getMessage_test)
109110

110111
// test message creation on the same channel it was allocated with
111112
{
112-
std::vector<testData, std::pmr::polymorphic_allocator<testData>> v(std::pmr::polymorphic_allocator<testData>{allocZMQ});
113+
std::vector<testData, polymorphic_allocator<testData>> v(polymorphic_allocator<testData>{allocZMQ});
113114
v.emplace_back(1);
114115
v.emplace_back(2);
115116
v.emplace_back(3);
@@ -124,7 +125,7 @@ BOOST_AUTO_TEST_CASE(getMessage_test)
124125

125126
// test message creation on a different channel than it was allocated with
126127
{
127-
std::vector<testData, std::pmr::polymorphic_allocator<testData>> v(std::pmr::polymorphic_allocator<testData>{allocZMQ});
128+
std::vector<testData, polymorphic_allocator<testData>> v(polymorphic_allocator<testData>{allocZMQ});
128129
v.emplace_back(4);
129130
v.emplace_back(5);
130131
v.emplace_back(6);
@@ -136,6 +137,7 @@ BOOST_AUTO_TEST_CASE(getMessage_test)
136137
BOOST_CHECK(message->GetSize() == 3 * sizeof(testData));
137138
messageArray = static_cast<int*>(message->GetData());
138139
BOOST_CHECK(messageArray[0] == 4 && messageArray[1] == 5 && messageArray[2] == 6);
140+
139141
}
140142

141143
}; // namespace o2::pmr

Detectors/CTP/reconstruction/include/CTPReconstruction/CTFCoder.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include "CTPReconstruction/CTFHelper.h"
2727
#include "CTPReconstruction/RawDataDecoder.h"
2828
#include "DataFormatsCTP/Configuration.h"
29-
#include <vector>
3029

3130
class TTree;
3231

@@ -226,7 +225,7 @@ o2::ctf::CTFIOSize CTFCoder::decode(const CTF::base& ec, VTRG& data, LumiInfo& l
226225
trgclassmask = mCTPConfig.getTriggerClassMask();
227226
}
228227
// std::cout << "trgclassmask:" << std::hex << trgclassmask << std::dec << std::endl;
229-
std::pmr::vector<CTPDigit> digits;
228+
o2::pmr::vector<CTPDigit> digits;
230229
o2::ctp::RawDataDecoder::shiftInputs(digitsMap, digits, mFirstTFOrbit, trgclassmask);
231230
for (auto const& dig : digits) {
232231
data.emplace_back(dig);

0 commit comments

Comments
 (0)