1
1

Avoid use Status member in Comm, Message and File.

This commit was SVN r31198.
Этот коммит содержится в:
Oscar Vega-Gisbert 2014-03-24 22:28:30 +00:00
родитель 0ed44f2fdb
Коммит cc511d0efc
8 изменённых файлов: 133 добавлений и 120 удалений

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

@ -108,6 +108,8 @@ int ompi_java_attrDelete(void *attrVal);
MPI_Op ompi_java_op_getHandle(
JNIEnv *env, jobject jOp, jlong hOp, int baseType);
jlongArray ompi_java_status_new(
JNIEnv *env, MPI_Status *status);
void ompi_java_status_set(
JNIEnv *env, jlongArray jData, MPI_Status *status);
void ompi_java_status_setIndex(

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

@ -715,20 +715,14 @@ JNIEXPORT jint JNICALL Java_mpi_Comm_packSize(
return size;
}
JNIEXPORT jboolean JNICALL Java_mpi_Comm_iProbe(
JNIEnv *env, jobject jthis, jlong comm,
jint source, jint tag, jlongArray jStatus)
JNIEXPORT jlongArray JNICALL Java_mpi_Comm_iProbe(
JNIEnv *env, jobject jthis, jlong comm, jint source, jint tag)
{
int flag;
MPI_Status status;
int rc = MPI_Iprobe(source, tag, (MPI_Comm)comm, &flag, &status);
ompi_java_exceptionCheck(env, rc);
if(flag == 0)
return JNI_FALSE;
ompi_java_status_set(env, jStatus, &status);
return JNI_TRUE;
return !flag ? NULL : ompi_java_status_new(env, &status);
}
JNIEXPORT void JNICALL Java_mpi_Comm_probe(

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

@ -46,9 +46,8 @@ JNIEXPORT jlong JNICALL Java_mpi_Message_mProbe(
return (jlong)message;
}
JNIEXPORT jboolean JNICALL Java_mpi_Message_imProbe(
JNIEnv *env, jobject jthis, jint source,
jint tag, jlong jComm, jlongArray jStatus)
JNIEXPORT jlongArray JNICALL Java_mpi_Message_imProbe(
JNIEnv *env, jobject jthis, jint source, jint tag, jlong jComm)
{
MPI_Comm comm = (MPI_Comm)jComm;
MPI_Message message;
@ -57,11 +56,10 @@ JNIEXPORT jboolean JNICALL Java_mpi_Message_imProbe(
rc = MPI_Improbe(source, tag, comm, &flag, &message, &status);
if(ompi_java_exceptionCheck(env, rc) || !flag)
return JNI_FALSE;
return NULL;
(*env)->SetLongField(env, jthis, ompi_java.MessageHandle, (jlong)message);
ompi_java_status_set(env, jStatus, &status);
return JNI_TRUE;
return ompi_java_status_new(env, &status);
}
JNIEXPORT jlong JNICALL Java_mpi_Message_mRecv(

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

@ -104,6 +104,13 @@ JNIEXPORT jint JNICALL Java_mpi_Status_getElements(
return count;
}
jlongArray ompi_java_status_new(JNIEnv *env, MPI_Status *status)
{
jlongArray jData = (*env)->NewLongArray(env, 6);
ompi_java_status_set(env, jData, status);
return jData;
}
void ompi_java_status_set(JNIEnv *env, jlongArray jData, MPI_Status *status)
{
/* Copy the whole thing to Java */

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

@ -63,12 +63,6 @@ import static mpi.MPI.assertDirectBuffer;
*/
public class Comm implements Freeable
{
// Auxiliary status data.
// It's used to avoid creating status objects in the C side.
// It also avoids setting objects attributes in the C side.
// Calling java methods and setting object attributes from C is very slow.
private long[] status = Status.newData();
protected final static int SELF = 1;
protected final static int WORLD = 2;
protected long handle;
@ -318,10 +312,12 @@ public final Status recv(Object buf, int count,
buf = ((Buffer)buf).array();
}
recv(handle, buf, db, off, count,
type.handle, type.baseType, source, tag, status);
Status status = new Status();
return newStatus();
recv(handle, buf, db, off, count,
type.handle, type.baseType, source, tag, status.data);
return status;
}
private native void recv(
@ -374,12 +370,14 @@ public final Status sendRecv(
recvbuf = ((Buffer)recvbuf).array();
}
Status status = new Status();
sendRecv(handle, sendbuf, sdb, sendoff, sendcount,
sendtype.handle, sendtype.baseType, dest, sendtag,
recvbuf, rdb, recvoff, recvcount,
recvtype.handle, recvtype.baseType, source, recvtag, status);
recvtype.handle, recvtype.baseType, source, recvtag, status.data);
return newStatus();
return status;
}
private native void sendRecv(
@ -420,10 +418,12 @@ public final Status sendRecvReplace(
buf = ((Buffer)buf).array();
}
sendRecvReplace(handle, buf, db, off, count, type.handle, type.baseType,
dest, sendtag, source, recvtag, status);
Status status = new Status();
return newStatus();
sendRecvReplace(handle, buf, db, off, count, type.handle, type.baseType,
dest, sendtag, source, recvtag, status.data);
return status;
}
private native void sendRecvReplace(
@ -894,10 +894,11 @@ private native int packSize(long comm, int incount, long type)
public final Status iProbe(int source, int tag) throws MPIException
{
MPI.check();
return iProbe(handle, source, tag, status) ? newStatus() : null;
long[] status = iProbe(handle, source, tag);
return status == null ? null : new Status(status);
}
private native boolean iProbe(long comm, int source, int tag, long[] status)
private native long[] iProbe(long comm, int source, int tag)
throws MPIException;
/**
@ -913,8 +914,9 @@ private native boolean iProbe(long comm, int source, int tag, long[] status)
public final Status probe(int source, int tag) throws MPIException
{
MPI.check();
probe(handle, source, tag, status);
return newStatus();
Status status = new Status();
probe(handle, source, tag, status.data);
return status;
}
private native void probe(long comm, int source, int tag, long[] stat)
@ -2840,11 +2842,4 @@ public final String getName() throws MPIException
private native String getName(long handle) throws MPIException;
private Status newStatus()
{
Status s = new Status(status);
status = Status.newData();
return s;
}
} // Comm

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

@ -36,12 +36,6 @@ import static mpi.MPI.assertDirectBuffer;
*/
public final class File
{
// Auxiliary status data.
// It's used to avoid creating status objects in the C side.
// It also avoids setting objects attributes in the C side.
// Calling java methods and setting object attributes from C is very slow.
private long[] status = Status.newData();
private long handle;
private FileView view = new FileView(0, MPI.BYTE, MPI.BYTE, "native");
private Status beginStatus;
@ -269,6 +263,7 @@ public Status readAt(long offset, Object buf, int count, Datatype type)
MPI.check();
int off = 0;
boolean db = false;
Status status = new Status();
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
@ -277,9 +272,9 @@ public Status readAt(long offset, Object buf, int count, Datatype type)
}
readAt(handle, offset, buf, db, off, count,
type.handle, type.baseType, status);
type.handle, type.baseType, status.data);
return newStatus();
return status;
}
private native void readAt(
@ -301,6 +296,7 @@ public Status readAtAll(long offset, Object buf, int count, Datatype type)
MPI.check();
int off = 0;
boolean db = false;
Status status = new Status();
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
@ -309,9 +305,9 @@ public Status readAtAll(long offset, Object buf, int count, Datatype type)
}
readAtAll(handle, offset, buf, db, off, count,
type.handle, type.baseType, status);
type.handle, type.baseType, status.data);
return newStatus();
return status;
}
private native void readAtAll(
@ -333,6 +329,7 @@ public Status writeAt(long offset, Object buf, int count, Datatype type)
MPI.check();
int off = 0;
boolean db = false;
Status status = new Status();
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
@ -341,9 +338,9 @@ public Status writeAt(long offset, Object buf, int count, Datatype type)
}
writeAt(handle, offset, buf, db, off, count,
type.handle, type.baseType, status);
type.handle, type.baseType, status.data);
return newStatus();
return status;
}
private native void writeAt(
@ -365,6 +362,7 @@ public Status writeAtAll(long offset, Object buf, int count, Datatype type)
MPI.check();
int off = 0;
boolean db = false;
Status status = new Status();
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
@ -373,9 +371,9 @@ public Status writeAtAll(long offset, Object buf, int count, Datatype type)
}
writeAtAll(handle, offset, buf, db, off, count,
type.handle, type.baseType, status);
type.handle, type.baseType, status.data);
return newStatus();
return status;
}
private native void writeAtAll(
@ -437,6 +435,7 @@ public Status read(Object buf, int count, Datatype type) throws MPIException
MPI.check();
int off = 0;
boolean db = false;
Status status = new Status();
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
@ -444,8 +443,8 @@ public Status read(Object buf, int count, Datatype type) throws MPIException
buf = ((Buffer)buf).array();
}
read(handle, buf, db, off, count, type.handle, type.baseType, status);
return newStatus();
read(handle, buf, db, off, count, type.handle, type.baseType, status.data);
return status;
}
private native void read(
@ -465,6 +464,7 @@ public Status readAll(Object buf, int count, Datatype type) throws MPIException
MPI.check();
int off = 0;
boolean db = false;
Status status = new Status();
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
@ -472,8 +472,8 @@ public Status readAll(Object buf, int count, Datatype type) throws MPIException
buf = ((Buffer)buf).array();
}
readAll(handle, buf, db, off, count, type.handle, type.baseType, status);
return newStatus();
readAll(handle, buf,db,off, count, type.handle, type.baseType, status.data);
return status;
}
private native void readAll(
@ -493,6 +493,7 @@ public Status write(Object buf, int count, Datatype type) throws MPIException
MPI.check();
int off = 0;
boolean db = false;
Status status = new Status();
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
@ -500,8 +501,8 @@ public Status write(Object buf, int count, Datatype type) throws MPIException
buf = ((Buffer)buf).array();
}
write(handle, buf, db, off, count, type.handle, type.baseType, status);
return newStatus();
write(handle, buf, db, off, count, type.handle, type.baseType, status.data);
return status;
}
private native void write(
@ -521,6 +522,7 @@ public Status writeAll(Object buf, int count, Datatype type) throws MPIException
MPI.check();
int off = 0;
boolean db = false;
Status status = new Status();
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
@ -528,8 +530,8 @@ public Status writeAll(Object buf, int count, Datatype type) throws MPIException
buf = ((Buffer)buf).array();
}
writeAll(handle, buf,db,off, count, type.handle, type.baseType, status);
return newStatus();
writeAll(handle, buf,db,off, count, type.handle,type.baseType, status.data);
return status;
}
private native void writeAll(
@ -627,6 +629,7 @@ public Status readShared(Object buf, int count, Datatype type)
MPI.check();
int off = 0;
boolean db = false;
Status status = new Status();
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
@ -634,8 +637,10 @@ public Status readShared(Object buf, int count, Datatype type)
buf = ((Buffer)buf).array();
}
readShared(handle, buf, db, off, count, type.handle, type.baseType, status);
return newStatus();
readShared(handle, buf, db, off, count,
type.handle, type.baseType, status.data);
return status;
}
private native void readShared(
@ -656,6 +661,7 @@ public Status writeShared(Object buf, int count, Datatype type)
MPI.check();
int off = 0;
boolean db = false;
Status status = new Status();
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
@ -663,8 +669,10 @@ public Status writeShared(Object buf, int count, Datatype type)
buf = ((Buffer)buf).array();
}
writeShared(handle, buf,db,off, count, type.handle, type.baseType, status);
return newStatus();
writeShared(handle, buf, db, off, count,
type.handle, type.baseType, status.data);
return status;
}
private native void writeShared(
@ -723,6 +731,7 @@ public Status readOrdered(Object buf, int count, Datatype type)
MPI.check();
int off = 0;
boolean db = false;
Status status = new Status();
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
@ -730,8 +739,10 @@ public Status readOrdered(Object buf, int count, Datatype type)
buf = ((Buffer)buf).array();
}
readOrdered(handle, buf,db,off, count, type.handle, type.baseType, status);
return newStatus();
readOrdered(handle, buf, db, off, count,
type.handle, type.baseType, status.data);
return status;
}
private native void readOrdered(
@ -752,6 +763,7 @@ public Status writeOrdered(Object buf, int count, Datatype type)
MPI.check();
int off = 0;
boolean db = false;
Status status = new Status();
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
@ -759,8 +771,10 @@ public Status writeOrdered(Object buf, int count, Datatype type)
buf = ((Buffer)buf).array();
}
writeOrdered(handle, buf,db,off, count, type.handle, type.baseType, status);
return newStatus();
writeOrdered(handle, buf, db, off, count,
type.handle, type.baseType, status.data);
return status;
}
private native void writeOrdered(
@ -815,6 +829,7 @@ public void readAtAllBegin(long offset, Object buf, int count, Datatype type)
else
{
int off = 0;
Status status = new Status();
if(isHeapBuffer(buf))
{
@ -823,9 +838,9 @@ public void readAtAllBegin(long offset, Object buf, int count, Datatype type)
}
readAtAll(handle, offset, buf, false, off, count,
type.handle, type.baseType, status);
type.handle, type.baseType, status.data);
beginStatus = newStatus();
beginStatus = status;
}
}
@ -845,8 +860,9 @@ public Status readAtAllEnd(Object buf) throws MPIException
if(isDirectBuffer(buf))
{
readAtAllEnd(handle, buf, status);
return newStatus();
Status status = new Status();
readAtAllEnd(handle, buf, status.data);
return status;
}
else
{
@ -877,6 +893,7 @@ public void writeAtAllBegin(long offset, Object buf, int count, Datatype type)
else
{
int off = 0;
Status status = new Status();
if(isHeapBuffer(buf))
{
@ -885,9 +902,9 @@ public void writeAtAllBegin(long offset, Object buf, int count, Datatype type)
}
writeAtAll(handle, offset, buf, false, off, count,
type.handle, type.baseType, status);
type.handle, type.baseType, status.data);
beginStatus = newStatus();
beginStatus = status;
}
}
@ -907,8 +924,9 @@ public Status writeAtAllEnd(Object buf) throws MPIException
if(isDirectBuffer(buf))
{
writeAtAllEnd(handle, buf, status);
return newStatus();
Status status = new Status();
writeAtAllEnd(handle, buf, status.data);
return status;
}
else
{
@ -938,6 +956,7 @@ public void readAllBegin(Object buf, int count, Datatype type)
else
{
int off = 0;
Status status = new Status();
if(isHeapBuffer(buf))
{
@ -946,9 +965,9 @@ public void readAllBegin(Object buf, int count, Datatype type)
}
readAll(handle, buf, false, off, count,
type.handle, type.baseType, status);
type.handle, type.baseType, status.data);
beginStatus = newStatus();
beginStatus = status;
}
}
@ -967,8 +986,9 @@ public Status readAllEnd(Object buf) throws MPIException
if(isDirectBuffer(buf))
{
readAllEnd(handle, buf, status);
return newStatus();
Status status = new Status();
readAllEnd(handle, buf, status.data);
return status;
}
else
{
@ -998,6 +1018,7 @@ public void writeAllBegin(Object buf, int count, Datatype type)
else
{
int off = 0;
Status status = new Status();
if(isHeapBuffer(buf))
{
@ -1006,9 +1027,9 @@ public void writeAllBegin(Object buf, int count, Datatype type)
}
writeAll(handle, buf, false, off, count,
type.handle, type.baseType, status);
type.handle, type.baseType, status.data);
beginStatus = newStatus();
beginStatus = status;
}
}
@ -1027,8 +1048,9 @@ public Status writeAllEnd(Object buf) throws MPIException
if(isDirectBuffer(buf))
{
writeAllEnd(handle, buf, status);
return newStatus();
Status status = new Status();
writeAllEnd(handle, buf, status.data);
return status;
}
else
{
@ -1058,6 +1080,7 @@ public void readOrderedBegin(Object buf, int count, Datatype type)
else
{
int off = 0;
Status status = new Status();
if(isHeapBuffer(buf))
{
@ -1066,9 +1089,9 @@ public void readOrderedBegin(Object buf, int count, Datatype type)
}
readOrdered(handle, buf, false, off, count,
type.handle, type.baseType, status);
type.handle, type.baseType, status.data);
beginStatus = newStatus();
beginStatus = status;
}
}
@ -1087,8 +1110,9 @@ public Status readOrderedEnd(Object buf) throws MPIException
if(isDirectBuffer(buf))
{
readOrderedEnd(handle, buf, status);
return newStatus();
Status status = new Status();
readOrderedEnd(handle, buf, status.data);
return status;
}
else
{
@ -1118,6 +1142,7 @@ public void writeOrderedBegin(Object buf, int count, Datatype type)
else
{
int off = 0;
Status status = new Status();
if(isHeapBuffer(buf))
{
@ -1126,9 +1151,9 @@ public void writeOrderedBegin(Object buf, int count, Datatype type)
}
writeOrdered(handle, buf, false, off, count,
type.handle, type.baseType, status);
type.handle, type.baseType, status.data);
beginStatus = newStatus();
beginStatus = status;
}
}
@ -1147,8 +1172,9 @@ public Status writeOrderedEnd(Object buf) throws MPIException
if(isDirectBuffer(buf))
{
writeOrderedEnd(handle, buf, status);
return newStatus();
Status status = new Status();
writeOrderedEnd(handle, buf, status.data);
return status;
}
else
{
@ -1206,11 +1232,4 @@ public void sync() throws MPIException
private native void sync(long handle) throws MPIException;
private Status newStatus()
{
Status s = new Status(status);
status = Status.newData();
return s;
}
} // File

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

@ -34,12 +34,6 @@ import static mpi.MPI.assertDirectBuffer;
*/
public final class Message
{
// Auxiliary status data.
// It's used to avoid creating status objects in the C side.
// It also avoids setting objects attributes in the C side.
// Calling java methods and setting object attributes from C is very slow.
private long[] status = Status.newData();
protected long handle;
private static long NULL, NO_PROC;
@ -87,8 +81,9 @@ public boolean isNoProc()
public Status mProbe(int source, int tag, Comm comm) throws MPIException
{
MPI.check();
handle = mProbe(source, tag, comm.handle, status);
return newStatus();
Status status = new Status();
handle = mProbe(source, tag, comm.handle, status.data);
return status;
}
private native long mProbe(int source, int tag, long comm, long[] status)
@ -105,10 +100,11 @@ private native long mProbe(int source, int tag, long comm, long[] status)
public Status imProbe(int source, int tag, Comm comm) throws MPIException
{
MPI.check();
return imProbe(source, tag, comm.handle, status) ? newStatus() : null;
long[] status = imProbe(source, tag, comm.handle);
return status == null ? null : new Status(status);
}
private native boolean imProbe(int source, int tag, long comm, long[] status)
private native long[] imProbe(int source, int tag, long comm)
throws MPIException;
/**
@ -123,6 +119,7 @@ public Status mRecv(Object buf, int count, Datatype type) throws MPIException
MPI.check();
int off = 0;
boolean db = false;
Status status = new Status();
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
@ -131,9 +128,9 @@ public Status mRecv(Object buf, int count, Datatype type) throws MPIException
}
handle = mRecv(handle, buf, db, off, count,
type.handle, type.baseType, status);
type.handle, type.baseType, status.data);
return newStatus();
return status;
}
private native long mRecv(
@ -159,11 +156,4 @@ public Request imRecv(Buffer buf, int count, Datatype type)
private native long imRecv(long message, Object buf, int count, long type)
throws MPIException;
private Status newStatus()
{
Status s = new Status(status);
status = Status.newData();
return s;
}
} // Message

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

@ -52,6 +52,14 @@ public final class Status
{
protected final long[] data;
/**
* Status objects must be created only by the MPI methods.
*/
protected Status()
{
data = new long[6];
}
/**
* Status objects must be created only by the MPI methods.
*/