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 { ... } }
class locale

locale is the abstract class from which the various implementations inherit. It specifies the required interface and implements part of it, but requires the rest to be provided by the corresponding concrete classes.

proc 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. 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 the CHPL_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 or slurm) 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 numCores: int

numCores is a deprecated predecessor to numPUs, equivalant to numPUs(logical=true, accessible=true). It will be removed after Chapel 1.13 is released.

var maxTaskPar: int

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.

const callStackSize: size_t

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.

proc id: int

Get the integer identifier for the top-level locale the current task is running on.

Returns:locale number, in the range 0..numLocales-1
Return type:int
proc name

Get the name of the top-level locale the current task is running on.

Returns:locale name
Return type:string
proc here

This returns the locale from which the call is made.

Returns:current locale
Return type:locale