-/* reorder is ignored, don't know what would be the consequences of a dumb
- * reordering but neither do I see the point of reordering*/
-int smpi_mpi_cart_create(MPI_Comm comm_old, int ndims, int dims[], int periods[], int reorder, MPI_Comm *comm_cart) {
- int retval = MPI_SUCCESS;
- int i;
- MPI_Topology newCart;
- MPI_Group newGroup, oldGroup;
- int rank, nranks, newSize;
-
- rank = smpi_comm_rank(comm_old);
-
- newSize = 1;
- if(ndims != 0) {
- for (i = 0 ; i < ndims ; i++) {
- newSize *= dims[i];
- }
- if(rank >= newSize) {
- *comm_cart = MPI_COMM_NULL;
- return retval;
- }
- newCart = smpi_cart_topo_create(ndims);
- oldGroup = smpi_comm_group(comm_old);
- newGroup = smpi_group_new(newSize);
- for (i = 0 ; i < newSize ; i++) {
- smpi_group_set_mapping(newGroup, smpi_group_index(oldGroup, i), i);
- }
-
- newCart->topo.cart->nnodes = newSize;
-
- // FIXME : code duplication... See smpi_mpi_cart_coords
- nranks = newSize;
- for (i=0; i<ndims; i++) {
- newCart->topo.cart->dims[i] = dims[i];
- newCart->topo.cart->periodic[i] = periods[i];
- nranks = nranks / dims[i];
- /* FIXME: nranks could be zero (?) */
- newCart->topo.cart->position[i] = rank / nranks;
- rank = rank % nranks;
- }
-
- *comm_cart = smpi_comm_new(newGroup, newCart);
- } else {
- if (rank == 0) {
- newCart = smpi_cart_topo_create(ndims);
- *comm_cart = smpi_comm_new(smpi_group_copy(smpi_comm_group(MPI_COMM_SELF)), newCart);
- } else {
- *comm_cart = MPI_COMM_NULL;
- }
- }
- return retval;
-}
+/* reorder is ignored, don't know what would be the consequences of a dumb reordering but neither do I see the point of
+ * reordering*/
+Topo_Cart::Topo_Cart(MPI_Comm comm_old, int ndims, int dims[], int periods[], int reorder, MPI_Comm *comm_cart) : Topo_Cart(ndims) {
+ MPI_Group newGroup;
+ MPI_Group oldGroup;
+ int nranks;