Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#ifndef GPUCA_STANDALONE
#include <Framework/Traits.h>
#endif
#include <span>

class TTree;

Expand Down Expand Up @@ -132,7 +133,7 @@ template <typename TruthElement>
class ConstMCTruthContainerView
{
public:
ConstMCTruthContainerView(gsl::span<const char> const bufferview) : mStorage(bufferview){};
ConstMCTruthContainerView(std::span<const char> const bufferview) : mStorage(bufferview.data(), bufferview.size()) {};
ConstMCTruthContainerView(ConstMCTruthContainer<TruthElement> const& cont) : mStorage(gsl::span<const char>(cont)){};
// be explicit that we want nullptr / 0 for an uninitialized container (needs (void)0 to avoid false codechecker warning)
ConstMCTruthContainerView() : mStorage{nullptr, static_cast<gsl::span<const char>::size_type>(0)}
Expand Down
8 changes: 4 additions & 4 deletions Detectors/CPV/simulation/src/RawWriter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ bool RawWriter::processOrbit(const gsl::span<o2::cpv::Digit> digitsbranch, const
}
}
mRawWriter->addData(links[iLink].feeId, links[iLink].cruId, links[iLink].linkId, links[iLink].endPointId, currentIR,
gsl::span<char>(mPayload[iLink].data(), mPayload[iLink].size()), preformatted);
std::span<char>(mPayload[iLink].data(), mPayload[iLink].size()), preformatted);
mPayload[iLink].clear();
cpvWordCounter[iLink] = 0;
cpvWordCounterBeforeCPVTrailer[iLink] = 0;
Expand Down Expand Up @@ -262,7 +262,7 @@ bool RawWriter::processOrbit(const gsl::span<o2::cpv::Digit> digitsbranch, const
}
}
mRawWriter->addData(links[iLink].feeId, links[iLink].cruId, links[iLink].linkId, links[iLink].endPointId, currentIR,
gsl::span<char>(mPayload[iLink].data(), mPayload[iLink].size()), preformatted);
std::span<char>(mPayload[iLink].data(), mPayload[iLink].size()), preformatted);

mPayload[iLink].clear();
cpvWordCounter[iLink] = 0;
Expand Down Expand Up @@ -322,7 +322,7 @@ bool RawWriter::processOrbit(const gsl::span<o2::cpv::Digit> digitsbranch, const
}
}
mRawWriter->addData(links[iLink].feeId, links[iLink].cruId, links[iLink].linkId, links[iLink].endPointId, currentIR,
gsl::span<char>(mPayload[iLink].data(), mPayload[iLink].size()), preformatted);
std::span<char>(mPayload[iLink].data(), mPayload[iLink].size()), preformatted);

mPayload[iLink].clear();
cpvWordCounter[iLink] = 0;
Expand Down Expand Up @@ -373,7 +373,7 @@ bool RawWriter::processOrbit(const gsl::span<o2::cpv::Digit> digitsbranch, const
}
}
mRawWriter->addData(links[iLink].feeId, links[iLink].cruId, links[iLink].linkId, links[iLink].endPointId,
trgs.back().getBCData(), gsl::span<char>(mPayload[iLink].data(), mPayload[iLink].size()), preformatted);
trgs.back().getBCData(), std::span<char>(mPayload[iLink].data(), mPayload[iLink].size()), preformatted);
mPayload[iLink].clear();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "GPUTPCGMMergedTrackHit.h"
#include "DataFormatsITS/TrackITS.h"
#include <set>
#include <gsl/span>
#include <vector>

namespace o2
Expand Down
2 changes: 1 addition & 1 deletion Detectors/HMPID/simulation/src/HmpidCoder2.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ void HmpidCoder2::writePaginatedEvent(uint32_t orbit, uint16_t bc)
ReadOut::LnkId(eq),
0,
{bc, orbit},
gsl::span<char>(reinterpret_cast<char*>(ptrStartEquipment),
std::span<char>(reinterpret_cast<char*>(ptrStartEquipment),
EventSize * sizeof(uint32_t)),
false,
0,
Expand Down
2 changes: 1 addition & 1 deletion Detectors/ITSMFT/common/simulation/src/MC2RawEncoder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ void MC2RawEncoder<Mapping>::fillGBTLinks(RUDecodeData& ru)
LOGF(debug, "Filled %s with %d GBT words", link->describe(), nPayLoadWordsNeeded + 3);

// flush to writer
mWriter.addData(link->feeID, link->cruID, link->idInCRU, link->endPointID, mCurrIR, gsl::span((char*)link->data.data(), link->data.getSize()));
mWriter.addData(link->feeID, link->cruID, link->idInCRU, link->endPointID, mCurrIR, std::span((char*)link->data.data(), link->data.getSize()));
link->data.clear();
//
} // loop over links of RU
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void paginate(o2::raw::RawFileWriter& rawFileWriter,
filled[o2::InteractionRecord{h.bc, h.orbit}].insert(li.value());
rawFileWriter.addData(rdhFromLinkInfo(li.value()),
{h.bc, h.orbit},
gsl::span<char>(const_cast<char*>(reinterpret_cast<const char*>(&b.payload[0])),
std::span<char>(const_cast<char*>(reinterpret_cast<const char*>(&b.payload[0])),
b.payload.size()));
}

Expand Down
5 changes: 3 additions & 2 deletions Detectors/Raw/include/DetectorsRaw/RawFileWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
/// @brief Utility class to write detectors data to (multiple) raw data file(s) respecting CRU format

#include <gsl/span>
#include <span>
#include <unordered_map>
#include <vector>
#include <map>
Expand Down Expand Up @@ -205,10 +206,10 @@ class RawFileWriter
}

void addData(uint16_t feeid, uint16_t cru, uint8_t lnk, uint8_t endpoint, const IR& ir,
const gsl::span<char> data, bool preformatted = false, uint32_t trigger = 0, uint32_t detField = 0);
const std::span<char> data, bool preformatted = false, uint32_t trigger = 0, uint32_t detField = 0);

template <typename H>
void addData(const H& rdh, const IR& ir, const gsl::span<char> data, bool preformatted = false, uint32_t trigger = 0)
void addData(const H& rdh, const IR& ir, const std::span<char> data, bool preformatted = false, uint32_t trigger = 0)
{
RDHAny::sanityCheckLoose<H>();
addData(RDHUtils::getFEEID(rdh), RDHUtils::getCRUID(rdh), RDHUtils::getLinkID(rdh), RDHUtils::getEndPointID(rdh), ir, data, trigger);
Expand Down
2 changes: 1 addition & 1 deletion Detectors/Raw/src/RawFileWriter.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ RawFileWriter::LinkData& RawFileWriter::registerLink(uint16_t fee, uint16_t cru,
}

//_____________________________________________________________________
void RawFileWriter::addData(uint16_t feeid, uint16_t cru, uint8_t lnk, uint8_t endpoint, const IR& ir, const gsl::span<char> data, bool preformatted, uint32_t trigger, uint32_t detField)
void RawFileWriter::addData(uint16_t feeid, uint16_t cru, uint8_t lnk, uint8_t endpoint, const IR& ir, const std::span<char> data, bool preformatted, uint32_t trigger, uint32_t detField)
{
// add payload to relevant links
auto sspec = RDHUtils::getSubSpec(cru, lnk, endpoint, feeid);
Expand Down
2 changes: 1 addition & 1 deletion Detectors/TOF/reconstruction/src/Encoder.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ bool Encoder::flush(int icrate)
if (nbyte) {
if (mCrateOn[icrate]) {
//printf("flush crate %d -- byte = %d -- orbit = %d, bc = %d\n",icrate, nbyte, mIR.orbit, mIR.bc);
mFileWriter.addData(Geo::getFEEid(icrate), Geo::getCRUid(icrate), Geo::getCRUlink(icrate), Geo::getCRUendpoint(icrate), mIR, gsl::span(mBuffer[icrate], nbyte));
mFileWriter.addData(Geo::getFEEid(icrate), Geo::getCRUid(icrate), Geo::getCRUlink(icrate), Geo::getCRUendpoint(icrate), mIR, std::span(mBuffer[icrate], nbyte));
}
mIntegratedAllBytes += nbyte;
}
Expand Down
2 changes: 1 addition & 1 deletion Detectors/TPC/workflow/src/ClusterDecoderRawSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ DataProcessorSpec getClusterDecoderRawSpec(bool sendMC)
std::vector<ConstMCLabelContainerView> mcinCopiesFlatView;
ConstMCLabelContainerView mcin;
if (DataRefUtils::isValid(mclabelref)) {
mcin = pc.inputs().get<gsl::span<char>>(mclabelref);
mcin = pc.inputs().get<std::span<char>>(mclabelref);
mcinCopiesFlat.resize(nPages);
mcinCopiesFlatView.reserve(nPages);
if (verbosity > 0) {
Expand Down
2 changes: 1 addition & 1 deletion Detectors/TPC/workflow/src/ClustererSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ DataProcessorSpec getClustererSpec(bool sendMC)
}
ConstMCLabelContainerView inMCLabels;
if (DataRefUtils::isValid(mclabelref)) {
inMCLabels = pc.inputs().get<gsl::span<char>>(mclabelref);
inMCLabels = pc.inputs().get<std::span<char>>(mclabelref);
}
auto inDigits = pc.inputs().get<gsl::span<o2::tpc::Digit>>(dataref);
if (verbosity > 0 && inMCLabels.getBuffer().size()) {
Expand Down
1 change: 1 addition & 0 deletions Detectors/TPC/workflow/src/ZSSpec.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include <iomanip>
#include <stdexcept>
#include <array>
#include <span>
#include <unistd.h>
#include <atomic>
#include "GPUO2InterfaceUtils.h"
Expand Down
4 changes: 2 additions & 2 deletions Framework/Core/include/Framework/InputRecord.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,6 @@ class InputRecord
// implementation (f)
} else if constexpr (is_span<T>::value) {
// substitution for span of messageable objects
// FIXME: there will be std::span in C++20
static_assert(is_messageable<typename T::value_type>::value, "span can only be created for messageable types");
auto header = DataRefUtils::getHeader<header::DataHeader*>(ref);
assert(header);
Expand All @@ -318,7 +317,8 @@ class InputRecord
" payload size " + std::to_string(payloadSize))
.c_str());
}
return gsl::span<ValueT const>(reinterpret_cast<ValueT const*>(ref.payload), payloadSize / sizeof(ValueT));
using SpanT = std::conditional_t<std::is_same_v<T, std::span<ValueT>>, std::span<ValueT const>, gsl::span<ValueT const>>;
return SpanT(reinterpret_cast<ValueT const*>(ref.payload), payloadSize / sizeof(ValueT));

// implementation (g)
} else if constexpr (is_container<T>::value) {
Expand Down
6 changes: 5 additions & 1 deletion Framework/Core/include/Framework/TypeTraits.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "Framework/Traits.h"

#include <gsl/gsl>
#include <span>

namespace o2::framework
{
Expand Down Expand Up @@ -60,6 +61,9 @@ struct is_messageable : std::conditional<(std::is_trivially_copyable<T>::value |
template <typename T>
struct is_messageable<gsl::span<T>> : std::false_type {
};
template <typename T>
struct is_messageable<std::span<T>> : std::false_type {
};

// Detect a container by checking on the container properties
// this is the default trait implementation inheriting from false_type
Expand Down Expand Up @@ -107,7 +111,7 @@ template <typename T, typename _ = void>
struct is_span : std::false_type {
};
template <typename T>
struct is_span<T, std::conditional_t<false, typename T::value_type, void>> : std::is_same<gsl::span<typename T::value_type>, T> {
struct is_span<T, std::conditional_t<false, typename T::value_type, void>> : std::bool_constant<std::is_same_v<gsl::span<typename T::value_type>, T> || std::is_same_v<std::span<typename T::value_type>, T>> {
};

// Detect whether a class has a ROOT dictionary
Expand Down
3 changes: 3 additions & 0 deletions Framework/Core/test/test_TypeTraits.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,12 @@ TEST_CASE("TestIsSpan")
gsl::span<int> a;
int b;
std::vector<char> c;
std::span<int> d;
REQUIRE(is_span<decltype(a)>::value == true);
REQUIRE(is_span<decltype(b)>::value == false);
REQUIRE(is_span<decltype(c)>::value == false);
REQUIRE(is_span<decltype(d)>::value == true);
REQUIRE(is_messageable<decltype(d)>::value == false);
}

template <typename A>
Expand Down