1
1
openmpi/ompi/mpi/java/java/LongInt.java
Jeff Squyres e4e3e411fc Next generation of MPI Java bindings.
Includes all MPI functions supported by Open MPI, including MPI-3
functions (as of about 2 weeks ago).  Many changes compared to the
prior generation of Java bindings; not much is left from the prior
generation, actually.  The changes include (but are not limited to):

 * Add support for more than just a subset of MPI-1 functions
 * Use typical Java case for symbol names
 * Support Java Direct buffers (giving darn-near "native C"
   performance)
 * Support "type struct" better than the prior generation
 * Make more of an effort for the Java bindings to be a thin layer
   over the back-end C bindings
 * ...and more

A proper README with more information about what is supported, how to
use these bindings, etc. will be committed shortly.

This commit was SVN r29263.
2013-09-26 21:44:39 +00:00

109 строки
2.2 KiB
Java

package mpi;
/**
* Java binding of the MPI data type {@code MPI_LONG_INT}.
*/
public final class LongInt extends Struct
{
private final int lSize, iOff, iSize;
/** The struct will be created only in MPI class. */
protected LongInt(int longSize, int intOff, int intSize)
{
lSize = longSize;
iSize = intSize;
int lOff;
switch(lSize)
{
case 4: lOff = addInt(); break;
case 8: lOff = addLong(); break;
default: throw new AssertionError("Unsupported long size: "+ lSize);
}
assert lOff == 0;
setOffset(intOff);
switch(iSize)
{
case 4: iOff = addInt(); break;
case 8: iOff = addLong(); break;
default: throw new AssertionError("Unsupported int size: "+ iSize);
}
assert(intOff == iOff);
}
/**
* Creates a Data object.
* @return new Data object.
*/
@Override protected LongInt.Data newData()
{
return new LongInt.Data();
}
/**
* Class for reading/writing data in a struct stored in a byte buffer.
*/
public final class Data extends Struct.Data
{
/**
* Gets the long value.
* @return long value
*/
public long getValue()
{
switch(lSize)
{
case 8: return getLong(0);
case 4: return getInt(0);
default: throw new AssertionError();
}
}
/**
* Gets the int value.
* @return int value
*/
public int getIndex()
{
switch(iSize)
{
case 4: return getInt(iOff);
case 8: return (int)getLong(iOff);
default: throw new AssertionError();
}
}
/**
* Puts the long value.
* @param v long value
*/
public void putValue(long v)
{
switch(lSize)
{
case 8: putLong(0, v); break;
case 4: putInt(0, (int)v); break;
default: throw new AssertionError();
}
}
/**
* Puts the int value.
* @param v int value
*/
public void putIndex(int v)
{
switch(iSize)
{
case 4: putInt(iOff, v); break;
case 8: putLong(iOff, v); break;
default: throw new AssertionError();
}
}
} // Data
} // LongInt