/**
 * Measurement wrapper for MPI_Cart_coords
 * @note Auto-generated by wrapgen from template: std.w
 * @note C interface
 * @note Introduced with MPI 1.0
 * @ingroup topo
 */
int MPI_Cart_coords(MPI_Comm comm,
                    int      rank,
                    int      maxdims,
                    int*     coords)
{
  int return_val;

  if (IS_EVENT_GEN_ON_FOR(TOPO))
  {
    EVENT_GEN_OFF();
    esd_enter(epk_mpi_regid[EPK__MPI_CART_COORDS]);

    return_val = PMPI_Cart_coords(comm, rank, maxdims, coords);

    esd_exit(epk_mpi_regid[EPK__MPI_CART_COORDS]);
    EVENT_GEN_ON();
  }
  else
  {
    return_val = PMPI_Cart_coords(comm, rank, maxdims, coords);
  }

  return return_val;
}
/**
 * Measurement wrapper for MPI_Cart_create
 * @note Manually adapted wrapper
 * @note C interface
 * @note Introduced with MPI 1.0
 * @ingroup topo
 */
int MPI_Cart_create(MPI_Comm  comm_old,
                    int       ndims,
                    int*      dims,
                    int*      periodv,
                    int       reorder,
                    MPI_Comm* comm_cart)
{
  const int event_gen_active = IS_EVENT_GEN_ON_FOR(TOPO);
  int       return_val;

  if (event_gen_active)
  {
    EVENT_GEN_OFF();
    esd_enter(epk_mpi_regid[EPK__MPI_CART_CREATE]);
  }

  return_val = PMPI_Cart_create(comm_old,
                                ndims,
                                dims,
                                periodv,
                                reorder,
                                comm_cart);

  if (*comm_cart != MPI_COMM_NULL)
  {
    int  cid, my_rank, i;
    int* coordv;

    /* Create new topology object  and set name */
    EPIK_TOPOL * topology = EPIK_Cart_create("MPI Cartesian topology", ndims);

    epk_comm_create(*comm_cart);

    /* get the topid and cid */
    cid = epk_comm_id(*comm_cart);

    /* find the rank of the calling process */
    PMPI_Comm_rank(*comm_cart, &my_rank);

    /* assign the cartesian topology dimension parameters */
    for (i = 0; i < ndims; i++)
    {
      EPIK_Cart_add_dim(topology, dims[i], periodv[i], "");
    }

    /* allocate space for coordv and ucoordv */
    coordv = calloc(topology->num_dims, sizeof(elg_ui4));
    if (coordv == NULL)
    {
      elg_error();
    }

    /* get the coordinates of the calling process in coordv */
    PMPI_Cart_coords(*comm_cart, my_rank, ndims, coordv);

    /* assign the coordinates */
    for (i = 0; i < topology->num_dims; i++)
    {
      topology->coords[i] = (elg_ui4)coordv[i];
    }

    /* create the cartesian topology definition record */
    /* Note: cannot call EPIK_Cart_commit because it does NOT record "cid" */
    topology->topid = esd_def_cart(cid, topology);

    /* create the coordinates definition record */
    /* Could call EPIK_Cart_coords_commit, but does just produce 1 extra
     * useless fun ction call */
    esd_def_coords(topology);
  }

  if (event_gen_active)
  {
    esd_exit(epk_mpi_regid[EPK__MPI_CART_CREATE]);
    EVENT_GEN_ON();
  }

  return return_val;
} /* MPI_Cart_create */
Esempio n. 3
0
int MPI_Cart_coords(MPI_Comm comm, int rank, int maxdims, int* coords) {
  return PMPI_Cart_coords(comm, rank, maxdims, coords);
}