16#ifndef RANS_BENCHMARKS_HELPERS_H_
17#define RANS_BENCHMARKS_HELPERS_H_
21#ifdef ENABLE_VTUNE_PROFILER
25#ifdef RANS_ENABLE_JSON
26#include <rapidjson/document.h>
27#include <rapidjson/writer.h>
28#include <rapidjson/istreamwrapper.h>
29#include <rapidjson/ostreamwrapper.h>
31#include <fairlogger/Logger.h>
36#ifdef RANS_PARALLEL_STL
40#ifdef RANS_ENABLE_JSON
45 size_t nAttachedClusters,
46 size_t nUnattachedClusters,
47 size_t nAttachedClustersReduced) : nTracks(nTracks),
48 nAttachedClusters(nAttachedClusters),
49 nUnattachedClusters(nUnattachedClusters),
50 nAttachedClustersReduced(nAttachedClustersReduced)
52 qTotA.resize(this->nAttachedClusters);
53 qMaxA.resize(this->nAttachedClusters);
54 flagsA.resize(this->nAttachedClusters);
55 rowDiffA.resize(this->nAttachedClustersReduced);
56 sliceLegDiffA.resize(this->nAttachedClustersReduced);
57 padResA.resize(this->nAttachedClustersReduced);
58 timeResA.resize(this->nAttachedClustersReduced);
59 sigmaPadA.resize(this->nAttachedClusters);
60 sigmaTimeA.resize(this->nAttachedClusters);
62 qPtA.resize(this->nTracks);
63 rowA.resize(this->nTracks);
64 sliceA.resize(this->nTracks);
65 timeA.resize(this->nTracks);
66 padA.resize(this->nTracks);
68 qTotU.resize(this->nUnattachedClusters);
69 qMaxU.resize(this->nUnattachedClusters);
70 flagsU.resize(this->nUnattachedClusters);
71 padDiffU.resize(this->nUnattachedClusters);
72 timeDiffU.resize(this->nUnattachedClusters);
73 sigmaPadU.resize(this->nUnattachedClusters);
74 sigmaTimeU.resize(this->nUnattachedClusters);
76 nTrackClusters.resize(this->nTracks);
77 nSliceRowClusters.resize(this->nSliceRows);
81 size_t nAttachedClusters = 0;
82 size_t nUnattachedClusters = 0;
83 size_t nAttachedClustersReduced = 0;
84 size_t nSliceRows = 36 * 152;
86 std::vector<uint16_t> qTotA{};
87 std::vector<uint16_t> qMaxA{};
88 std::vector<uint8_t> flagsA{};
89 std::vector<uint8_t> rowDiffA{};
90 std::vector<uint8_t> sliceLegDiffA{};
91 std::vector<uint16_t> padResA{};
92 std::vector<uint32_t> timeResA{};
93 std::vector<uint8_t> sigmaPadA{};
94 std::vector<uint8_t> sigmaTimeA{};
96 std::vector<uint8_t> qPtA{};
97 std::vector<uint8_t> rowA{};
98 std::vector<uint8_t> sliceA{};
99 std::vector<uint32_t>
timeA{};
100 std::vector<uint16_t> padA{};
102 std::vector<uint16_t> qTotU{};
103 std::vector<uint16_t> qMaxU{};
104 std::vector<uint8_t> flagsU{};
105 std::vector<uint16_t> padDiffU{};
106 std::vector<uint32_t> timeDiffU{};
107 std::vector<uint8_t> sigmaPadU{};
108 std::vector<uint8_t> sigmaTimeU{};
110 std::vector<uint16_t> nTrackClusters{};
111 std::vector<uint32_t> nSliceRowClusters{};
114class TPCJsonHandler :
public rapidjson::BaseReaderHandler<rapidjson::UTF8<>, TPCJsonHandler>
120 CurrentVector() =
default;
122 template <
typename T>
123 CurrentVector(std::vector<T>&
vec) : mVectorConcept{
std::make_unique<VectorWrapper<
T>>(
vec)} {};
125 inline void push_back(
unsigned i) { mVectorConcept->push_back(
i); };
127 struct VectorConcept {
128 virtual ~VectorConcept() =
default;
129 virtual void push_back(
unsigned i) = 0;
132 template <
typename T>
133 struct VectorWrapper : VectorConcept {
134 VectorWrapper(std::vector<T>& vector) : mVector(
vector){};
136 void push_back(
unsigned i)
override { mVector.push_back(
static_cast<T>(
i)); };
139 std::vector<T>& mVector{};
142 std::unique_ptr<VectorConcept> mVectorConcept{};
146 bool Null() {
return true; };
147 bool Bool(
bool b) {
return true; };
148 bool Int(
int i) {
return this->Uint(
static_cast<unsigned>(
i)); };
149 bool Uint(
unsigned i)
151 mCurrentVector.push_back(
i);
154 bool Int64(
int64_t i) {
return this->Uint(
static_cast<unsigned>(
i)); };
156 bool Double(
double d) {
return this->Uint(
static_cast<unsigned>(
d)); };
157 bool RawNumber(
const Ch*
str, rapidjson::SizeType
length,
bool copy) {
return true; };
158 bool String(
const Ch*
str, rapidjson::SizeType
length,
bool copy) {
return true; };
159 bool StartObject() {
return true; };
160 bool Key(
const Ch*
str, rapidjson::SizeType
length,
bool copy)
162 if (
str == std::string{
"qTotA"}) {
163 LOGP(info,
"parsing {}",
str);
164 mCurrentVector = CurrentVector{mCompressedClusters.qTotA};
165 }
else if (
str == std::string{
"qMaxA"}) {
166 LOGP(info,
"parsing {}",
str);
167 mCurrentVector = CurrentVector{mCompressedClusters.qMaxA};
168 }
else if (
str == std::string{
"flagsA"}) {
169 LOGP(info,
"parsing {}",
str);
170 mCurrentVector = CurrentVector{mCompressedClusters.flagsA};
171 }
else if (
str == std::string{
"rowDiffA"}) {
172 LOGP(info,
"parsing {}",
str);
173 mCurrentVector = CurrentVector{mCompressedClusters.rowDiffA};
174 }
else if (
str == std::string{
"sliceLegDiffA"}) {
175 LOGP(info,
"parsing {}",
str);
176 mCurrentVector = CurrentVector{mCompressedClusters.sliceLegDiffA};
177 }
else if (
str == std::string{
"padResA"}) {
178 LOGP(info,
"parsing {}",
str);
179 mCurrentVector = CurrentVector{mCompressedClusters.padResA};
180 }
else if (
str == std::string{
"timeResA"}) {
181 LOGP(info,
"parsing {}",
str);
182 mCurrentVector = CurrentVector{mCompressedClusters.timeResA};
183 }
else if (
str == std::string{
"sigmaPadA"}) {
184 LOGP(info,
"parsing {}",
str);
185 mCurrentVector = CurrentVector{mCompressedClusters.sigmaPadA};
186 }
else if (
str == std::string{
"sigmaTimeA"}) {
187 LOGP(info,
"parsing {}",
str);
188 mCurrentVector = CurrentVector{mCompressedClusters.sigmaTimeA};
189 }
else if (
str == std::string{
"qPtA"}) {
190 LOGP(info,
"parsing {}",
str);
191 mCurrentVector = CurrentVector{mCompressedClusters.qPtA};
192 }
else if (
str == std::string{
"rowA"}) {
193 LOGP(info,
"parsing {}",
str);
194 mCurrentVector = CurrentVector{mCompressedClusters.rowA};
195 }
else if (
str == std::string{
"sliceA"}) {
196 LOGP(info,
"parsing {}",
str);
197 mCurrentVector = CurrentVector{mCompressedClusters.sliceA};
198 }
else if (
str == std::string{
"timeA"}) {
199 LOGP(info,
"parsing {}",
str);
200 mCurrentVector = CurrentVector{mCompressedClusters.timeA};
201 }
else if (
str == std::string{
"padA"}) {
202 LOGP(info,
"parsing {}",
str);
203 mCurrentVector = CurrentVector{mCompressedClusters.padA};
204 }
else if (
str == std::string{
"qTotU"}) {
205 LOGP(info,
"parsing {}",
str);
206 mCurrentVector = CurrentVector{mCompressedClusters.qTotU};
207 }
else if (
str == std::string{
"qMaxU"}) {
208 LOGP(info,
"parsing {}",
str);
209 mCurrentVector = CurrentVector{mCompressedClusters.qMaxU};
210 }
else if (
str == std::string{
"flagsU"}) {
211 LOGP(info,
"parsing {}",
str);
212 mCurrentVector = CurrentVector{mCompressedClusters.flagsU};
213 }
else if (
str == std::string{
"padDiffU"}) {
214 LOGP(info,
"parsing {}",
str);
215 mCurrentVector = CurrentVector{mCompressedClusters.padDiffU};
216 }
else if (
str == std::string{
"timeDiffU"}) {
217 LOGP(info,
"parsing {}",
str);
218 mCurrentVector = CurrentVector{mCompressedClusters.timeDiffU};
219 }
else if (
str == std::string{
"sigmaPadU"}) {
220 LOGP(info,
"parsing {}",
str);
221 mCurrentVector = CurrentVector{mCompressedClusters.sigmaPadU};
222 }
else if (
str == std::string{
"sigmaTimeU"}) {
223 LOGP(info,
"parsing {}",
str);
224 mCurrentVector = CurrentVector{mCompressedClusters.sigmaTimeU};
225 }
else if (
str == std::string{
"nTrackClusters"}) {
226 LOGP(info,
"parsing {}",
str);
227 mCurrentVector = CurrentVector{mCompressedClusters.nTrackClusters};
228 }
else if (
str == std::string{
"nSliceRowClusters"}) {
229 LOGP(info,
"parsing {}",
str);
230 mCurrentVector = CurrentVector{mCompressedClusters.nSliceRowClusters};
237 bool EndObject(rapidjson::SizeType memberCount)
239 LOGP(info,
"parsed {} objects", memberCount);
246 bool EndArray(rapidjson::SizeType elementCount)
248 LOGP(info,
"parsed {} elements", elementCount);
256 CurrentVector mCurrentVector;
262 std::ifstream is(
filename, std::ios_base::in);
264 rapidjson::IStreamWrapper isWrapper{is};
266 TPCJsonHandler handler;
267 rapidjson::Reader reader;
268 reader.Parse(isWrapper, handler);
270 compressedClusters = std::move(handler).release();
272 compressedClusters.nAttachedClusters = compressedClusters.qTotA.size();
273 compressedClusters.nAttachedClustersReduced = compressedClusters.rowDiffA.size();
274 compressedClusters.nUnattachedClusters = compressedClusters.qTotA.size();
275 compressedClusters.nTracks = compressedClusters.nTrackClusters.size();
280 return compressedClusters;
284template <
typename source_T,
typename stream_T = u
int32_t>
301template <
typename source_T>
307 template <
typename T>
310#ifdef RANS_PARALLEL_STL
311 return std::equal(std::execution::par_unseq,
buffer.begin(),
buffer.end(), std::begin(correct), std::end(correct));
313 return std::equal(
buffer.begin(),
buffer.end(), std::begin(correct), std::end(correct));
o2::monitoring::tags::Key Key
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events Show standalone event Run event generator maximum time bin of continuous for triggered for automatic continuous for automatic continuous triggered uint64_t
Timeframe settings Average distance in cm of events merged into Randomize distance around average distance of merged events Simulate correct bunch interactions instead of placing only the average number of events A value[n] sets TFlen for[n] collisions in Number of bunches per trainsort Number of bunch trains Instantaneous interaction rate Do not simulate border Total number of collisions to be placed in the interior of all time Do not select random but walk over array of events in stride steps h Event generator settings h configStandalone Use CPU for GPU Force usage of the specified GPU device no CPU fallback Continue processing after an error First event to Number of events to Number of iterations to Number of iterations to Number of initial iterations excluded from const char Directory with events to Events directory is and not inside events d
preprocessor defines to enable features based on CPU architecture
GLboolean GLboolean GLboolean b
GLuint GLsizei GLsizei * length
std::vector< T, fair::mq::pmr::polymorphic_allocator< T > > vector
bool readFile(std::string filename, o2::mid::Decoder &decoder, std::vector< o2::mid::ROBoard > &data, std::vector< o2::mid::ROFRecord > &rofRecords, unsigned long int nHBFs)
DecodeBuffer(size_t sourceSize)
bool operator==(const T &correct)
std::vector< source_T > literals
stream_T * encodeBufferEnd
EncodeBuffer(size_t sourceSize)
std::vector< o2::ctf::BufferType > vec