I am learning Chapel and have worked with blockdist but I can't figure out how can I distribute a 2-dimension array in row wise fashion among locales.
Distribute 2D array row wise among Locales in Chapel
387 views Asked by Robin Sharma At
1
The key is to pass a reshaped
Localesarray as thetargetLocalesargument toBlock. This is explained further below.Here's a simple example of distributing a 2D array in a row-wise fashion:
Sample outputs:
By default, distributions will use the built-in
Localesarray as thetargetLocalesargument, which specifies how to paritition the elements of an array across the locales within a particular domain map, e.g.Block.Since
Localesis a 1D array, and you're distributing a 2D array, theBlockdistribution wrapsLocaleslike so:So an array of shape
(4,4)would get mapped to 4 locales as:By providing a 2D
targetLocalesargument, we can tellBlockexplicitly how we'd like the elements to be mapped to locales, rather than rely on the wrapping. Passing atargetLocalesarray of locales with a shape of(4,1), will result in the desired row-wise distribution:So an array of shape
(4,4)would get mapped to 4 locales as:This concept applies to other distributions as well.