std::tie(global_ptr<T>, global_ptr<T>) = when_all(....).wait();

Issue #132 resolved
BrianS created an issue

so this works in my upcxx/examples/prog-guide/non-contig-example.cpp

  future<global_ptr<float>> dgpf = dmesh.fetch(nebrHi);
  future<global_ptr<float>> sgpf = smesh.fetch(nebrLo);

  when_all(dgpf, sgpf).wait();

  global_ptr<float> d_gp=dgpf.result();
  global_ptr<float> s_gp=sgpf.result();

but this fails with a compiler error

  global_ptr<float> d_gp, s_gp;
  std::tie(d_gp, s_gp) = when_all(dmesh.fetch(nebrHi), smesh.fetch(nebrLo)).wait();

with the compiler error with clang++ as

non-contig-example.cpp:73:24: error: no viable overloaded '='
  std::tie(d_gp, s_gp) = when_all(dmesh.fetch(nebrHi), smesh.fetch(nebrLo)).wait();
  ~~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/tuple:876:12: note: 
      candidate function not viable: no known conversion from
      'decltype(this->result())' (aka '__type_pack_element<0UL,
      upcxx::global_ptr<float>, upcxx::global_ptr<float> >') to 'const typename
      conditional<_CanCopyAssign::value, tuple<global_ptr<float> &,
      global_ptr<float> &>, __nat>::type' (aka 'const
      std::__1::tuple<upcxx::global_ptr<float> &, upcxx::global_ptr<float> &>')
      for 1st argument
    tuple& operator=(typename conditional<_CanCopyAssign::value, tuple...
           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/tuple:884:12: note: 
      candidate function not viable: no known conversion from
      'decltype(this->result())' (aka '__type_pack_element<0UL,
      upcxx::global_ptr<float>, upcxx::global_ptr<float> >') to 'typename
      conditional<_CanMoveAssign::value, tuple<global_ptr<float> &,
      global_ptr<float> &>, __nat>::type' (aka
      'std::__1::tuple<upcxx::global_ptr<float> &, upcxx::global_ptr<float>
      &>') for 1st argument
    tuple& operator=(typename conditional<_CanMoveAssign::value, tuple...
           ^
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/tuple:894:26: note: 
      candidate template ignored: disabled by 'enable_if' [with _Tuple =
      upcxx::global_ptr<float>]
                         __tuple_assignable<_Tuple, tuple>::value
                         ^
1 error generated.

I don't know where tuple_assignable for global_ptr is determined and why it is different from how this works with using std::tie with futures.

Comments (4)

  1. BrianS reporter

    I think this can be changed to a feature request. The code does do what the spec currently says. We probably want to upgrade the spec to wait return a tuple and not just the first element of the tuple.

  2. Log in to comment