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

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

Open
jdahm opened this issue Jan 21, 2022 · 0 comments
Open

Comments

@jdahm
Copy link
Contributor

jdahm commented Jan 21, 2022

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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant