Skip to content

Commit

Permalink
DPL Analysis: optimise compilation
Browse files Browse the repository at this point in the history
Avoids iterating on dynamic and persistent columns separately when
doing the bindings.

As a side effect we can get rid of the dynamic_columns_t type completely.
  • Loading branch information
ktf committed Jun 25, 2024
1 parent a067a54 commit 539bb82
Showing 1 changed file with 15 additions and 19 deletions.
34 changes: 15 additions & 19 deletions Framework/Core/include/Framework/ASoA.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "Framework/ArrowTypes.h"
#include "Framework/ArrowTableSlicingCache.h"
#include "Framework/SliceCache.h"
#include "Framework/VariantHelpers.h"
#include <arrow/table.h>
#include <arrow/array.h>
#include <arrow/util/config.h>
Expand Down Expand Up @@ -558,6 +559,9 @@ using is_persistent_t = decltype(persistent_type_helper::test<T>(nullptr));
template <typename T>
constexpr auto is_persistent_v = is_persistent_t<T>::value;

template <typename T>
constexpr auto is_dynamic_v = is_dynamic_t<T>::value;

template <typename T>
using is_external_index_t = typename std::conditional<is_index_column_v<T>, std::true_type, std::false_type>::type;

Expand Down Expand Up @@ -784,7 +788,6 @@ struct RowViewCore : public IP, C... {
using table_t = o2::soa::Table<C...>;
using all_columns = framework::pack<C...>;
using persistent_columns_t = framework::selected_pack<is_persistent_t, C...>;
using dynamic_columns_t = framework::selected_pack<is_dynamic_t, C...>;
using index_columns_t = framework::selected_pack<is_index_t, C...>;
constexpr inline static bool has_index_v = framework::pack_size(index_columns_t{}) > 0;
using external_index_columns_t = framework::selected_pack<is_external_index_t, C...>;
Expand All @@ -794,8 +797,7 @@ struct RowViewCore : public IP, C... {
: IP{policy},
C(columnData[framework::has_type_at_v<C>(all_columns{})])...
{
bindIterators(persistent_columns_t{});
bindAllDynamicColumns(dynamic_columns_t{});
bind();
// In case we have an index column might need to constrain the actual
// number of rows in the view to the range provided by the index.
// FIXME: we should really understand what happens to an index when we
Expand All @@ -810,25 +812,22 @@ struct RowViewCore : public IP, C... {
: IP{static_cast<IP const&>(other)},
C(static_cast<C const&>(other))...
{
bindIterators(persistent_columns_t{});
bindAllDynamicColumns(dynamic_columns_t{});
bind();
}

RowViewCore& operator=(RowViewCore other)
{
IP::operator=(static_cast<IP const&>(other));
(void(static_cast<C&>(*this) = static_cast<C>(other)), ...);
bindIterators(persistent_columns_t{});
bindAllDynamicColumns(dynamic_columns_t{});
bind();
return *this;
}

RowViewCore(RowViewCore<FilteredIndexPolicy, C...> const& other) requires std::is_same_v<IP, DefaultIndexPolicy>
: IP{static_cast<IP const&>(other)},
C(static_cast<C const&>(other))...
{
bindIterators(persistent_columns_t{});
bindAllDynamicColumns(dynamic_columns_t{});
bind();
}

RowViewCore& operator++()
Expand Down Expand Up @@ -947,18 +946,15 @@ struct RowViewCore : public IP, C... {

/// Helper which binds all the ColumnIterators to the
/// index of a the associated RowView
template <typename... PC>
auto bindIterators(framework::pack<PC...>)
{
using namespace o2::soa;
(void(PC::mColumnIterator.mCurrentPos = &this->mRowIndex), ...);
}

template <typename... DC>
auto bindAllDynamicColumns(framework::pack<DC...>)
void bind()
{
using namespace o2::soa;
(bindDynamicColumn<DC>(typename DC::bindings_t{}), ...);
auto f = framework::overloaded {
[this]<typename T>(T*) -> void requires is_persistent_v<T> { T::mColumnIterator.mCurrentPos = &this->mRowIndex; },
[this]<typename T>(T*) -> void requires is_dynamic_v<T> { bindDynamicColumn<T>(typename T::bindings_t{});},
[this]<typename T>(T*) -> void {},
};
(f(static_cast<C*>(nullptr)), ...);
if constexpr (has_index_v) {
this->setIndices(this->getIndices());
this->setOffsets(this->getOffsets());
Expand Down

0 comments on commit 539bb82

Please sign in to comment.