Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resources can not be compared or used in containers #55

Open
MrBurmark opened this issue Apr 28, 2021 · 3 comments
Open

Resources can not be compared or used in containers #55

MrBurmark opened this issue Apr 28, 2021 · 3 comments

Comments

@MrBurmark
Copy link
Member

Currently resources are not comparable of hashable so they can't be used as keys in unordered containers. It would also generally be useful if they were comparable so it would be possible to know if two represented the same resource, for example the same cuda stream.

@trws
Copy link
Member

trws commented Apr 29, 2021 via email

@MrBurmark
Copy link
Member Author

  1. That makes sense to me, and presumably this only really matters for the type erased resource. Would combining the number and the platform in some way provide a reasonable hash?
  2. That's a good point. My first instinct is to honor the actual behavior/result, but I can see why it would also make sense to depend on the logical behavior. I can imagine wanting to put thing in an associative container by the behavior of the resource and by the number that was used. Perhaps comparison should use the number and a separate function can distinguish between resources with equivalent behavior? Then we could at least make a comparator that uses equivalence.

@trws
Copy link
Member

trws commented Apr 30, 2021

That seems like a good compromise to me.

The hash we can probably hack together by just taking the number that goes in and ORing it with the shifted platform ID or something, since they have essentially unique numbers to begin with that would be a nearly-perfect hash essentially for free.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants