Package mpi

Class Datatype

java.lang.Object
mpi.Datatype
All Implemented Interfaces:
Cloneable, Freeable

public final class Datatype extends Object implements Freeable, Cloneable
The Datatype class represents MPI_Datatype handles.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected int
     
    protected int
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected long
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
    protected static final int
     
  • Constructor Summary

    Constructors
    Modifier
    Constructor
    Description
    protected
     
  • Method Summary

    Modifier and Type
    Method
    Description
    Java binding of MPI_TYPE_DUP.
    void
    Commits a derived datatype.
    static Datatype
    createContiguous(int count, Datatype oldType)
    Construct new datatype representing replication of old datatype into contiguous locations.
    static Datatype
    createHIndexed(int[] blockLengths, int[] displacements, Datatype oldType)
    Identical to createIndexed except that the displacements are expressed directly in terms of the buffer index, rather than the units of the old type.
    static Datatype
    createHVector(int count, int blockLength, int stride, Datatype oldType)
    Identical to createVector except that the stride is expressed directly in terms of the buffer index, rather than the units of the old type.
    static Datatype
    createIndexed(int[] blockLengths, int[] displacements, Datatype oldType)
    Construct new datatype representing replication of old datatype into a sequence of blocks where each block can contain a different number of copies and have a different displacement.
    static int
    Create a new attribute key.
    static Datatype
    createResized(Datatype oldType, int lb, int extent)
    Create a datatype with a new lower bound and extent from an existing datatype.
    static Datatype
    createStruct(int[] blockLengths, int[] displacements, Datatype[] types)
    The most general type constructor.
    static Datatype
    createVector(int count, int blockLength, int stride, Datatype oldType)
    Construct new datatype representing replication of old datatype into locations that consist of equally spaced blocks.
    void
    deleteAttr(int keyval)
    Deletes an attribute value associated with a key.
    dup()
    Java binding of MPI_TYPE_DUP.
    void
    Frees the datatype.
    static void
    freeKeyval(int keyval)
    Frees an attribute key.
    getAttr(int keyval)
    Retrieves attribute value by key.
    int
    Returns the extent of a datatype.
    int
    Returns the lower bound of a datatype.
    Return the print name from the datatype.
    protected int
    getOffset(Object buffer)
    Gets the offset of a buffer in bytes.
    int
    Returns the total size of a datatype - the number of buffer elements it represents.
    int
    Returns the true extent of a datatype.
    int
    Returns the true lower bound of a datatype.
    boolean
    Returns true if this datatype is MPI_DATATYPE_NULL.
    void
    setAttr(int keyval, Object value)
    Stores attribute value associated with a key.
    protected void
    setBasic(int type)
     
    protected void
    setBasic(int type, Datatype oldType)
     
    void
    Sets the print name for the datatype.

    Methods inherited from class java.lang.Object

    equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Datatype

      protected Datatype()
  • Method Details

    • setBasic

      protected void setBasic(int type)
    • setBasic

      protected void setBasic(int type, Datatype oldType)
    • getLb

      public int getLb() throws MPIException
      Returns the lower bound of a datatype.

      Java binding of the MPI operation MPI_TYPE_GET_EXTENT.

      Returns:
      lower bound of datatype
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • getExtent

      public int getExtent() throws MPIException
      Returns the extent of a datatype.

      Java binding of the MPI operation MPI_TYPE_GET_EXTENT.

      Returns:
      datatype extent
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • getTrueLb

      public int getTrueLb() throws MPIException
      Returns the true lower bound of a datatype.

      Java binding of the MPI operation MPI_TYPE_GET_TRUE_EXTENT.

      Returns:
      lower bound of datatype
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • getTrueExtent

      public int getTrueExtent() throws MPIException
      Returns the true extent of a datatype.

      Java binding of the MPI operation MPI_TYPE_GET_TRUE_EXTENT.

      Returns:
      datatype true extent
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • getSize

      public int getSize() throws MPIException
      Returns the total size of a datatype - the number of buffer elements it represents.

      Java binding of the MPI operation MPI_TYPE_SIZE.

      Returns:
      datatype size
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • commit

      public void commit() throws MPIException
      Commits a derived datatype. Java binding of the MPI operation MPI_TYPE_COMMIT.
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • free

      public void free() throws MPIException
      Frees the datatype.

      Java binding of the MPI operation MPI_TYPE_FREE.

      Specified by:
      free in interface Freeable
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • isNull

      public boolean isNull()
      Returns true if this datatype is MPI_DATATYPE_NULL.
      Returns:
      true if this datatype is MPI_DATATYPE_NULL
    • clone

      public Datatype clone()
      Java binding of MPI_TYPE_DUP.

      It is recommended to use dup() instead of clone() because the last can't throw an MPIException.

      Overrides:
      clone in class Object
      Returns:
      new datatype
    • dup

      public Datatype dup() throws MPIException
      Java binding of MPI_TYPE_DUP.
      Returns:
      new datatype
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • createContiguous

      public static Datatype createContiguous(int count, Datatype oldType) throws MPIException
      Construct new datatype representing replication of old datatype into contiguous locations.

      Java binding of the MPI operation MPI_TYPE_CONTIGUOUS.

      The base type of the new datatype is the same as the base type of oldType.

      Parameters:
      count - replication count
      oldType - old datatype
      Returns:
      new datatype
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • createVector

      public static Datatype createVector(int count, int blockLength, int stride, Datatype oldType) throws MPIException
      Construct new datatype representing replication of old datatype into locations that consist of equally spaced blocks.

      Java binding of the MPI operation MPI_TYPE_VECTOR.

      The base type of the new datatype is the same as the base type of oldType.

      Parameters:
      count - number of blocks
      blockLength - number of elements in each block
      stride - number of elements between start of each block
      oldType - old datatype
      Returns:
      new datatype
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • createHVector

      public static Datatype createHVector(int count, int blockLength, int stride, Datatype oldType) throws MPIException
      Identical to createVector except that the stride is expressed directly in terms of the buffer index, rather than the units of the old type.

      Java binding of the MPI operation MPI_TYPE_CREATE_HVECTOR.

      Parameters:
      count - number of blocks
      blockLength - number of elements in each
      stride - number of bytes between start of each block
      oldType - old datatype
      Returns:
      new datatype
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • createIndexed

      public static Datatype createIndexed(int[] blockLengths, int[] displacements, Datatype oldType) throws MPIException
      Construct new datatype representing replication of old datatype into a sequence of blocks where each block can contain a different number of copies and have a different displacement.

      Java binding of the MPI operation MPI_TYPE_INDEXED.

      The number of blocks is taken to be size of the blockLengths argument. The second argument, displacements, should be the same size. The base type of the new datatype is the same as the base type of oldType.

      Parameters:
      blockLengths - number of elements per block
      displacements - displacement of each block in units of old type
      oldType - old datatype
      Returns:
      new datatype
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • createHIndexed

      public static Datatype createHIndexed(int[] blockLengths, int[] displacements, Datatype oldType) throws MPIException
      Identical to createIndexed except that the displacements are expressed directly in terms of the buffer index, rather than the units of the old type.

      Java binding of the MPI operation MPI_TYPE_CREATE_HINDEXED.

      Parameters:
      blockLengths - number of elements per block
      displacements - byte displacement in buffer for each block
      oldType - old datatype
      Returns:
      new datatype
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • createStruct

      public static Datatype createStruct(int[] blockLengths, int[] displacements, Datatype[] types) throws MPIException
      The most general type constructor.

      Java binding of the MPI operation MPI_TYPE_CREATE_STRUCT.

      The number of blocks is taken to be size of the blockLengths argument. The second and third arguments, displacements, and types, should be the same size.

      Parameters:
      blockLengths - number of elements in each block
      displacements - byte displacement of each block
      types - type of elements in each block
      Returns:
      new datatype
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • createResized

      public static Datatype createResized(Datatype oldType, int lb, int extent) throws MPIException
      Create a datatype with a new lower bound and extent from an existing datatype.

      Java binding of the MPI operation MPI_TYPE_CREATE_RESIZED.

      Parameters:
      oldType - input datatype
      lb - new lower bound of datatype (address integer)
      extent - new extent of datatype (address integer)
      Returns:
      new datatype
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • setName

      public void setName(String name) throws MPIException
      Sets the print name for the datatype.
      Parameters:
      name - name for the datatype
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • getName

      public String getName() throws MPIException
      Return the print name from the datatype.
      Returns:
      name of the datatype
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • createKeyval

      public static int createKeyval() throws MPIException
      Create a new attribute key.

      Java binding of the MPI operation MPI_TYPE_CREATE_KEYVAL.

      Returns:
      attribute key for future access
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • freeKeyval

      public static void freeKeyval(int keyval) throws MPIException
      Frees an attribute key.

      Java binding of the MPI operation MPI_TYPE_FREE_KEYVAL.

      Parameters:
      keyval - attribute key
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • setAttr

      public void setAttr(int keyval, Object value) throws MPIException
      Stores attribute value associated with a key.

      Java binding of the MPI operation MPI_TYPE_SET_ATTR.

      Parameters:
      keyval - attribute key
      value - attribute value
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • getAttr

      public Object getAttr(int keyval) throws MPIException
      Retrieves attribute value by key.

      Java binding of the MPI operation MPI_TYPE_GET_ATTR.

      Parameters:
      keyval - attribute key
      Returns:
      attribute value or null if no attribute is associated with the key.
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • deleteAttr

      public void deleteAttr(int keyval) throws MPIException
      Deletes an attribute value associated with a key.

      Java binding of the MPI operation MPI_TYPE_DELETE_ATTR.

      Parameters:
      keyval - attribute key
      Throws:
      MPIException - Signals that an MPI exception of some sort has occurred.
    • getOffset

      protected int getOffset(Object buffer)
      Gets the offset of a buffer in bytes.
      Parameters:
      buffer - buffer
      Returns:
      offset in bytes