Skip to content

Commit 83467b3

Browse files
committed
DPL: move to std::pmr where possible
1 parent 0e23762 commit 83467b3

File tree

37 files changed

+115
-128
lines changed

37 files changed

+115
-128
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 & 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-
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) {

CCDB/src/CcdbApi.cxx

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

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

18391839
void CcdbApi::getFromSnapshot(bool createSnapshot, std::string const& path,
18401840
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
1841+
std::string& snapshotpath, std::pmr::vector<char>& dest, int& fromSnapshot, std::string const& etag) const
18421842
{
18431843
if (createSnapshot) { // create named semaphore
18441844
std::string logfile = mSnapshotCachePath + "/log";
@@ -1892,7 +1892,7 @@ void CcdbApi::loadFileToMemory(std::vector<char>& dest, std::string const& path,
18921892
std::map<std::string, std::string>* headers, std::string const& etag,
18931893
const std::string& createdNotAfter, const std::string& createdNotBefore, bool considerSnapshot) const
18941894
{
1895-
o2::pmr::vector<char> destP;
1895+
std::pmr::vector<char> destP;
18961896
destP.reserve(dest.size());
18971897
loadFileToMemory(destP, path, metadata, timestamp, headers, etag, createdNotAfter, createdNotBefore, considerSnapshot);
18981898
dest.clear();
@@ -1902,7 +1902,7 @@ void CcdbApi::loadFileToMemory(std::vector<char>& dest, std::string const& path,
19021902
}
19031903
}
19041904

1905-
void CcdbApi::loadFileToMemory(o2::pmr::vector<char>& dest, std::string const& path,
1905+
void CcdbApi::loadFileToMemory(std::pmr::vector<char>& dest, std::string const& path,
19061906
std::map<std::string, std::string> const& metadata, long timestamp,
19071907
std::map<std::string, std::string>* headers, std::string const& etag,
19081908
const std::string& createdNotAfter, const std::string& createdNotBefore, bool considerSnapshot) const
@@ -1920,7 +1920,7 @@ void CcdbApi::loadFileToMemory(o2::pmr::vector<char>& dest, std::string const& p
19201920
vectoredLoadFileToMemory(contexts);
19211921
}
19221922

1923-
void CcdbApi::appendFlatHeader(o2::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers)
1923+
void CcdbApi::appendFlatHeader(std::pmr::vector<char>& dest, const std::map<std::string, std::string>& headers)
19241924
{
19251925
size_t hsize = getFlatHeaderSize(headers), cnt = dest.size();
19261926
dest.resize(cnt + hsize);
@@ -1985,7 +1985,7 @@ void CcdbApi::vectoredLoadFileToMemory(std::vector<RequestContext>& requestConte
19851985
}
19861986
}
19871987

1988-
bool CcdbApi::loadLocalContentToMemory(o2::pmr::vector<char>& dest, std::string& url) const
1988+
bool CcdbApi::loadLocalContentToMemory(std::pmr::vector<char>& dest, std::string& url) const
19891989
{
19901990
if (url.find("alien:/", 0) != std::string::npos) {
19911991
std::map<std::string, std::string> localHeaders;
@@ -2013,7 +2013,7 @@ bool CcdbApi::loadLocalContentToMemory(o2::pmr::vector<char>& dest, std::string&
20132013
return false;
20142014
}
20152015

2016-
void CcdbApi::loadFileToMemory(o2::pmr::vector<char>& dest, const std::string& path, std::map<std::string, std::string>* localHeaders, bool fetchLocalMetaData) const
2016+
void CcdbApi::loadFileToMemory(std::pmr::vector<char>& dest, const std::string& path, std::map<std::string, std::string>* localHeaders, bool fetchLocalMetaData) const
20172017
{
20182018
// Read file to memory as vector. For special case of the locally cached file retriev metadata stored directly in the file
20192019
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

DataFormats/Headers/include/Headers/Stack.h

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

14-
#include "MemoryResources/MemoryResources.h"
1514
#include "Headers/DataHeader.h"
1615

16+
#include <memory_resource>
17+
1718
namespace o2::header
1819
{
1920
//__________________________________________________________________________________________________
@@ -32,7 +33,7 @@ namespace o2::header
3233
/// - returns a Stack ready to be shipped.
3334
struct Stack {
3435

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

3738
private:
3839
struct freeobj {
@@ -42,7 +43,7 @@ struct Stack {
4243
};
4344

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

@@ -87,9 +88,9 @@ struct Stack {
8788
/// all headers must derive from BaseHeader, in addition also other stacks can be passed to ctor.
8889
template <typename FirstArgType, typename... Headers,
8990
typename std::enable_if_t<
90-
!std::is_convertible<FirstArgType, fair::mq::pmr::polymorphic_allocator<std::byte>>::value, int> = 0>
91+
!std::is_convertible<FirstArgType, std::pmr::polymorphic_allocator<std::byte>>::value, int> = 0>
9192
Stack(FirstArgType&& firstHeader, Headers&&... headers)
92-
: Stack(fair::mq::pmr::new_delete_resource(), std::forward<FirstArgType>(firstHeader),
93+
: Stack(std::pmr::new_delete_resource(), std::forward<FirstArgType>(firstHeader),
9394
std::forward<Headers>(headers)...)
9495
{
9596
}
@@ -140,7 +141,7 @@ struct Stack {
140141
constexpr static size_t calculateSize() { return 0; }
141142

142143
private:
143-
allocator_type allocator{fair::mq::pmr::new_delete_resource()};
144+
allocator_type allocator{std::pmr::new_delete_resource()};
144145
size_t bufferSize{0};
145146
BufferType buffer{nullptr, freeobj{allocator.resource()}};
146147

DataFormats/Headers/test/testDataHeader.cxx

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

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

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

DataFormats/MemoryResources/include/MemoryResources/MemoryResources.h

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
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>
3431
#include <cstring>
3532
#include <string>
3633
#include <type_traits>
@@ -45,12 +42,8 @@
4542
namespace o2::pmr
4643
{
4744

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

6659
public:
@@ -82,7 +75,7 @@ class MessageResource : public FairMQMemoryResource
8275
size_t getNumberOfMessages() const noexcept override { return mMessageData ? 1 : 0; }
8376

8477
protected:
85-
FairMQMemoryResource* mUpstream{nullptr};
78+
fair::mq::MemoryResource* mUpstream{nullptr};
8679
size_t mMessageSize{0};
8780
void* mMessageData{nullptr};
8881
bool initialImport{true};
@@ -113,14 +106,14 @@ class MessageResource : public FairMQMemoryResource
113106

114107
// The NoConstructAllocator behaves like the normal pmr vector but does not call constructors / destructors
115108
template <typename T>
116-
class NoConstructAllocator : public fair::mq::pmr::polymorphic_allocator<T>
109+
class NoConstructAllocator : public std::pmr::polymorphic_allocator<T>
117110
{
118111
public:
119-
using fair::mq::pmr::polymorphic_allocator<T>::polymorphic_allocator;
112+
using std::pmr::polymorphic_allocator<T>::polymorphic_allocator;
120113
using propagate_on_container_move_assignment = std::true_type;
121114

122115
template <typename... Args>
123-
NoConstructAllocator(Args&&... args) : fair::mq::pmr::polymorphic_allocator<T>(std::forward<Args>(args)...)
116+
NoConstructAllocator(Args&&... args) : std::pmr::polymorphic_allocator<T>(std::forward<Args>(args)...)
124117
{
125118
}
126119

@@ -145,13 +138,13 @@ class NoConstructAllocator : public fair::mq::pmr::polymorphic_allocator<T>
145138
//__________________________________________________________________________________________________
146139
//__________________________________________________________________________________________________
147140

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

152145
//__________________________________________________________________________________________________
153146
/// Get the allocator associated to a transport factory
154-
inline static FairMQMemoryResource* getTransportAllocator(fair::mq::TransportFactory* factory)
147+
inline static fair::mq::MemoryResource* getTransportAllocator(fair::mq::TransportFactory* factory)
155148
{
156149
return *factory;
157150
}

DataFormats/MemoryResources/test/testMemoryResources.cxx

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

2324
namespace o2::pmr
2425
{
@@ -60,8 +61,6 @@ BOOST_AUTO_TEST_CASE(transportallocatormap_test)
6061
BOOST_CHECK(_tmp == allocZMQ);
6162
}
6263

63-
using namespace fair::mq::pmr;
64-
6564
BOOST_AUTO_TEST_CASE(allocator_test)
6665
{
6766
size_t session{(size_t)getpid() * 1000 + 1};
@@ -76,7 +75,7 @@ BOOST_AUTO_TEST_CASE(allocator_test)
7675
testData::nconstructions = 0;
7776

7877
{
79-
std::vector<testData, polymorphic_allocator<testData>> v(polymorphic_allocator<testData>{allocZMQ});
78+
std::vector<testData, std::pmr::polymorphic_allocator<testData>> v(std::pmr::polymorphic_allocator<testData>{allocZMQ});
8079
v.reserve(3);
8180
BOOST_CHECK(v.capacity() == 3);
8281
BOOST_CHECK(allocZMQ->getNumberOfMessages() == 1);
@@ -110,7 +109,7 @@ BOOST_AUTO_TEST_CASE(getMessage_test)
110109

111110
// test message creation on the same channel it was allocated with
112111
{
113-
std::vector<testData, polymorphic_allocator<testData>> v(polymorphic_allocator<testData>{allocZMQ});
112+
std::vector<testData, std::pmr::polymorphic_allocator<testData>> v(std::pmr::polymorphic_allocator<testData>{allocZMQ});
114113
v.emplace_back(1);
115114
v.emplace_back(2);
116115
v.emplace_back(3);
@@ -125,7 +124,7 @@ BOOST_AUTO_TEST_CASE(getMessage_test)
125124

126125
// test message creation on a different channel than it was allocated with
127126
{
128-
std::vector<testData, polymorphic_allocator<testData>> v(polymorphic_allocator<testData>{allocZMQ});
127+
std::vector<testData, std::pmr::polymorphic_allocator<testData>> v(std::pmr::polymorphic_allocator<testData>{allocZMQ});
129128
v.emplace_back(4);
130129
v.emplace_back(5);
131130
v.emplace_back(6);
@@ -137,7 +136,6 @@ BOOST_AUTO_TEST_CASE(getMessage_test)
137136
BOOST_CHECK(message->GetSize() == 3 * sizeof(testData));
138137
messageArray = static_cast<int*>(message->GetData());
139138
BOOST_CHECK(messageArray[0] == 4 && messageArray[1] == 5 && messageArray[2] == 6);
140-
141139
}
142140

143141
}; // namespace o2::pmr

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

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

3031
class TTree;
3132

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

0 commit comments

Comments
 (0)