Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Algorithm/include/Algorithm/TableView.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class TableView

/// descriptor pointing to payload of one frame
struct FrameData {
const byte* buffer = nullptr;
const std::byte* buffer = nullptr;
size_t size = 0;
};

Expand All @@ -94,7 +94,7 @@ class TableView
* @param seqSize Length of sequence
* @return number of inserted elements
*/
size_t addRow(RowDescType rowData, byte* seqData, size_t seqSize)
size_t addRow(RowDescType rowData, std::byte* seqData, size_t seqSize)
{
unsigned nFrames = mFrames.size();
unsigned currentRow = mRowData.size();
Expand All @@ -118,7 +118,7 @@ class TableView

// insert frame descriptor under key composed from header and row
auto result = mFrames.emplace(FrameIndex{*entry.header, currentRow},
FrameData{entry.payload, entry.length});
FrameData{(std::byte*)entry.payload, entry.length});
return result.second;
});
auto insertedFrames = mFrames.size() - nFrames;
Expand Down
6 changes: 3 additions & 3 deletions Algorithm/test/tableview.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ BOOST_AUTO_TEST_CASE(test_tableview_reverse)
dh2.subSpecification = 0xdeadbeef;
dh2.payloadSize = 0;

heartbeatview.addRow(dh1, tf1.buffer.get(), tf1.size());
heartbeatview.addRow(dh2, tf2.buffer.get(), tf2.size());
heartbeatview.addRow(dh1, (std::byte*)tf1.buffer.get(), tf1.size());
heartbeatview.addRow(dh2, (std::byte*)tf2.buffer.get(), tf2.size());

std::cout << "slots: " << heartbeatview.getNRows()
<< " columns: " << heartbeatview.getNColumns()
Expand Down Expand Up @@ -145,7 +145,7 @@ BOOST_AUTO_TEST_CASE(test_tableview_formaterror)
dh.subSpecification = 0;
dh.payloadSize = 0;

heartbeatview.addRow(dh, tf1.buffer.get(), tf1.size());
heartbeatview.addRow(dh, (std::byte*)tf1.buffer.get(), tf1.size());

BOOST_CHECK(heartbeatview.getNRows() == 0);
BOOST_CHECK(heartbeatview.getNColumns() == 0);
Expand Down
23 changes: 10 additions & 13 deletions DataFormats/Headers/include/Headers/DataHeader.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,15 @@
#ifndef ALICEO2_BASE_DATA_HEADER_
#define ALICEO2_BASE_DATA_HEADER_

#include <cstddef>
#include <cstdint>
#include <memory>
#include <cassert>
#include <cstring> //needed for memcmp
#include <algorithm> // std::min
#include <stdexcept>
#include <string>
#include <stdexcept>
#include <climits>
#include <limits>
// FIXME: for o2::byte. Use std::byte as soon as we move to C++17..
#include "MemoryResources/Types.h"
#include <cerrno>

namespace o2::header
{
Expand Down Expand Up @@ -285,7 +282,7 @@ struct Descriptor {
{
static_assert(L <= N + 1, "initializer string must not exceed descriptor size");
unsigned i = 0;
for (; in[i] && i < std::min(N, L); ++i) {
for (; in[i] && i < (N < L ? N : L); ++i) {
str[i] = in[i];
}
}
Expand Down Expand Up @@ -436,7 +433,7 @@ struct BaseHeader {
/// @brief access header in buffer
///
/// this is to guess if the buffer starting at b looks like a header
inline static const BaseHeader* get(const o2::byte* b, size_t /*len*/ = 0)
inline static const BaseHeader* get(const std::byte* b, size_t /*len*/ = 0)
{
return (b != nullptr && *(reinterpret_cast<const uint32_t*>(b)) == sMagicString)
? reinterpret_cast<const BaseHeader*>(b)
Expand All @@ -446,27 +443,27 @@ struct BaseHeader {
/// @brief access header in buffer
///
/// this is to guess if the buffer starting at b looks like a header
inline static BaseHeader* get(o2::byte* b, size_t /*len*/ = 0)
inline static BaseHeader* get(std::byte* b, size_t /*len*/ = 0)
{
return (b != nullptr && *(reinterpret_cast<uint32_t*>(b)) == sMagicString) ? reinterpret_cast<BaseHeader*>(b)
: nullptr;
}

constexpr uint32_t size() const noexcept { return headerSize; }
inline const o2::byte* data() const noexcept { return reinterpret_cast<const o2::byte*>(this); }
inline const std::byte* data() const noexcept { return reinterpret_cast<const std::byte*>(this); }

/// get the next header if any (const version)
inline const BaseHeader* next() const noexcept
{
// BaseHeader::get checks that next header starts with the BaseHeader information at the
// offset given by the size of the current header.
return (flagsNextHeader) ? BaseHeader::get(reinterpret_cast<const o2::byte*>(this) + headerSize) : nullptr;
return (flagsNextHeader) ? BaseHeader::get(reinterpret_cast<const std::byte*>(this) + headerSize) : nullptr;
}

/// get the next header if any (non-const version)
inline BaseHeader* next() noexcept
{
return (flagsNextHeader) ? BaseHeader::get(reinterpret_cast<o2::byte*>(this) + headerSize) : nullptr;
return (flagsNextHeader) ? BaseHeader::get(reinterpret_cast<std::byte*>(this) + headerSize) : nullptr;
}

/// check if the header matches expected version
Expand All @@ -485,7 +482,7 @@ struct BaseHeader {
/// use like this:
/// HeaderType* h = get<HeaderType*>(buffer)
template <typename HeaderType, typename std::enable_if_t<std::is_pointer<HeaderType>::value, int> = 0>
auto get(const o2::byte* buffer, size_t /*len*/ = 0)
auto get(const std::byte* buffer, size_t /*len*/ = 0)
{
using HeaderConstPtrType = const typename std::remove_pointer<HeaderType>::type*;
using HeaderValueType = typename std::remove_pointer<HeaderType>::type;
Expand Down Expand Up @@ -526,7 +523,7 @@ auto get(const o2::byte* buffer, size_t /*len*/ = 0)
template <typename HeaderType, typename std::enable_if_t<std::is_pointer<HeaderType>::value, int> = 0>
auto get(const void* buffer, size_t len = 0)
{
return get<HeaderType>(reinterpret_cast<const byte*>(buffer), len);
return get<HeaderType>(reinterpret_cast<const std::byte*>(buffer), len);
}

//__________________________________________________________________________________________________
Expand Down
26 changes: 13 additions & 13 deletions DataFormats/Headers/include/Headers/Stack.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ struct Stack {
struct freeobj {
freeobj(memory_resource* mr) : resource(mr) {}
memory_resource* resource{nullptr};
void operator()(o2::byte* ptr) { resource->deallocate(ptr, 0, 0); }
void operator()(std::byte* ptr) { resource->deallocate(ptr, 0, 0); }
};

public:
using allocator_type = boost::container::pmr::polymorphic_allocator<o2::byte>;
using value_type = o2::byte;
using allocator_type = boost::container::pmr::polymorphic_allocator<std::byte>;
using value_type = std::byte;
using BufferType = std::unique_ptr<value_type[], freeobj>; //this gives us proper default move semantics for free

Stack() = default;
Expand All @@ -57,16 +57,16 @@ struct Stack {
size_t size() const { return bufferSize; }
allocator_type get_allocator() const { return allocator; }
const BaseHeader* first() const { return reinterpret_cast<const BaseHeader*>(this->data()); }
static const BaseHeader* firstHeader(o2::byte const* buf) { return BaseHeader::get(buf); }
static const BaseHeader* lastHeader(o2::byte const* buf)
static const BaseHeader* firstHeader(std::byte const* buf) { return BaseHeader::get(buf); }
static const BaseHeader* lastHeader(std::byte const* buf)
{
const BaseHeader* last{firstHeader(buf)};
while (last && last->flagsNextHeader) {
last = last->next();
}
return last;
}
static size_t headerStackSize(o2::byte const* buf)
static size_t headerStackSize(std::byte const* buf)
{
size_t result = 0;
const BaseHeader* last{firstHeader(buf)};
Expand All @@ -88,7 +88,7 @@ struct Stack {
/// all headers must derive from BaseHeader, in addition also other stacks can be passed to ctor.
template <typename FirstArgType, typename... Headers,
typename std::enable_if_t<
!std::is_convertible<FirstArgType, boost::container::pmr::polymorphic_allocator<o2::byte>>::value, int> = 0>
!std::is_convertible<FirstArgType, boost::container::pmr::polymorphic_allocator<std::byte>>::value, int> = 0>
Stack(FirstArgType&& firstHeader, Headers&&... headers)
: Stack(boost::container::pmr::new_delete_resource(), std::forward<FirstArgType>(firstHeader),
std::forward<Headers>(headers)...)
Expand All @@ -100,7 +100,7 @@ struct Stack {
Stack(const allocator_type allocatorArg, Headers&&... headers)
: allocator{allocatorArg},
bufferSize{calculateSize(std::forward<Headers>(headers)...)},
buffer{static_cast<o2::byte*>(allocator.resource()->allocate(bufferSize, alignof(std::max_align_t))), freeobj{allocator.resource()}}
buffer{static_cast<std::byte*>(allocator.resource()->allocate(bufferSize, alignof(std::max_align_t))), freeobj{allocator.resource()}}
{
inject(buffer.get(), std::forward<Headers>(headers)...);
}
Expand All @@ -117,7 +117,7 @@ struct Stack {
constexpr static size_t calculateSize(T&& h) noexcept
{
//if it's a pointer (to a stack) traverse it
if constexpr (std::is_convertible_v<T, o2::byte*>) {
if constexpr (std::is_convertible_v<T, std::byte*>) {
const BaseHeader* next = BaseHeader::get(std::forward<T>(h));
if (!next) {
return 0;
Expand All @@ -143,7 +143,7 @@ struct Stack {

//______________________________________________________________________________________________
template <typename T>
static o2::byte* inject(o2::byte* here, T&& h, bool more = false) noexcept
static std::byte* inject(std::byte* here, T&& h, bool more = false) noexcept
{
using headerType = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
if (here == nullptr) {
Expand All @@ -168,7 +168,7 @@ struct Stack {
::new (static_cast<void*>(here)) headerType(std::forward<T>(h));
reinterpret_cast<BaseHeader*>(here)->flagsNextHeader = more;
return here + h.size();
} else if constexpr (std::is_same_v<headerType, o2::byte*>) {
} else if constexpr (std::is_same_v<headerType, std::byte*>) {
BaseHeader* from{BaseHeader::get(h)};
BaseHeader* last{nullptr};
while (from) {
Expand All @@ -188,7 +188,7 @@ struct Stack {

//______________________________________________________________________________________________
template <typename T, typename... Args>
static o2::byte* inject(o2::byte* here, T&& h, Args&&... args) noexcept
static std::byte* inject(std::byte* here, T&& h, Args&&... args) noexcept
{
bool more = hasNonEmptyArg(args...);
auto alsohere = inject(here, h, more);
Expand All @@ -210,7 +210,7 @@ struct Stack {
template <typename T>
static bool hasNonEmptyArg(const T& h) noexcept
{
if constexpr (std::is_convertible_v<T, o2::byte*>) {
if constexpr (std::is_convertible_v<T, std::byte*>) {
return get<BaseHeader*>(h);
} else {
if (h.size() > 0) {
Expand Down
8 changes: 4 additions & 4 deletions DataFormats/Headers/src/DataHeader.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ void o2::header::hexDump(const char* desc, const void* voidaddr, size_t len, siz
size_t i;
unsigned char buff[17]; // stores the ASCII data
memset(&buff[0], '\0', 17);
const byte* addr = reinterpret_cast<const byte*>(voidaddr);
const std::byte* addr = reinterpret_cast<const std::byte*>(voidaddr);

// Output description if given.
if (desc != nullptr) {
Expand Down Expand Up @@ -143,13 +143,13 @@ void o2::header::hexDump(const char* desc, const void* voidaddr, size_t len, siz
}

// Now the hex code for the specific character.
printf(" %02x", addr[i]);
printf(" %02x", (char)addr[i]);

// And store a printable ASCII character for later.
if ((addr[i] < 0x20) || (addr[i] > 0x7e)) {
if (((char)addr[i] < 0x20) || ((char)addr[i] > 0x7e)) {
buff[i % 16] = '.';
} else {
buff[i % 16] = addr[i];
buff[i % 16] = (char)addr[i];
}
buff[(i % 16) + 1] = '\0';
fflush(stdout);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@
#include <FairMQTransportFactory.h>
#include <fairmq/MemoryResources.h>
#include <fairmq/MemoryResourceTools.h>
#include "Types.h"

namespace o2
{
Expand Down Expand Up @@ -305,8 +304,8 @@ class NoConstructAllocator : public boost::container::pmr::polymorphic_allocator
//__________________________________________________________________________________________________
//__________________________________________________________________________________________________

using ByteSpectatorAllocator = SpectatorAllocator<o2::byte>;
using BytePmrAllocator = boost::container::pmr::polymorphic_allocator<o2::byte>;
using ByteSpectatorAllocator = SpectatorAllocator<std::byte>;
using BytePmrAllocator = boost::container::pmr::polymorphic_allocator<std::byte>;
template <class T>
using vector = std::vector<T, o2::pmr::polymorphic_allocator<T>>;

Expand Down
19 changes: 0 additions & 19 deletions DataFormats/MemoryResources/include/MemoryResources/Types.h

This file was deleted.

2 changes: 1 addition & 1 deletion DataFormats/MemoryResources/test/testMemoryResources.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ BOOST_AUTO_TEST_CASE(allocator_test)
v.emplace_back(1);
v.emplace_back(2);
v.emplace_back(3);
BOOST_CHECK((byte*)&(*v.end()) - (byte*)&(*v.begin()) == 3 * sizeof(testData));
BOOST_CHECK((std::byte*)&(*v.end()) - (std::byte*)&(*v.begin()) == 3 * sizeof(testData));
BOOST_CHECK(testData::nconstructions == 3);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
#include <gsl/span>
#include "DetectorsRaw/RDHUtils.h"

#include "MemoryResources/Types.h"
#include "TPCBase/CRU.h"
#include "Headers/RAWDataHeader.h"
#include "Headers/RDHAny.h"
Expand Down Expand Up @@ -239,7 +238,7 @@ class GBTFrame
void getAdcValues(ADCRawData& rawData);

/// read from memory
void readFromMemory(gsl::span<const o2::byte> data);
void readFromMemory(gsl::span<const std::byte> data);

/// read from istream
void streamFrom(std::istream& input);
Expand Down Expand Up @@ -610,7 +609,7 @@ class RawReaderCRU

/// Process data from memory for a single link
/// The data must be collected before, merged over 8k packets
int processMemory(const std::vector<o2::byte>& data, ADCRawData& rawData);
int processMemory(const std::vector<std::byte>& data, ADCRawData& rawData);

/// process links
void processLinks(const uint32_t linkMask = 0);
Expand Down Expand Up @@ -798,7 +797,7 @@ class RawReaderCRU
std::ifstream mFileHandle; ///< file handle for input file

/// collect raw GBT data
void collectGBTData(std::vector<o2::byte>& data);
void collectGBTData(std::vector<std::byte>& data);

/// fill adc data to output map
void fillADCdataMap(const ADCRawData& rawData);
Expand Down Expand Up @@ -915,7 +914,7 @@ inline void GBTFrame::getAdcValues(ADCRawData& rawData)
// std::cout << std::endl;
}

inline void GBTFrame::readFromMemory(gsl::span<const o2::byte> data)
inline void GBTFrame::readFromMemory(gsl::span<const std::byte> data)
{
assert(sizeof(mData) == data.size_bytes());
memcpy(mData.data(), data.data(), data.size_bytes());
Expand Down
10 changes: 5 additions & 5 deletions Detectors/TPC/reconstruction/src/RawReaderCRU.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ int RawReaderCRU::processPacket(GBTFrame& gFrame, uint32_t startPos, uint32_t si
return 0;
}

int RawReaderCRU::processMemory(const std::vector<o2::byte>& data, ADCRawData& rawData)
int RawReaderCRU::processMemory(const std::vector<std::byte>& data, ADCRawData& rawData)
{
GBTFrame gFrame;

Expand All @@ -507,7 +507,7 @@ int RawReaderCRU::processMemory(const std::vector<o2::byte>& data, ADCRawData& r
// reinterpret_cast<const uint32_t*>(data.data() + iFrame * 16), so it could be accessed the
// same way as the mData array.
// however, this was ~5% slower in execution time. I suspect due to cache misses
gFrame.readFromMemory(gsl::span<const o2::byte>(data.data() + iFrame * 16, 16));
gFrame.readFromMemory(gsl::span<const std::byte>(data.data() + iFrame * 16, 16));

// extract the half words from the 4 32-bit words
gFrame.getFrameHalfWords();
Expand Down Expand Up @@ -702,7 +702,7 @@ void RawReaderCRU::processDataMemory()
//dataSize = 4000 * 16;
//}

std::vector<o2::byte> data;
std::vector<std::byte> data;
data.reserve(dataSize);
collectGBTData(data);

Expand All @@ -718,7 +718,7 @@ void RawReaderCRU::processDataMemory()
}
}

void RawReaderCRU::collectGBTData(std::vector<o2::byte>& data)
void RawReaderCRU::collectGBTData(std::vector<std::byte>& data)
{
const auto& linkInfoArray = mManager->mEventSync.getLinkInfoArrayForEvent(mEventNumber, mCRU);
auto& file = getFileHandle();
Expand All @@ -732,7 +732,7 @@ void RawReaderCRU::collectGBTData(std::vector<o2::byte>& data)

const auto payloadStart = packet.getPayloadOffset();
const auto payloadSize = size_t(packet.getPayloadSize());
data.insert(data.end(), payloadSize, 0);
data.insert(data.end(), payloadSize, (std::byte)0);
// jump to the start position of the packet
file.seekg(payloadStart, std::ios::beg);

Expand Down
Loading