/* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ /* * File : Cartcomm.java * Author : Xinying Li * Created : Thu Apr 9 12:22:15 1998 * Revision : $Revision: 1.7 $ * Updated : $Date: 2001/10/22 21:07:55 $ * Copyright: Northeast Parallel Architectures Center * at Syracuse University 1998 */ package mpi; public class Cartcomm extends Intracomm { protected Cartcomm(long handle) throws MPIException { super(handle) ; } public Object clone() { try { return new Cartcomm(super.dup()) ; } catch (MPIException e) { throw new RuntimeException(e.getMessage()) ; } } /** * Returns Cartesian topology information. *

* * *
returns: object containing dimensions, * periods and local coordinates
*

* Java binding of the MPI operations MPI_CARTDIM_GET and * MPI_CART_GET. *

* The number of dimensions can be obtained from the size of (eg) * dims field of the returned object. */ public native CartParms Get() throws MPIException ; /** * Translate logical process coordinates to process rank. *

* * * *
coords Cartesian coordinates of a * process
returns: rank of the specified process
*

* Java binding of the MPI operation MPI_CART_RANK. */ public native int Rank(int[] coords) throws MPIException ; /** * Translate process rank to logical process coordinates. *

* * * *
rank rank of a process
returns: Cartesian coordinates of the * specified process
*

* Java binding of the MPI operation MPI_CART_COORDS. */ public native int [] Coords(int rank) throws MPIException ; /** * Compute source and destination ranks for ``shift'' communication. *

* * * * *
direction coordinate dimension of shift
disp displacement
returns: object containing ranks of source * and destination processes
*

* Java binding of the MPI operation MPI_CART_SHIFT. */ public native ShiftParms Shift(int direction, int disp) throws MPIException ; /** * Partition Cartesian communicator into subgroups of lower dimension. *

* * * *
remain_dims by dimension, true if * dimension is to be kept, * false otherwise
returns: communicator containing subgrid * including this process
*

* Java binding of the MPI operation MPI_CART_SUB. */ public Cartcomm Sub(boolean [] remain_dims) throws MPIException { return new Cartcomm(sub(remain_dims)) ; } private native long sub(boolean [] remain_dims); /** * Compute an optimal placement. *

* * * * *
dims the number of processes in each * dimension
periods true if grid is periodic, * false if not, in each * dimension
returns: reordered rank of calling * process
*

* Java binding of the MPI operation MPI_CART_MAP. *

* The number of dimensions is taken to be size of the dims argument. */ public native int Map(int [] dims, boolean [] periods) throws MPIException ; /** * Select a balanced distribution of processes per coordinate direction. *

* * * * *
nnodes number of nodes in a grid
ndims number of dimensions of grid
dims array specifying the number of nodes * in each dimension
*

* Java binding of the MPI operation MPI_DIMS_CREATE. *

* Size dims should be ndims. Note that * dims is an inout parameter. */ static public native void Dims_create(int nnodes, int[] dims) throws MPIException ; }