Adlib has some support for irregular communications in the form of collective gather and scatter operations. The simplest form of the gather operation for one-dimensional arrays has prototypes
The subscripts array should have the same shape as, and be aligned with, the destination array. In pseudocode, the gather operation is equivalent tovoid gather(
[[]] destination,
[[]] source, int [[]] subscripts) ;
wherefor all
in
in parallel do
destination [
] = source [subscripts [
]] ;
where fun is an arbitrary function, it can be expressed in HPJava asfor all
in
in parallel do
a [
] = b [
fun(i)] ;
where p and x are the distribution group and range of a. The source array may have a completely unrelated mapping.int [[]] tmp = new int [[x]] on p ;
on(p)
overall(i = x for :)
tmp [i] =
fun(i
) ;
Adlib.gather(a, b, tmp) ;
The one-dimensional case generalizes to give a rather complicated family of prototypes for multidimensional arrays:
The complexity arises because now that the source and destination arrays can have different ranks. The pattern is that the subscript arrays have the same and alignment shape as the destination arrays. The number of subscript arrays is equal to the rank of the source array. As an example, the last of the prototypes enumerated above behaves likevoid gather(
[[]] destination,
[[]] source,
int [[]] subscripts) ;
void gather(
[[,]] destination,
[[]] source,
int [[,]] subscripts) ;
void gather(
[[,,]] destination,
[[]] source,
int [[,,]] subscripts) ;
...
void gather(
[[]] destination,
[[,]] source,
int [[]] subscripts1, int [[]] subscripts2) ;
void gather(
[[,]] destination,
[[,]] source,
int [[,]] subscripts1, int [[,]] subscripts2) ;
void gather(
[[,,]] destination,
[[,]] source,
int [[,,]] subscripts1, int [[,,]] subscripts2) ;
...
...
wherefor all
in
in parallel do
for all
in
in parallel do
for all
in
in parallel do
destination [
,
,
] = source [
subscripts1 [
,
,
],
subscripts2 [
,
,
]] ;
The basic scatter function has very similar prototypes, but the names source and destination are switched. The one-dimensional case is
and it behaves likevoid scatter(
[[]] source,
[[]] destination,
int [[]] subscripts) ;
for all
in
in parallel do
destination [subscripts [
]] = source [
] ;