The array notation such as that which copies two arrays
t[k .. hi by s] = _t[i .. m]; //
is very clear and nice and tight. It predates the foreach statement. I note that
foreach (_k, _i) in zip(k .. hi by s, i .. m)
{
t[_k] = _t[_i];
}
will today run faster the line of code using the earlier array notation, albeit more verbosely.
Should the former be implemented in terms of the latter at some stage?
It should not necessarily be a high priority task. Thanks.
Hi Damian,
This has been a long-standing wish that recently surfaced in other contexts, too.
proposal: optimize whole-array operations on array views · Issue #16133 · chapel-lang/chapel · GitHub is the best issue that captures the request and potential solutions.
It should not necessarily be a high priority task.
Thanks for this info as well. Personally, I see this as a fun rainy day task that's on my mind these days. I might impulsively implement it one day, but I'd be happy if someone else beats me to it
Please let us know if your sense of priorities change before we can add the optimization.
Engin
1 Like
Hello Damian,
Chapel 2.2 that is planned to go out tomorrow will have an optimization called "array view elision", or AVE, that will help these cases. I just confirmed that the code similar to what you have above will have improved performance with that optimization. As with any optimization, there are some areas where optimization will not apply right away. That's mostly out of abundance of caution. If you notice that your actual use case doesn't benefit from it, please let us know, ideally with a snippet resembling your code that also doesn't benefit from it.
There will be some more info on the Release Announcement due together with the release, and probably some more in the Release Notes that will come online in a couple of weeks. In the meantime Implement array view elision by e-kayrakli · Pull Request #24390 · chapel-lang/chapel · GitHub has some performance data that shows the improvement with this optimization.
Please let us know about your experience with it.
Best,
Engin
3 Likes
@damianmoz — Following up on Engin's comment, Chapel 2.2 is out now and contains this optimization (you probably saw announcement of the release announcement, which describes it, available here: Announcing Chapel 2.2!
As Engin says, we'll be curious to hear how this works for you,
-Brad