Skip to content

Error if number of offsets passed to accessor does not match declaration #1696

@jdahm

Description

@jdahm

I noticed that there is no static assertion when the number of accessor arguments does not match the SID. In particular this happens for temporaries declared with GT_DECLARE_TMP, for example in this bit of code:

#include <gridtools/stencil/cartesian.hpp>
#include <gridtools/stencil/cpu_kfirst.hpp>

namespace stencil_impl_ {
using Domain = std::array<gridtools::uint_t, 3>;
using namespace gridtools::stencil;
using namespace gridtools::stencil::cartesian;

struct HorizontalExecution7645380272 {
  using tmp = inout_accessor<0, extent<0, 0, 0, 0, 0, 0>, 4>;
  using in_field = in_accessor<1, extent<0, 0, 0, 0, 0, 1>, 3>;
  using out_field = inout_accessor<2, extent<0, 0, 0, 0, 0, 0>, 3>;

  using param_list = make_param_list<tmp, in_field, out_field>;

  template <typename Evaluation>
  GT_FUNCTION static void
  apply(Evaluation eval, gridtools::stencil::core::interval<
                             gridtools::stencil::core::level<0, 1, 3>,
                             gridtools::stencil::core::level<1, -2, 3>>) {

    eval(tmp(0, 0, 0, static_cast<std::int32_t>(0))) = eval(in_field());
    eval(tmp(0, 0, 0, static_cast<std::int32_t>(1))) = eval(in_field(0, 0, 1));
    eval(out_field()) = (eval(tmp(0, 0, 0, static_cast<std::int32_t>(0))) +
                         eval(tmp(0, 0, 0, static_cast<std::int32_t>(1))));
  }
};

auto stencil(Domain domain) {
  return [domain](auto &&in_field, auto &&out_field) {
    {
      auto grid = make_grid(domain[0], domain[1],
                            axis<1, axis_config::offset_limit<3>>{domain[2]});

      auto GTComputationCall7644409616 = [](auto in_field, auto out_field) {
        GT_DECLARE_TMP(double, tmp);
        return multi_pass(execute_parallel().ij_cached(tmp).stage(
            HorizontalExecution7645380272(), tmp, in_field, out_field));
      };

      run(GTComputationCall7644409616, cpu_kfirst<>{}, grid,
          std::forward<decltype(in_field)>(in_field),
          std::forward<decltype(out_field)>(out_field));
    }
  };
}
} // namespace stencil_impl_

auto stencil(stencil_impl_::Domain domain) {
  return stencil_impl_::stencil(domain);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions