12 static bool cached =
false;
13 static char hostname[128];
16 gethostname(hostname, 128);
24 static unsigned long int rand_seed = 137;
35 const double twoneg48 = 0.35527136788005009e-14;
36 const unsigned long int m = 25214903917, a = 11, mask = 281474976710655;
37 rand_seed = (m * rand_seed + a) & mask;
38 return (twoneg48 * rand_seed);
54 std::copy(
static_cast<char *
>(buffer),
static_cast<char *
>(buffer) + nbytes,
static_cast<char *
>(
tmp));
55 }
catch (std::exception &e) {
56 printfQuda(
"ERROR: buffer failed (%s:%d in %s(), dim=%d, dir=%d, nbytes=%zu)\n", file, line, func,
dim, dir,
87 std::fill(
static_cast<char *
>(buffer),
static_cast<char *
>(buffer) + nbytes, 0);
88 }
catch (std::exception &e) {
89 printfQuda(
"ERROR: buffer failed (%s:%d in %s(), dim=%d, dir=%d, nbytes=%zu)\n", file, line, func,
dim, dir,
109 int dir,
size_t blksize,
int nblocks,
size_t stride)
118 for (
int i = 0; i < nblocks; i++)
119 std::copy(
static_cast<char *
>(buffer) + i * stride,
static_cast<char *
>(buffer) + i * stride + blksize,
120 static_cast<char *
>(
tmp));
121 }
catch (std::exception &e) {
122 printfQuda(
"ERROR: buffer failed (%s:%d in %s(), dim=%d, dir=%d, blksize=%zu nblocks=%d stride=%zu)\n", file,
123 line, func,
dim, dir, blksize, nblocks, stride);
131 qudaMemcpy2D(
tmp, blksize, buffer, stride, blksize, nblocks, cudaMemcpyDeviceToDevice);
146 int dir,
size_t blksize,
int nblocks,
size_t stride)
154 for (
int i = 0; i < nblocks; i++)
155 std::fill(
static_cast<char *
>(buffer) + i * stride,
static_cast<char *
>(buffer) + i * stride + blksize, 0);
156 }
catch (std::exception &e) {
157 printfQuda(
"ERROR: buffer failed (%s:%d in %s(), dim=%d, dir=%d, blksize=%zu nblocks=%d stride=%zu)\n", file,
158 line, func,
dim, dir, blksize, nblocks, stride);
182 for (
int i = 0; i < ndim; i++) {
183 topo->
dims[i] = dims[i];
187 topo->
ranks =
new int[nodes];
194 int rank = rank_from_coords(x, map_data);
195 topo->
ranks[index(ndim, dims, x)] = rank;
196 for (
int i = 0; i < ndim; i++) { topo->
coords[rank][i] = x[i]; }
197 }
while (advance_coords(ndim, dims, x));
200 for (
int i = 0; i < ndim; i++) { topo->
my_coords[i] = topo->
coords[my_rank][i]; }
203 if (
comm_gpuid() < 0) { rand_seed = 17 * my_rank + 137; }
213 #ifdef QUDA_BACKWARDSCPP
214 backward::StackTrace st;
char * comm_hostname(void)
void comm_abort(int status)
Topology * comm_create_topology(int ndim, const int *dims, QudaCommsMap rank_from_coords, void *map_data, int my_rank)
MsgHandle * comm_declare_receive_relative_(const char *func, const char *file, int line, void *buffer, int dim, int dir, size_t nbytes)
MsgHandle * comm_declare_strided_receive_relative_(const char *func, const char *file, int line, void *buffer, int dim, int dir, size_t blksize, int nblocks, size_t stride)
MsgHandle * comm_declare_send_relative_(const char *func, const char *file, int line, void *buffer, int dim, int dir, size_t nbytes)
MsgHandle * comm_declare_strided_send_relative_(const char *func, const char *file, int line, void *buffer, int dim, int dir, size_t blksize, int nblocks, size_t stride)
MsgHandle * comm_declare_strided_send_displaced(void *buffer, const int displacement[], size_t blksize, int nblocks, size_t stride)
MsgHandle * comm_declare_receive_displaced(void *buffer, const int displacement[], size_t nbytes)
struct Topology_s Topology
MsgHandle * comm_declare_send_displaced(void *buffer, const int displacement[], size_t nbytes)
MsgHandle * comm_declare_strided_receive_displaced(void *buffer, const int displacement[], size_t blksize, int nblocks, size_t stride)
int(* QudaCommsMap)(const int *coords, void *fdata)
void comm_abort_(int status)
bool isHost(const void *buffer)
cudaColorSpinorField * tmp
#define device_malloc(size)
#define safe_malloc(size)
void copy(ColorSpinorField &dst, const ColorSpinorField &src)
#define qudaMemset2D(ptr, pitch, value, width, height)
#define qudaMemcpy2D(dst, dpitch, src, spitch, width, height, kind)
#define qudaMemcpy(dst, src, count, kind)
#define qudaMemset(ptr, value, count)
#define QUDA_MAX_DIM
Maximum number of dimensions supported by QUDA. In practice, no routines make use of more than 5.
int(* coords)[QUDA_MAX_DIM]
int my_coords[QUDA_MAX_DIM]