pnnl / SHAD

Scalable High-performance Algorithms and Data-structures
Apache License 2.0
122 stars 35 forks source link

HashMap compile error #235

Open yinengy opened 1 year ago

yinengy commented 1 year ago
include/shad/data_structures/local_hashmap.h:1078:31: error: no match for call to '(agile::wk2_exact::intTimeInserter<long int>) (shad::rt::Handle&, long int*, const long int&, bool)'
 1078 |         bool inserted = insfun(handle, &entry->value, value, false);
      |                         ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from wk2_exact/pattern.cc:47:
include/agile/wk2_exact/pattern.h:56:8: note: candidate: 'bool agile::wk2_exact::intTimeInserter<T>::operator()(T*, const T&, bool) [with T = long int]'
   56 |   bool operator()(T * const lhs, const T & rhs, bool same_key) {
      |        ^~~~~~~~
include/agile/wk2_exact/pattern.h:56:8: note:   candidate expects 3 arguments, 4 provided

Get this compiling error from latest code.

My inserter is code is

template <typename T>
struct intTimeInserter {
  intTimeInserter() { }

  bool operator()(T * const lhs, const T & rhs, bool same_key) {
    if (same_key) {     // entry in hashmap, value = min(current value, new value)
       if (* lhs > rhs) * lhs = rhs;
    } else {            // entry not in hashmap, value = new value
       * lhs = rhs;
    }

    return true;
  }

  bool Insert(T *const lhs, const T &rhs, bool same_key) {
    if (same_key) {     // entry in hashmap, value = minimum(current value, new value)
       if (* lhs > rhs) * lhs = rhs;
    } else {            // entry not in hashmap, value = new value
       * lhs = rhs;
    }

    return true;
  }
};

Looks like the required signature changes, how should the inserter code be fixed to work with the new changes?

Looks like from recent commit https://github.com/pnnl/SHAD/commit/0805ea1f28147192d05a71d2f5009bc9ec7cd0dc