Skip to content

[ENHANCEMENT]: Add for_each device API #499

@sleeepyjack

Description

@sleeepyjack

Is your feature request related to a problem? Please describe.

There's currently no way of iterating over all matching values for a given key from the device.
The current retrieve API isn't exposed to the public since it is highly optimized for bulk retrieve and thus not well-suited for general use.

Describe the solution you'd like

Implement a device function that allows for iterating over all values found and then process them according to some user-defined callback function:

template <class CG, class ProbeKey, class Callback>
void for_each(CG tile, ProbeKey key, Callback f) {...}

During probing for key, if a thread in tile hits a matching slot, it will pass a non-incrementable iterator to said slot to the callback which then handles the downstream processing.

This API can also be used to implement the aforementioned optimized retrieve.

Describe alternatives you've considered

for_each handles all of the probing logic internally and just calls the callback with the found values.
The counter design to this would consist of a "heavy" iterator which is returned from a new retrieve device functionThe iterator will handle the probing internally, returningend()once there are no more matching values for the givenkey`.
I have some concerns with this design:

  • If we use window loads, i.e., load multiple slots per thread at once, then the iterator has to store this window internally
  • The iterator needs to be kept in the same CG context. If we can't ensure that the iterator is incremented in a CG context we might loose some of the values. There's no way we can ensure this never happens with this design. The for_each function, however, ensures that probing is always performed in the same CG context

Additional context

WarpCore had a for_each function although my design back in the day wasn't perfect: https://github.com/sleeepyjack/warpcore/blob/ba5a6a84a8797464e2ce8dd03b269907ee70e7c2/include/warpcore/multi_value_hash_table.cuh#L607

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions