Locales¶
A locale is a Chapel abstraction for a piece of a target architecture that has processing and storage capabilities. Generally speaking, the tasks running within a locale have roughly uniform access to values stored in the locale’s local memory and longer latencies for accessing the memories of other locales. As examples, a single shared memory machine would be defined as a single locale, while in a system consisting of a group of network-connected multicore nodes or SMPs each node would be defined as a locale.
Chapel provides several predefined methods on locales, as well as a few variables that describe the locales upon which a program is running.
In addition to what is documented below, numLocales
, LocaleSpace
,
and Locales
are available as global variables.
numLocales
is the number of top-level (network connected) locales.
config const numLocales: int;
LocaleSpace
is the domain over which the global Locales
array is
defined.
const LocaleSpace = {0..numLocales-1};
The global Locales
array contains an entry for each top-level locale.
const Locales: [LocaleSpace] locale;
One common code idiom in Chapel is the following, which spreads parallel tasks across the network-connected locales upon which the program is running:
coforall loc in Locales { on loc { ... } }
The default value for a locale
variable is Locales[0]
-
proc
here
¶ This returns the locale from which the call is made.
Returns: current locale Return type: locale
-
proc
locale.
hostname
¶ Get the hostname of this locale.
Returns: the hostname of the compute node associated with the locale Return type: string
-
proc
locale.
name
¶ Get the name of this locale. In practice, this is often the same as the hostname, though in some cases (like when using local launchers), it may be modified.
Returns: locale name Return type: string
-
proc
locale.
id
¶ Get the integer identifier for this locale.
Returns: locale number, in the range 0..numLocales-1
Return type: int
-
proc
locale.
maxTaskPar
¶ This is the maximum task concurrency that one can expect to achieve on this locale. The value is an estimate by the runtime tasking layer. Typically it is the number of physical processor cores available to the program. Creating more tasks than this will probably increase walltime rather than decrease it.
-
proc
locale.
numPUs
(logical: bool = false, accessible: bool = true)¶ A processing unit or PU is an instance of the processor architecture, basically the thing that executes instructions.
locale.numPUs
tells how many of these are present on this locale. It can count either physical PUs (commonly known as cores) or hardware threads such as hyperthreads and the like. It can also either take into account any OS limits on which PUs the program has access to or do its best to ignore such limits. By default it returns the number of accessible physical cores.Arguments: - logical : bool – Count logical PUs (hyperthreads and the like), or physical ones (cores)? Defaults to false, for cores.
- accessible : bool – Count only PUs that can be reached, or all of them? Defaults to true, for accessible PUs.
Returns: number of PUs
Return type: int
There are several things that can cause the OS to limit the processor resources available to a Chapel program. On plain Linux systems using the
taskset(1)
command will do it. On Cray systems theCHPL_LAUNCHER_CORES_PER_LOCALE
environment variable may do it, indirectly via the system job launcher. Also on Cray systems, using a system job launcher (aprun
orslurm
) to run a Chapel program manually may do it, as can running programs within Cray batch jobs that have been set up with limited processor resources.
-
proc
locale.
callStackSize
¶ callStackSize
holds the size of a task stack on a given locale. Thus,here.callStackSize
is the size of the call stack for any task on the current locale, including the caller.