More one sided java bindings.
Bindings for the MPI_WIN_FLUSH_LOCAL, MPI_WIN_FLUSH_LOCAL_ALL, MPI_WIN_ALLOCATE, MPI_WIN_ALLOCATE_SHARED, and MPI_COMM_SPLIT_TYPE. Also added several necessary constants. Signed-off-by: Nathaniel Graham ngraham@lanl.gov
Этот коммит содержится в:
родитель
e9d6c7a910
Коммит
7f6d141bd6
@ -9,6 +9,8 @@
|
|||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
|
||||||
|
* reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -66,6 +68,15 @@ JNIEXPORT jlong JNICALL Java_mpi_Intracomm_split(
|
|||||||
return (jlong)newcomm;
|
return (jlong)newcomm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_mpi_Intracomm_splitType(
|
||||||
|
JNIEnv *env, jobject jthis, jlong comm, jint splitType, jint key, jlong info)
|
||||||
|
{
|
||||||
|
MPI_Comm newcomm;
|
||||||
|
int rc = MPI_Comm_split_type((MPI_Comm)comm, splitType, key, (MPI_Info)info, &newcomm);
|
||||||
|
ompi_java_exceptionCheck(env, rc);
|
||||||
|
return (jlong)newcomm;
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL Java_mpi_Intracomm_create(
|
JNIEXPORT jlong JNICALL Java_mpi_Intracomm_create(
|
||||||
JNIEnv *env, jobject jthis, jlong comm, jlong group)
|
JNIEnv *env, jobject jthis, jlong comm, jlong group)
|
||||||
{
|
{
|
||||||
|
@ -45,6 +45,32 @@ JNIEXPORT jlong JNICALL Java_mpi_Win_createWin(
|
|||||||
return (jlong)win;
|
return (jlong)win;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_mpi_Win_allocateWin(JNIEnv *env, jobject jthis,
|
||||||
|
jint size, jint dispUnit, jlong info, jlong comm, jobject jBase)
|
||||||
|
{
|
||||||
|
void *basePtr = (*env)->GetDirectBufferAddress(env, jBase);
|
||||||
|
MPI_Win win;
|
||||||
|
|
||||||
|
int rc = MPI_Win_allocate((MPI_Aint)size, dispUnit,
|
||||||
|
(MPI_Info)info, (MPI_Comm)comm, basePtr, &win);
|
||||||
|
|
||||||
|
ompi_java_exceptionCheck(env, rc);
|
||||||
|
return (jlong)win;
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT jlong JNICALL Java_mpi_Win_allocateSharedWin(JNIEnv *env, jobject jthis,
|
||||||
|
jint size, jint dispUnit, jlong info, jlong comm, jobject jBase)
|
||||||
|
{
|
||||||
|
void *basePtr = (*env)->GetDirectBufferAddress(env, jBase);
|
||||||
|
MPI_Win win;
|
||||||
|
|
||||||
|
int rc = MPI_Win_allocate_shared((MPI_Aint)size, dispUnit,
|
||||||
|
(MPI_Info)info, (MPI_Comm)comm, basePtr, &win);
|
||||||
|
|
||||||
|
ompi_java_exceptionCheck(env, rc);
|
||||||
|
return (jlong)win;
|
||||||
|
}
|
||||||
|
|
||||||
JNIEXPORT jlong JNICALL Java_mpi_Win_createDynamicWin(
|
JNIEXPORT jlong JNICALL Java_mpi_Win_createDynamicWin(
|
||||||
JNIEnv *env, jobject jthis,
|
JNIEnv *env, jobject jthis,
|
||||||
jlong info, jlong comm)
|
jlong info, jlong comm)
|
||||||
@ -434,3 +460,15 @@ JNIEXPORT void JNICALL Java_mpi_Win_fetchAndOp(JNIEnv *env, jobject jthis, jlong
|
|||||||
int rc = MPI_Fetch_and_op(orgPtr, resultPtr, dataType, targetRank, targetDisp, op, (MPI_Win)win);
|
int rc = MPI_Fetch_and_op(orgPtr, resultPtr, dataType, targetRank, targetDisp, op, (MPI_Win)win);
|
||||||
ompi_java_exceptionCheck(env, rc);
|
ompi_java_exceptionCheck(env, rc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_mpi_Win_flushLocal(JNIEnv *env, jobject jthis, jlong win, jint targetRank)
|
||||||
|
{
|
||||||
|
int rc = MPI_Win_flush_local(targetRank, (MPI_Win)win);
|
||||||
|
ompi_java_exceptionCheck(env, rc);
|
||||||
|
}
|
||||||
|
|
||||||
|
JNIEXPORT void JNICALL Java_mpi_Win_flushLocalAll(JNIEnv *env, jobject jthis, jlong win)
|
||||||
|
{
|
||||||
|
int rc = MPI_Win_flush_local_all((MPI_Win)win);
|
||||||
|
ompi_java_exceptionCheck(env, rc);
|
||||||
|
}
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
* Copyright (c) 2015 Research Organization for Information Science
|
* Copyright (c) 2015 Research Organization for Information Science
|
||||||
* and Technology (RIST). All rights reserved.
|
* and Technology (RIST). All rights reserved.
|
||||||
|
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
|
||||||
|
* reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -65,6 +67,7 @@ import static mpi.MPI.assertDirectBuffer;
|
|||||||
*/
|
*/
|
||||||
public class Comm implements Freeable
|
public class Comm implements Freeable
|
||||||
{
|
{
|
||||||
|
public final static int TYPE_SHARED = 0;
|
||||||
protected final static int SELF = 1;
|
protected final static int SELF = 1;
|
||||||
protected final static int WORLD = 2;
|
protected final static int WORLD = 2;
|
||||||
protected long handle;
|
protected long handle;
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
* University of Stuttgart. All rights reserved.
|
* University of Stuttgart. All rights reserved.
|
||||||
* Copyright (c) 2004-2005 The Regents of the University of California.
|
* Copyright (c) 2004-2005 The Regents of the University of California.
|
||||||
* All rights reserved.
|
* All rights reserved.
|
||||||
|
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
|
||||||
|
* reserved.
|
||||||
* $COPYRIGHT$
|
* $COPYRIGHT$
|
||||||
*
|
*
|
||||||
* Additional copyrights may follow
|
* Additional copyrights may follow
|
||||||
@ -139,6 +141,24 @@ public final Intracomm split(int colour, int key) throws MPIException
|
|||||||
|
|
||||||
private native long split(long comm, int colour, int key) throws MPIException;
|
private native long split(long comm, int colour, int key) throws MPIException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Partition the group associated with this communicator and create
|
||||||
|
* a new communicator within each subgroup.
|
||||||
|
* <p>Java binding of the MPI operation {@code MPI_COMM_SPLIT_TYPE}.
|
||||||
|
* @param splitType type of processes to be grouped together
|
||||||
|
* @param key control of rank assignment
|
||||||
|
* @param info info argument
|
||||||
|
* @return new communicator
|
||||||
|
* @throws MPIException
|
||||||
|
*/
|
||||||
|
public final Intracomm splitType(int splitType, int key, Info info) throws MPIException
|
||||||
|
{
|
||||||
|
MPI.check();
|
||||||
|
return new Intracomm(splitType(handle, splitType, key, info.handle));
|
||||||
|
}
|
||||||
|
|
||||||
|
private native long splitType(long comm, int colour, int key, long info) throws MPIException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new communicator.
|
* Create a new communicator.
|
||||||
* <p>Java binding of the MPI operation {@code MPI_COMM_CREATE}.
|
* <p>Java binding of the MPI operation {@code MPI_COMM_CREATE}.
|
||||||
|
@ -30,6 +30,9 @@ import java.nio.*;
|
|||||||
public final class Win implements Freeable
|
public final class Win implements Freeable
|
||||||
{
|
{
|
||||||
private long handle;
|
private long handle;
|
||||||
|
public static final int WIN_NULL = 0;
|
||||||
|
public static final int FLAVOR_PRIVATE = 0;
|
||||||
|
public static final int FLAVOR_SHARED = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Java binding of {@code MPI_WIN_CREATE}.
|
* Java binding of {@code MPI_WIN_CREATE}.
|
||||||
@ -69,6 +72,53 @@ private native long createWin(
|
|||||||
Buffer base, int size, int dispUnit, long info, long comm)
|
Buffer base, int size, int dispUnit, long info, long comm)
|
||||||
throws MPIException;
|
throws MPIException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Java binding of {@code MPI_WIN_ALLOCATE} and {@code MPI_WIN_ALLOCATE_SHARED}.
|
||||||
|
* @param size size of window (buffer elements)
|
||||||
|
* @param dispUnit local unit size for displacements (buffer elements)
|
||||||
|
* @param info info object
|
||||||
|
* @param comm communicator
|
||||||
|
* @param base initial address of window
|
||||||
|
* @param flavor FLAVOR_PRIVATE or FLAVOR_SHARED
|
||||||
|
* @throws MPIException
|
||||||
|
*/
|
||||||
|
public Win(int size, int dispUnit, Info info, Comm comm, Buffer base, int flavor)
|
||||||
|
throws MPIException
|
||||||
|
{
|
||||||
|
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,
|
||||||
|
dispBytes = dispUnit * baseSize;
|
||||||
|
|
||||||
|
if(flavor == 0) {
|
||||||
|
handle = allocateWin(sizeBytes, dispBytes, info.handle, comm.handle, base);
|
||||||
|
} else if(flavor == 1) {
|
||||||
|
handle = allocateSharedWin(sizeBytes, dispBytes, info.handle, comm.handle, base);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private native long allocateWin(
|
||||||
|
int size, int dispUnit, long info, long comm, Buffer base)
|
||||||
|
throws MPIException;
|
||||||
|
|
||||||
|
private native long allocateSharedWin(
|
||||||
|
int size, int dispUnit, long info, long comm, Buffer base)
|
||||||
|
throws MPIException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Java binding of {@code MPI_WIN_CREATE_DYNAMIC}.
|
* Java binding of {@code MPI_WIN_CREATE_DYNAMIC}.
|
||||||
* @param info info object
|
* @param info info object
|
||||||
@ -784,11 +834,38 @@ public void fetchAndOp(Buffer origin, Buffer resultAddr, Datatype dataType,
|
|||||||
throw new IllegalArgumentException("The origin must be direct buffer.");
|
throw new IllegalArgumentException("The origin must be direct buffer.");
|
||||||
|
|
||||||
fetchAndOp(handle, origin, resultAddr, dataType.handle, targetRank,
|
fetchAndOp(handle, origin, resultAddr, dataType.handle, targetRank,
|
||||||
targetDisp, op, op.handle, getBaseType(dataType, dataType)); //neccessary?
|
targetDisp, op, op.handle, getBaseType(dataType, dataType));
|
||||||
}
|
}
|
||||||
|
|
||||||
private native void fetchAndOp(
|
private native void fetchAndOp(
|
||||||
long win, Buffer origin, Buffer resultAddr, long targetType, int targetRank,
|
long win, Buffer origin, Buffer resultAddr, long targetType, int targetRank,
|
||||||
int targetDisp, Op jOp, long hOp, int baseType) throws MPIException;
|
int targetDisp, Op jOp, long hOp, int baseType) throws MPIException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Java binding of the MPI operation {@code MPI_WIN_FLUSH_LOCAL}.
|
||||||
|
* @param targetRank rank of target window
|
||||||
|
* @throws MPIException
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void flushLocal(int targetRank) throws MPIException
|
||||||
|
{
|
||||||
|
MPI.check();
|
||||||
|
flushLocal(handle, targetRank);
|
||||||
|
}
|
||||||
|
|
||||||
|
private native void flushLocal(long win, int targetRank) throws MPIException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Java binding of the MPI operation {@code MPI_WIN_FLUSH_LOCAL_ALL}.
|
||||||
|
* @throws MPIException
|
||||||
|
*/
|
||||||
|
|
||||||
|
public void flushLocalAll() throws MPIException
|
||||||
|
{
|
||||||
|
MPI.check();
|
||||||
|
flushLocalAll(handle);
|
||||||
|
}
|
||||||
|
|
||||||
|
private native void flushLocalAll(long win) throws MPIException;
|
||||||
|
|
||||||
} // Win
|
} // Win
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user