From 7e9d76f55e21912c89e798724c7db42370d87a1e Mon Sep 17 00:00:00 2001 From: saganatt Date: Sat, 1 Jan 2022 23:00:28 +0100 Subject: [PATCH 1/4] Attempt at setting tables only once --- .../Core/include/Framework/AnalysisManagers.h | 12 ++++++++++- .../Core/include/Framework/AnalysisTask.h | 2 ++ .../include/Framework/GroupedCombinations.h | 21 +++++++++++++++---- 3 files changed, 30 insertions(+), 5 deletions(-) diff --git a/Framework/Core/include/Framework/AnalysisManagers.h b/Framework/Core/include/Framework/AnalysisManagers.h index d9daf7ab89147..ba7c09bf537ef 100644 --- a/Framework/Core/include/Framework/AnalysisManagers.h +++ b/Framework/Core/include/Framework/AnalysisManagers.h @@ -27,6 +27,8 @@ #include "Framework/ExpressionHelpers.h" #include "Framework/CommonServices.h" +#include + namespace o2::framework { @@ -45,7 +47,15 @@ struct GroupedCombinationManager 0, "There must be associated tables in process() for a correct pair"); static_assert(!soa::is_soa_iterator_t>::value, "Only full tables can be in process(), no grouping"); - if constexpr (std::conjunction_v, std::is_same>) { + std::cout << "Combinations grouping type: " << typeid(G).name() << " received grouping type: " << typeid(TG).name() << std::endl; + std::cout << "Combinations associated type:" << std::endl; + print_pack>(); + std::cout << "received associated type:" << std::endl; + print_pack>(); + std::cout << "Combinations unique types:" << std::endl; + print_pack>(); + if constexpr (std::is_same_v && std::is_same_v) { + std::cout << "Setting tables in manager" << std::endl; // Take respective unique associated tables for grouping auto associatedTuple = std::tuple(std::get(associated)...); comb.setTables(hashes, grouping, associatedTuple); diff --git a/Framework/Core/include/Framework/AnalysisTask.h b/Framework/Core/include/Framework/AnalysisTask.h index 7a20528622a65..cfbdc2672e59e 100644 --- a/Framework/Core/include/Framework/AnalysisTask.h +++ b/Framework/Core/include/Framework/AnalysisTask.h @@ -38,6 +38,7 @@ #include #include #include +#include namespace o2::framework { /// A more familiar task API for the DPL analysis framework. @@ -315,6 +316,7 @@ struct AnalysisDataProcessorBuilder { associatedTables); // GroupedCombinations bound separately, as they should be set once for all associated tables + std::cout << "Analysis task applying tables to grouped combs" << std::endl; auto hashes = std::get<0>(associatedTables); auto realAssociated = tuple_tail(associatedTables); homogeneous_apply_refs([&groupingTable, &hashes, &realAssociated](auto& t) { diff --git a/Framework/Core/include/Framework/GroupedCombinations.h b/Framework/Core/include/Framework/GroupedCombinations.h index 5f2bb736c4c58..7645f8d646bad 100644 --- a/Framework/Core/include/Framework/GroupedCombinations.h +++ b/Framework/Core/include/Framework/GroupedCombinations.h @@ -17,6 +17,8 @@ #include "Framework/Pack.h" #include +#include + namespace o2::framework { @@ -83,6 +85,7 @@ struct GroupedCombinationsGenerator, As... void setTables(const H& hashes, const G& grouping, std::shared_ptr> slicer_ptr) { + std::cout << "Setting tables" << std::endl; mGrouping = std::make_shared(std::vector{grouping.asArrowTable()}); mSlicer = slicer_ptr; setMultipleGroupingTables(join(hashes, grouping)); @@ -94,6 +97,7 @@ struct GroupedCombinationsGenerator, As... template void setMultipleGroupingTables(const T& param, const Args&... args) { + std::cout << "Setting grouping tables" << std::endl; if constexpr (N == 1) { GroupingPolicy::setTables(param, args...); } else { @@ -139,6 +143,7 @@ struct GroupedCombinationsGenerator, As... private: std::tuple getAssociatedTables() { + std::cout << "Getting associated tables" << std::endl; auto& currentGrouping = GroupingPolicy::mCurrent; constexpr auto k = sizeof...(As); auto slicerIterators = functionToTuple(&GroupSlicer::begin, *mSlicer); @@ -171,6 +176,7 @@ struct GroupedCombinationsGenerator, As... void setCurrentGroupedCombination() { + std::cout << "Setting grouped combination" << std::endl; std::tuple initAssociatedTables = getAssociatedTables(); constexpr auto k = sizeof...(As); bool moveForward = false; @@ -193,11 +199,14 @@ struct GroupedCombinationsGenerator, As... if (!this->mIsEnd) { auto& currentGrouping = GroupingPolicy::mCurrent; + std::cout << "Received current grouping" << std::endl; o2::soa::for_([&](auto i) { std::get(associatedTables).bindExternalIndices(mGrouping.get()); }); + std::cout << "Bound associated tables" << std::endl; mCurrentGrouped.emplace(interleaveTuples(currentGrouping, associatedTables)); + std::cout << "Interleaved tuples" << std::endl; } } @@ -235,10 +244,13 @@ struct GroupedCombinationsGenerator, As... void setTables(H& hashes, G& grouping, std::tuple& associated) { - std::shared_ptr slicer_ptr = std::make_shared>(grouping, associated); - mBegin.setTables(hashes, grouping, slicer_ptr); - mEnd.setTables(hashes, grouping, slicer_ptr); - mEnd.moveToEnd(); + std::cout << "Setting tables in generator" << std::endl; + if (mSlicer == nullptr) { + mSlicer = std::make_shared>(grouping, associated); + mBegin.setTables(hashes, grouping, mSlicer); + mEnd.setTables(hashes, grouping, mSlicer); + mEnd.moveToEnd(); + } } private: @@ -247,6 +259,7 @@ struct GroupedCombinationsGenerator, As... const char* mCategory; const int mCatNeighbours; const T1 mOutsider; + std::shared_ptr> mSlicer = nullptr; }; // Aliases for 2-particle correlations From 6bdf1095cff56e50d19c390d72e0d0f6e1298915 Mon Sep 17 00:00:00 2001 From: saganatt Date: Thu, 27 Jan 2022 15:47:14 +0100 Subject: [PATCH 2/4] Remove debug prints --- Framework/Core/include/Framework/AnalysisManagers.h | 10 ---------- Framework/Core/include/Framework/AnalysisTask.h | 2 -- Framework/Core/include/Framework/GroupedCombinations.h | 10 ---------- 3 files changed, 22 deletions(-) diff --git a/Framework/Core/include/Framework/AnalysisManagers.h b/Framework/Core/include/Framework/AnalysisManagers.h index ba7c09bf537ef..6bd4f46a649aa 100644 --- a/Framework/Core/include/Framework/AnalysisManagers.h +++ b/Framework/Core/include/Framework/AnalysisManagers.h @@ -27,8 +27,6 @@ #include "Framework/ExpressionHelpers.h" #include "Framework/CommonServices.h" -#include - namespace o2::framework { @@ -47,15 +45,7 @@ struct GroupedCombinationManager 0, "There must be associated tables in process() for a correct pair"); static_assert(!soa::is_soa_iterator_t>::value, "Only full tables can be in process(), no grouping"); - std::cout << "Combinations grouping type: " << typeid(G).name() << " received grouping type: " << typeid(TG).name() << std::endl; - std::cout << "Combinations associated type:" << std::endl; - print_pack>(); - std::cout << "received associated type:" << std::endl; - print_pack>(); - std::cout << "Combinations unique types:" << std::endl; - print_pack>(); if constexpr (std::is_same_v && std::is_same_v) { - std::cout << "Setting tables in manager" << std::endl; // Take respective unique associated tables for grouping auto associatedTuple = std::tuple(std::get(associated)...); comb.setTables(hashes, grouping, associatedTuple); diff --git a/Framework/Core/include/Framework/AnalysisTask.h b/Framework/Core/include/Framework/AnalysisTask.h index cfbdc2672e59e..7a20528622a65 100644 --- a/Framework/Core/include/Framework/AnalysisTask.h +++ b/Framework/Core/include/Framework/AnalysisTask.h @@ -38,7 +38,6 @@ #include #include #include -#include namespace o2::framework { /// A more familiar task API for the DPL analysis framework. @@ -316,7 +315,6 @@ struct AnalysisDataProcessorBuilder { associatedTables); // GroupedCombinations bound separately, as they should be set once for all associated tables - std::cout << "Analysis task applying tables to grouped combs" << std::endl; auto hashes = std::get<0>(associatedTables); auto realAssociated = tuple_tail(associatedTables); homogeneous_apply_refs([&groupingTable, &hashes, &realAssociated](auto& t) { diff --git a/Framework/Core/include/Framework/GroupedCombinations.h b/Framework/Core/include/Framework/GroupedCombinations.h index 7645f8d646bad..e23ba7e1cc199 100644 --- a/Framework/Core/include/Framework/GroupedCombinations.h +++ b/Framework/Core/include/Framework/GroupedCombinations.h @@ -17,8 +17,6 @@ #include "Framework/Pack.h" #include -#include - namespace o2::framework { @@ -85,7 +83,6 @@ struct GroupedCombinationsGenerator, As... void setTables(const H& hashes, const G& grouping, std::shared_ptr> slicer_ptr) { - std::cout << "Setting tables" << std::endl; mGrouping = std::make_shared(std::vector{grouping.asArrowTable()}); mSlicer = slicer_ptr; setMultipleGroupingTables(join(hashes, grouping)); @@ -97,7 +94,6 @@ struct GroupedCombinationsGenerator, As... template void setMultipleGroupingTables(const T& param, const Args&... args) { - std::cout << "Setting grouping tables" << std::endl; if constexpr (N == 1) { GroupingPolicy::setTables(param, args...); } else { @@ -143,7 +139,6 @@ struct GroupedCombinationsGenerator, As... private: std::tuple getAssociatedTables() { - std::cout << "Getting associated tables" << std::endl; auto& currentGrouping = GroupingPolicy::mCurrent; constexpr auto k = sizeof...(As); auto slicerIterators = functionToTuple(&GroupSlicer::begin, *mSlicer); @@ -176,7 +171,6 @@ struct GroupedCombinationsGenerator, As... void setCurrentGroupedCombination() { - std::cout << "Setting grouped combination" << std::endl; std::tuple initAssociatedTables = getAssociatedTables(); constexpr auto k = sizeof...(As); bool moveForward = false; @@ -199,14 +193,11 @@ struct GroupedCombinationsGenerator, As... if (!this->mIsEnd) { auto& currentGrouping = GroupingPolicy::mCurrent; - std::cout << "Received current grouping" << std::endl; o2::soa::for_([&](auto i) { std::get(associatedTables).bindExternalIndices(mGrouping.get()); }); - std::cout << "Bound associated tables" << std::endl; mCurrentGrouped.emplace(interleaveTuples(currentGrouping, associatedTables)); - std::cout << "Interleaved tuples" << std::endl; } } @@ -244,7 +235,6 @@ struct GroupedCombinationsGenerator, As... void setTables(H& hashes, G& grouping, std::tuple& associated) { - std::cout << "Setting tables in generator" << std::endl; if (mSlicer == nullptr) { mSlicer = std::make_shared>(grouping, associated); mBegin.setTables(hashes, grouping, mSlicer); From 303f34bd1d20c09253510a0eea1588419861a62e Mon Sep 17 00:00:00 2001 From: saganatt Date: Fri, 28 Jan 2022 17:12:45 +0100 Subject: [PATCH 3/4] Minor nitpicks and checking also associated tables for out-of-process() mixing --- Framework/Core/include/Framework/AnalysisManagers.h | 2 +- Framework/Core/include/Framework/GroupedCombinations.h | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Framework/Core/include/Framework/AnalysisManagers.h b/Framework/Core/include/Framework/AnalysisManagers.h index 6bd4f46a649aa..519a81e03c738 100644 --- a/Framework/Core/include/Framework/AnalysisManagers.h +++ b/Framework/Core/include/Framework/AnalysisManagers.h @@ -45,7 +45,7 @@ struct GroupedCombinationManager 0, "There must be associated tables in process() for a correct pair"); static_assert(!soa::is_soa_iterator_t>::value, "Only full tables can be in process(), no grouping"); - if constexpr (std::is_same_v && std::is_same_v) { + if constexpr (std::is_same_v && std::is_same_v && std::conjunction_v...>) { // Take respective unique associated tables for grouping auto associatedTuple = std::tuple(std::get(associated)...); comb.setTables(hashes, grouping, associatedTuple); diff --git a/Framework/Core/include/Framework/GroupedCombinations.h b/Framework/Core/include/Framework/GroupedCombinations.h index e23ba7e1cc199..a4f64e1a4d94e 100644 --- a/Framework/Core/include/Framework/GroupedCombinations.h +++ b/Framework/Core/include/Framework/GroupedCombinations.h @@ -231,6 +231,8 @@ struct GroupedCombinationsGenerator, As... { setTables(hashes, grouping, associated); } + GroupedCombinationsGenerator(GroupedCombinationsGenerator const&) = default; + GroupedCombinationsGenerator& operator=(GroupedCombinationsGenerator const&) = default; ~GroupedCombinationsGenerator() = default; void setTables(H& hashes, G& grouping, std::tuple& associated) @@ -257,13 +259,13 @@ struct GroupedCombinationsGenerator, As... template using joinedCollisions = typename soa::Join::table_t; template , joinedCollisions>> -using Pair = GroupedCombinationsGenerator>>; +using Pair = GroupedCombinationsGenerator>, A1, A2>; template , joinedCollisions>> using SameKindPair = GroupedCombinationsGenerator, A, A>; // Aliases for 3-particle correlations template , joinedCollisions, joinedCollisions>> -using Triple = GroupedCombinationsGenerator>>; +using Triple = GroupedCombinationsGenerator>, A1, A2, A3>; template , joinedCollisions, joinedCollisions>> using SameKindTriple = GroupedCombinationsGenerator, A, A, A>; From d26e49999862ff6115cf3d9c8bd159789be547ff Mon Sep 17 00:00:00 2001 From: saganatt Date: Fri, 28 Jan 2022 17:21:43 +0100 Subject: [PATCH 4/4] Remove check for associated --- Framework/Core/include/Framework/AnalysisManagers.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Framework/Core/include/Framework/AnalysisManagers.h b/Framework/Core/include/Framework/AnalysisManagers.h index 519a81e03c738..6bd4f46a649aa 100644 --- a/Framework/Core/include/Framework/AnalysisManagers.h +++ b/Framework/Core/include/Framework/AnalysisManagers.h @@ -45,7 +45,7 @@ struct GroupedCombinationManager 0, "There must be associated tables in process() for a correct pair"); static_assert(!soa::is_soa_iterator_t>::value, "Only full tables can be in process(), no grouping"); - if constexpr (std::is_same_v && std::is_same_v && std::conjunction_v...>) { + if constexpr (std::is_same_v && std::is_same_v) { // Take respective unique associated tables for grouping auto associatedTuple = std::tuple(std::get(associated)...); comb.setTables(hashes, grouping, associatedTuple);