chapel icon indicating copy to clipboard operation
chapel copied to clipboard

[Feature Request]: A better alternative than `isDefaultRectangular` for checking whether an array/domain is local

Open e-kayrakli opened this issue 1 year ago • 7 comments

Summary of Feature

Description: Today, the go-to user-facing way of checking whether an array or domain is distributed is to call the isDefaultRectangular method on them. But the term "default rectangular" is not something user-facing nor intuitive. Can we add a method with a more intuitive name.

Is this issue currently blocking your progress? No

Code Sample

myArray.isDistributed();

My first reflex was isLocal, but that's tricky. An array can be non-distributed but remote.

Arguably, isDistributed also has some gotchas:

  • Is a block-distributed array "distributed", if the program is run with -nl1 ?
  • Is it distributed if its targetLocales only has a single locale?

To me, the answer is "yes" in both scenarios, but I admit that cases like these are where isDefaultRectangular seems more precise.

An interesting take could be something like hasDistribution. Technically, all arrays and domains have distributions in Chapel, but they are not very first class in the language, and from a user's perspective, it may be thought as if non-distributed arrays don't have a distribution.

e-kayrakli avatar Apr 21 '25 17:04 e-kayrakli

To me, the answer is "yes" in both scenarios

My intuition matches, and I think if the documentation for the routine is clear about this, that's acceptable—specifically, it'd be nice if this could be a param-returning routine, which would mean making the decision without knowing the two conditions you mention.

We could consider also supporting spansMultipleLocales() or something like that to ask the more dynamic question of whether multiple locales own a piece of the array.

I think whatever we do here, we should do the same for domains. I think a number of homegrown variations of these queries have appeared over the years (e.g., in the LinearAlgebra package), and it's overdue to add support for them for real.

bradcray avatar Apr 21 '25 17:04 bradcray

Today, the go-to user-facing way of checking whether an array or domain is distributed is to call the isDefaultRectangular method on them

Also note, I don't think isDefaultRectangular is really user facing. We use it in a number of internal modules, but to my knowledge its not documented anywhere.

jabraham17 avatar Apr 21 '25 17:04 jabraham17

I agree with what has been said above, and I feel like this being a param returning routine is important for its usefulness since all the current uses of isDefaultRectangular that I've come across happen in where clauses.

ShreyasKhandekar avatar Apr 21 '25 18:04 ShreyasKhandekar

In my own code I have isDistributedDomain for this. https://github.com/femto-dev/femto/blob/a10668efb3e4bb58e22b17f980fb94b7932109da/src/ssort_chpl/Utility.chpl#L75-L79

Perhaps myArray.isDistributed, because it's a property, it doesn't do anything, we like parenless for this?

mppf avatar Apr 22 '25 21:04 mppf

Perhaps myArray.isDistributed, because it's a property, it doesn't do anything, we like parenless for this?

It hadn't occurred to me, but I like this idea. We should take a look at any other existing methods of similar nature and make sure that things are consistent, if they exist.

e-kayrakli avatar Apr 23 '25 16:04 e-kayrakli

I agree with the proposal to check on current patterns and usages. I agree that this could be considered a property / field-like, but I tend to think of .isDistributed() as being a method due to the presence of is (that is, I don't think I'd name a field that). Meanwhile, .distributed feels like something I might use as a field name, but I'm not sure that it's a good/clear name for the query.

If we have other queries that start with is… or has… that are typically paren-less or not, that'd be good data to have in making the decision.

bradcray avatar Apr 23 '25 16:04 bradcray

I remember the presence of "is"/"has" and parenless-ness coming up when we were discussing naming for 2.0, so there are probably notes to that effect internally

lydia-duncan avatar Apr 23 '25 17:04 lydia-duncan