Project
Loading...
Searching...
No Matches
MoveBuffer.h
Go to the documentation of this file.
1// Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3// All rights not expressly granted are reserved.
4//
5// This software is distributed under the terms of the GNU General Public
6// License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7//
8// In applying this license CERN does not waive the privileges and immunities
9// granted to it by virtue of its status as an Intergovernmental Organization
10// or submit itself to any jurisdiction.
11
12#ifndef O2_MCH_RAW_IMPL_HELPERS_MOVEBUFFER_H
13#define O2_MCH_RAW_IMPL_HELPERS_MOVEBUFFER_H
14
15#include <vector>
16#include <iostream>
17#include <gsl/span>
18
19namespace o2::mch::raw::impl
20{
21
24size_t copyBuffer(const std::vector<uint64_t>& b64,
25 std::vector<std::byte>& b8,
26 uint64_t prefix = 0)
27{
28 constexpr uint64_t m = 0xFF;
29 auto s8 = b8.size();
30 b8.reserve(s8 + b64.size() / 8);
31 for (auto& b : b64) {
32 uint64_t g = b | prefix;
33 for (uint64_t i = 0; i < 64; i += 8) {
34 uint64_t w = m << i;
35 b8.emplace_back(std::byte{static_cast<uint8_t>((g & w) >> i)});
36 }
37 }
38 return b8.size() - s8;
39}
40
43size_t moveBuffer(std::vector<uint64_t>& b64,
44 std::vector<std::byte>& b8,
45 uint64_t prefix = 0)
46{
47 auto s = copyBuffer(b64, b8, prefix);
48 b64.clear();
49 return s;
50}
51
52uint64_t b8to64(gsl::span<const std::byte> buffer, size_t i)
53{
54 return (static_cast<uint64_t>(buffer[i + 0])) |
55 (static_cast<uint64_t>(buffer[i + 1]) << 8) |
56 (static_cast<uint64_t>(buffer[i + 2]) << 16) |
57 (static_cast<uint64_t>(buffer[i + 3]) << 24) |
58 (static_cast<uint64_t>(buffer[i + 4]) << 32) |
59 (static_cast<uint64_t>(buffer[i + 5]) << 40) |
60 (static_cast<uint64_t>(buffer[i + 6]) << 48) |
61 (static_cast<uint64_t>(buffer[i + 7]) << 56);
62}
63
66size_t copyBuffer(gsl::span<const std::byte> b8,
67 std::vector<uint64_t>& b64,
68 uint64_t prefix = 0)
69{
70 if (b8.size() % 8) {
71 throw std::invalid_argument("b8 span must have a size that is a multiple of 8");
72 }
73 auto s = b64.size();
74 for (auto i = 0; i < b8.size(); i += 8) {
75 uint64_t w = b8to64(b8, i);
76 b64.emplace_back(w | prefix);
77 }
78 return b64.size() - s;
79}
80
81} // namespace o2::mch::raw::impl
82
83#endif
int32_t i
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 s
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
GLboolean GLboolean g
Definition glcorearb.h:1233
const GLfloat * m
Definition glcorearb.h:4066
GLboolean GLboolean GLboolean b
Definition glcorearb.h:1233
GLubyte GLubyte GLubyte GLubyte w
Definition glcorearb.h:852
uint64_t b8to64(gsl::span< const std::byte > buffer, size_t i)
Definition MoveBuffer.h:52
size_t copyBuffer(const std::vector< uint64_t > &b64, std::vector< std::byte > &b8, uint64_t prefix=0)
Definition MoveBuffer.h:24
size_t moveBuffer(std::vector< uint64_t > &b64, std::vector< std::byte > &b8, uint64_t prefix=0)
Definition MoveBuffer.h:43