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

Partitioned vector updates #6550

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,18 +35,6 @@

namespace hpx::components {

///////////////////////////////////////////////////////////////////////////
/// \cond NOINTERNAL
namespace detail {

HPX_FORCEINLINE constexpr std::size_t round_to_multiple(
std::size_t n1, std::size_t n2, std::size_t n3) noexcept
{
return (n1 / n2) * n3;
}
} // namespace detail
/// \endcond

/// This class specifies the parameters for a simple distribution policy
/// to use for creating (and evenly distributing) a given number of items
/// on a given set of localities.
Expand Down Expand Up @@ -314,14 +302,16 @@ namespace hpx::components {
return (items < num_loc) ? 1 : 0;
}

std::size_t const items_per_loc = (items + locs - 1) / locs;

// the last locality might get fewer items
if (locs > 1 && loc == localities_->back())
{
return items - detail::round_to_multiple(items, locs, locs - 1);
return items - (locs - 1) * items_per_loc;
}

// otherwise just distribute evenly
return (items + locs - 1) / locs;
return items_per_loc;
}
/// \endcond

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,6 @@ int main()
copy_tests<double>();
copy_tests<int>();

return 0;
return hpx::util::report_errors();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hah! No wonder our tests always passed ;-) Nice catch!

}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,6 @@ int main()
fill_tests<double>();
fill_tests<int>();

return 0;
return hpx::util::report_errors();
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ int main()
generate_tests<double>();
generate_tests<int>();

return 0;
return hpx::util::report_errors();
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ int main()
handle_values_tests<double>();
handle_values_tests<int>();

return 0;
return hpx::util::report_errors();
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,6 @@ int main()
trivial_tests<double>();
trivial_tests<int>();

return 0;
return hpx::util::report_errors();
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,6 @@ int main()
move_tests<int>(43, 42);
move_tests<std::string>("test", "not_test");

return 0;
return hpx::util::report_errors();
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ int main()
allocation_tests<double>();
allocation_tests<int>();

return 0;
return hpx::util::report_errors();
}

#endif
Loading