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

Add most of the C++17 numeric functions to libcpp.numeric #4423

Merged
merged 15 commits into from Nov 2, 2021

Conversation

jhelgert
Copy link
Contributor

Adds most of the C++17 STL functions of the numeric library to libcpp.numeric, i.e.

  • reduce
  • transform_reduce
  • inclusive_scan
  • exclusive_scan
  • transform_inclusive_scan
  • transform_exclusive_scan

Unfortunately, I'm not really aware of an appropriate way to handle the ambiguous overloads in Cython only, so I excluded some of them, see also my question at the mailing list.

Copy link
Contributor

@scoder scoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. Minor nits below.

tests/run/cpp_stl_numeric_ops_cpp17.pyx Outdated Show resolved Hide resolved
Cython/Includes/libcpp/numeric.pxd Outdated Show resolved Hide resolved
@scoder scoder added this to the 3.0 milestone Oct 22, 2021
jhelgert and others added 2 commits October 23, 2021 08:45
@jhelgert
Copy link
Contributor Author

@scoder Should we worry about the failing job?

@scoder
Copy link
Contributor

scoder commented Oct 25, 2021

@scoder Should we worry about the failing job?

Yes, absolutely. It shows that your tests are failing due to incorrect C++ code being generated, e.g.

In file included from cpp_stl_numeric_ops_cpp17.cpp:811:
/usr/include/c++/11/numeric:534:5: note: candidate: ‘template<class _InputIterator, class _OutputIterator, class _BinaryOperation, class _Tp> _OutputIterator std::inclusive_scan(_InputIterator, _InputIterator, _OutputIterator, _BinaryOperation, _Tp)’
  534 |     inclusive_scan(_InputIterator __first, _InputIterator __last,
      |     ^~~~~~~~~~~~~~
/usr/include/c++/11/numeric:534:5: note:   template argument deduction/substitution failed:
cpp_stl_numeric_ops_cpp17.cpp:3781:146: error: wrong number of template arguments (5, should be 4)
 3781 |   (void)(std::inclusive_scan<std::execution::sequenced_policy const &,std::vector<int> ::iterator,std::vector<int> ::iterator,int (int, int),int>(std::execution::seq, __pyx_v_v.begin(), __pyx_v_v.end(), __pyx_v_out.begin(), __pyx_f_25cpp_stl_numeric_ops_cpp17_add_integers, __pyx_v_init));
In file included from /usr/include/c++/11/execution:43,
                 from cpp_stl_numeric_ops_cpp17.cpp:812:
/usr/include/c++/11/pstl/glue_numeric_impl.h:134:1: note: provided for ‘template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryOperation> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _Tp> std::inclusive_scan(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _BinaryOperation)’
  134 | inclusive_scan(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last,
      | ^~~~~~~~~~~~~~
/usr/include/c++/11/pstl/glue_numeric_impl.h:143:1: note: candidate: ‘__pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _Tp> std::inclusive_scan(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _BinaryOperation, _Tp) [with _ExecutionPolicy = const __pstl::execution::v1::sequenced_policy&; _ForwardIterator1 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _ForwardIterator2 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Tp = int(int, int); _BinaryOperation = int; __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _Tp> = std::enable_if<true, __gnu_cxx::__normal_iterator<int*, std::vector<int> > >::type]’ (near match)
  143 | inclusive_scan(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last,
      | ^~~~~~~~~~~~~~
/usr/include/c++/11/pstl/glue_numeric_impl.h:143:1: note:   conversion of argument 6 would be ill-formed:
cpp_stl_numeric_ops_cpp17.cpp:3781:275: error: invalid conversion from ‘int’ to ‘int (*)(int, int)’ [-fpermissive]
 3781 |   (void)(std::inclusive_scan<std::execution::sequenced_policy const &,std::vector<int> ::iterator,std::vector<int> ::iterator,int (int, int),int>(std::execution::seq, __pyx_v_v.begin(), __pyx_v_v.end(), __pyx_v_out.begin(), __pyx_f_25cpp_stl_numeric_ops_cpp17_add_integers, __pyx_v_init));
In file included from cpp_stl_numeric_ops_cpp17.cpp:811:
/usr/include/c++/11/numeric: In instantiation of ‘_Tp std::transform_reduce(_InputIterator1, _InputIterator1, _InputIterator2, _Tp, _BinaryOperation1, _BinaryOperation2) [with _InputIterator1 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _InputIterator2 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Tp = int; _BinaryOperation1 = int(int, int); _BinaryOperation2 = int(int)]’:
cpp_stl_numeric_ops_cpp17.cpp:2992:143:   required from here
/usr/include/c++/11/numeric:369:51: error: too many arguments to function
  369 |               _Tp __v1 = __binary_op1(__binary_op2(__first1[0], __first2[0]),
      |                                       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/numeric:370:51: error: too many arguments to function
  370 |                                       __binary_op2(__first1[1], __first2[1]));
      |                                       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/numeric:371:51: error: too many arguments to function
  371 |               _Tp __v2 = __binary_op1(__binary_op2(__first1[2], __first2[2]),
      |                                       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/numeric:372:51: error: too many arguments to function
  372 |                                       __binary_op2(__first1[3], __first2[3]));
      |                                       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/11/numeric:380:51: error: too many arguments to function
  380 |         __init = __binary_op1(__init, __binary_op2(*__first1, *__first2));
      |                                       ~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~

And various others (although mostly similar ones).
https://github.com/cython/cython/runs/3982999617

@jhelgert
Copy link
Contributor Author

Thanks, it should be fixed now. The tests related to this PR are skipped on macOS, so I'm not really sure why it fails.

@scoder
Copy link
Contributor

scoder commented Oct 25, 2021

The tests related to this PR are skipped on macOS, so I'm not really sure why it fails.

There's currently an issue with Py3.10 on macOS that I'm investigating. Those failures are ok for now.

@scoder
Copy link
Contributor

scoder commented Oct 28, 2021

Why did you have to remove the other method overload?

@jhelgert
Copy link
Contributor Author

Strangely, the last overload of inclusive_scan (6), i.e.

# (1) 3 args
OutputIt inclusive_scan[InputIt, OutputIt](InputIt first, InputIt last, OutputIt d_first)

# (2) 4 args, ambiguous with next overload
# ForwardIt2 inclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2](
#    ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, 
#    ForwardIt2 d_first)

# (3) 4 args
OutputIt inclusive_scan[InputIt, OutputIt, BinaryOperation](
    InputIt first, InputIt last, OutputIt d_first, BinaryOperation binary_op)

# (4) 5 args, ambiguous with next overload
# ForwardIt2 inclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, BinaryOperation](
#   ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, 
#   BinaryOperation binary_op)

# (5) 5 args
OutputIt inclusive_scan[InputIt, OutputIt, BinaryOperation, T](
    InputIt first, InputIt last, OutputIt d_first, BinaryOperation binary_op, 
    T init)

# (6) 6 Args
ForwardIt2 inclusive_scan[ExecutionPolicy, ForwardIt1, ForwardIt2, BinaryOperation, T](
    ExecutionPolicy&& policy, ForwardIt1 first, ForwardIt1 last, ForwardIt2 d_first, 
    BinaryOperation binary_op, T init)

broke everything and I still don't really see why.

compiler errors on ubuntu 20.04 with g++-11
runTest (__main__.CythonRunTestCase)
compiling (cpp/cy2) and running cpp_stl_numeric_ops_cpp17 ... 
=== C/C++ compiler output: =========
Compiler output for module cpp_stl_numeric_ops_cpp17:
cpp_stl_numeric_ops_cpp17.cpp: In function ‘PyObject* __pyx_pf_25cpp_stl_numeric_ops_cpp17_20test_inclusive_scan_with_execpolicy_bin_op_and_init(PyObject*, std::vector<int>, int)’:
cpp_stl_numeric_ops_cpp17.cpp:3781:146: error: no matching function for call to ‘inclusive_scan<const __pstl::execution::v1::sequenced_policy&, std::vector<int>::iterator, std::vector<int>::iterator, int(int, int), int>(const __pstl::execution::v1::sequenced_policy&, std::vector<int>::iterator, std::vector<int>::iterator, std::vector<int>::iterator, int (&)(int, int), int&)’
 3781 |   (void)(std::inclusive_scan<std::execution::sequenced_policy const &,std::vector<int> ::iterator,std::vector<int> ::iterator,int (int, int),int>(std::execution::seq, __pyx_v_v.begin(), __pyx_v_v.end(), __pyx_v_out.begin(), __pyx_f_25cpp_stl_numeric_ops_cpp17_add_integers, __pyx_v_init));
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from cpp_stl_numeric_ops_cpp17.cpp:811:
/usr/include/c++/11/numeric:534:5: note: candidate: ‘template<class _InputIterator, class _OutputIterator, class _BinaryOperation, class _Tp> _OutputIterator std::inclusive_scan(_InputIterator, _InputIterator, _OutputIterator, _BinaryOperation, _Tp)’
  534 |     inclusive_scan(_InputIterator __first, _InputIterator __last,
      |     ^~~~~~~~~~~~~~
/usr/include/c++/11/numeric:534:5: note:   template argument deduction/substitution failed:
cpp_stl_numeric_ops_cpp17.cpp:3781:146: error: wrong number of template arguments (5, should be 4)
 3781 |   (void)(std::inclusive_scan<std::execution::sequenced_policy const &,std::vector<int> ::iterator,std::vector<int> ::iterator,int (int, int),int>(std::execution::seq, __pyx_v_v.begin(), __pyx_v_v.end(), __pyx_v_out.begin(), __pyx_f_25cpp_stl_numeric_ops_cpp17_add_integers, __pyx_v_init));
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from cpp_stl_numeric_ops_cpp17.cpp:811:
/usr/include/c++/11/numeric:534:5: note: provided for ‘template<class _InputIterator, class _OutputIterator, class _BinaryOperation, class _Tp> _OutputIterator std::inclusive_scan(_InputIterator, _InputIterator, _OutputIterator, _BinaryOperation, _Tp)’
  534 |     inclusive_scan(_InputIterator __first, _InputIterator __last,
      |     ^~~~~~~~~~~~~~
/usr/include/c++/11/numeric:563:5: note: candidate: ‘template<class _InputIterator, class _OutputIterator, class _BinaryOperation> _OutputIterator std::inclusive_scan(_InputIterator, _InputIterator, _OutputIterator, _BinaryOperation)’
  563 |     inclusive_scan(_InputIterator __first, _InputIterator __last,
      |     ^~~~~~~~~~~~~~
/usr/include/c++/11/numeric:563:5: note:   template argument deduction/substitution failed:
cpp_stl_numeric_ops_cpp17.cpp:3781:146: error: wrong number of template arguments (5, should be 3)
 3781 |   (void)(std::inclusive_scan<std::execution::sequenced_policy const &,std::vector<int> ::iterator,std::vector<int> ::iterator,int (int, int),int>(std::execution::seq, __pyx_v_v.begin(), __pyx_v_v.end(), __pyx_v_out.begin(), __pyx_f_25cpp_stl_numeric_ops_cpp17_add_integers, __pyx_v_init));
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from cpp_stl_numeric_ops_cpp17.cpp:811:
/usr/include/c++/11/numeric:563:5: note: provided for ‘template<class _InputIterator, class _OutputIterator, class _BinaryOperation> _OutputIterator std::inclusive_scan(_InputIterator, _InputIterator, _OutputIterator, _BinaryOperation)’
  563 |     inclusive_scan(_InputIterator __first, _InputIterator __last,
      |     ^~~~~~~~~~~~~~
/usr/include/c++/11/numeric:596:5: note: candidate: ‘template<class _InputIterator, class _OutputIterator> _OutputIterator std::inclusive_scan(_InputIterator, _InputIterator, _OutputIterator)’
  596 |     inclusive_scan(_InputIterator __first, _InputIterator __last,
      |     ^~~~~~~~~~~~~~
/usr/include/c++/11/numeric:596:5: note:   template argument deduction/substitution failed:
cpp_stl_numeric_ops_cpp17.cpp:3781:146: error: wrong number of template arguments (5, should be 2)
 3781 |   (void)(std::inclusive_scan<std::execution::sequenced_policy const &,std::vector<int> ::iterator,std::vector<int> ::iterator,int (int, int),int>(std::execution::seq, __pyx_v_v.begin(), __pyx_v_v.end(), __pyx_v_out.begin(), __pyx_f_25cpp_stl_numeric_ops_cpp17_add_integers, __pyx_v_init));
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from cpp_stl_numeric_ops_cpp17.cpp:811:
/usr/include/c++/11/numeric:596:5: note: provided for ‘template<class _InputIterator, class _OutputIterator> _OutputIterator std::inclusive_scan(_InputIterator, _InputIterator, _OutputIterator)’
  596 |     inclusive_scan(_InputIterator __first, _InputIterator __last,
      |     ^~~~~~~~~~~~~~
In file included from /usr/include/c++/11/execution:43,
                 from cpp_stl_numeric_ops_cpp17.cpp:812:
/usr/include/c++/11/pstl/glue_numeric_impl.h:124:1: note: candidate: ‘template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _Tp> std::inclusive_scan(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)’
  124 | inclusive_scan(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last,
      | ^~~~~~~~~~~~~~
/usr/include/c++/11/pstl/glue_numeric_impl.h:124:1: note:   template argument deduction/substitution failed:
cpp_stl_numeric_ops_cpp17.cpp:3781:146: error: wrong number of template arguments (5, should be 3)
 3781 |   (void)(std::inclusive_scan<std::execution::sequenced_policy const &,std::vector<int> ::iterator,std::vector<int> ::iterator,int (int, int),int>(std::execution::seq, __pyx_v_v.begin(), __pyx_v_v.end(), __pyx_v_out.begin(), __pyx_f_25cpp_stl_numeric_ops_cpp17_add_integers, __pyx_v_init));
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/execution:43,
                 from cpp_stl_numeric_ops_cpp17.cpp:812:
/usr/include/c++/11/pstl/glue_numeric_impl.h:124:1: note: provided for ‘template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _Tp> std::inclusive_scan(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2)’
  124 | inclusive_scan(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last,
      | ^~~~~~~~~~~~~~
/usr/include/c++/11/pstl/glue_numeric_impl.h:134:1: note: candidate: ‘template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryOperation> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _Tp> std::inclusive_scan(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _BinaryOperation)’
  134 | inclusive_scan(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last,
      | ^~~~~~~~~~~~~~
/usr/include/c++/11/pstl/glue_numeric_impl.h:134:1: note:   template argument deduction/substitution failed:
cpp_stl_numeric_ops_cpp17.cpp:3781:146: error: wrong number of template arguments (5, should be 4)
 3781 |   (void)(std::inclusive_scan<std::execution::sequenced_policy const &,std::vector<int> ::iterator,std::vector<int> ::iterator,int (int, int),int>(std::execution::seq, __pyx_v_v.begin(), __pyx_v_v.end(), __pyx_v_out.begin(), __pyx_f_25cpp_stl_numeric_ops_cpp17_add_integers, __pyx_v_init));
      |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/execution:43,
                 from cpp_stl_numeric_ops_cpp17.cpp:812:
/usr/include/c++/11/pstl/glue_numeric_impl.h:134:1: note: provided for ‘template<class _ExecutionPolicy, class _ForwardIterator1, class _ForwardIterator2, class _BinaryOperation> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _Tp> std::inclusive_scan(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _BinaryOperation)’
  134 | inclusive_scan(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last,
      | ^~~~~~~~~~~~~~
/usr/include/c++/11/pstl/glue_numeric_impl.h:143:1: note: candidate: ‘__pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _Tp> std::inclusive_scan(_ExecutionPolicy&&, _ForwardIterator1, _ForwardIterator1, _ForwardIterator2, _BinaryOperation, _Tp) [with _ExecutionPolicy = const __pstl::execution::v1::sequenced_policy&; _ForwardIterator1 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _ForwardIterator2 = __gnu_cxx::__normal_iterator<int*, std::vector<int> >; _Tp = int(int, int); _BinaryOperation = int; __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, _Tp> = std::enable_if<true, __gnu_cxx::__normal_iterator<int*, std::vector<int> > >::type]’ (near match)
  143 | inclusive_scan(_ExecutionPolicy&& __exec, _ForwardIterator1 __first, _ForwardIterator1 __last,
      | ^~~~~~~~~~~~~~
/usr/include/c++/11/pstl/glue_numeric_impl.h:143:1: note:   conversion of argument 6 would be ill-formed:
cpp_stl_numeric_ops_cpp17.cpp:3781:275: error: invalid conversion from ‘int’ to ‘int (*)(int, int)’ [-fpermissive]
 3781 |   (void)(std::inclusive_scan<std::execution::sequenced_policy const &,std::vector<int> ::iterator,std::vector<int> ::iterator,int (int, int),int>(std::execution::seq, __pyx_v_v.begin(), __pyx_v_v.end(), __pyx_v_out.begin(), __pyx_f_25cpp_stl_numeric_ops_cpp17_add_integers, __pyx_v_init));
      |                                                                                                                                                                                                                                                                                   ^~~~~~~~~~~~
      |                                                                                                                                                                                                                                                                                   |
      |                                                                                                                                                                                                                                                                                   int
cpp_stl_numeric_ops_cpp17.cpp: In function ‘PyObject* __pyx_convert_vector_to_py_int(const std::vector<int>&)’:
cpp_stl_numeric_ops_cpp17.cpp:5364:33: warning: comparison of integer expressions of different signedness: ‘Py_ssize_t’ {aka ‘long int’} and ‘size_t’ {aka ‘long unsigned int’} [-Wsign-compare]
 5364 |   for (__pyx_t_5 = 0; __pyx_t_5 < __pyx_t_4; __pyx_t_5+=1) {
      |                       ~~~~~~~~~~^~~~~~~~~~~
====================================
ERROR

From what I can see, it seems like the generated cpp code uses the wrong template types, i.e.

(void)(std::inclusive_scan<std::execution::sequenced_policy const &,
                           std::vector<int>::iterator,
                           std::vector<int>::iterator,
                           int (int, int),
                           int>
            (std::execution::seq, __pyx_v_v.begin(), __pyx_v_v.end(), __pyx_v_out.begin(), 
              __pyx_f_25cpp_stl_numeric_ops_cpp17_add_integers, __pyx_v_init));

instead of

(void)(std::inclusive_scan<std::execution::sequenced_policy const &,
                           std::vector<int>::iterator,
                           std::vector<int>::iterator,
                           std::vector<int>::iterator,
                           int (int, int),
                           int>
            (std::execution::seq, __pyx_v_v.begin(), __pyx_v_v.end(), __pyx_v_out.begin(), 
              __pyx_f_25cpp_stl_numeric_ops_cpp17_add_integers, __pyx_v_init));

@jhelgert
Copy link
Contributor Author

jhelgert commented Nov 2, 2021

@scoder How should we proceed? IMHO, it can be merged. It may be worth working on the ambiguous overloads with an execution policy in another PR, though.

@scoder scoder merged commit b5f81f5 into cython:master Nov 2, 2021
@scoder
Copy link
Contributor

scoder commented Nov 2, 2021

I think it's good for a merge. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants