Skip to content

Commit

Permalink
Use east const in binding allocators
Browse files Browse the repository at this point in the history
  • Loading branch information
msimberg committed Feb 13, 2020
1 parent 9bf6976 commit 1ecc311
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 22 deletions.
22 changes: 11 additions & 11 deletions hpx/parallel/util/numa_binding_allocator.hpp
Expand Up @@ -58,7 +58,7 @@ namespace hpx { namespace threads { namespace executors {
{
// The call operator () must return an int type
// The arguments must be const ref versions of the equivalent task arguments
int operator()(const int& domain) const
int operator()(int const& domain) const
{
nba_deb.debug(debug::str<>("pool_numa_hint"),
"allocator returns domain ", domain);
Expand All @@ -79,8 +79,8 @@ namespace hpx { namespace compute { namespace host {
// should touch this page. The thread with the matching domain will
// perform a memory read/write on the page.
virtual std::size_t operator()(const T* const /*base_ptr*/,
const T* const /*page_ptr*/, const std::size_t /*page_size*/,
const std::size_t /*domains*/) const
const T* const /*page_ptr*/, std::size_t const /*page_size*/,
std::size_t const /*domains*/) const
{
return 0;
}
Expand Down Expand Up @@ -570,11 +570,11 @@ namespace hpx { namespace compute { namespace host {

void touch_pages(pointer p, size_t n, numa_binding_helper_ptr helper,
size_type numa_domain,
const std::vector<threads::hwloc_bitmap_ptr>& nodesets) const
std::vector<threads::hwloc_bitmap_ptr> const& nodesets) const
{
const size_type pagesize = threads::get_memory_page_size();
const size_type pageN = pagesize / sizeof(T);
const size_type num_pages =
size_type const pagesize = threads::get_memory_page_size();
size_type const pageN = pagesize / sizeof(T);
size_type const num_pages =
(n * sizeof(T) + pagesize - 1) / pagesize;
pointer page_ptr = p;
HPX_ASSERT(reinterpret_cast<std::intptr_t>(p) % pagesize == 0);
Expand Down Expand Up @@ -615,11 +615,11 @@ namespace hpx { namespace compute { namespace host {
// This is obsolete but kept for possible future use
void bind_pages(pointer p, size_t n, numa_binding_helper_ptr helper,
size_type numa_domain,
const std::vector<threads::hwloc_bitmap_ptr>& nodesets) const
std::vector<threads::hwloc_bitmap_ptr> const& nodesets) const
{
const size_type pagesize = threads::get_memory_page_size();
const size_type pageN = pagesize / sizeof(T);
const size_type num_pages =
size_type const pagesize = threads::get_memory_page_size();
size_type const pageN = pagesize / sizeof(T);
size_type const num_pages =
(n * sizeof(T) + pagesize - 1) / pagesize;
pointer page_ptr = p;
HPX_ASSERT(reinterpret_cast<std::intptr_t>(p) % pagesize == 0);
Expand Down
10 changes: 5 additions & 5 deletions tests/unit/topology/allocator_binder_linear.hpp
Expand Up @@ -24,18 +24,18 @@ struct linear_numa_binder : hpx::compute::host::numa_binding_helper<T>
explicit linear_numa_binder(std::size_t num_pages)
: hpx::compute::host::numa_binding_helper<T>()
{
const std::size_t cache_line_size = hpx::threads::get_cache_line_size();
const std::size_t page_size = hpx::threads::get_memory_page_size();
const std::size_t alignment = (std::max)(page_size, cache_line_size);
std::size_t const cache_line_size = hpx::threads::get_cache_line_size();
std::size_t const page_size = hpx::threads::get_memory_page_size();
std::size_t const alignment = (std::max)(page_size, cache_line_size);
elements_page_ = (alignment / sizeof(T));
N_ = num_pages * elements_page_;
}

// return the domain that a given page should be bound to
virtual std::size_t operator()(const T* const base_ptr,
const T* const page_ptr,
const std::size_t pagesize,
const std::size_t domains) const override
std::size_t const pagesize,
std::size_t const domains) const override
{
std::intptr_t offset = page_ptr - base_ptr;
std::size_t index = (offset / elements_page_);
Expand Down
12 changes: 6 additions & 6 deletions tests/unit/topology/allocator_binder_matrix.hpp
Expand Up @@ -33,10 +33,10 @@ struct matrix_numa_binder : hpx::compute::host::numa_binding_helper<T>
, colprocs_(Ncolprocs)
, rowprocs_(Nrowprocs)
{
const int cache_line_size = hpx::threads::get_cache_line_size();
const int page_size = hpx::threads::get_memory_page_size();
const int alignment = (std::max)(page_size, cache_line_size);
const int elems_align = (alignment / sizeof(T));
int const cache_line_size = hpx::threads::get_cache_line_size();
int const page_size = hpx::threads::get_memory_page_size();
int const alignment = (std::max)(page_size, cache_line_size);
int const elems_align = (alignment / sizeof(T));
rows_page_ = elems_align;
leading_dim_ =
elems_align * ((rows_ * sizeof(T) + alignment - 1) / alignment);
Expand All @@ -46,8 +46,8 @@ struct matrix_numa_binder : hpx::compute::host::numa_binding_helper<T>
// return the domain that a given page should be bound to
virtual std::size_t operator()(const T* const base_ptr,
const T* const page_ptr,
const std::size_t pagesize,
const std::size_t domains) const override
std::size_t const pagesize,
std::size_t const domains) const override
{
std::intptr_t offset = page_ptr - base_ptr;
std::size_t col = (offset / leading_dim_);
Expand Down

0 comments on commit 1ecc311

Please sign in to comment.