libxmp/libxmpf in Omni Compiler  1.3.4
xmp_bcast.c File Reference
#include <stdio.h>
#include <stdarg.h>
#include "mpi.h"
#include "xmp_internal.h"
#include "xmp_math_function.h"
Include dependency graph for xmp_bcast.c:

Macros

#define MPI_PORTABLE_PLATFORM_H
 

Functions

void _XMP_bcast_NODES_ENTIRE_OMITTED (_XMP_nodes_t *bcast_nodes, void *addr, int count, size_t datatype_size)
 
void _XMP_bcast_NODES_ENTIRE_NODES (_XMP_nodes_t *bcast_nodes, void *addr, int count, size_t datatype_size, _XMP_nodes_t *from_nodes,...)
 
void _XMP_bcast_NODES_ENTIRE_NODES_V (_XMP_nodes_t *bcast_nodes, void *addr, int count, size_t datatype_size, _XMP_nodes_t *from_nodes, va_list args)
 

Macro Definition Documentation

◆ MPI_PORTABLE_PLATFORM_H

#define MPI_PORTABLE_PLATFORM_H

Function Documentation

◆ _XMP_bcast_NODES_ENTIRE_NODES()

void _XMP_bcast_NODES_ENTIRE_NODES ( _XMP_nodes_t bcast_nodes,
void *  addr,
int  count,
size_t  datatype_size,
_XMP_nodes_t from_nodes,
  ... 
)
60  {
61  va_list args;
62  va_start(args, from_nodes);
63 
64  _XMP_bcast_NODES_ENTIRE_NODES_V(bcast_nodes, addr, count, datatype_size, from_nodes, args);
65 
66  va_end(args);
67 }
Here is the call graph for this function:

◆ _XMP_bcast_NODES_ENTIRE_NODES_V()

void _XMP_bcast_NODES_ENTIRE_NODES_V ( _XMP_nodes_t bcast_nodes,
void *  addr,
int  count,
size_t  datatype_size,
_XMP_nodes_t from_nodes,
va_list  args 
)
70  {
72 
73  if (!bcast_nodes->is_member) {
74  return;
75  }
76 
77  if (!from_nodes->is_member) {
78  _XMP_fatal("broadcast failed, cannot find the source node");
79  }
80 
81  // calc source nodes number
82  int root = 0;
83  int acc_nodes_size = 1;
84  int from_dim = from_nodes->dim;
85  int from_lower, from_upper, from_stride;
86  _XMP_nodes_inherit_info_t *inherit_info = bcast_nodes->inherit_info;
87 
88  if(inherit_info == NULL){
89  for (int i = 0; i < from_dim; i++) {
90  int size = from_nodes->info[i].size;
91  if(inherit_info != NULL){
92  if(inherit_info[i].shrink == true)
93  continue;
94  size = inherit_info[i].upper - inherit_info[i].lower + 1;
95  if(size == 0) continue;
96  }
97  int rank = from_nodes->info[i].rank;
98 
99  if (va_arg(args, int) == 1) {
100  root += (acc_nodes_size * rank);
101  }
102  else {
103  from_lower = va_arg(args, int) - 1;
104  from_upper = va_arg(args, int) - 1;
105  from_stride = va_arg(args, int);
106 
107  // check <from-ref>
108  if (_XMP_M_COUNT_TRIPLETi(from_lower, from_upper, from_stride) != 1) {
109  _XMP_fatal("multiple source nodes indicated in bcast directive");
110  }
111 
112  root += (acc_nodes_size * (from_lower));
113  }
114 
115  acc_nodes_size *= size;
116  }
117  }
118  else{
119  int inherit_node_dim = bcast_nodes->inherit_nodes->dim;
120 
121  for (int i = 0; i < inherit_node_dim; i++) {
122 
123  if(inherit_info[i].shrink) // skip i
124  continue;
125 
126  int size = inherit_info[i].upper - inherit_info[i].lower + 1;
127 
128  if(size == 0) { // skip arguments
129  va_arg(args, int); // is_astrisk
130  va_arg(args, int); // from_lower
131  va_arg(args, int); // from_upper
132  va_arg(args, int); // from_stride
133  continue;
134  }
135 
136  int is_astrisk = va_arg(args, int);
137  if (is_astrisk == 1){
138  int rank = from_nodes->info[i].rank;
139  root += (acc_nodes_size * rank);
140  }
141  else {
142  from_lower = va_arg(args, int) - 1;
143  from_upper = va_arg(args, int) - 1;
144  va_arg(args, int); // skip from_stride
145 
146  // check <from-ref>
147  if(from_lower != from_upper)
148  _XMP_fatal("multiple source nodes indicated in bcast directive");
149 
150  root += (acc_nodes_size * (from_lower - inherit_info[i].lower));
151  }
152 
153  acc_nodes_size *= size;
154  }
155  }
156 
157 #ifdef _XMP_MPI3
158  if(xmp_is_async()){
160  MPI_Ibcast(addr, count*datatype_size, MPI_BYTE, root,
161  *((MPI_Comm *)bcast_nodes->comm), &async->reqs[async->nreqs]);
162  async->nreqs++;
163  }
164  else
165 #endif
166  MPI_Bcast(addr, count*datatype_size, MPI_BYTE, root,
167  *((MPI_Comm *)bcast_nodes->comm));
168 
169  /* // setup type */
170  /* MPI_Datatype mpi_datatype; */
171  /* MPI_Type_contiguous(datatype_size, MPI_BYTE, &mpi_datatype); */
172  /* MPI_Type_commit(&mpi_datatype); */
173 
174  /* // bcast */
175  /* MPI_Bcast(addr, count, mpi_datatype, root, *((MPI_Comm *)bcast_nodes->comm)); */
176 
177  /* MPI_Type_free(&mpi_datatype); */
178 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ _XMP_bcast_NODES_ENTIRE_OMITTED()

void _XMP_bcast_NODES_ENTIRE_OMITTED ( _XMP_nodes_t bcast_nodes,
void *  addr,
int  count,
size_t  datatype_size 
)
12  {
14 
15  if(!bcast_nodes->is_member) return;
16 
17 #ifdef _XMP_MPI3
18  if(xmp_is_async()){
20  MPI_Ibcast(addr, count*datatype_size, MPI_BYTE, _XMP_N_DEFAULT_ROOT_RANK,
21  *((MPI_Comm *)bcast_nodes->comm), &async->reqs[async->nreqs]);
22  async->nreqs++;
23  }
24  else
25 #endif
26  MPI_Bcast(addr, count*datatype_size, MPI_BYTE, _XMP_N_DEFAULT_ROOT_RANK,
27  *((MPI_Comm *)bcast_nodes->comm));
28 }
Here is the call graph for this function:
_XMP_nodes_info_type::size
int size
Definition: xmp_data_struct.h:32
_XMP_nodes_type::info
_XMP_nodes_info_t info[1]
Definition: xmp_data_struct.h:60
xmp_is_async
_Bool xmp_is_async()
Definition: xmp_async.c:20
_XMP_nodes_type::is_member
int is_member
Definition: xmp_data_struct.h:46
_XMP_nodes_type::inherit_nodes
struct _XMP_nodes_type * inherit_nodes
Definition: xmp_data_struct.h:57
_XMP_nodes_inherit_info_type
Definition: xmp_data_struct.h:20
_XMP_N_DEFAULT_ROOT_RANK
#define _XMP_N_DEFAULT_ROOT_RANK
Definition: xmp_constant.h:25
_XMP_get_current_async
_XMP_async_comm_t * _XMP_get_current_async()
Definition: xmp_async.c:205
_XMP_nodes_type::inherit_info
_XMP_nodes_inherit_info_t * inherit_info
Definition: xmp_data_struct.h:59
_XMP_async_comm::nreqs
int nreqs
Definition: xmp_data_struct.h:460
_XMP_async_comm::reqs
MPI_Request * reqs
Definition: xmp_data_struct.h:464
_XMP_async_comm
Definition: xmp_data_struct.h:458
_XMP_nodes_info_type::rank
int rank
Definition: xmp_data_struct.h:35
_XMP_nodes_inherit_info_type::lower
int lower
Definition: xmp_data_struct.h:23
_XMP_bcast_NODES_ENTIRE_NODES_V
void _XMP_bcast_NODES_ENTIRE_NODES_V(_XMP_nodes_t *bcast_nodes, void *addr, int count, size_t datatype_size, _XMP_nodes_t *from_nodes, va_list args)
Definition: xmp_bcast.c:69
_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
_XMP_nodes_type::dim
int dim
Definition: xmp_data_struct.h:47
_XMP_M_COUNT_TRIPLETi
#define _XMP_M_COUNT_TRIPLETi(l_, u_, s_)
Definition: xmp_gpu_func.hpp:25
_XMP_RETURN_IF_SINGLE
#define _XMP_RETURN_IF_SINGLE
Definition: xmp_internal.h:37
_XMP_nodes_inherit_info_type::upper
int upper
Definition: xmp_data_struct.h:24