Exemplo n.º 1
0
int divide_parallel_processes(int numgroups)
{
#ifdef HAVE_MPI
  end_divide_parallel();
  if (numgroups > count_processors()) abort("numgroups > count_processors");
  int mygroup = (my_rank() * numgroups) / count_processors();
  MPI_Comm_split(MPI_COMM_WORLD, mygroup, my_rank(), &mycomm);
  return mygroup;
#else
  if (numgroups != 1) abort("cannot divide processes in non-MPI mode");
  return 0;
#endif
}
Exemplo n.º 2
0
void set_random_seed(unsigned long seed) {
  init_rand();
  seed = ((unsigned long) broadcast(0, (int) seed)) + my_rank();
#ifdef HAVE_LIBGSL
  gsl_rng_set(rng, seed);
#else
  srand(seed);
#endif
}
Exemplo n.º 3
0
void debug_printf(const char *fmt, ...) {
  va_list ap;
  va_start(ap, fmt);
  if (debf == NULL) {
    char temp[50];
    snprintf(temp, 50, "debug_out_%d", my_rank());
    debf = fopen(temp,"w");
    if (!debf) abort("Unable to open debug output %s\n", temp);
  }
  vfprintf(debf, fmt, ap);
  fflush(debf);
  va_end(ap);
}
Exemplo n.º 4
0
complex<double> Ssend(int from, int to, complex<double> data )
{
#ifdef HAVE_MPI
	if (from == to) return data;
	const int me = my_rank();
	if (from == me) MPI_Ssend( &data, 2, MPI_DOUBLE, to, 1, mycomm);
	MPI_Status stat;
	if (to == me) MPI_Recv( &data, 2, MPI_DOUBLE, from, 1, mycomm, &stat);
#else
	UNUSED(from);
	UNUSED(to);
	UNUSED(data);
#endif
	return data;
}
Exemplo n.º 5
0
void send(int from, int to, float *data, int size) {
#ifdef HAVE_MPI
  if (from == to) return;
  if (size == 0) return;
  const int me = my_rank();
  if (from == me) MPI_Send(data, size, MPI_FLOAT, to, 1, mycomm);
  MPI_Status stat;
  if (to == me) MPI_Recv(data, size, MPI_FLOAT, from, 1, mycomm, &stat);
#else
  UNUSED(from);
  UNUSED(to);
  UNUSED(data);
  UNUSED(size);
#endif
}