Compile errors passing lambda variables to rpc and as_rpc
Issue #219
resolved
Example program (based on a version of Jacobi from Scott):
#include <upcxx/upcxx.hpp>
int nCount[2];
int phase = 1;
int main() {
upcxx::init();
auto f = [] (int phase){ nCount[phase]++;};
upcxx::global_ptr<int> uL = upcxx::new_<int>();
upcxx::rpc(0, f, phase);
if ( uL ){
rput( 4, uL, upcxx::remote_cx::as_rpc( f , phase) );
}
upcxx::finalize();
return 0;
}
Compiler errors with g++ 7.4.0:
In file included from /usr/local/upcxx-2019.3.0/upcxx.debug.gasnet_seq.smp/include/upcxx/team_fwd.hpp:4:0,
from /usr/local/upcxx-2019.3.0/upcxx.debug.gasnet_seq.smp/include/upcxx/team.hpp:4,
from /usr/local/upcxx-2019.3.0/upcxx.debug.gasnet_seq.smp/include/upcxx/backend.hpp:7,
from /usr/local/upcxx-2019.3.0/upcxx.debug.gasnet_seq.smp/include/upcxx/allocate.hpp:8,
from /usr/local/upcxx-2019.3.0/upcxx.debug.gasnet_seq.smp/include/upcxx/upcxx.hpp:8,
from lambda.cpp:1:
/usr/local/upcxx-2019.3.0/upcxx.debug.gasnet_seq.smp/include/upcxx/bind.hpp: In instantiation of 'upcxx::bound_function_of<decltype (upcxx::detail::globalize_fnptr(declval<Fn&&>())), B&& ...> upcxx::detail::bind<FnStripped>::operator()(Fn&&, B&& ...) const [with Fn = main()::<lambda(int)>&; B = {int&}; FnStripped = main()::<lambda(int)>; upcxx::bound_function_of<decltype (upcxx::detail::globalize_fnptr(declval<Fn&&>())), B&& ...> = upcxx::bound_function<main()::<lambda(int)>, int>; typename upcxx::binding<decltype (upcxx::detail::globalize_fnptr(declval<Fn&&>()))>::stripped_type = main()::<lambda(int)>]':
/usr/local/upcxx-2019.3.0/upcxx.debug.gasnet_seq.smp/include/upcxx/bind.hpp:417:65: required from 'decltype (upcxx::detail::bind<typename upcxx::binding<T&&>::stripped_type>()(forward<Fn>(fn), (forward<B>)(upcxx::bind::b)...)) upcxx::bind(Fn&&, B&& ...) [with Fn = main()::<lambda(int)>&; B = {int&}; decltype (upcxx::detail::bind<typename upcxx::binding<T&&>::stripped_type>()(forward<Fn>(fn), (forward<B>)(upcxx::bind::b)...)) = upcxx::bound_function<main()::<lambda(int)>, int>; typename upcxx::binding<T&&>::stripped_type = main()::<lambda(int)>]'
/usr/local/upcxx-2019.3.0/upcxx.debug.gasnet_seq.smp/include/upcxx/completion.hpp:256:24: required from 'static upcxx::detail::support_as_rpc<Event>::as_rpc_t<Fn&&, Args&& ...> upcxx::detail::support_as_rpc<Event>::as_rpc(Fn&&, Args&& ...) [with Fn = main()::<lambda(int)>&; Args = {int&}; Event = upcxx::remote_cx_event; upcxx::detail::support_as_rpc<Event>::as_rpc_t<Fn&&, Args&& ...> = upcxx::completions<upcxx::rpc_cx<upcxx::remote_cx_event, upcxx::bound_function<main()::<lambda(int)>, int> > >; decltype (upcxx::bind(declval<Fn&&>(), (declval<Args&>)()...)) = upcxx::bound_function<main()::<lambda(int)>, int>]'
lambda.cpp:13:53: required from here
/usr/local/upcxx-2019.3.0/upcxx.debug.gasnet_seq.smp/include/upcxx/bind.hpp:387:9: error: cannot bind rvalue reference of type 'upcxx::binding_trivial<main()::<lambda(int)> >::on_wire_type&& {aka main()::<lambda(int)>&&}' to lvalue of type 'main()::<lambda(int)>'
};
^
/usr/local/upcxx-2019.3.0/upcxx.debug.gasnet_seq.smp/include/upcxx/bind.hpp:234:5: note: initializing argument 1 of 'upcxx::bound_function<Fn, B>::bound_function(typename upcxx::binding<T>::on_wire_type&&, std::tuple<typename upcxx::binding<B>::on_wire_type ...>&&) [with Fn = main()::<lambda(int)>; B = {int}; typename upcxx::binding<T>::on_wire_type = main()::<lambda(int)>]'
bound_function(
^~~~~~~~~~~~~~
Comments (2)
-
reporter -
- changed status to resolved
Fixed issue 219, and fixed issue 108 for clang 4.0: - test added test/regression/issue219.cpp - involved refactorings to src/bind.hpp and hooking into them from src/completion.hpp
PGI fixes: - src/serialization.cpp had a number of integer sign warnings, now refactored a little and better comments. - test/serialization.cpp had a legit sign error.
→ <<cset 22bfe572feed>>
- Log in to comment
A fix for this defect is pending in pull request #96