StanfordLegion / legion

The Legion Parallel Programming System
https://legion.stanford.edu
Apache License 2.0
687 stars 144 forks source link

Legion types are not hashable #1712

Closed Jacobfaib closed 4 months ago

Jacobfaib commented 4 months ago

Legion::PhysicalInstance has no specialization for std::hash, but it does have a operator<(). This means it can be used in std::map but not std::unordered_map. This is surprising.

There are other such classes which appear to have operator<() defined (presumably to allow them to be put in std::map) but no std::hash specializations:

  1. IndexSpace
  2. IndexPartition
  3. FieldSpace
  4. LogicalRegion
  5. LogicalPartition
  6. FieldAllocator
  7. UntypedBuffer
  8. ArgumentMap
  9. Predicate
  10. Lock
  11. Grant
  12. PhaseBarrier
  13. RegionRequirement
  14. OutputRequirement
  15. IndexSpaceRequirement
  16. FieldSpaceRequirement
  17. Future
  18. FutureMap
  19. PhysicalRegion
lightsighter commented 4 months ago

Want to make me a merge request for that if it is important?

Jacobfaib commented 4 months ago

Yeah, that would be useful. Off the top of my head, the most critical ones would be:

  1. PhysicalInstance
  2. IndexPartition
  3. LogicalRegion
  4. FieldSpace
  5. Future
  6. FutureMap

But they would all benefit from hash overloads if applicable.

magnatelee commented 4 months ago

I think practically the last two are the only problematic ones, as the first four reveal their unique identifiers in one way or another that we can hash off of.

lightsighter commented 4 months ago

Yeah, that would be useful.

Looking forward to it. Be careful about what guarantees you want to make about hash values of data structures that represent the same thing from different nodes.

Jacobfaib commented 4 months ago

https://gitlab.com/StanfordLegion/legion/-/merge_requests/1372

lightsighter commented 4 months ago

Merged