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

[FEA]: Introduce sentinel ranges into cuda.parallel #2480

Open
1 task done
gevtushenko opened this issue Sep 29, 2024 · 0 comments
Open
1 task done

[FEA]: Introduce sentinel ranges into cuda.parallel #2480

gevtushenko opened this issue Sep 29, 2024 · 0 comments
Assignees
Labels
feature request New feature or request.

Comments

@gevtushenko
Copy link
Collaborator

Is this a duplicate?

Area

General CCCL

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

We are lacking functionality of sentinel fancy iterators such as thrust::counting_iterator, and thrust::constant_iterator in cuda.parallel.

Describe the solution you'd like

We should introduce cuda.parallel.experimental.itertools module with repeat(value) for thrust::constant_iterator, and count(start) for thrust::counting_iterator.

Naive implementation might look like:

class CountingIterator(ctypes.Structure):
    _fields_ = [("offset", ctypes.c_int64)]

    def advance(self_ptr, offset):
        self_ptr[0] = self_ptr[0] + offset

    def dereference(self_ptr):
        return self_ptr[0]


def count(start):
    return CountingIterator(start)

This issue can be closed by three tests in python/cuda_parallel/tests/test_reduce.py:

  1. device sum of repeat(1) is equal to num_items
  2. device sum of repeat(UserDefinedPair(1, 2)) is equal to UserDefinedPair(num_items, 2 * num_items)
  3. device sum of count(1) is equal to num_items * (num_items + 1) / 2

Describe alternatives you've considered

No response

Additional context

No response

@gevtushenko gevtushenko added the feature request New feature or request. label Sep 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request New feature or request.
Projects
Status: In Progress
Development

No branches or pull requests

2 participants