chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.78k stars 419 forks source link

Location of `locale.physicalMemory` #22215

Open jabraham17 opened 1 year ago

jabraham17 commented 1 year ago

The MemDiagnostics (which is currently marked unstable) module defines a method on locales to query the physical memory present on a locale.

proc locale.physicalMemory(unit: MemUnits=MemUnits.Bytes, type retType=int(64))

Is this defined in the right place? Would it make more sense to be defined in ChapelLocale.chpl? Or somewhere else?

A few notes on this:

bradcray commented 1 year ago

My (reasonably strong) inclination here would be to make locale.physicalMemory() a primary/secondary method on the locale type (that is, one that's defined alongside the type itself). It feels like an innate property of a locale and not something that should require using a standard module to query.

I suspect that the enum is the main reason that we didn't do this from the start (though this is truly ancient code that's been in the memory module from the start, so who knows what we were thinking back then?), and for simplicity, we may just want to deprecate support for the enum (and the optional return type) at the same time that we move the routine, and rely on the user to do the math to convert bytes to another form for now, with the option to beef up the interface over time (specifically, I don't think we'd want this enum to be auto-available to all Chapel programs just because the locale type is... at least in the 2.0 timeframe).

In saying that, I haven't looked at existing use cases to see how heavily those arguments are used in "real codes".