示例#1
0
int ZMPI_Reduce_scatter_block_intsum_proclists_isendirecv(const int *sendbuf, int nsendprocs, int *sendprocs, int *recvbuf, int recvcount, int nrecvprocs, int *recvprocs, MPI_Comm comm) /* zmpi_func ZMPI_Reduce_scatter_block_intsum_proclists_isendirecv */
{
  int i, j;

  int *recvbuf_full;
  MPI_Request *reqs;


  recvbuf_full = z_alloc(nrecvprocs * recvcount, sizeof(int));

  reqs = z_alloc(nsendprocs + nrecvprocs, sizeof(MPI_Request));

  for (j = 0; j < nrecvprocs; ++j) MPI_Irecv(&recvbuf_full[j * recvcount], recvcount, MPI_INT, recvprocs[j], 0, comm, &reqs[j]);

  for (j = 0; j < nsendprocs; ++j) MPI_Isend((void *) &sendbuf[sendprocs[j] * recvcount], recvcount, MPI_INT, sendprocs[j], 0, comm, &reqs[nrecvprocs + j]);

  MPI_Waitall(nsendprocs + nrecvprocs, reqs, MPI_STATUSES_IGNORE);

  for (i = 0; i < recvcount; ++i) recvbuf[i] = DEFAULT_INT;

  for (j = 0; j < nrecvprocs; ++j)
    for (i = 0; i < recvcount; ++i) recvbuf[i] += recvbuf_full[j * recvcount + i];

  z_free(reqs);

  z_free(recvbuf_full);

  return MPI_SUCCESS;
}
示例#2
0
int ZMPI_Alltoallv_proclists(void* sendbuf, int *sendcounts, int *sdispls, MPI_Datatype sendtype, int nsendprocs, int *sendprocs, void* recvbuf, int *recvcounts, int *rdispls, MPI_Datatype recvtype, int nrecvprocs, int *recvprocs, MPI_Comm comm) /* zmpi_func ZMPI_Alltoallv_proclists */
{
  int i, j;

  const int tag = 0;

  int nreqs;
  MPI_Request *reqs;
  MPI_Status *stats;

  MPI_Aint sendtype_lb, sendtype_extent, recvtype_lb, recvtype_extent;


  reqs = z_alloc(nrecvprocs + nsendprocs, sizeof(MPI_Request));
  stats = z_alloc(nrecvprocs + nsendprocs, sizeof(MPI_Status));

  MPI_Type_get_extent(sendtype, &sendtype_lb, &sendtype_extent);
  MPI_Type_get_extent(recvtype, &recvtype_lb, &recvtype_extent);

  nreqs = 0;

  for (i = 0; i < nrecvprocs; ++i)
  {
    j = recvprocs[i];
    if (recvcounts[j] > 0)
    {
      MPI_Irecv(((char *) recvbuf) + (rdispls[j] * recvtype_extent), recvcounts[j], recvtype, j, tag, comm, &reqs[nreqs]);
      ++nreqs;
    }
  }

  for (i = 0; i < nsendprocs; ++i)
  {
    j = sendprocs[i];
    if (sendcounts[j] > 0)
    {
      MPI_Isend(((char *) sendbuf) + (sdispls[j] * sendtype_extent), sendcounts[j], sendtype, j, tag, comm, &reqs[nreqs]);
      ++nreqs;
    }
  }

  MPI_Waitall(nreqs, reqs, stats);

  z_free(reqs);
  z_free(stats);

  return MPI_SUCCESS;
}
示例#3
0
int ZMPI_Alltoall_int_proclists_alltoallv(int *sendbuf, int nsprocs, int *sprocs, int *recvbuf, int nrprocs, int *rprocs, MPI_Comm comm) /* zmpi_func ZMPI_Alltoall_int_proclists_alltoallv */
{
  int i, size;

  int *scounts2, *sdispls2, *rcounts2, *rdispls2;


  MPI_Comm_size(comm, &size);

  scounts2 = z_alloc(4 * size, sizeof(int));
  sdispls2 = scounts2 + 1 * size;
  rcounts2 = scounts2 + 2 * size;
  rdispls2 = scounts2 + 3 * size;

  for (i = 0; i < size; ++i)
  {
    scounts2[i] = rcounts2[i] = DEFAULT_INT;
    sdispls2[i] = rdispls2[i] = i;
    recvbuf[i] = 0;
  }

  for (i = 0; i < nsprocs; ++i) scounts2[sprocs[i]] = 1;
  for (i = 0; i < nrprocs; ++i) rcounts2[rprocs[i]] = 1;

  MPI_Alltoallv(sendbuf, scounts2, sdispls2, MPI_INT, recvbuf, rcounts2, rdispls2, MPI_INT, comm);

  z_free(scounts2);

  return MPI_SUCCESS;
}
示例#4
0
int ZMPI_Reduce_scatter_block_intsum_proclists_alltoallv(const int *sendbuf, int nsendprocs, int *sendprocs, int *recvbuf, int recvcount, int nrecvprocs, int *recvprocs, MPI_Comm comm) /* zmpi_func ZMPI_Reduce_scatter_block_intsum_proclists_alltoallv */
{
  int i, j, size, rank;

  int *recvbuf_full;
  int *scounts, *sdispls, *rcounts, *rdispls;


  MPI_Comm_size(comm, &size);
  MPI_Comm_rank(comm, &rank);

  recvbuf_full = z_alloc(nrecvprocs * recvcount, sizeof(int));

  scounts = z_alloc(4 * size, sizeof(int));
  sdispls = scounts + 1 * size;
  rcounts = scounts + 2 * size;
  rdispls = scounts + 3 * size;

  memset(scounts, 0, 4 * size * sizeof(int));

  for (j = 0; j < nrecvprocs; ++j)
  {
    rcounts[recvprocs[j]] = recvcount;
    rdispls[recvprocs[j]] = j * recvcount;
  }

  for (j = 0; j < nsendprocs; ++j)
  {
    scounts[sendprocs[j]] = recvcount;
    sdispls[sendprocs[j]] = sendprocs[j] * recvcount;
  }

  MPI_Alltoallv((void *) sendbuf, scounts, sdispls, MPI_INT, recvbuf_full, rcounts, rdispls, MPI_INT, comm);

  for (i = 0; i < recvcount; ++i) recvbuf[i] = DEFAULT_INT;

  for (j = 0; j < nrecvprocs; ++j)
    for (i = 0; i < recvcount; ++i) recvbuf[i] += recvbuf_full[j * recvcount + i];

  z_free(scounts);

  z_free(recvbuf_full);

  return MPI_SUCCESS;
}
示例#5
0
void z_digest_hash_open(void **hdl) /* z_proto, z_func z_digest_hash_open */
{
#ifdef HAVE_GCRYPT_H
  gcry_md_hd_t *gcry_hdl;
  
  gcry_hdl = z_alloc(1, sizeof(gcry_md_hd_t));

  gcry_md_open(gcry_hdl, z_digest_hash_gcrypt_algo, 0);

  *hdl = gcry_hdl;
#endif
}
示例#6
0
static int create_proclists_from_mpi_comm_topology(MPI_Comm comm, int rank, int *nsend_procs, int **send_procs, int *nrecv_procs, int **recv_procs)
{
  int status;

  int n, i;


  MPI_Topo_test(comm, &status);

  switch (status)
  {
    case MPI_CART:
      MPI_Cartdim_get(comm, &n);
      *nsend_procs = *nrecv_procs = 2 * n;
      *send_procs = *recv_procs = z_alloc(2 * n, sizeof(int));
      for (i = 0; i < n; ++i) MPI_Cart_shift(comm, i, -1, &(*send_procs)[2 * i + 1], &(*send_procs)[2 * i + 0]);
      break;
    case MPI_GRAPH:
      MPI_Graph_neighbors_count(comm, rank, &n);
      *nsend_procs = *nrecv_procs = n;
      *send_procs = *recv_procs = z_alloc(n, sizeof(int));
      MPI_Graph_neighbors(comm, rank, n, *send_procs);
      break;
#if MPI_VERSION >= 2 && MPI_SUBVERSION >= 2
    case MPI_DIST_GRAPH:
      MPI_Dist_graph_neighbors_count(comm, nrecv_procs, nsend_procs, &n);
      *send_procs = z_alloc(*nsend_procs + *nrecv_procs, sizeof(int));
      *recv_procs = *send_procs + *nsend_procs;
      MPI_Dist_graph_neighbors(comm, *nrecv_procs, *recv_procs, MPI_UNWEIGHTED, *nsend_procs, *send_procs, MPI_UNWEIGHTED);
      break;
#endif
    default:
      return 0;
  }

  return 1;
}
示例#7
0
int ZMPI_Reduce_scatter_block(const void *sendbuf, void *recvbuf, int recvcount, MPI_Datatype datatype, MPI_Op op, MPI_Comm comm) /* zmpi_func ZMPI_Reduce_scatter_block */
{
#if MPI_VERSION >= 2 && MPI_SUBVERSION >= 2

  return MPI_Reduce_scatter_block((void *) sendbuf, recvbuf, recvcount, datatype,op, comm);

#else

  int comm_size, *recvcounts, i, exit_code;


  MPI_Comm_size(comm, &comm_size);

  recvcounts = z_alloc(comm_size, sizeof(int));

  for (i = 0; i < comm_size; ++i) recvcounts[i] = recvcount;

  exit_code = MPI_Reduce_scatter((void *) sendbuf, recvbuf, recvcounts, datatype, op, comm);

  z_free(recvcounts);

  return exit_code;
#endif
}