Skip to content

[Feature Request]: Expand the Python module Chapel Array Shim objects API #27073

Open
@jabraham17

Description

@jabraham17

This issue captures all of the future work generated by #26940. In that PR, we add support for multi-dimensional Chapel and Python arrays.

Multi-dimensional Chapel Arrays are represented in Python as a shim object that knows how to translate Python calls to Chapel calls for things like indexing. These shim objects also implement the buffer protocol, allowing libraries like numpy to get direct handles to the Chapel array memory.

Users can take these shim objects and do np_arr = np.asarray(chplArrayShimObject) to get a numpy view of a Chapel array. Then they can index/slice this numpy array arbitrarily.

For 1-D arrays, we implement logic in the Shim Object to index the array. For ND-arrays, we explicitly fail. This is because multi-dim array indexing/slicing is more complicated, and right now the numpy usecase is the primary usecase. Ideally, we also implement the indexing natively and support more types. For example, the Python array API only supports primitive types, but we could support a wider range of types (because Chapel arrays support more types). The primary challenge to this is that all of the Shim logic has to be re-implemented in C. Ideally, we could pass Chapel function pointers and use those, but thats a much bigger undertaking (but worthwhile to support more advanced indexing/slicing)

Lastly, we can and should expose more aspects of the Chapel arrays, especially their shape.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions