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

MDRangePolicy Reduction requires value_type typedef in Functor #1379

Closed
crtrott opened this issue Jan 31, 2018 · 5 comments
Closed

MDRangePolicy Reduction requires value_type typedef in Functor #1379

crtrott opened this issue Jan 31, 2018 · 5 comments
Assignees
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos)
Milestone

Comments

@crtrott
Copy link
Member

crtrott commented Jan 31, 2018

Apparently the value_type deduction is screwed up, and we do not have a test which uses either a Lambda or a functor without value_type typedef.

Example:

Kokkos::parallel_reduce(Kokkos::MDRangePolicy<Kokkos::Rank<2>> ({0,0},{10,10}), KOKKOS_LAMBDA (const int i, const int j, int& lsum) {
    lsum += i*10+j;
  },result);

Error:

/home/crtrott/Kokkos/kokkos/core/src/Kokkos_Serial.hpp: In instantiation of ‘class Kokkos::Impl::ParallelReduce<main(int, char**)::<lambda(const int&, const int&, int&)>, Kokkos::MDRangePolicy<Kokkos::Rank<2u, (Kokkos::Iterate)0, (Kokkos::Iterate)0> >, Kokkos::InvalidType, Kokkos::Serial>’:
/home/crtrott/Kokkos/kokkos/core/src/Kokkos_Parallel_Reduce.hpp:890:14:   required from ‘static void Kokkos::Impl::ParallelReduceAdaptor<PolicyType, FunctorType, ReturnType>::execute(const string&, const PolicyType&, const FunctorType&, ReturnType&) [with PolicyType = Kokkos::MDRangePolicy<Kokkos::Rank<2u, (Kokkos::Iterate)0, (Kokkos::Iterate)0> >; FunctorType = main(int, char**)::<lambda(const int&, const int&, int&)>; ReturnType = int; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/crtrott/Kokkos/kokkos/core/src/Kokkos_Parallel_Reduce.hpp:978:74:   required from ‘void Kokkos::parallel_reduce(const PolicyType&, const FunctorType&, ReturnType&, typename Kokkos::Impl::enable_if<Kokkos::is_execution_policy<PolicyType>::value>::type*) [with PolicyType = Kokkos::MDRangePolicy<Kokkos::Rank<2u, (Kokkos::Iterate)0, (Kokkos::Iterate)0> >; FunctorType = main(int, char**)::<lambda(const int&, const int&, int&)>; ReturnType = int; typename Kokkos::Impl::enable_if<Kokkos::is_execution_policy<PolicyType>::value>::type = void]’
main.cpp:23:11:   required from here
/home/crtrott/Kokkos/kokkos/core/src/Kokkos_Serial.hpp:708:47: error: no type named ‘value_type’ in ‘Kokkos::Impl::ParallelReduce<main(int, char**)::<lambda(const int&, const int&, int&)>, Kokkos::MDRangePolicy<Kokkos::Rank<2u, (Kokkos::Iterate)0, (Kokkos::Iterate)0> >, Kokkos::InvalidType, Kokkos::Serial>::ReducerTypeFwd {aka struct main(int, char**)::<lambda(const int&, const int&, int&)>}’
   typedef typename ReducerTypeFwd::value_type ValueType; 
                                               ^
In file included from /home/crtrott/Kokkos/kokkos/core/src/Kokkos_Parallel.hpp:62:0,
                 from /home/crtrott/Kokkos/kokkos/core/src/Kokkos_Serial.hpp:55,
                 from /home/crtrott/Kokkos/kokkos/core/src/Kokkos_Core.hpp:53,
                 from main.cpp:1:
/home/crtrott/Kokkos/kokkos/core/src/impl/Kokkos_FunctorAnalysis.hpp: In instantiation of ‘struct Kokkos::Impl::FunctorAnalysis<Kokkos::Impl::FunctorPatternInterface::REDUCE, Kokkos::RangePolicy<Kokkos::Serial, Kokkos::Schedule<Kokkos::Static>, long unsigned int>, main(int, char**)::<lambda(const int&, const int&, int&)> >::deduce_value_type<main(int, char**)::<lambda(const int&, const int&, int&)>, Kokkos::Impl::FunctorPatternInterface::REDUCE, void, true>’:
/home/crtrott/Kokkos/kokkos/core/src/impl/Kokkos_FunctorAnalysis.hpp:206:70:   required from ‘struct Kokkos::Impl::FunctorAnalysis<Kokkos::Impl::FunctorPatternInterface::REDUCE, Kokkos::RangePolicy<Kokkos::Serial, Kokkos::Schedule<Kokkos::Static>, long unsigned int>, main(int, char**)::<lambda(const int&, const int&, int&)> >’
/home/crtrott/Kokkos/kokkos/core/src/Kokkos_Serial.hpp:714:46:   required from ‘class Kokkos::Impl::ParallelReduce<main(int, char**)::<lambda(const int&, const int&, int&)>, Kokkos::MDRangePolicy<Kokkos::Rank<2u, (Kokkos::Iterate)0, (Kokkos::Iterate)0> >, Kokkos::InvalidType, Kokkos::Serial>’
/home/crtrott/Kokkos/kokkos/core/src/Kokkos_Parallel_Reduce.hpp:890:14:   required from ‘static void Kokkos::Impl::ParallelReduceAdaptor<PolicyType, FunctorType, ReturnType>::execute(const string&, const PolicyType&, const FunctorType&, ReturnType&) [with PolicyType = Kokkos::MDRangePolicy<Kokkos::Rank<2u, (Kokkos::Iterate)0, (Kokkos::Iterate)0> >; FunctorType = main(int, char**)::<lambda(const int&, const int&, int&)>; ReturnType = int; std::__cxx11::string = std::__cxx11::basic_string<char>]’
/home/crtrott/Kokkos/kokkos/core/src/Kokkos_Parallel_Reduce.hpp:978:74:   required from ‘void Kokkos::parallel_reduce(const PolicyType&, const FunctorType&, ReturnType&, typename Kokkos::Impl::enable_if<Kokkos::is_execution_policy<PolicyType>::value>::type*) [with PolicyType = Kokkos::MDRangePolicy<Kokkos::Rank<2u, (Kokkos::Iterate)0, (Kokkos::Iterate)0> >; FunctorType = main(int, char**)::<lambda(const int&, const int&, int&)>; ReturnType = int; typename Kokkos::Impl::enable_if<Kokkos::is_execution_policy<PolicyType>::value>::type = void]’
main.cpp:23:11:   required from here
/home/crtrott/Kokkos/kokkos/core/src/impl/Kokkos_FunctorAnalysis.hpp:163:34: error: no matching function for call to ‘Kokkos::Impl::FunctorAnalysis<Kokkos::Impl::FunctorPatternInterface::REDUCE, Kokkos::RangePolicy<Kokkos::Serial, Kokkos::Schedule<Kokkos::Static>, long unsigned int>, main(int, char**)::<lambda(const int&, const int&, int&)> >::deduce_value_type<main(int, char**)::<lambda(const int&, const int&, int&)>, Kokkos::Impl::FunctorPatternInterface::REDUCE, void, true>::deduce(void (main(int, char**)::<lambda(const int&, const int&, int&)>::*)(const int&, const int&, int&) const)’
     using type = decltype( deduce( & F::operator() ) );

@crtrott crtrott added Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos) Blocks Promotion Overview issue for release-blocking bugs labels Jan 31, 2018
@crtrott crtrott added this to the 2018 February milestone Jan 31, 2018
@ndellingwood
Copy link
Contributor

Made a similar test (with double as the result type)
ReturnType in parallel_reduce is double (as expected), but the ReducerType parameter in ParallelReduce is an InvalidType so I think what's happening is the ValueType Is trying to be set to the value_type of the non-existent functor (since a lambda was passed in).

ParallelReduceReturnValue<void, ReturnType, FunctorType>::reducer_type coming back as an InvalidType rather than the return_type may be triggering this, still digging.

@ndellingwood
Copy link
Contributor

Have a fix for this, having issues with my VPN and pushing the commit from home, will put in PR tomorrow.

ndellingwood added a commit to ndellingwood/kokkos that referenced this issue Feb 1, 2018
Commit addresses issue kokkos#1379 and kokkos#1054
Fix to allow lambda with MDRangePolicy within parallel_for and
parallel_reduce
Unit test with lambda added for ranks 1 to 6
@ndellingwood
Copy link
Contributor

PR #1380 in for this issue.

@ndellingwood
Copy link
Contributor

Related to #1054

ndellingwood added a commit to ndellingwood/kokkos that referenced this issue Feb 1, 2018
Added during work on issue kokkos#1379
@ndellingwood
Copy link
Contributor

Fix in PR #1380 spot checked with test_all_sandia and should be ready for merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Broken / incorrect code; it could be Kokkos' responsibility, or others’ (e.g., Trilinos)
Projects
None yet
Development

No branches or pull requests

2 participants