1
1

MPI_Win_{attach,detach} : add Java bindings

Этот коммит содержится в:
Gilles Gouaillardet 2015-06-02 19:15:05 +09:00
родитель ade7de549c
Коммит 0836344673
2 изменённых файлов: 68 добавлений и 0 удалений

Просмотреть файл

@ -55,6 +55,29 @@ JNIEXPORT jlong JNICALL Java_mpi_Win_create_dynamicWin(
return (jlong)win;
}
JNIEXPORT void JNICALL Java_mpi_Win_attach(
JNIEnv *env, jobject jthis, jobject jBase,
jint size)
{
void *base = (*env)->GetDirectBufferAddress(env, jBase);
MPI_Win win;
int rc = MPI_Win_attach(win, base, (MPI_Aint)size);
ompi_java_exceptionCheck(env, rc);
}
JNIEXPORT void JNICALL Java_mpi_Win_detach(
JNIEnv *env, jobject jthis, jobject jBase)
{
void *base = (*env)->GetDirectBufferAddress(env, jBase);
MPI_Win win;
int rc = MPI_Win_detach(win, base);
ompi_java_exceptionCheck(env, rc);
}
JNIEXPORT jlong JNICALL Java_mpi_Win_getGroup(
JNIEnv *env, jobject jthis, jlong win)
{

Просмотреть файл

@ -97,6 +97,51 @@ private int getBaseType(Datatype orgType, Datatype targetType)
return baseType;
}
/**
* Java binding of {@code MPI_WIN_ATTACH}.
* @param assertion program assertion
*/
public void attach(Buffer base, int size) throws MPIException
{
MPI.check();
if(!base.isDirect())
throw new IllegalArgumentException("The buffer must be direct.");
int baseSize;
if(base instanceof ByteBuffer)
baseSize = 1;
else if(base instanceof CharBuffer || base instanceof ShortBuffer)
baseSize = 2;
else if(base instanceof IntBuffer || base instanceof FloatBuffer)
baseSize = 4;
else if(base instanceof LongBuffer || base instanceof DoubleBuffer)
baseSize = 8;
else
throw new AssertionError();
int sizeBytes = size * baseSize,
attach(handle, base, size);
}
private native void attach(long win, Buffer base, int size) throws MPIException;
/**
* Java binding of {@code MPI_WIN_DETACH}.
* @param assertion program assertion
*/
public void detach(Buffer base) throws MPIException
{
MPI.check();
if(!base.isDirect())
throw new IllegalArgumentException("The buffer must be direct.");
detach(handle, base);
}
private native void detach(long win, Buffer base) throws MPIException;
/**
* Java binding of the MPI operation {@code MPI_GET_GROUP}.
* @return group of processes which share access to the window