-
Notifications
You must be signed in to change notification settings - Fork 195
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Improvement] cuda.parallel: Don't require value_type when constructi…
…ng iterators (#3105) * Don't require value_type when constructing iterators * Small fixes --------- Co-authored-by: Ashwin Srinath <[email protected]>
- Loading branch information
Showing
3 changed files
with
21 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 12 additions & 13 deletions
25
python/cuda_parallel/cuda/parallel/experimental/iterators.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,34 @@ | ||
from . import _iterators | ||
|
||
|
||
def CacheModifiedInputIterator(device_array, value_type, modifier): | ||
"""Python fascade for Random Access Cache Modified Iterator that wraps a native device pointer. | ||
def CacheModifiedInputIterator(device_array, modifier): | ||
"""Python facade for Random Access Cache Modified Iterator that wraps a native device pointer. | ||
Similar to https://nvidia.github.io/cccl/cub/api/classcub_1_1CacheModifiedInputIterator.html | ||
Currently the only supported modifier is "stream" (LOAD_CS). | ||
""" | ||
if modifier != "stream": | ||
raise NotImplementedError("Only stream modifier is supported") | ||
value_type = device_array.dtype | ||
return _iterators.CacheModifiedPointer( | ||
device_array.__cuda_array_interface__["data"][0], | ||
_iterators.numba_type_from_any(value_type), | ||
) | ||
|
||
|
||
def ConstantIterator(value, value_type): | ||
"""Python fascade (similar to itertools.repeat) for C++ Random Access ConstantIterator.""" | ||
return _iterators.ConstantIterator( | ||
value, _iterators.numba_type_from_any(value_type) | ||
) | ||
def ConstantIterator(value): | ||
"""Python facade (similar to itertools.repeat) for C++ Random Access ConstantIterator.""" | ||
value_type = value.dtype | ||
return _iterators.ConstantIterator(value) | ||
|
||
|
||
def CountingIterator(offset, value_type): | ||
"""Python fascade (similar to itertools.count) for C++ Random Access CountingIterator.""" | ||
return _iterators.CountingIterator( | ||
offset, _iterators.numba_type_from_any(value_type) | ||
) | ||
def CountingIterator(offset): | ||
"""Python facade (similar to itertools.count) for C++ Random Access CountingIterator.""" | ||
value_type = offset.dtype | ||
return _iterators.CountingIterator(offset) | ||
|
||
|
||
def TransformIterator(op, it): | ||
"""Python fascade (similar to built-in map) mimicking a C++ Random Access TransformIterator.""" | ||
"""Python facade (similar to built-in map) mimicking a C++ Random Access TransformIterator.""" | ||
return _iterators.TransformIterator(op, it) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters