Non-uniform behavior for RPC on function pointers

Issue #108 resolved
Dan Bonachea created an issue

Spec for RPC function argument says:

Func must be a Serializable type and a function-object type.

I think the implication is any pointer to global-scope function foo should work. C++ allows operator() calls thru such pointers as foo or &foo (the two are essentially equivalent).

Consider the following program:

#include <iostream>
#include <upcxx/upcxx.hpp>

void foo0(void) { std::cout << "foo0" << std::endl; }
void foo2I(int a, int b) { std::cout << "foo2I(" << a << "," << b << ")" << std::endl; }

int main(int argc, char *argv[])
{
    upcxx::init();

    foo0();    // works (regular C++)
    (&foo0)(); // works (regular C++)
    upcxx::rpc(upcxx::rank_me(),foo0).wait();  // works
    upcxx::rpc(upcxx::rank_me(),&foo0).wait(); // works

    foo2I(1,2);    // works (regular C++)
    (&foo2I)(1,2); // works (regular C++)
    #if !SKIP_BROKEN
    upcxx::rpc(upcxx::rank_me(),foo2I,1,2).wait();  // FAILS!!!
    #endif
    upcxx::rpc(upcxx::rank_me(),&foo2I,1,2).wait(); // works

    upcxx::finalize();
    return 0;
}   

All of the above works except for the line annotated as "FAILS", which generates a large number of template instantiation errors on d29da42 (see first one below).

As a user I see no reason why that form should fail, given the surrounding analogous calls all work. We need to either (hopefully) fix this as a bug, or find a way to explain and specify why rpc needs a particular syntax for the function pointer with args > 0.

In file included from /usr/local/pkg/upcxx-dirac/gcc-7.2.0/nightly-2017.12.11/upcxx.debug.gasnet1_seq.ibv/include/upcxx/dist_object.hpp:4:0,
                 from /usr/local/pkg/upcxx-dirac/gcc-7.2.0/nightly-2017.12.11/upcxx.debug.gasnet1_seq.ibv/include/upcxx/upcxx.hpp:10,
                 from rpcbind.cpp:2:
/usr/local/pkg/upcxx-dirac/gcc-7.2.0/nightly-2017.12.11/upcxx.debug.gasnet1_seq.ibv/include/upcxx/bind.hpp: In instantiation of 'struct upcxx::binding<void(int, int)>':
/usr/local/pkg/upcxx-dirac/gcc-7.2.0/nightly-2017.12.11/upcxx.debug.gasnet1_seq.ibv/include/upcxx/bind.hpp:88:23   recursively required by substitution of 'template<class T> struct upcxx::binding_is_trivial<T, std::integral_constant<bool, upcxx::binding<T>::is_trivial> > [with T = void (&)(int, int)]'
/usr/local/pkg/upcxx-dirac/gcc-7.2.0/nightly-2017.12.11/upcxx.debug.gasnet1_seq.ibv/include/upcxx/bind.hpp:88:23   required from 'struct upcxx::bound_function<void (&)(int, int), int&&, int&&>'
/usr/local/pkg/upcxx-dirac/gcc-7.2.0/nightly-2017.12.11/upcxx.debug.gasnet1_seq.ibv/include/upcxx/rpc.hpp:60:24:   required from 'struct upcxx::detail::rpc_return<void, void (&)(int, int), int, int>'
/usr/local/pkg/upcxx-dirac/gcc-7.2.0/nightly-2017.12.11/upcxx.debug.gasnet1_seq.ibv/include/upcxx/rpc.hpp:70:8:   required by substitution of 'template<class Fn, class ... Args> typename upcxx::detail::rpc_return<decltype (fn(upcxx::rpc::args ...)), Fn, Args ...>::type upcxx::rpc(upcxx::intrank_t, Fn&&, Args&& ...) [with Fn = void (&)(int, int); Args = {int, int}]'
rpcbind.cpp:19:42:   required from here
/usr/local/pkg/upcxx-dirac/gcc-7.2.0/nightly-2017.12.11/upcxx.debug.gasnet1_seq.ibv/include/upcxx/bind.hpp:35:14 error: function returning a function
     static T on_wire(T x) {
              ^~~~~~~

Comments (2)

  1. john bachan

    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>>

  2. Log in to comment