Skip to content

Commit 28d2013

Browse files
authored
Merge c8a21c1 into sapling-pr-archive-ktf
2 parents 2f98e52 + c8a21c1 commit 28d2013

File tree

17 files changed

+144
-208
lines changed

17 files changed

+144
-208
lines changed

DataFormats/Detectors/GlobalTracking/src/RecoContainer.cxx

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,8 +1440,7 @@ RecoContainer::GlobalIDSet RecoContainer::getSingleDetectorRefs(GTrackID gidx) c
14401440
table[GTrackID::TRD] = parent0.getTrackRef(); // there is no standalone TRD track, so use the index for the ITSTPCTRD track array
14411441
} else if (src == GTrackID::TPCTRDTOF) {
14421442
const auto& parent0 = getTOFMatch(gidx); // TPCTRD : TOF
1443-
const auto& parent1 = getITSTPCTRDTrack<o2::trd::TrackTRD>(parent0.getTrackRef());
1444-
const auto& parent2 = getTPCITSTrack(parent1.getRefGlobalTrackId());
1443+
const auto& parent1 = getTPCTRDTrack<o2::trd::TrackTRD>(parent0.getTrackRef());
14451444
table[GTrackID::TPCTRD] = parent0.getTrackRef();
14461445
table[GTrackID::TPC] = parent1.getRefGlobalTrackId();
14471446
table[GTrackID::TOF] = {unsigned(parent0.getIdxTOFCl()), GTrackID::TOF};
@@ -1547,8 +1546,6 @@ const o2::dataformats::MCTruthContainer<o2::emcal::MCLabel>* RecoContainer::getE
15471546
void RecoContainer::getTrackTimeITSTPCTRDTOF(GTrackID gid, float& t, float& tErr) const
15481547
{
15491548
const auto& match = getITSTPCTRDTOFMatches()[gid];
1550-
auto gidx = match.getTrackRef(); // this should be corresponding ITS-TPC-TRD track
1551-
// const auto& tofCl = getTOFClusters()[match.getTOFClIndex()];
15521549
t = (match.getSignal() - match.getLTIntegralOut().getTOF(o2::track::PID::Pion)) * PS2MUS; // tof time in \mus, FIXME: account for time of flight to R TOF
15531550
tErr = 0.010f;
15541551
}
@@ -1557,8 +1554,6 @@ void RecoContainer::getTrackTimeITSTPCTRDTOF(GTrackID gid, float& t, float& tErr
15571554
void RecoContainer::getTrackTimeTPCTRDTOF(GTrackID gid, float& t, float& tErr) const
15581555
{
15591556
const auto& match = getTPCTRDTOFMatches()[gid];
1560-
auto gidx = match.getTrackRef(); // this should be corresponding ITS-TPC-TRD track
1561-
// const auto& tofCl = getTOFClusters()[match.getTOFClIndex()];
15621557
t = (match.getSignal() - match.getLTIntegralOut().getTOF(o2::track::PID::Pion)) * PS2MUS; // tof time in \mus, FIXME: account for time of flight to R TOF
15631558
tErr = 0.010f;
15641559
}
@@ -1567,8 +1562,6 @@ void RecoContainer::getTrackTimeTPCTRDTOF(GTrackID gid, float& t, float& tErr) c
15671562
void RecoContainer::getTrackTimeITSTPCTOF(GTrackID gid, float& t, float& tErr) const
15681563
{
15691564
const auto& match = getITSTPCTOFMatches()[gid];
1570-
auto gidx = match.getTrackRef(); // this should be corresponding ITS-TPC track
1571-
// const auto& tofCl = getTOFClusters()[match.getTOFClIndex()];
15721565
t = (match.getSignal() - match.getLTIntegralOut().getTOF(o2::track::PID::Pion)) * PS2MUS; // tof time in \mus, FIXME: account for time of flight to R TOF
15731566
tErr = 0.010f;
15741567
}

Framework/Core/include/Framework/TableBuilder.h

Lines changed: 9 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,11 @@ class Table;
4242
class Array;
4343
} // namespace arrow
4444

45-
template <typename T>
46-
struct BulkInfo {
47-
const T ptr;
48-
size_t size;
49-
};
45+
extern template class arrow::NumericBuilder<arrow::UInt8Type>;
46+
extern template class arrow::NumericBuilder<arrow::UInt32Type>;
47+
extern template class arrow::NumericBuilder<arrow::FloatType>;
48+
extern template class arrow::NumericBuilder<arrow::Int32Type>;
49+
extern template class arrow::NumericBuilder<arrow::Int8Type>;
5050

5151
extern template class arrow::NumericBuilder<arrow::UInt8Type>;
5252
extern template class arrow::NumericBuilder<arrow::UInt32Type>;
@@ -200,34 +200,6 @@ struct BuilderUtils {
200200
}
201201
}
202202

203-
template <typename HolderType, typename PTR>
204-
static arrow::Status bulkAppend(HolderType& holder, size_t bulkSize, const PTR ptr)
205-
{
206-
return holder.builder->AppendValues(ptr, bulkSize, nullptr);
207-
}
208-
209-
template <typename HolderType, typename PTR>
210-
static arrow::Status bulkAppendChunked(HolderType& holder, BulkInfo<PTR> info)
211-
{
212-
// Appending nullptr is a no-op.
213-
if (info.ptr == nullptr) {
214-
return arrow::Status::OK();
215-
}
216-
if constexpr (std::is_same_v<decltype(holder.builder), std::unique_ptr<arrow::FixedSizeListBuilder>>) {
217-
if (appendToList<std::remove_pointer_t<decltype(info.ptr)>>(holder.builder, info.ptr, info.size).ok() == false) {
218-
throw runtime_error("Unable to append to column");
219-
} else {
220-
return arrow::Status::OK();
221-
}
222-
} else {
223-
if (holder.builder->AppendValues(info.ptr, info.size, nullptr).ok() == false) {
224-
throw runtime_error("Unable to append to column");
225-
} else {
226-
return arrow::Status::OK();
227-
}
228-
}
229-
}
230-
231203
template <typename HolderType, typename ITERATOR>
232204
static arrow::Status append(HolderType& holder, std::pair<ITERATOR, ITERATOR> ip)
233205
{
@@ -518,14 +490,6 @@ struct TableBuilderHelpers {
518490
return {BuilderTraits<ARGS>::make_datatype()...};
519491
}
520492

521-
template <typename... ARGS, size_t NCOLUMNS = sizeof...(ARGS)>
522-
static std::vector<std::shared_ptr<arrow::Field>> makeFields(std::array<char const*, NCOLUMNS> const& names)
523-
{
524-
char const* const* names_ptr = names.data();
525-
return {
526-
std::make_shared<arrow::Field>(*names_ptr++, BuilderMaker<ARGS>::make_datatype(), true, nullptr)...};
527-
}
528-
529493
/// Invokes the append method for each entry in the tuple
530494
template <typename... Ts, typename VALUES>
531495
static bool append(std::tuple<Ts...>& holders, VALUES&& values)
@@ -542,19 +506,6 @@ struct TableBuilderHelpers {
542506
(BuilderUtils::unsafeAppend(std::get<Ts::index>(holders), std::get<Ts::index>(values)), ...);
543507
}
544508

545-
template <typename... Ts, typename PTRS>
546-
static bool bulkAppend(std::tuple<Ts...>& holders, size_t bulkSize, PTRS ptrs)
547-
{
548-
return (BuilderUtils::bulkAppend(std::get<Ts::index>(holders), bulkSize, std::get<Ts::index>(ptrs)).ok() && ...);
549-
}
550-
551-
/// Return true if all columns are done.
552-
template <typename... Ts, typename INFOS>
553-
static bool bulkAppendChunked(std::tuple<Ts...>& holders, INFOS infos)
554-
{
555-
return (BuilderUtils::bulkAppendChunked(std::get<Ts::index>(holders), std::get<Ts::index>(infos)).ok() && ...);
556-
}
557-
558509
/// Invokes the append method for each entry in the tuple
559510
template <typename... Ts>
560511
static bool finalize(std::vector<std::shared_ptr<arrow::Array>>& arrays, std::tuple<Ts...>& holders)
@@ -575,15 +526,9 @@ constexpr auto tuple_to_pack(std::tuple<ARGS...>&&)
575526
return framework::pack<ARGS...>{};
576527
}
577528

578-
template <typename T>
579-
concept BulkInsertable = (std::integral<std::decay<T>> && !std::same_as<bool, std::decay_t<T>>);
580-
581529
template <typename T>
582530
struct InsertionTrait {
583-
static consteval DirectInsertion<T> policy()
584-
requires(!BulkInsertable<T>);
585-
static consteval CachedInsertion<T> policy()
586-
requires(BulkInsertable<T>);
531+
static consteval DirectInsertion<T> policy();
587532
using Policy = decltype(policy());
588533
};
589534

@@ -658,7 +603,9 @@ class TableBuilder
658603
template <typename... ARGS, size_t I = sizeof...(ARGS)>
659604
auto makeBuilders(std::array<char const*, I> const& columnNames, size_t nRows)
660605
{
661-
mSchema = std::make_shared<arrow::Schema>(TableBuilderHelpers::makeFields<ARGS...>(columnNames));
606+
char const* const* names_ptr = columnNames.data();
607+
mSchema = std::make_shared<arrow::Schema>(
608+
std::vector<std::shared_ptr<arrow::Field>>({std::make_shared<arrow::Field>(*names_ptr++, BuilderMaker<ARGS>::make_datatype(), true, nullptr)...}));
662609

663610
mHolders = makeHolders<ARGS...>(mMemoryPool, nRows);
664611
mFinalizer = [](std::vector<std::shared_ptr<arrow::Array>>& arrays, void* holders) -> bool {
@@ -768,45 +715,6 @@ class TableBuilder
768715
}(typename T::table_t::persistent_columns_t{});
769716
}
770717

771-
template <typename... ARGS, size_t NCOLUMNS = sizeof...(ARGS)>
772-
auto preallocatedPersist(std::array<char const*, NCOLUMNS> const& columnNames, int nRows)
773-
{
774-
constexpr size_t nColumns = NCOLUMNS;
775-
validate();
776-
mArrays.resize(nColumns);
777-
makeBuilders<ARGS...>(columnNames, nRows);
778-
779-
// Callback used to fill the builders
780-
return [holders = mHolders](unsigned int /*slot*/, typename BuilderMaker<ARGS>::FillType... args) -> void {
781-
TableBuilderHelpers::unsafeAppend(*(HoldersTupleIndexed<ARGS...>*)holders, std::forward_as_tuple(args...));
782-
};
783-
}
784-
785-
template <typename... ARGS, size_t NCOLUMNS = sizeof...(ARGS)>
786-
auto bulkPersist(std::array<char const*, NCOLUMNS> const& columnNames, size_t nRows)
787-
{
788-
validate();
789-
// Should not be called more than once
790-
mArrays.resize(NCOLUMNS);
791-
makeBuilders<ARGS...>(columnNames, nRows);
792-
793-
return [holders = mHolders](unsigned int /*slot*/, size_t batchSize, typename BuilderMaker<ARGS>::FillType const*... args) -> void {
794-
TableBuilderHelpers::bulkAppend(*(HoldersTupleIndexed<ARGS...>*)holders, batchSize, std::forward_as_tuple(args...));
795-
};
796-
}
797-
798-
template <typename... ARGS, size_t NCOLUMNS = sizeof...(ARGS)>
799-
auto bulkPersistChunked(std::array<char const*, NCOLUMNS> const& columnNames, size_t nRows)
800-
{
801-
validate();
802-
mArrays.resize(NCOLUMNS);
803-
makeBuilders<ARGS...>(columnNames, nRows);
804-
805-
return [holders = mHolders](unsigned int /*slot*/, BulkInfo<typename BuilderMaker<ARGS>::STLValueType const*>... args) -> bool {
806-
return TableBuilderHelpers::bulkAppendChunked(*(HoldersTupleIndexed<ARGS...>*)holders, std::forward_as_tuple(args...));
807-
};
808-
}
809-
810718
/// Reserve method to expand the columns as needed.
811719
template <typename... Ts>
812720
auto reserveArrays(std::tuple<Ts...>& holders, int s)

Framework/Core/test/benchmark_TableBuilder.cxx

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -62,39 +62,6 @@ static void BM_TableBuilderScalarReserved(benchmark::State& state)
6262
BENCHMARK(BM_TableBuilderScalarReserved)->Arg(1 << 21);
6363
BENCHMARK(BM_TableBuilderScalarReserved)->Range(8, 8 << 16);
6464

65-
static void BM_TableBuilderScalarPresized(benchmark::State& state)
66-
{
67-
using namespace o2::framework;
68-
for (auto _ : state) {
69-
TableBuilder builder;
70-
auto rowWriter = builder.preallocatedPersist<float>({"x"}, state.range(0));
71-
for (auto i = 0; i < state.range(0); ++i) {
72-
rowWriter(0, 0.f);
73-
}
74-
auto table = builder.finalize();
75-
}
76-
}
77-
78-
BENCHMARK(BM_TableBuilderScalarPresized)->Arg(1 << 20);
79-
BENCHMARK(BM_TableBuilderScalarPresized)->Range(8, 8 << 16);
80-
81-
static void BM_TableBuilderScalarBulk(benchmark::State& state)
82-
{
83-
using namespace o2::framework;
84-
auto chunkSize = state.range(0) / 256;
85-
std::vector<float> buffer(chunkSize, 0.); // We assume data is chunked in blocks 256th of the total size
86-
for (auto _ : state) {
87-
TableBuilder builder;
88-
auto bulkWriter = builder.bulkPersist<float>({"x"}, state.range(0));
89-
for (auto i = 0; i < state.range(0) / chunkSize; ++i) {
90-
bulkWriter(0, chunkSize, buffer.data());
91-
}
92-
auto table = builder.finalize();
93-
}
94-
}
95-
96-
BENCHMARK(BM_TableBuilderScalarBulk)->Range(256, 1 << 20);
97-
9865
static void BM_TableBuilderSimple(benchmark::State& state)
9966
{
10067
using namespace o2::framework;

Framework/Core/test/test_TableBuilder.cxx

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -162,30 +162,6 @@ TEST_CASE("TestTableBuilderStruct")
162162
}
163163
}
164164

165-
TEST_CASE("TestTableBuilderBulk")
166-
{
167-
using namespace o2::framework;
168-
TableBuilder builder;
169-
auto bulkWriter = builder.bulkPersist<int, int>({"x", "y"}, 10);
170-
int x[] = {0, 1, 2, 3, 4, 5, 6, 7};
171-
int y[] = {0, 1, 2, 3, 4, 5, 6, 7};
172-
173-
bulkWriter(0, 8, x, y);
174-
175-
auto table = builder.finalize();
176-
REQUIRE(table->num_columns() == 2);
177-
REQUIRE(table->num_rows() == 8);
178-
REQUIRE(table->schema()->field(0)->name() == "x");
179-
REQUIRE(table->schema()->field(1)->name() == "y");
180-
REQUIRE(table->schema()->field(0)->type()->id() == arrow::int32()->id());
181-
REQUIRE(table->schema()->field(1)->type()->id() == arrow::int32()->id());
182-
183-
for (int64_t i = 0; i < 8; ++i) {
184-
auto p = std::dynamic_pointer_cast<arrow::NumericArray<arrow::Int32Type>>(table->column(0)->chunk(0));
185-
REQUIRE(p->Value(i) == i);
186-
}
187-
}
188-
189165
TEST_CASE("TestTableBuilderMore")
190166
{
191167
using namespace o2::framework;
@@ -288,13 +264,3 @@ TEST_CASE("TestColumnCount")
288264
int count2 = TableBuilder::countColumns<float, int, char[3]>();
289265
REQUIRE(count2 == 3);
290266
}
291-
292-
TEST_CASE("TestMakeFields")
293-
{
294-
auto fields = TableBuilderHelpers::makeFields<int, float>({"i", "f"});
295-
REQUIRE(fields.size() == 2);
296-
REQUIRE(fields[0]->name() == "i");
297-
REQUIRE(fields[1]->name() == "f");
298-
REQUIRE(fields[0]->type()->name() == "int32");
299-
REQUIRE(fields[1]->type()->name() == "float");
300-
}

GPU/Common/GPUCommonTypeTraits.h

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <type_traits>
2323
#endif
2424
#else
25-
// We just reimplement some type traits in std for the GPU
25+
// We just reimplement some type traits in std for the GPU // TODO: Check if meanwhile we can get rid of GPUCommonTypeTraits and GPUCommonArray, and just use the std headers.
2626
namespace std
2727
{
2828
template <bool B, class T, class F>
@@ -35,6 +35,7 @@ struct conditional<false, T, F> {
3535
};
3636
template <bool B, class T, class F>
3737
using contitional_t = typename conditional<B, T, F>::type;
38+
3839
template <class T, class U>
3940
struct is_same {
4041
static constexpr bool value = false;
@@ -45,13 +46,15 @@ struct is_same<T, T> {
4546
};
4647
template <class T, class U>
4748
static constexpr bool is_same_v = is_same<T, U>::value;
49+
4850
template <bool B, class T = void>
4951
struct enable_if {
5052
};
5153
template <class T>
5254
struct enable_if<true, T> {
5355
typedef T type;
5456
};
57+
5558
template <class T>
5659
struct remove_cv {
5760
typedef T type;
@@ -68,6 +71,9 @@ template <class T>
6871
struct remove_cv<const volatile T> {
6972
typedef T type;
7073
};
74+
template <class T>
75+
using remove_cv_t = typename remove_cv<T>::type;
76+
7177
template <class T>
7278
struct remove_const {
7379
typedef T type;
@@ -76,6 +82,9 @@ template <class T>
7682
struct remove_const<const T> {
7783
typedef T type;
7884
};
85+
template <class T>
86+
using remove_const_t = typename remove_const<T>::type;
87+
7988
template <class T>
8089
struct remove_volatile {
8190
typedef T type;
@@ -84,6 +93,9 @@ template <class T>
8493
struct remove_volatile<volatile T> {
8594
typedef T type;
8695
};
96+
template <class T>
97+
using remove_volatile_t = typename remove_volatile<T>::type;
98+
8799
template <class T>
88100
struct is_pointer_t {
89101
static constexpr bool value = false;
@@ -95,6 +107,36 @@ struct is_pointer_t<T*> {
95107
template <class T>
96108
struct is_pointer : is_pointer_t<typename std::remove_cv<T>::type> {
97109
};
110+
111+
template <class T>
112+
struct remove_reference {
113+
typedef T type;
114+
};
115+
template <class T>
116+
struct remove_reference<T&> {
117+
typedef T type;
118+
};
119+
template <class T>
120+
struct remove_reference<T&&> {
121+
typedef T type;
122+
};
123+
template <class T>
124+
using remove_reference_t = typename remove_reference<T>::type;
125+
126+
template <class T>
127+
struct is_member_pointer_helper {
128+
static constexpr bool value = false;
129+
};
130+
template <class T, class U>
131+
struct is_member_pointer_helper<T U::*> {
132+
static constexpr bool value = true;
133+
};
134+
template <class T>
135+
struct is_member_pointer : is_member_pointer_helper<typename std::remove_cv<T>::type> {
136+
};
137+
template <class T>
138+
static constexpr bool is_member_pointer_v = is_member_pointer<T>::value;
139+
98140
} // namespace std
99141
#endif
100142

GPU/GPUTracking/Base/cuda/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ set(GPU_RTC_BIN ${CMAKE_CURRENT_BINARY_DIR}/GPUReconstructionCUDArtc)
6868
add_custom_command(
6969
OUTPUT ${GPU_RTC_BIN}.src
7070
COMMAND cp ${GPUDIR}/Base/cuda/GPUReconstructionCUDAIncludesSystem.h ${GPU_RTC_BIN}.src
71-
COMMAND ${CMAKE_CXX_COMPILER} ${GPU_RTC_DEFINES} ${GPU_RTC_INCLUDES} -std=c++${CMAKE_CUDA_STANDARD} -D__CUDA_ARCH__=${RTC_CUDA_ARCH} -D__CUDACC__ -x c++ -nostdinc -E -P ${GPU_RTC_SRC} >> ${GPU_RTC_BIN}.src
71+
COMMAND ${CMAKE_CUDA_COMPILER} ${GPU_RTC_DEFINES} ${GPU_RTC_INCLUDES} -std=c++${CMAKE_CUDA_STANDARD} -D__CUDA_ARCH__=${RTC_CUDA_ARCH} -D__CUDACC__ -x c++ -E -Xcompiler "-nostdinc -P" ${GPU_RTC_SRC} >> ${GPU_RTC_BIN}.src
7272
MAIN_DEPENDENCY ${GPU_RTC_SRC}
7373
IMPLICIT_DEPENDS CXX ${GPU_RTC_SRC}
7474
COMMAND_EXPAND_LISTS

0 commit comments

Comments
 (0)