Conversation
Since #771 the `mapping` of an `NDRange` decides how blocked indices map to `ndrange` indices, and every backend derives the index, validity and linear index of a work item from `expand`, `in` and `linear_index`. That makes it possible for a package to launch kernels over an iteration space of its own, such as a list of indices, by specializing `partition` and `cartesian` for its launch object and `expand` for its mapping, but nothing said so, and a backend overriding `__validindex` for a generic context would silently break such an extension. The `NDRange` docstring now lists the functions a custom mapping defines, `partition` and the new `cartesian` and `expand` docstrings point to it, and the notes for backend implementations state that a backend must go through `expand`, `in` and `linear_index` and must not assume the `ndrange` of a context is a `CartesianIndices`. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VHciC8x39gm97sABrSvBkt
Benchmark ResultsShow table
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #781 +/- ##
=======================================
Coverage 64.89% 64.89%
=======================================
Files 23 23
Lines 2011 2011
=======================================
Hits 1305 1305
Misses 706 706 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| A backend must not assume that `__ndrange(ctx)` is a `CartesianIndices` or that | ||
| `expand` is an affine map: the `mapping` field of the `NDRange` lets a package | ||
| define its own iteration space, for example a list of indices to visit, by |
There was a problem hiding this comment.
This is a new contract, I am not supper happy about. These are private implementation details and a packing extending them is doing fishy work, and potentially type piracy.
I would be much happier if we had a public interface that folks could extend
abstract type Mapping end
And then Oceananigans could do its subtype of that, and so ndrange=Mapping()
No description provided.