libxmp/libxmpf in Omni Compiler  1.3.4
xmpco_lib.c File Reference
#include <string.h>
#include "xmpco_internal.h"
#include "_xmpco_alloc.h"
Include dependency graph for xmpco_lib.c:

Functions

void XMPCO_this_image_coarray (CoarrayInfo_t *cinfo, int corank, int image[])
 
int XMPCO_this_image_coarray_dim (CoarrayInfo_t *cinfo, int corank, int dim)
 
MPI_Comm _XMPCO_get_comm_of_nodes (_XMP_nodes_t *nodes)
 
int _XMPCO_num_images_onNodes (_XMP_nodes_t *nodes)
 
int _XMPCO_this_image_onNodes (_XMP_nodes_t *nodes)
 
void _XMPCO_set_initialThisImage ()
 
void _XMPCO_set_initialNumImages ()
 
int _XMPCO_get_initialThisImage ()
 
int _XMPCO_get_initialNumImages ()
 
int _XMPCO_get_currentNumImages ()
 
int _XMPCO_get_currentThisImage ()
 
MPI_Comm _XMPCO_get_currentComm ()
 
BOOL _XMPCO_is_subset_exec ()
 
int _XMPCO_transImage_withComm (MPI_Comm comm1, int image1, MPI_Comm comm2)
 
int _XMPCO_transImage_current2initial (int image)
 
int _XMPCO_get_initial_image_withDescPtr (int image, CoarrayInfo_t *descPtr)
 
void _XMPCO_clean_imageDirNodes ()
 
void _XMPCO_set_imageDirNodes (_XMP_nodes_t *nodes)
 
_XMP_nodes_t_XMPCO_get_imageDirNodes ()
 
_XMP_nodes_t_XMPCO_consume_imageDirNodes ()
 
MPI_Comm _XMPCO_get_comm_current ()
 
MPI_Comm _XMPCO_consume_comm_current ()
 

Function Documentation

◆ _XMPCO_clean_imageDirNodes()

void _XMPCO_clean_imageDirNodes ( )
273 {
274  _imageDirNodes = NULL;
275 }

◆ _XMPCO_consume_comm_current()

MPI_Comm _XMPCO_consume_comm_current ( )
316 {
318  if (imageNodes != NULL)
319  return *(MPI_Comm*)(imageNodes->comm);
320 
321  MPI_Comm *commp = (MPI_Comm*)(_XMP_get_execution_nodes()->comm);
322  if (commp != NULL)
323  return *commp;
324  return MPI_COMM_WORLD;
325 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMPCO_consume_imageDirNodes()

_XMP_nodes_t* _XMPCO_consume_imageDirNodes ( )
293 {
294  _XMP_nodes_t *ret = _imageDirNodes;
295  _imageDirNodes = NULL;
296  return ret;
297 }
Here is the caller graph for this function:

◆ _XMPCO_get_comm_current()

MPI_Comm _XMPCO_get_comm_current ( )
305 {
306  if (_imageDirNodes != NULL)
307  return *(MPI_Comm*)(_imageDirNodes->comm);
308 
309  MPI_Comm *commp = (MPI_Comm*)(_XMP_get_execution_nodes()->comm);
310  if (commp != NULL)
311  return *commp;
312  return MPI_COMM_WORLD;
313 }

◆ _XMPCO_get_comm_of_nodes()

MPI_Comm _XMPCO_get_comm_of_nodes ( _XMP_nodes_t nodes)
84 {
85  if (!nodes->is_member)
86  return MPI_COMM_NULL;
87  return *(MPI_Comm*)(nodes->comm);
88 }

◆ _XMPCO_get_currentComm()

MPI_Comm _XMPCO_get_currentComm ( )
164 {
165  MPI_Comm *commp;
166  _XMP_nodes_t *nodes;
167 
168  if ((nodes = _XMPCO_get_imageDirNodes()) == NULL)
169  nodes = _XMP_get_execution_nodes();
170 
171  commp = (MPI_Comm*)nodes->comm;
172  return *commp;
173 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMPCO_get_currentNumImages()

int _XMPCO_get_currentNumImages ( )
144 {
145  _XMP_nodes_t *nodes;
146 
147  if ((nodes = _XMPCO_get_imageDirNodes()) == NULL)
148  nodes = _XMP_get_execution_nodes();
149 
150  return nodes->comm_size;
151 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMPCO_get_currentThisImage()

int _XMPCO_get_currentThisImage ( )
154 {
155  _XMP_nodes_t *nodes;
156 
157  if ((nodes = _XMPCO_get_imageDirNodes()) == NULL)
158  nodes = _XMP_get_execution_nodes();
159 
160  return nodes->comm_rank + 1;
161 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMPCO_get_imageDirNodes()

_XMP_nodes_t* _XMPCO_get_imageDirNodes ( )
287 {
288  return _imageDirNodes;
289 }
Here is the caller graph for this function:

◆ _XMPCO_get_initial_image_withDescPtr()

int _XMPCO_get_initial_image_withDescPtr ( int  image,
CoarrayInfo_t descPtr 
)
247 {
248  if (descPtr == NULL)
249  return _XMPCO_transImage_current2initial(image);
250 
251  MPI_Comm nodesComm =
253  if (nodesComm == MPI_COMM_NULL)
254  return _XMPCO_transImage_current2initial(image);
255 
256  // The coarray is specified with a COARRAY directive.
257 
258  int initImage = _XMPCO_transImage_withComm(nodesComm, image,
259  MPI_COMM_WORLD);
260 
261  _XMPCO_debugPrint("*** got the initial image (%d) from the image mapping to nodes (%d)\n",
262  initImage, image);
263 
264  return initImage;
265 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMPCO_get_initialNumImages()

int _XMPCO_get_initialNumImages ( )
134 {
135  return _initialNumImages;
136 }
Here is the caller graph for this function:

◆ _XMPCO_get_initialThisImage()

int _XMPCO_get_initialThisImage ( )
129 {
130  return _initialThisImage;
131 }
Here is the caller graph for this function:

◆ _XMPCO_is_subset_exec()

BOOL _XMPCO_is_subset_exec ( )
177 {
178  if (_XMPCO_get_currentNumImages() < _initialNumImages)
179  // now executing in a task region
180  return TRUE;
181  if (_XMPCO_get_imageDirNodes() != NULL)
182  // image directive is now valid
183  return TRUE;
184  return FALSE;
185 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMPCO_num_images_onNodes()

int _XMPCO_num_images_onNodes ( _XMP_nodes_t nodes)
91 {
92  return nodes->comm_size;
93 }

◆ _XMPCO_set_imageDirNodes()

void _XMPCO_set_imageDirNodes ( _XMP_nodes_t nodes)
278 {
279  if (_imageDirNodes != NULL)
280  _XMP_fatal("INTERNAL: _imageDirNodes was not consumed but is defined.");
281  _imageDirNodes = nodes;
282 
283  _XMPCO_debugPrint("SET _imageDirNodes (%d nodes) done.\n", nodes->comm_size);
284 }

◆ _XMPCO_set_initialNumImages()

void _XMPCO_set_initialNumImages ( )
119 {
120  int size;
121 
122  if (MPI_Comm_size(MPI_COMM_WORLD, &size) != 0)
123  _XMPCO_fatal("INTERNAL ERROR: "
124  "MPI_Comm_size(MPI_COMM_WORLD, ) failed");
125  _initialNumImages = size;
126 }
Here is the call graph for this function:

◆ _XMPCO_set_initialThisImage()

void _XMPCO_set_initialThisImage ( )
108 {
109  int rank;
110 
111  if (MPI_Comm_rank(MPI_COMM_WORLD, &rank) != 0)
112  _XMPCO_fatal("INTERNAL ERROR: "
113  "MPI_Comm_rank(MPI_COMM_WORLD, ) failed");
114 
115  _initialThisImage = rank + 1;
116 }
Here is the call graph for this function:

◆ _XMPCO_this_image_onNodes()

int _XMPCO_this_image_onNodes ( _XMP_nodes_t nodes)
96 {
97  if (!nodes->is_member)
98  return 0; // This image is out of the node.
99  return nodes->comm_rank + 1;
100 }
Here is the caller graph for this function:

◆ _XMPCO_transImage_current2initial()

int _XMPCO_transImage_current2initial ( int  image)
223 {
224  int num = _XMPCO_get_currentNumImages();
225 
226  if (image <= 0 || num < image)
227  _XMPCO_fatal("ERROR: image index (%d) not specified within the range (1 to %d)\n",
228  image, num);
229 
230  if (!_XMPCO_is_subset_exec())
231  return image;
232 
233  int initImage = _XMPCO_transImage_withComm(_XMPCO_get_currentComm(), image,
234  MPI_COMM_WORLD);
235 
236  _XMPCO_debugPrint("*** got the initial image (%d) from the current image (%d)\n",
237  initImage, image);
238 
239  return initImage;
240 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMPCO_transImage_withComm()

int _XMPCO_transImage_withComm ( MPI_Comm  comm1,
int  image1,
MPI_Comm  comm2 
)
191 {
192  int image2, rank1, rank2;
193  MPI_Group group1, group2;
194  int stat1, stat2, stat3;
195 
196  rank1 = image1 - 1;
197  stat1 = MPI_Comm_group(comm1, &group1);
198  stat2 = MPI_Comm_group(comm2, &group2);
200  _XMPCO_debugPrint("gege comm1=%d, comm2=%d, image1=%d\n", comm1, comm2, image1);
202 
203  stat3 = MPI_Group_translate_ranks(group1, 1, &rank1, group2, &rank2);
204  // (in:Group1, n, rank1[n], Group2, out:rank2[n])
205  if (rank2 == MPI_UNDEFINED)
206  image2 = 0;
207  else
208  image2 = rank2 + 1;
209 
210  if (stat1 != 0 || stat2 != 0 || stat3 != 0)
211  _XMPCO_fatal("INTERNAL: _transimage_withComm failed with "
212  "stat1=%d, stat2=%d, stat3=%d",
213  stat1, stat2, stat3);
214 
215  _XMPCO_debugPrint("***IMAGE NUMBER translated from %d to %d\n",
216  image1, image2);
217 
218  return image2;
219 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ XMPCO_this_image_coarray()

void XMPCO_this_image_coarray ( CoarrayInfo_t cinfo,
int  corank,
int  image[] 
)
18 {
19  int size, index, image_coarray, magic;
20  _XMP_nodes_t *nodes;
21 
22  nodes = cinfo->nodes;
23  if (nodes != NULL) {
24  image_coarray = _XMPCO_this_image_onNodes(nodes);
25  } else {
26  image_coarray = _XMPCO_get_currentThisImage();
27  }
28 
29  if (image_coarray == 0) { // This image is out of the nodes.
30  for (int i = 0; i < corank; i++)
31  image[i] = 0;
32  return;
33  }
34 
35  magic = image_coarray - 1;
36  for (int i = 0; i < corank; i++) {
37  size = cinfo->cosize[i];
38  index = magic % size;
39  image[i] = index + cinfo->lcobound[i];
40  magic /= size;
41  }
42 }
Here is the call graph for this function:

◆ XMPCO_this_image_coarray_dim()

int XMPCO_this_image_coarray_dim ( CoarrayInfo_t cinfo,
int  corank,
int  dim 
)
46 {
47  int size, index, image_coarray, magic;
48  //int image_init;
49  int k;
50  _XMP_nodes_t *nodes;
51  //MPI_Comm comm_coarray;
52 
53  if (dim <= 0 || corank < dim)
54  _XMPCO_fatal("Too large or non-positive argument 'dim' of this_image:"
55  "%d\n", dim);
56 
57  nodes = cinfo->nodes;
58  if (nodes != NULL) {
59  image_coarray = _XMPCO_this_image_onNodes(nodes);
60  } else {
61  image_coarray = _XMPCO_get_currentThisImage();
62  }
63 
64  if (image_coarray == 0) // This image is out of the nodes.
65  return 0;
66 
67  magic = image_coarray - 1;
68  k = dim - 1;
69  for (int i = 0; i < k; i++) {
70  size = cinfo->cosize[i];
71  magic /= size;
72  }
73  size = cinfo->cosize[k];
74  index = magic % size;
75  return index + cinfo->lcobound[k];
76 }
Here is the call graph for this function:
_XMP_nodes_type::comm_size
int comm_size
Definition: xmp_data_struct.h:48
_XMP_nodes_type::is_member
int is_member
Definition: xmp_data_struct.h:46
_XMPCO_transImage_withComm
int _XMPCO_transImage_withComm(MPI_Comm comm1, int image1, MPI_Comm comm2)
Definition: xmpco_lib.c:190
_XMPCO_consume_imageDirNodes
_XMP_nodes_t * _XMPCO_consume_imageDirNodes()
Definition: xmpco_lib.c:292
_XMPCO_get_currentThisImage
int _XMPCO_get_currentThisImage()
Definition: xmpco_lib.c:153
FALSE
#define FALSE
Definition: xmpco_internal.h:16
_XMPCO_debugPrint
void _XMPCO_debugPrint(char *format,...)
Definition: xmpco_msg.c:20
_XMP_nodes_type::comm_rank
int comm_rank
Definition: xmp_data_struct.h:52
_XMPCO_get_imageDirNodes
_XMP_nodes_t * _XMPCO_get_imageDirNodes()
Definition: xmpco_lib.c:286
_XMPCO_transImage_current2initial
int _XMPCO_transImage_current2initial(int image)
Definition: xmpco_lib.c:222
_coarrayInfo_t::cosize
int * cosize
Definition: _xmpco_alloc.h:102
_XMPCO_this_image_onNodes
int _XMPCO_this_image_onNodes(_XMP_nodes_t *nodes)
Definition: xmpco_lib.c:95
_coarrayInfo_t::nodes
_XMP_nodes_t * nodes
Definition: _xmpco_alloc.h:103
_XMPCO_fatal
void _XMPCO_fatal(char *format,...)
Definition: xmpco_msg.c:4
TRUE
#define TRUE
Definition: xmpco_internal.h:15
_XMPCO_get_currentComm
MPI_Comm _XMPCO_get_currentComm()
Definition: xmpco_lib.c:163
_XMP_nodes_type::comm
_XMP_comm_t * comm
Definition: xmp_data_struct.h:53
_XMP_fatal
void _XMP_fatal(char *msg)
Definition: xmp_util.c:42
_XMPCO_get_currentNumImages
int _XMPCO_get_currentNumImages()
Definition: xmpco_lib.c:143
_XMP_nodes_type
Definition: xmp_data_struct.h:40
_XMPCO_is_subset_exec
BOOL _XMPCO_is_subset_exec()
Definition: xmpco_lib.c:176
_coarrayInfo_t::lcobound
int * lcobound
Definition: _xmpco_alloc.h:100
_XMP_get_execution_nodes
void * _XMP_get_execution_nodes(void)
Definition: xmp_nodes_stack.c:46
_XMPCO_get_comm_fromCoarrayInfo
MPI_Comm _XMPCO_get_comm_fromCoarrayInfo(CoarrayInfo_t *cinfo)
Definition: xmpco_alloc.c:527