QUDA  v1.1.0
A library for QCD on GPUs
communicator_single.cpp
Go to the documentation of this file.
1 
5 #include <stdlib.h>
6 #include <string.h>
7 
8 #include <communicator_quda.h>
9 
10 Communicator::Communicator(int nDim, const int *commDims, QudaCommsMap rank_from_coords, void *map_data,
11  bool user_set_comm_handle, void *user_comm)
12 {
13  comm_init(nDim, commDims, rank_from_coords, map_data);
14 }
15 
16 Communicator::Communicator(Communicator &other, const int *comm_split)
17 {
18  constexpr int nDim = 4;
19 
20  quda::CommKey comm_dims_split;
21 
22  quda::CommKey comm_key_split;
23  quda::CommKey comm_color_split;
24 
25  for (int d = 0; d < nDim; d++) {
26  assert(other.comm_dim(d) % comm_split[d] == 0);
27  comm_dims_split[d] = other.comm_dim(d) / comm_split[d];
28  comm_key_split[d] = other.comm_coord(d) % comm_dims_split[d];
29  comm_color_split[d] = other.comm_coord(d) / comm_dims_split[d];
30  }
31 
33  comm_init(nDim, comm_dims_split.data(), func, comm_dims_split.data());
34 
35  printf("Creating a split communicator for a single build, which doesn't really make sense.\n");
36 }
37 
39 
40 void Communicator::comm_init(int ndim, const int *dims, QudaCommsMap rank_from_coords, void *map_data)
41 {
42  for (int d = 0; d < ndim; d++) {
43  if (dims[d] > 1) errorQuda("Grid dimension grid[%d] = %d greater than 1", d, dims[d]);
44  }
45  comm_init_common(ndim, dims, rank_from_coords, map_data);
46 }
47 
48 int Communicator::comm_rank(void) { return 0; }
49 
50 int Communicator::comm_size(void) { return 1; }
51 
52 void Communicator::comm_gather_hostname(char *hostname_recv_buf) { strncpy(hostname_recv_buf, comm_hostname(), 128); }
53 
54 void Communicator::comm_gather_gpuid(int *gpuid_recv_buf) { gpuid_recv_buf[0] = comm_gpuid(); }
55 
56 MsgHandle *Communicator::comm_declare_send_rank(void *buffer, int rank, int tag, size_t nbytes) { return nullptr; }
57 
58 MsgHandle *Communicator::comm_declare_recv_rank(void *buffer, int rank, int tag, size_t nbytes) { return nullptr; }
59 
60 MsgHandle *Communicator::comm_declare_send_displaced(void *buffer, const int displacement[], size_t nbytes)
61 {
62  return nullptr;
63 }
64 
65 MsgHandle *Communicator::comm_declare_receive_displaced(void *buffer, const int displacement[], size_t nbytes)
66 {
67  return nullptr;
68 }
69 
70 MsgHandle *Communicator::comm_declare_strided_send_displaced(void *buffer, const int displacement[], size_t blksize,
71  int nblocks, size_t stride)
72 {
73  return nullptr;
74 }
75 
76 MsgHandle *Communicator::comm_declare_strided_receive_displaced(void *buffer, const int displacement[], size_t blksize,
77  int nblocks, size_t stride)
78 {
79  return nullptr;
80 }
81 
83 
85 
87 
88 int Communicator::comm_query(MsgHandle *mh) { return 1; }
89 
90 void Communicator::comm_allreduce(double *data) {}
91 
92 void Communicator::comm_allreduce_max(double *data) {}
93 
94 void Communicator::comm_allreduce_min(double *data) {}
95 
96 void Communicator::comm_allreduce_array(double *data, size_t size) {}
97 
98 void Communicator::comm_allreduce_max_array(double *data, size_t size) {}
99 
100 void Communicator::comm_allreduce_int(int *data) {}
101 
102 void Communicator::comm_allreduce_xor(uint64_t *data) {}
103 
104 void Communicator::comm_broadcast(void *data, size_t nbytes) {}
105 
106 void Communicator::comm_barrier(void) {}
107 
108 void Communicator::comm_abort_(int status) { exit(status); }
109 
110 int Communicator::comm_rank_global() { return 0; }
char * comm_hostname(void)
Definition: comm_common.cpp:10
int(* QudaCommsMap)(const int *coords, void *fdata)
Definition: comm_quda.h:12
int lex_rank_from_coords_dim_t(const int *coords, void *fdata)
int comm_dim(int dim)
void comm_allreduce_max(double *data)
void comm_wait(MsgHandle *mh)
void comm_allreduce(double *data)
void comm_broadcast(void *data, size_t nbytes)
int comm_query(MsgHandle *mh)
void comm_gather_gpuid(int *gpuid_recv_buf)
void comm_init(int ndim, const int *dims, QudaCommsMap rank_from_coords, void *map_data)
void comm_allreduce_min(double *data)
int comm_coord(int dim)
static int comm_rank_global()
MsgHandle * comm_declare_strided_send_displaced(void *buffer, const int displacement[], size_t blksize, int nblocks, size_t stride)
void comm_barrier(void)
static void comm_abort_(int status)
MsgHandle * comm_declare_send_rank(void *buffer, int rank, int tag, size_t nbytes)
MsgHandle * comm_declare_strided_receive_displaced(void *buffer, const int displacement[], size_t blksize, int nblocks, size_t stride)
void comm_allreduce_max_array(double *data, size_t size)
MsgHandle * comm_declare_send_displaced(void *buffer, const int displacement[], size_t nbytes)
void comm_gather_hostname(char *hostname_recv_buf)
void comm_allreduce_xor(uint64_t *data)
void comm_allreduce_int(int *data)
MsgHandle * comm_declare_receive_displaced(void *buffer, const int displacement[], size_t nbytes)
void comm_free(MsgHandle *&mh)
MsgHandle * comm_declare_recv_rank(void *buffer, int rank, int tag, size_t nbytes)
void comm_finalize(void)
static int comm_gpuid()
void comm_init_common(int ndim, const int *dims, QudaCommsMap rank_from_coords, void *map_data)
void comm_start(MsgHandle *mh)
void comm_allreduce_array(double *data, size_t size)
constexpr int * data()
Definition: comm_key.h:18
#define errorQuda(...)
Definition: util_quda.h:120