22
33.. _Chapter-Domain_Maps :
44
5- ===========
6- Domain Maps
7- ===========
5+ =============
6+ Distributions
7+ =============
88
9- A domain map specifies the implementation of the domains and arrays that
9+ A distribution, also called a *domain map *,
10+ specifies the implementation of the domains and arrays that
1011are *mapped * using it. That is, it defines how domain indices and array
1112elements are mapped to locales, how they are stored in memory, and how
1213operations such as accesses, iteration, and slicing are performed. Each
13- domain and array is mapped using some domain map .
14+ domain and array is mapped using some distribution .
1415
15- A domain map is either a * layout * or a * distribution *. A layout
16- describes domains and arrays that exist on a single locale, whereas a
17- distribution describes domains and arrays that are partitioned across
18- multiple locales .
16+ In general, a distribution describes domains and arrays
17+ that are partitioned across multiple locales.
18+ A * layout * is a distribution that describes domains and arrays
19+ that exist on a single locale .
1920
20- A domain map is represented in the program with an instance of a * domain
21- map class *. Chapel provides a set of standard domain map classes. Users
22- can create domain map classes as well.
21+ A distribution is represented in the program with an instance of a
22+ * distribution record *. Chapel provides a set of standard distributions.
23+ Users can create distributions as well.
2324
24- Domain maps are presented as follows:
25+ Distributions are presented as follows:
2526
26- - domain maps for domain types :ref: `Domain_Maps_For_Types `,
27- domain values :ref: `Domain_Maps_For_Values `, and arrays
28- :ref: `Domain_Maps_For_Arrays `
27+ - distributions for
28+ :ref: `domain types <Domain_Maps_For_Types >`,
29+ :ref: `domain values <Domain_Maps_For_Values >`,
30+ :ref: `arrays <Domain_Maps_For_Arrays >`
2931
30- - domain maps are not retained upon domain assignment
31- :ref: `Domain_Maps_Not_Assigned `
32+ - :ref: `distributions are not retained upon domain assignment <Domain_Maps_Not_Assigned >`
3233
33- - standard layouts and distributions, such as Block and Cyclic, are
34- documented under
35- :ref: `Standard Layouts and Distributions <layouts_and_distributions >`
34+ - :ref: `Standard Layouts and Distributions <layouts_and_distributions >`,
35+ such as Block and Cyclic
3636
37- - specification of user-defined domain maps is forthcoming; please
37+ - specification of user-defined distributions is forthcoming; please
3838 refer to the
3939 :ref: `Domain Map Standard Interface technical note <readme-dsi >`
4040
4141.. _Domain_Maps_For_Types :
4242
43- Domain Maps for Domain Types
44- ----------------------------
43+ Distributions for Domain Types
44+ ------------------------------
4545
46- Each domain type has a domain map associated with it. This domain map is
46+ Each domain type has a distribution associated with it. This distribution is
4747used to map all domain values of this type
48- (:ref: `Domain_Maps_For_Values `).
48+ (see :ref: `Domain_Maps_For_Values `).
4949
50- If a domain type does not have a domain map specified for it explicitly
51- as described below, a default domain map is provided by the Chapel
52- implementation. Such a domain map will typically be a layout that maps
53- the entire domain to the locale on which the domain value is created or
50+ If a domain type does not have a distribution specified for it explicitly
51+ as described below, a default distribution is provided by the Chapel
52+ implementation. Such a distribution will typically be a layout that maps
53+ the entire domain to the locale on which the current task is executed or
5454the domain or array variable is declared.
5555
56- A domain map can be specified explicitly by providing a *dmap value * in
57- a ``dmapped `` clause:
58-
59-
56+ A distribution can be specified explicitly using a ``dmapped `` clause:
6057
6158.. code-block :: syntax
6259
6360 mapped-domain-type:
64- domain-type 'dmapped' dmap-value
61+ domain-type 'dmapped' distribution-record
6562
66- dmap-value :
63+ distribution-record :
6764 expression
6865
69- A dmap value consists of an instance of a domain map class wrapped in an
70- instance of the predefined record ``dmap ``. The domain map class is
71- chosen and instantiated by the user. ``dmap `` behaves like a generic
72- record with a single generic field, which holds the domain map instance.
73-
74- *Example *.
66+ where the ``distribution-record `` expression produces
67+ an instance of a distribution record.
7568
76- The code
69+ .. warning ::
7770
78- .. code-block :: chapel
79-
80- use BlockDist;
81- var MyBlockDist: dmap(Block(rank=2));
82-
83- declares a variable capable of storing dmap values for a
84- two-dimensional Block distribution. The Block distribution is
85- described in more detail in the standard library documentation.
86- See the module documentation for :mod: `BlockDist `.
71+ The ``dmapped `` keyword and the ``dmapped `` clause
72+ are currently unstable and may change in the future.
73+ Factory functions provided by the desired distribution,
74+ when available, should be used instead.
8775
8876..
8977
@@ -94,9 +82,10 @@ record with a single generic field, which holds the domain map instance.
9482 .. code-block :: chapel
9583
9684 use BlockDist;
97- var MyBlockDist: dmap(Block(rank=2)) = new dmap(new Block( {1..5,1..6}) );
85+ var MyBlockDist = new blockDist( {1..5,1..6});
9886
99- creates a dmap value wrapping a two-dimensional Block distribution
87+ creates an instance of the Block distribution record
88+ for two-dimensional domains and arrays
10089 with a bounding box of ``{1..5, 1..6} `` over all of the locales.
10190
10291 *Example *.
@@ -106,17 +95,16 @@ record with a single generic field, which holds the domain map instance.
10695 .. code-block :: chapel
10796
10897 use BlockDist;
109- var MyBlockDist = new dmap(new Block( {1..5,1..6}) );
98+ var MyBlockDist = new blockDist( {1..5,1..6});
11099 type MyBlockedDom = domain(2) dmapped MyBlockDist;
111100
112- defines a two-dimensional rectangular domain type that is mapped
113- using a Block distribution.
101+ defines the type of two-dimensional rectangular domains
102+ that are mapped using a Block distribution.
114103
115104The following syntactic sugar is provided within the ``dmapped `` clause.
116- If a ``dmapped `` clause starts with the name of a domain map class , it
105+ If a ``dmapped `` clause starts with the name of a distribution record , it
117106is considered to be an initialization expression as if preceded by
118- ``new ``. The resulting domain map instance is wrapped in a newly-created
119- instance of ``dmap `` implicitly.
107+ ``new ``.
120108
121109 *Example *.
122110
@@ -125,23 +113,23 @@ instance of ``dmap`` implicitly.
125113 .. code-block :: chapel
126114
127115 use BlockDist;
128- type BlockDom = domain(2) dmapped Block ({1..5,1..6});
116+ type BlockDom = domain(2) dmapped blockDist ({1..5,1..6});
129117
130118 is equivalent to
131119
132120 .. code-block :: chapel
133121
134122 use BlockDist;
135- type BlockDom = domain(2) dmapped new dmap(new Block( {1..5,1..6}) );
123+ type BlockDom = domain(2) dmapped new blockDist( {1..5,1..6});
136124
137125 .. _Domain_Maps_For_Values :
138126
139- Domain Maps for Domain Values
140- -----------------------------
127+ Distributions for Domain Values
128+ -------------------------------
141129
142- A domain value is always mapped using the domain map of that value’ s
130+ A domain value is always mapped using the distribution of that value' s
143131type. The type inferred for a domain literal
144- (:ref: `Rectangular_Domain_Values `) has a default domain map .
132+ (see :ref: `Rectangular_Domain_Values `) has a default distribution .
145133
146134 *Example *.
147135
@@ -151,22 +139,19 @@ type. The type inferred for a domain literal
151139
152140 use BlockDist;
153141 var MyDomLiteral = {1..2,1..3};
154- var MyBlockedDom: domain(2) dmapped Block({1..5,1..6}) = MyDomLiteral;
155-
156- ``MyDomLiteral `` is given the inferred type of the domain literal and
157- so will be mapped using a default map. MyBlockedDom is given a type
158- explicitly, in accordance to which it will be mapped using a Block
159- distribution.
160-
161- A domain value’s map can be changed explicitly with a ``dmapped ``
162- clause, in the same way as a domain type’s map.
142+ var MyBlockedDom: domain(2) dmapped blockDist({1..5,1..6}) = MyDomLiteral;
163143
144+ ``MyDomLiteral `` is a domain literal and so will be mapped using
145+ a default distribution. MyBlockedDom is given a type explicitly,
146+ therefore it will be mapped using a Block distribution.
164147
148+ A domain value's distribution can be specified explicitly with a ``dmapped ``
149+ clause, in the same way as a domain type's distribution.
165150
166151.. code-block :: syntax
167152
168153 mapped-domain-expression:
169- domain-expression 'dmapped' dmap-value
154+ domain-expression 'dmapped' distribution-record
170155
171156..
172157
@@ -177,18 +162,18 @@ clause, in the same way as a domain type’s map.
177162 .. code-block :: chapel
178163
179164 use BlockDist;
180- var MyBlockedDomLiteral1 = {1..2,1..3} dmapped new dmap(new Block( {1..5,1..6}) );
181- var MyBlockedDomLiteral2 = {1..2,1..3} dmapped Block ({1..5,1..6});
165+ var MyBlockedDomLiteral1 = {1..2,1..3} dmapped new blockDist( {1..5,1..6});
166+ var MyBlockedDomLiteral2 = {1..2,1..3} dmapped blockDist ({1..5,1..6});
182167
183168 both ``MyBlockedDomLiteral1 `` and ``MyBlockedDomLiteral2 `` will be
184169 mapped using a Block distribution.
185170
186171.. _Domain_Maps_For_Arrays :
187172
188- Domain Maps for Arrays
189- ----------------------
173+ Distributions for Arrays
174+ ------------------------
190175
191- Each array is mapped using the domain map of the domain over which the
176+ Each array is mapped using the distribution of the domain over which the
192177array was declared.
193178
194179 *Example *.
@@ -198,20 +183,20 @@ array was declared.
198183 .. code-block :: chapel
199184
200185 use BlockDist;
201- var Dom: domain(2) dmapped Block ({1..5,1..6}) = {1..5,1..6};
186+ var Dom: domain(2) dmapped blockDist ({1..5,1..6}) = {1..5,1..6};
202187 var MyArray: [Dom] real;
203188
204- the domain map used for ``MyArray `` is the Block distribution from
189+ the distribution used for ``MyArray `` is the Block distribution from
205190 the type of ``Dom ``.
206191
207192.. _Domain_Maps_Not_Assigned :
208193
209- Domain Maps Are Not Retained upon Domain Assignment
210- ---------------------------------------------------
194+ Distributions Are Not Retained upon Domain Assignment
195+ -----------------------------------------------------
211196
212- Domain assignment ( :ref: `Domain_Assignment `) transfers only the
197+ :ref: `Domain assignment < Domain_Assignment >` transfers only the
213198index set of the right-hand side expression. The implementation of the
214- left-hand side domain expression, including its domain map , is
199+ left-hand side domain expression, including its distribution , is
215200determined by its type and so does not change upon a domain assignment.
216201
217202 *Example *.
@@ -221,10 +206,10 @@ determined by its type and so does not change upon a domain assignment.
221206 .. code-block :: chapel
222207
223208 use BlockDist;
224- var Dom1: domain(2) dmapped Block ({1..5,1..6}) = {1..5,1..6};
209+ var Dom1: domain(2) dmapped blockDist ({1..5,1..6}) = {1..5,1..6};
225210 var Dom2: domain(2) = Dom1;
226211
227- ``Dom2 `` is mapped using the default distribution, despite ``Dom1 ``
212+ ``Dom2 `` is mapped using a default distribution, despite ``Dom1 ``
228213 having a Block distribution.
229214
230215..
@@ -236,11 +221,11 @@ determined by its type and so does not change upon a domain assignment.
236221 .. code-block :: chapel
237222
238223 use BlockDist;
239- var Dom1: domain(2) dmapped Block ({1..5,1..6}) = {1..5,1..6};
224+ var Dom1: domain(2) dmapped blockDist ({1..5,1..6}) = {1..5,1..6};
240225 var Dom2 = Dom1;
241226
242227 ``Dom2 `` is mapped using the same distribution as ``Dom1 ``. This is
243228 because the declaration of ``Dom2 `` lacks an explicit type specifier
244229 and so its type is defined to be the type of its initialization
245230 expression, ``Dom1 ``. So in this situation the effect is that the
246- domain map does transfer upon an initializing assignment .
231+ distribution does transfer upon initialization .
0 commit comments