Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fn: introduce fn::index as alias to positional #1806

Merged
merged 3 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions include/gridtools/fn/common_interface.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@
*/
#pragma once

#include <type_traits>

#include "../common/tuple.hpp"
#include "../common/tuple_util.hpp"
#include "../stencil/positional.hpp"
#include "./backend/common.hpp"

namespace gridtools::fn {
Expand All @@ -30,4 +33,9 @@ namespace gridtools::fn {
return {std::forward<Args>(args)...};
}

template <class D>
constexpr auto index(D) {
return gridtools::stencil::positional<D>();
}

} // namespace gridtools::fn
8 changes: 3 additions & 5 deletions include/gridtools/fn/unstructured.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include "../common/ldg_ptr.hpp"
#include "../meta/logical.hpp"
#include "../sid/concept.hpp"
#include "../stencil/positional.hpp"
#include "./common_interface.hpp"
#include "./executor.hpp"
#include "./neighbor_table.hpp"
Expand All @@ -28,7 +27,6 @@ namespace gridtools::fn {
} // namespace unstructured::dim

namespace unstructured_impl_ {
using gridtools::stencil::positional;
namespace dim = unstructured::dim;

template <class Tables, class Sizes>
Expand Down Expand Up @@ -145,13 +143,13 @@ namespace gridtools::fn {
Domain m_domain;
TmpAllocator m_allocator;

static constexpr auto index = positional<dim::horizontal>();
static constexpr auto horizontal_index = index(dim::horizontal{});

auto stencil_executor() const {
return [&] {
return make_stencil_executor<1>(
m_backend, m_domain.m_sizes, m_domain.m_offsets, make_iterator(m_domain.without_offsets()))
.arg(index); // the horizontal index is passed as the first argument
.arg(horizontal_index); // the horizontal index is passed as the first argument
};
}

Expand All @@ -160,7 +158,7 @@ namespace gridtools::fn {
return [&] {
return make_vertical_executor<Vertical, 1>(
m_backend, m_domain.m_sizes, m_domain.m_offsets, make_iterator(m_domain.without_offsets()))
.arg(index); // the horizontal index is passed as the first argument
.arg(horizontal_index); // the horizontal index is passed as the first argument
};
}
};
Expand Down
Loading