serge-sans-paille / pythran

Ahead of Time compiler for numeric kernels
https://pythran.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.01k stars 193 forks source link

Pass all arguments of generated function by value #2091

Closed serge-sans-paille closed 1 year ago

serge-sans-paille commented 1 year ago

This is faster for scalars, but not for objects, so we need to generate std::move accordingly

serge-sans-paille commented 1 year ago

@jeanlaroche this patchset brings significant changes, could you give it a try on your codebase?

jeanlaroche commented 1 year ago

I will be not before Sunday. Don't have my machine with me...

On 3/31/2023 11:57 PM, serge-sans-paille wrote:

@jeanlaroche https://github.com/jeanlaroche this patchset brings significant changes, could you give it a try on your codebase?

— Reply to this email directly, view it on GitHub https://github.com/serge-sans-paille/pythran/pull/2091#issuecomment-1492855405, or unsubscribe https://github.com/notifications/unsubscribe-auth/AGUBEPPGKK33LDGROJLJ3SDW67GV3ANCNFSM6AAAAAAV7PJH3Y. You are receiving this because you were mentioned.Message ID: @.***>

jeanlaroche commented 1 year ago

I'm getting this error in one of my scripts. Do you need me to try to determine where exactly this comes from or can you intuit what the issue is?

/Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/utils/broadcast_copy.hpp:268:23: error: no member named 'buffer' in
      '(anonymous namespace)::pythonic::types::list<long>'
      std::copy(other.buffer, other.buffer + other.flat_size(), self.buffer);

In file included from /Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/core.hpp:46:
In file included from /Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/types/slice.hpp:5:
In file included from /Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/types/NoneType.hpp:6:
In file included from /Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/builtins/bool_.hpp:6:
In file included from /Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/types/tuple.hpp:13:
In file included from /Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/types/ndarray.hpp:12:
/Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/utils/broadcast_copy.hpp:268:23: error: no member named 'buffer' in
      '(anonymous namespace)::pythonic::types::list<long>'
      std::copy(other.buffer, other.buffer + other.flat_size(), self.buffer);
                ~~~~~ ^
/Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/utils/broadcast_copy.hpp:300:12: note: in instantiation of function template specialization
      '(anonymous namespace)::pythonic::utils::broadcast_copy_helper<(anonymous namespace)::pythonic::types::numpy_gexpr<(anonymous namespace)::pythonic::types::numpy_iexpr<(anonymous
      namespace)::pythonic::types::numpy_iexpr<const (anonymous namespace)::pythonic::types::ndarray<double, (anonymous namespace)::pythonic::types::pshape<long, long, std::integral_constant<long, 2>>>
      &>>, (anonymous namespace)::pythonic::types::contiguous_normalized_slice> &, (anonymous namespace)::pythonic::types::list<long>, 1, 0, false>' requested here
    return broadcast_copy_helper<E, F, N, D, vector_form>(
jeanlaroche commented 1 year ago

I'm also getting runtime errors :( divides by zero for example.

serge-sans-paille commented 1 year ago

Your first example is enough for me to create a reproducer, thanks. We'll discuss the divide by zero aspect afterward :-)

jeanlaroche commented 1 year ago

Ah great, let me know when I can dig further. I think the other issues are related to the fact that an integer scalar is not getting updated from 0, I think I see that in a lot of places, and that could also be the cause for the / 0 ...

jeanlaroche commented 1 year ago

After pulling the latest version I get this error:

INFO: gcc: /var/folders/j6/7t8sg1vj4q97zhh9z5cdmxbm4rz935/T/tmpba0fmb0u.cpp
In file included from /var/folders/j6/7t8sg1vj4q97zhh9z5cdmxbm4rz935/T/tmpba0fmb0u.cpp:1:
In file included from /Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/core.hpp:46:
In file included from /Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/types/slice.hpp:5:
In file included from /Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/types/NoneType.hpp:6:
In file included from /Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/builtins/bool_.hpp:6:
In file included from /Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/types/tuple.hpp:13:
/Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/types/ndarray.hpp:1058:5: error: reference to non-static member function must be called
    data = utils::shared_ref<T>(other.begin(), other.end());
    ^~~~
/Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/include/types/list.hpp:330:12: note: possible target for call
    dtype* data() { return _data->data();}
           ^
/Users/jlaroche/ua_conda_env-Darwin.x86_64/lib/python3.8/site-packages/pythran/pythonic/include/types/list.hpp:331:18: note: possible target for call
    const dtype* data() const { return _data->data();}
serge-sans-paille commented 1 year ago

Obsoleted by #2098