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

GTFN CPU bindings cannot handle tuples #1044

Closed
samkellerhals opened this issue Nov 10, 2022 · 2 comments
Closed

GTFN CPU bindings cannot handle tuples #1044

samkellerhals opened this issue Nov 10, 2022 · 2 comments
Labels
gt4py.next Issues concerning the new version with support for non-cartesian grids. module: backend Related to analysis/backend subpackages

Comments

@samkellerhals
Copy link
Contributor

Field operators which return a tuple fail using the gtfn cpu backend:

Example field operators:

@field_operator
    def _unpack(
            inp: Field[[IDim], float64],
    ) -> tuple[
        Field[[IDim], float64],
        Field[[IDim], float64],
        Field[[IDim], float64],
        Field[[IDim], float64],
    ]:
        a, b, c, d = (inp + 2., inp + 3., inp + 5., inp + 7.)
        return a, b, c, d
@field_operator
    def _unpack(
            inp: Field[[IDim], float64],
    ) -> tuple[
        Field[[IDim], float64],
        Field[[IDim], float64],
        Field[[IDim], float64],
        Field[[IDim], float64],
        Field[[IDim], float64],
        Field[[IDim], float64],
        Field[[IDim], float64],
        Field[[IDim], float64],
        Field[[IDim], float64]
    ]:
        *a, a2, a3 = (inp, inp + 2., inp + 3., inp + 5.)
        b1, *b, b3 = (inp + 7., inp + 11., inp + 13., inp + 17.)
        c1, c2, *c = (inp + 19., inp + 23., inp + 29., inp + 31.)

        a_sum = a[0] + a[1]
        b_sum = b[0] + b[1]
        c_sum = c[0] + c[1]

        return a_sum, a2, a3, b1, b_sum, b3, c1, c2, c_sum

The following error occurs in the generated bindings:

/compile_commands_cache_gridtools_master_pybind11_2_9_2_Debug__7d6131381ac7c32e4f8dc19a1bccf7c68e5d21953a0fdafeb68f42bea07c5c45/build/_deps/gridtools-src/include/gridtools/fn/./common_interface.hpp:25:47: error: no matching function for call to ‘get<-1>(gridtools::tuple<double, double, double, double>)’
In file included from /tmp/gt4py_cache/compile_commands_cache_gridtools_master_pybind11_2_9_2_Debug__7d6131381ac7c32e4f8dc19a1bccf7c68e5d21953a0fdafeb68f42bea07c5c45/build/_deps/gridtools-src/include/gridtools/common/iterate_on_host_device.hpp:72,
                 from /tmp/gt4py_cache/compile_commands_cache_gridtools_master_pybind11_2_9_2_Debug__7d6131381ac7c32e4f8dc19a1bccf7c68e5d21953a0fdafeb68f42bea07c5c45/build/_deps/gridtools-src/include/gridtools/fn/backend/../../common/tuple_util.hpp:478,
                 from /tmp/gt4py_cache/compile_commands_cache_gridtools_master_pybind11_2_9_2_Debug__7d6131381ac7c32e4f8dc19a1bccf7c68e5d21953a0fdafeb68f42bea07c5c45/build/_deps/gridtools-src/include/gridtools/fn/backend/../../common/hymap.hpp:106,
                 from /tmp/gt4py_cache/compile_commands_cache_gridtools_master_pybind11_2_9_2_Debug__7d6131381ac7c32e4f8dc19a1bccf7c68e5d21953a0fdafeb68f42bea07c5c45/build/_deps/gridtools-src/include/gridtools/fn/backend/naive.hpp:13,
                 from /tmp/gt4py_cache/unpack_6cab28797b68484a541fc8abd58bcde586a1740d683737077b524e4d4321005a/unpack.cpp.inc:1,
                 from /tmp/gt4py_cache/unpack_6cab28797b68484a541fc8abd58bcde586a1740d683737077b524e4d4321005a/unpack_bindings.cpp:1:
/tmp/gt4py_cache/compile_commands_cache_gridtools_master_pybind11_2_9_2_Debug__7d6131381ac7c32e4f8dc19a1bccf7c68e5d21953a0fdafeb68f42bea07c5c45/build/_deps/gridtools-src/include/gridtools/common/tuple_util.hpp:518:64: note: candidate: ‘template<long unsigned int I, class T, class Getter> constexpr decltype(auto) gridtools::tuple_util::host::get(T&&)’
  518 |             GT_TARGET GT_FORCE_INLINE constexpr decltype(auto) get(T && obj) noexcept {
      |                                                                ^~~
/tmp/gt4py_cache/compile_commands_cache_gridtools_master_pybind11_2_9_2_Debug__7d6131381ac7c32e4f8dc19a1bccf7c68e5d21953a0fdafeb68f42bea07c5c45/build/_deps/gridtools-src/include/gridtools/common/tuple_util.hpp:518:64: note:   template argument deduction/substitution failed:
In file included from /tmp/gt4py_cache/compile_commands_cache_gridtools_master_pybind11_2_9_2_Debug__7d6131381ac7c32e4f8dc19a1bccf7c68e5d21953a0fdafeb68f42bea07c5c45/build/_deps/gridtools-src/include/gridtools/fn/cartesian.hpp:16,
                 from /tmp/gt4py_cache/unpack_6cab28797b68484a541fc8abd58bcde586a1740d683737077b524e4d4321005a/unpack.cpp.inc:4,
                 from /tmp/gt4py_cache/unpack_6cab28797b68484a541fc8abd58bcde586a1740d683737077b524e4d4321005a/unpack_bindings.cpp:1:
/tmp/gt4py_cache/compile_commands_cache_gridtools_master_pybind11_2_9_2_Debug__7d6131381ac7c32e4f8dc19a1bccf7c68e5d21953a0fdafeb68f42bea07c5c45/build/_deps/gridtools-src/include/gridtools/fn/./common_interface.hpp:25:47: error: narrowing conversion of ‘-1’ from ‘int’ to ‘long unsigned int’ [-Wnarrowing]
   25 |         return tuple_util::host_device::get<I>(std::forward<Tuple>(t));
      |                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/c++ -DBOOST_ALL_NO_LIB -Dunpack_EXPORTS -I/tmp/gt4py_cache/compile_commands_cache_gridtools_master_pybind11_2_9_2_Debug__7d6131381ac7c32e4f8dc19a1bccf7c68e5d21953a0fdafeb68f42bea07c5c45/build/_deps/gridtools-src/include -isystem /home/sk/Dev/gt4py/.venv/lib/python3.10/site-packages/pybind11/include -isystem /usr/include/python3.10 -g -fPIC -MD -MT build/unpack_bindings.cpp.o -MF build/unpack_bindings.cpp.o.d -o build/unpack_bindings.cpp.o -c /tmp/gt4py_cache/unpack_6cab28797b68484a541fc8abd58bcde586a1740d683737077b524e4d4321005a/unpack_bindings.cpp

@samkellerhals samkellerhals added the gt4py.next Issues concerning the new version with support for non-cartesian grids. label Nov 10, 2022
@samkellerhals samkellerhals added the module: backend Related to analysis/backend subpackages label Nov 10, 2022
@havogt havogt changed the title GTFN CPU cannot return tuples GTFN CPU bindings cannot handle tuples Nov 10, 2022
@havogt
Copy link
Contributor

havogt commented Nov 10, 2022

Creating the bindings for tuples is part of this cycle (if we don't need the resources for one of the more urgent projects).

@havogt
Copy link
Contributor

havogt commented Jan 25, 2024

done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gt4py.next Issues concerning the new version with support for non-cartesian grids. module: backend Related to analysis/backend subpackages
Projects
Status: Done
Development

No branches or pull requests

2 participants