Skip to content

Commit feb8450

Browse files
committed
GPU: Switch from gsl::span to std::span
1 parent 46f2f29 commit feb8450

10 files changed

Lines changed: 33 additions & 27 deletions

File tree

‎Detectors/TPC/workflow/src/ZSSpec.cxx‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ DataProcessorSpec getZSEncoderSpec(std::vector<int> const& tpcSectors, bool outR
6363
std::string processorName = "tpc-zsEncoder";
6464
constexpr static size_t NSectors = o2::tpc::Sector::MAXSECTOR;
6565
constexpr static size_t NEndpoints = o2::gpu::GPUTrackingInOutZS::NENDPOINTS;
66-
using DigitArray = std::array<gsl::span<const o2::tpc::Digit>, NSectors>;
66+
using DigitArray = std::array<std::span<const o2::tpc::Digit>, NSectors>;
6767

6868
struct ProcessAttributes {
6969
std::unique_ptr<uint64_t[]> zsoutput;
@@ -113,9 +113,13 @@ DataProcessorSpec getZSEncoderSpec(std::vector<int> const& tpcSectors, bool outR
113113
}
114114

115115
const auto& inputs = getWorkflowTPCInput(pc, 0, false, false, tpcSectorMask, true);
116+
DigitArray inputDigits;
117+
for (size_t i = 0; i < NSectors; i++) {
118+
inputDigits[i] = {inputs->inputDigits[i].data(), inputs->inputDigits[i].size()};
119+
}
116120
sizes.resize(NSectors * NEndpoints);
117121
o2::InteractionRecord ir{0, pc.services().get<o2::framework::TimingInfo>().firstTForbit};
118-
o2::gpu::GPUO2InterfaceUtils::RunZSEncoder<DigitArray>(inputs->inputDigits, &zsoutput, sizes.data(), nullptr, &ir, processAttributes->config, 4, verify, false, digitsFilter);
122+
o2::gpu::GPUO2InterfaceUtils::RunZSEncoder<DigitArray>(inputDigits, &zsoutput, sizes.data(), nullptr, &ir, processAttributes->config, 4, verify, false, digitsFilter);
119123
ZeroSuppressedContainer8kb* page = reinterpret_cast<ZeroSuppressedContainer8kb*>(zsoutput.get());
120124
unsigned int offset = 0;
121125
for (unsigned int i = 0; i < NSectors; i++) {
@@ -168,7 +172,7 @@ DataProcessorSpec getZSEncoderSpec(std::vector<int> const& tpcSectors, bool outR
168172
writer.useCaching();
169173
}
170174
ir = o2::raw::HBFUtils::Instance().getFirstSampledTFIR();
171-
o2::gpu::GPUO2InterfaceUtils::RunZSEncoder(inputs->inputDigits, nullptr, nullptr, &writer, &ir, processAttributes->config, 4, false, false, digitsFilter);
175+
o2::gpu::GPUO2InterfaceUtils::RunZSEncoder(inputDigits, nullptr, nullptr, &writer, &ir, processAttributes->config, 4, false, false, digitsFilter);
172176
writer.writeConfFile("TPC", "RAWDATA", fmt::format("{}tpcraw.cfg", outDir));
173177
}
174178
zsoutput.reset(nullptr);

‎Detectors/TPC/workflow/src/convertDigitsToRawZS.cxx‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include <string_view>
1818
#include <memory>
1919
#include <vector>
20+
#include <span>
2021
#include <fmt/format.h>
2122
#include <filesystem>
2223
#include "TFile.h"
@@ -53,7 +54,7 @@ using o2::MCCompLabel;
5354

5455
constexpr static size_t NSectors = o2::tpc::Sector::MAXSECTOR;
5556
constexpr static size_t NEndpoints = o2::gpu::GPUTrackingInOutZS::NENDPOINTS;
56-
using DigitArray = std::array<gsl::span<const o2::tpc::Digit>, Sector::MAXSECTOR>;
57+
using DigitArray = std::array<std::span<const o2::tpc::Digit>, Sector::MAXSECTOR>;
5758

5859
static constexpr const char* CRU_FLPS[361] = {
5960
"alio2-cr1-flp070", "alio2-cr1-flp069", "alio2-cr1-flp070", "alio2-cr1-flp069", "alio2-cr1-flp072", "alio2-cr1-flp071", "alio2-cr1-flp072", "alio2-cr1-flp071", "alio2-cr1-flp072", "alio2-cr1-flp071", "alio2-cr1-flp002", "alio2-cr1-flp001", "alio2-cr1-flp002", "alio2-cr1-flp001", "alio2-cr1-flp004", "alio2-cr1-flp003", "alio2-cr1-flp004", "alio2-cr1-flp003",

‎GPU/GPUTracking/Base/GPUReconstructionConvert.cxx‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "GPULogging.h"
3131
#include <algorithm>
3232
#include <vector>
33+
#include <span>
3334

3435
#include "clusterFinderDefs.h"
3536
#include "DataFormatsTPC/ZeroSuppression.h"
@@ -208,7 +209,7 @@ inline void zsEncoder::ZSstreamOut(uint16_t* bufIn, uint32_t& lenIn, uint8_t* bu
208209
static inline auto ZSEncoderGetDigits(const GPUTrackingInOutDigits& in, int32_t i) { return in.tpcDigits[i]; }
209210
static inline auto ZSEncoderGetNDigits(const GPUTrackingInOutDigits& in, int32_t i) { return in.nTPCDigits[i]; }
210211
#ifndef GPUCA_STANDALONE
211-
using DigitArray = std::array<gsl::span<const o2::tpc::Digit>, o2::tpc::Sector::MAXSECTOR>;
212+
using DigitArray = std::array<std::span<const o2::tpc::Digit>, o2::tpc::Sector::MAXSECTOR>;
212213
static inline auto ZSEncoderGetDigits(const DigitArray& in, int32_t i) { return in[i].data(); }
213214
static inline auto ZSEncoderGetNDigits(const DigitArray& in, int32_t i) { return in[i].size(); }
214215
#endif
@@ -1142,7 +1143,7 @@ inline uint32_t zsEncoderRun<T>::run(std::vector<zsPage>* buffer, std::vector<o2
11421143
size = CAMath::nextMultipleOf<o2::raw::RDHUtils::GBTWord128>(size);
11431144
#ifndef GPUCA_STANDALONE
11441145
if (raw) {
1145-
raw->addData(rawfeeid, rawcru, 0, rawendpoint, *ir + hbf * o2::constants::lhc::LHCMaxBunches, gsl::span<char>((char*)page + sizeof(o2::header::RAWDataHeader), (char*)page + size), true, 0, 2);
1146+
raw->addData(rawfeeid, rawcru, 0, rawendpoint, *ir + hbf * o2::constants::lhc::LHCMaxBunches, std::span<char>((char*)page + sizeof(o2::header::RAWDataHeader), (char*)page + size), true, 0, 2);
11461147
maxhbf = std::max<int32_t>(maxhbf, hbf);
11471148
minhbf = std::min<int32_t>(minhbf, hbf);
11481149
} else
@@ -1222,7 +1223,7 @@ inline uint32_t zsEncoderRun<T>::run(std::vector<zsPage>* buffer, std::vector<o2
12221223
#ifndef GPUCA_STANDALONE
12231224
if (iSector == 0) {
12241225
for (int32_t i = minhbf; i <= maxhbf; i++) {
1225-
raw->addData(46208, 360, rdh_utils::SACLinkID, 0, *ir + i * o2::constants::lhc::LHCMaxBunches, gsl::span<char>((char*)&singleBuffer, (char*)&singleBuffer), true, 0, 4);
1226+
raw->addData(46208, 360, rdh_utils::SACLinkID, 0, *ir + i * o2::constants::lhc::LHCMaxBunches, std::span<char>((char*)&singleBuffer, (char*)&singleBuffer), true, 0, 4);
12261227
}
12271228
}
12281229
#endif

‎GPU/GPUTracking/Global/GPUChainTrackingIO.cxx‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,11 @@
4545
#include "CalibdEdxContainer.h"
4646

4747
#include "TPCFastTransformPOD.h"
48-
49-
using namespace o2::gpu;
50-
5148
#include "GPUO2DataTypes.h"
5249

50+
#include <span>
51+
52+
using namespace o2::gpu;
5353
using namespace o2::tpc;
5454
using namespace o2::trd;
5555
using namespace o2::dataformats;
@@ -195,7 +195,7 @@ int32_t GPUChainTracking::ReadData(const char* filename)
195195
mIOPtrs.clustersNative = mIOMem.clusterNativeAccess.get();
196196
std::pair<const char*, size_t> tmp = {nullptr, 0};
197197
if (ReadData(fp, &tmp.first, &tmp.second, &mIOMem.clusterNativeMC, InOutPointerType::CLUSTER_NATIVE_MC)) {
198-
mIOMem.clusterNativeMCView = std::make_unique<ConstMCLabelContainerView>(gsl::span<const char>(tmp.first, tmp.first + tmp.second));
198+
mIOMem.clusterNativeMCView = std::make_unique<ConstMCLabelContainerView>(std::span<const char>(tmp.first, tmp.first + tmp.second));
199199
mIOMem.clusterNativeAccess->clustersMCTruth = mIOMem.clusterNativeMCView.get();
200200
}
201201
}
@@ -209,7 +209,7 @@ int32_t GPUChainTracking::ReadData(const char* filename)
209209
mIOMem.tpcDigitMCView.reset(new ConstMCLabelContainerView[NSECTORS]);
210210
for (uint32_t i = 0; i < NSECTORS; i++) {
211211
if (sizes[i]) {
212-
mIOMem.tpcDigitMCView.get()[i] = gsl::span<const char>(ptrs[i], ptrs[i] + sizes[i]);
212+
mIOMem.tpcDigitMCView.get()[i] = std::span<const char>(ptrs[i], ptrs[i] + sizes[i]);
213213
mIOMem.tpcDigitMCMap->v[i] = mIOMem.tpcDigitMCView.get() + i;
214214
} else {
215215
mIOMem.tpcDigitMCMap->v[i] = nullptr;

‎GPU/GPUTracking/Interface/GPUO2InterfaceConfiguration.h‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
#include <array>
2727
#include <vector>
2828
#include <functional>
29-
#include <gsl/gsl> // TODO: Get rid of gsl
3029

3130
class TH1F;
3231
class TH1D;

‎GPU/GPUTracking/Interface/GPUO2InterfaceRefit.cxx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
using namespace o2::gpu;
2626
using namespace o2::tpc;
2727

28-
void GPUO2InterfaceRefit::fillSharedClustersAndOccupancyMap(const ClusterNativeAccess* cl, const gsl::span<const TrackTPC> trks, const TPCClRefElem* trackRef, uint8_t* shmap, uint32_t* ocmap, uint32_t nHbfPerTf, const GPUParam* param)
28+
void GPUO2InterfaceRefit::fillSharedClustersAndOccupancyMap(const ClusterNativeAccess* cl, const std::span<const TrackTPC> trks, const TPCClRefElem* trackRef, uint8_t* shmap, uint32_t* ocmap, uint32_t nHbfPerTf, const GPUParam* param)
2929
{
3030
if (!cl || (!shmap && cl->nClustersTotal > 0)) {
3131
throw std::runtime_error("Must provide clusters access and preallocated buffer for shared map");

‎GPU/GPUTracking/Interface/GPUO2InterfaceRefit.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
#include <cstdint>
2020
#include <memory>
2121
#include <vector>
22-
#include <gsl/span>
22+
#include <span>
2323

2424
namespace o2::base
2525
{
@@ -79,7 +79,7 @@ class GPUO2InterfaceRefit
7979
// If the param object / default object requires an occupancy map, an occupancy map ptr and nHbfPerTf value must be provided.
8080
// You can use the function fillOccupancyMapGetSize(...) to get the required size of the occupancy map. If 0 is returned, no map is required.
8181
// Providing only the shmap ptr but no ocmap ptr will create only the shared map, but no occupancy map.
82-
static void fillSharedClustersAndOccupancyMap(const o2::tpc::ClusterNativeAccess* cl, const gsl::span<const o2::tpc::TrackTPC> trks, const o2::tpc::TPCClRefElem* trackRef, uint8_t* shmap, uint32_t* ocmap = nullptr, uint32_t nHbfPerTf = 0, const GPUParam* param = nullptr);
82+
static void fillSharedClustersAndOccupancyMap(const o2::tpc::ClusterNativeAccess* cl, const std::span<const o2::tpc::TrackTPC> trks, const o2::tpc::TPCClRefElem* trackRef, uint8_t* shmap, uint32_t* ocmap = nullptr, uint32_t nHbfPerTf = 0, const GPUParam* param = nullptr);
8383
static size_t fillOccupancyMapGetSize(uint32_t nHbfPerTf, const GPUParam* param = nullptr);
8484

8585
private:

‎GPU/GPUTracking/Interface/GPUO2InterfaceUtils.cxx‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727
#include "TPCBase/RDHUtils.h"
2828
#include "DataFormatsTPC/ZeroSuppression.h"
2929
#include "GPUTPCClusterOccupancyMap.h"
30-
#include <gsl/span>
30+
#include <span>
3131

3232
using namespace o2::gpu;
3333

34-
using DigitArray = std::array<gsl::span<const o2::tpc::Digit>, o2::tpc::Sector::MAXSECTOR>;
34+
using DigitArray = std::array<std::span<const o2::tpc::Digit>, o2::tpc::Sector::MAXSECTOR>;
3535

3636
std::unique_ptr<TPCPadGainCalib> GPUO2InterfaceUtils::getPadGainCalibDefault()
3737
{

‎GPU/GPUTracking/qa/GPUQA.h‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class GPUQA
6969
#include <vector>
7070
#include <memory>
7171
#ifndef GPUCA_RUN2
72-
#include <gsl/span>
72+
#include <span>
7373
#endif
7474

7575
namespace o2
@@ -103,7 +103,7 @@ class GPUQA
103103
~GPUQA();
104104

105105
#ifndef GPUCA_RUN2
106-
using mcLabels_t = gsl::span<const o2::MCCompLabel>;
106+
using mcLabels_t = std::span<const o2::MCCompLabel>;
107107
using mcLabel_t = o2::MCCompLabel;
108108
using mcLabelI_t = mcLabel_t;
109109
#else

‎GPU/Workflow/src/GPUWorkflowSpec.cxx‎

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@
101101
#include <fcntl.h>
102102
#include <chrono>
103103
#include <unordered_set>
104+
#include <span>
104105

105106
using namespace o2::framework;
106107
using namespace o2::header;
@@ -426,7 +427,7 @@ void GPURecoWorkflowSpec::processInputs(ProcessingContext& pc, D& tpcZSmeta, E&
426427
if (recv) {
427428
throw std::runtime_error("Received multiple TPCZS data");
428429
}
429-
inputZS = pc.inputs().get<gsl::span<o2::tpc::ZeroSuppressedContainer8kb>>(ref);
430+
inputZS = pc.inputs().get<std::span<o2::tpc::ZeroSuppressedContainer8kb>>(ref);
430431
recv = true;
431432
}
432433
if (!recv || !recvsizes) {
@@ -540,7 +541,7 @@ void GPURecoWorkflowSpec::run(ProcessingContext& pc)
540541
mTimer->Start(false);
541542
mNTFs++;
542543

543-
std::vector<gsl::span<const char>> inputs;
544+
std::vector<std::span<const char>> inputs;
544545

545546
const o2::tpc::CompressedClustersFlat* pCompClustersFlat = nullptr;
546547
size_t compClustersFlatDummyMemory[(sizeof(o2::tpc::CompressedClustersFlat) + sizeof(size_t) - 1) / sizeof(size_t)];
@@ -549,7 +550,7 @@ void GPURecoWorkflowSpec::run(ProcessingContext& pc)
549550
o2::gpu::GPUTrackingInOutZS tpcZS;
550551
GPURecoWorkflowSpec_TPCZSBuffers tpcZSmeta;
551552
std::array<uint32_t, NEndpoints * NSectors> tpcZSonTheFlySizes;
552-
gsl::span<const o2::tpc::ZeroSuppressedContainer8kb> inputZS;
553+
std::span<const o2::tpc::ZeroSuppressedContainer8kb> inputZS;
553554
std::unique_ptr<char[]> tmpEmptyCompClusters;
554555

555556
bool getWorkflowTPCInput_clusters = false, getWorkflowTPCInput_mc = false, getWorkflowTPCInput_digits = false;
@@ -853,7 +854,7 @@ void GPURecoWorkflowSpec::run(ProcessingContext& pc)
853854
FILE* fp = fopen(filename.c_str(), "w+b");
854855
std::vector<InputSpec> filter = {{"check", ConcreteDataTypeMatcher{gDataOriginTPC, "RAWDATA"}, Lifetime::Timeframe}};
855856
for (auto const& ref : InputRecordWalker(pc.inputs(), filter)) {
856-
auto data = pc.inputs().get<gsl::span<char>>(ref);
857+
auto data = pc.inputs().get<std::span<char>>(ref);
857858
if (mConfParam->dumpBadTFMode == 1) {
858859
uint64_t size = data.size();
859860
fwrite(&size, 1, sizeof(size), fp);
@@ -917,9 +918,9 @@ void GPURecoWorkflowSpec::run(ProcessingContext& pc)
917918
tmpEmptyClNative->clustersMCTruth = &clustersMCBuffer.second;
918919
}
919920
} else {
920-
gsl::span<const o2::tpc::TrackTPC> spanOutputTracks = {ptrs.outputTracksTPCO2, ptrs.nOutputTracksTPCO2};
921-
gsl::span<const uint32_t> spanOutputClusRefs = {ptrs.outputClusRefsTPCO2, ptrs.nOutputClusRefsTPCO2};
922-
gsl::span<const o2::MCCompLabel> spanOutputTracksMCTruth = {ptrs.outputTracksTPCO2MC, ptrs.outputTracksTPCO2MC ? ptrs.nOutputTracksTPCO2 : 0};
921+
std::span<const o2::tpc::TrackTPC> spanOutputTracks = {ptrs.outputTracksTPCO2, ptrs.nOutputTracksTPCO2};
922+
std::span<const uint32_t> spanOutputClusRefs = {ptrs.outputClusRefsTPCO2, ptrs.nOutputClusRefsTPCO2};
923+
std::span<const o2::MCCompLabel> spanOutputTracksMCTruth = {ptrs.outputTracksTPCO2MC, ptrs.outputTracksTPCO2MC ? ptrs.nOutputTracksTPCO2 : 0};
923924
if (!mConfParam->allocateOutputOnTheFly) {
924925
for (uint32_t i = 0; i < outputRegions.count(); i++) {
925926
if (outputRegions.asArray()[i].ptrBase) {

0 commit comments

Comments
 (0)