Skip to content

Commit

Permalink
Merge pull request #2897 from STEllAR-GROUP/fixing_2896
Browse files Browse the repository at this point in the history
Removing dependency on Boost.ICL
  • Loading branch information
hkaiser committed Sep 13, 2017
2 parents 61eefd2 + 26be28a commit 04fd3c0
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 70 deletions.
115 changes: 58 additions & 57 deletions src/runtime/agas/addressing_service.cpp
Expand Up @@ -45,7 +45,6 @@
#include <hpx/lcos/broadcast.hpp>

#include <boost/format.hpp>
#include <boost/icl/closed_interval.hpp>

#include <cstddef>
#include <cstdint>
Expand All @@ -60,69 +59,71 @@

namespace hpx { namespace agas
{
struct addressing_service::gva_cache_key
{ // {{{ gva_cache_key implementation
private:
typedef boost::icl::closed_interval<naming::gid_type, std::less>
key_type;

key_type key_;

public:
gva_cache_key()
: key_()
{}

explicit gva_cache_key(
naming::gid_type const& id_
, std::uint64_t count_ = 1
)
: key_(naming::detail::get_stripped_gid(id_)
, naming::detail::get_stripped_gid(id_) + (count_ - 1))
{
HPX_ASSERT(count_);
}
struct addressing_service::gva_cache_key
{ // {{{ gva_cache_key implementation
private:
typedef std::pair<naming::gid_type, naming::gid_type> key_type;

naming::gid_type get_gid() const
{
return boost::icl::lower(key_);
}
key_type key_;

std::uint64_t get_count() const
{
naming::gid_type const size = boost::icl::length(key_);
HPX_ASSERT(size.get_msb() == 0);
return size.get_lsb();
}
public:
gva_cache_key()
: key_()
{
}

friend bool operator<(
gva_cache_key const& lhs
, gva_cache_key const& rhs
)
{
return boost::icl::exclusive_less(lhs.key_, rhs.key_);
}
explicit gva_cache_key(
naming::gid_type const& id, std::uint64_t count = 1)
: key_(naming::detail::get_stripped_gid(id),
naming::detail::get_stripped_gid(id) + (count - 1))
{
HPX_ASSERT(count);
}

friend bool operator==(
gva_cache_key const& lhs
, gva_cache_key const& rhs
)
{
// Direct hit
if(lhs.key_ == rhs.key_)
return true;
naming::gid_type get_gid() const
{
return key_.first;
}

// Is lhs in rhs?
if (1 == lhs.get_count() && 1 != rhs.get_count())
return boost::icl::contains(rhs.key_, lhs.key_);
std::uint64_t get_count() const
{
naming::gid_type const size = key_.second - key_.first;
HPX_ASSERT(size.get_msb() == 0);
return size.get_lsb();
}

// Is rhs in lhs?
else if (1 != lhs.get_count() && 1 == rhs.get_count())
return boost::icl::contains(lhs.key_, rhs.key_);
friend bool operator<(
gva_cache_key const& lhs, gva_cache_key const& rhs)
{
return lhs.key_.second < rhs.key_.first;
}

return false;
}
}; // }}}
friend bool operator==(
gva_cache_key const& lhs, gva_cache_key const& rhs)
{
// Direct hit
if (lhs.key_ == rhs.key_)
{
return true;
}

// Is lhs in rhs?
if (1 == lhs.get_count() && 1 != rhs.get_count())
{
return rhs.key_.first <= lhs.key_.first &&
lhs.key_.second <= rhs.key_.second;
}

// Is rhs in lhs?
else if (1 != lhs.get_count() && 1 == rhs.get_count())
{
return lhs.key_.first <= rhs.key_.first &&
rhs.key_.second <= lhs.key_.second;
}

return false;
}
}; // }}}

addressing_service::addressing_service(
parcelset::parcelhandler& ph
Expand Down
37 changes: 24 additions & 13 deletions tests/performance/local/agas_cache_timings.cpp
Expand Up @@ -18,7 +18,6 @@
#include <hpx/util/histogram.hpp>

#include <boost/program_options.hpp>
#include <boost/icl/closed_interval.hpp>
#include <boost/accumulators/accumulators.hpp>

#include <algorithm>
Expand All @@ -37,52 +36,64 @@ typedef hpx::util::cache::entries::lfu_entry<hpx::agas::gva> gva_entry_type;
struct gva_cache_key
{
private:
typedef boost::icl::closed_interval<hpx::naming::gid_type, std::less>
key_type;
typedef std::pair<hpx::naming::gid_type, hpx::naming::gid_type> key_type;

key_type key_;

public:
gva_cache_key()
: key_()
{}
{
}

explicit gva_cache_key(hpx::naming::gid_type const& id, std::uint64_t count)
explicit gva_cache_key(
hpx::naming::gid_type const& id, std::uint64_t count = 1)
: key_(hpx::naming::detail::get_stripped_gid(id),
hpx::naming::detail::get_stripped_gid(id) + (count - 1))
hpx::naming::detail::get_stripped_gid(id) + (count - 1))
{
HPX_ASSERT(count);
}

hpx::naming::gid_type get_gid() const
{
return boost::icl::lower(key_);
return key_.first;
}

std::uint64_t get_count() const
{
hpx::naming::gid_type const size = boost::icl::length(key_);
hpx::naming::gid_type const size = key_.second - key_.first;
HPX_ASSERT(size.get_msb() == 0);
return size.get_lsb();
}

friend bool operator<(gva_cache_key const& lhs, gva_cache_key const& rhs)
{
return boost::icl::exclusive_less(lhs.key_, rhs.key_);
return lhs.key_.second < rhs.key_.first;
}

friend bool operator==(gva_cache_key const& lhs, gva_cache_key const& rhs)
{
// Direct hit
if (lhs.key_ == rhs.key_)
{
return true;
}

// Is lhs in rhs?
if (1 == lhs.get_count() && 1 != rhs.get_count())
return boost::icl::contains(rhs.key_, lhs.key_);
{
return rhs.key_.first <= lhs.key_.first &&
lhs.key_.second <= rhs.key_.second;
}

// Is rhs in lhs?
else if (1 != lhs.get_count() && 1 == rhs.get_count())
return boost::icl::contains(lhs.key_, rhs.key_);
{
return lhs.key_.first <= rhs.key_.first &&
rhs.key_.second <= lhs.key_.second;
}

// Direct hit
return lhs.key_ == rhs.key_;
return false;
}
};

Expand Down

0 comments on commit 04fd3c0

Please sign in to comment.