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

shad uses operator== instead of Equal #196

Open
NanmiaoWu opened this issue Mar 1, 2021 · 1 comment
Open

shad uses operator== instead of Equal #196

NanmiaoWu opened this issue Mar 1, 2021 · 1 comment

Comments

@NanmiaoWu
Copy link
Collaborator

  • The issue is: shad should use HandleTrait::Equal, but it uses operator==.
  • The detailed error info is shown as follow:
(base) nanmiao@jiujiu:~/Documents/my_project/src/SHAD/build_hpx_Debug$ make -j 10
[  2%] Built target cpp_simple_runtime
[  5%] Built target runtime
Scanning dependencies of target util
Scanning dependencies of target ei-sssp
Scanning dependencies of target shadtest_main
Scanning dependencies of target page-rank
Scanning dependencies of target pi
Scanning dependencies of target triangle-count
Scanning dependencies of target ei-triangle-count
Scanning dependencies of target ei-page-rank
Scanning dependencies of target ei-vertex_nomination
Scanning dependencies of target blackscholes
[  7%] Building CXX object src/util/CMakeFiles/util.dir/shad.cc.o
[  8%] Building CXX object examples/edge_index_graph/CMakeFiles/ei-sssp.dir/ei-sssp.cc.o
[ 10%] Building CXX object examples/array/CMakeFiles/page-rank.dir/page-rank.cc.o
[ 11%] Building CXX object examples/edge_index_graph/CMakeFiles/ei-page-rank.dir/ei-page-rank.cc.o
[ 13%] Building CXX object examples/edge_index_graph/CMakeFiles/ei-triangle-count.dir/ei-triangle-count.cc.o
[ 14%] Building CXX object examples/blackscholes/CMakeFiles/blackscholes.dir/blackscholes.cc.o
[ 16%] Building CXX object test/unit_tests/CMakeFiles/shadtest_main.dir/gtest_main.cc.o
[ 17%] Building CXX object examples/pi/CMakeFiles/pi.dir/pi.cc.o
[ 19%] Building CXX object examples/array/CMakeFiles/triangle-count.dir/triangle-count.cc.o
[ 20%] Building CXX object examples/edge_index_graph/CMakeFiles/ei-vertex_nomination.dir/ei-vertex_nomination.cc.o
In file included from /home/nanmiao/Documents/my_project/src/SHAD/include/shad/runtime/runtime.h:42,
                 from /home/nanmiao/Documents/my_project/src/SHAD/include/shad/data_structures/object_identifier.h:30,
                 from /home/nanmiao/Documents/my_project/src/SHAD/include/shad/data_structures/abstract_data_structure.h:35,
                 from /home/nanmiao/Documents/my_project/src/SHAD/include/shad/core/array.h:30,
                 from /home/nanmiao/Documents/my_project/src/SHAD/examples/pi/pi.cc:29:
/home/nanmiao/Documents/my_project/src/SHAD/include/shad/runtime/handle.h: In member function ‘bool shad::rt::Handle::IsNull() const’:
/home/nanmiao/Documents/my_project/src/SHAD/include/shad/runtime/handle.h:90:16: error: no match for ‘operator==’ (operand types are ‘const HandleTy’ {aka ‘const hpx::lcos::shared_future<void>’} and ‘shad::rt::impl::HandleTrait<shad::rt::impl::hpx_tag>::HandleTy’ {aka ‘hpx::lcos::shared_future<void>’})
   90 |     return id_ == impl::HandleTrait<TargetSystemTag>::NullValue();
      |            ~~~ ^~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      |            |                                                   |
      |            shared_future<[...]>                                shared_future<[...]>
  • The issue happens when I update HandleTrait in hpx_traits_mapping as follow
template <>
struct HandleTrait<hpx_tag> {
  using HandleTy = hpx::shared_future<void>;
  using ParameterTy = hpx::shared_future<void> &;
  using ConstParameterTy = const hpx::shared_future<void> &;

  static void Init(ParameterTy H, ConstParameterTy V) {
    H = V.then([](HandleTy&&){});
  }

  static HandleTy NullValue() { return hpx::shared_future<void>(); }

  static bool Equal(ConstParameterTy lhs, ConstParameterTy rhs) {
    return toUnsignedInt(lhs) == toUnsignedInt(rhs);
  }

  static std::string toString(ConstParameterTy H) {
    return std::to_string(toUnsignedInt(H));
  }

  static uint64_t toUnsignedInt(ConstParameterTy H) {
    return reinterpret_cast<uint64_t>(hpx::traits::detail::get_shared_state(H).get());
  }

  static HandleTy CreateNewHandle() { return hpx::shared_future<void>(); }

  static void WaitFor(ParameterTy H) { if (H.valid()) H.get(); }
};
@NanmiaoWu
Copy link
Collaborator Author

A workaround to this issue is: change IsNull() as follows:

  bool IsNull() const {
      return impl::HandleTrait<TargetSystemTag>::Equal(id_, impl::HandleTrait<TargetSystemTag>::NullValue());
  }

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

No branches or pull requests

1 participant