Skip to content

Vector inputs to a task #124

@josephjohnjj

Description

@josephjohnjj

I have a task that takes a std::vector<Octant_Aggregator_Data> as input

auto make_test(ttg::Edge<Key, std::vector<Octant_Aggregator_Data>>& testEdge) 
{
  auto f = [=](const Key& key, std::vector<Octant_Aggregator_Data>& testData, std::tuple<>& out)
            {
              printf("==========TEST========  \n"); 
            };
            
  return ttg::wrap<Key>(f, ttg::edges(testEdge), ttg::edges(), "test", {"testEdge"}, {});
} 

The class Octant_Aggregator_Data is as follows

struct Octant_Aggregator_Data
{
  Key octant_key;
  Key parent_key;
  int next_level;

  Octant_Aggregator_Data() = default;
  Octant_Aggregator_Data(Key key1, Key key2, int level) : 
    octant_key(key1), parent_key(key2), next_level(level){}

  bool operator==(const Octant_Aggregator_Data& b) const 
      { return octant_key == b.octant_key && parent_key == b.parent_key && next_level == b.next_level; }
      
  bool operator!=(const Octant_Aggregator_Data& b) const { return !((*this) == b); }

  Key get_octant_key() const { return octant_key; }
  Key get_parent_key() const { return parent_key; }
  int get_next_level() const { return next_level; }

  void set_octant_key(Key key)  { octant_key = key; }
  void set_parent_key(Key key)  { parent_key = key; }
  void set_next_level(int value) { next_level = value; }

  //template <typename Archive>
  //void serialize(Archive& ar) {
  //  ar& madness::archive::wrap((unsigned char*)this, sizeof(*this));
  //}

};

I followed ttg/examples/randomaccess/randomaccess.cc to serialise the object of this class:

namespace madness {
  namespace archive {
    template <class Archive>
      struct ArchiveStoreImpl<Archive, Octant_Aggregator_Data> {
        static inline void store(const Archive& ar, const Octant_Aggregator_Data& d) {
          ar << d.get_octant_key() << d.get_parent_key() << d.get_next_level();
          ar << wrap(&d, sizeof(Octant_Aggregator_Data));
        }
      };

    template <class Archive>
      struct ArchiveLoadImpl<Archive, Octant_Aggregator_Data> {
        static inline void load(const Archive& ar, Octant_Aggregator_Data& d) {
          Key octant_key;
          Key parent_key;
          int next_level;
          ar >> octant_key >> parent_key >> next_level;
          d = Octant_Aggregator_Data(octant_key, parent_key, next_level);
          ar >> wrap(&d, sizeof(Octant_Aggregator_Data));
        }
      };
  }
}

but I get the error

../examples/miniamr/miniamr.cc:565:88:   required from here
../ttg/ttg/parsec/ttg.h:546:21: error: incomplete type ‘ttg::default_data_descriptor<std::vector<Octant_Aggregator_Data>, void>’ used in nested name specifier
  546 |       if constexpr (!ttg::default_data_descriptor<ttg::meta::remove_cvr_t<T>>::serialize_size_is_const) {
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../ttg/ttg/parsec/ttg.h: In instantiation of ‘uint64_t ttg_parsec::Op<keyT, output_terminalsT, derivedT, input_valueTs>::pack(T&, void*, uint64_t) [with T = const std::vector<Octant_Aggregator_Data>; keyT = Key; output_terminalsT = std::tuple<>; derivedT = ttg_parsec::WrapOpArgs<make_test(ttg::Edge<Key, std::vector<Octant_Aggregator_Data> >&)::<lambda(const Key&, std::vector<Octant_Aggregator_Data>&, std::tuple<>&)>&, Key, std::tuple<>, std::vector<Octant_Aggregator_Data, std::allocator<Octant_Aggregator_Data> > >; input_valueTs = {std::vector<Octant_Aggregator_Data, std::allocator<Octant_Aggregator_Data> >}; uint64_t = long unsigned int]’:

Are there any problems with the load() and store() function here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions