Skip to content

Commit 569764c

Browse files
committed
Merge pull request #759 from nrgraham23/status_java_bindings
Java bindings for Status methods
2 parents 6c7875f + efe69c8 commit 569764c

File tree

2 files changed

+75
-0
lines changed

2 files changed

+75
-0
lines changed

ompi/mpi/java/c/mpi_Status.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,28 @@ JNIEXPORT jint JNICALL Java_mpi_Status_getElements(
109109
return count;
110110
}
111111

112+
JNIEXPORT jint JNICALL Java_mpi_Status_setElements(
113+
JNIEnv *env, jobject jthis, jint source, jint tag,
114+
jint error, jint cancelled, jlong ucount, jlong jType, int count)
115+
{
116+
MPI_Status stat;
117+
getStatus(&stat, source, tag, error, cancelled, ucount);
118+
MPI_Datatype datatype = (MPI_Datatype)jType;
119+
int rc = MPI_Status_set_elements(&stat, datatype, count);
120+
ompi_java_exceptionCheck(env, rc);
121+
return stat._ucount;
122+
}
123+
124+
JNIEXPORT void JNICALL Java_mpi_Status_setCancelled(
125+
JNIEnv *env, jobject jthis, jint source, jint tag,
126+
jint error, jint cancelled, jlong ucount, int flag)
127+
{
128+
MPI_Status stat;
129+
getStatus(&stat, source, tag, error, cancelled, ucount);
130+
int rc = MPI_Status_set_cancelled(&stat, flag);
131+
ompi_java_exceptionCheck(env, rc);
132+
}
133+
112134
jobject ompi_java_status_new(JNIEnv *env, MPI_Status *status)
113135
{
114136
jlongArray jData = (*env)->NewLongArray(env, 6);

ompi/mpi/java/java/Status.java

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,59 @@ private native int getElements(
137137
int source, int tag, int error,
138138
int cancelled, long ucount, long datatype) throws MPIException;
139139

140+
/**
141+
* Sets the number of basic elements for this status object.
142+
* <p>Java binding of the MPI operation {@code MPI_STATUS_SET_ELEMENTS}.
143+
* @param datatype datatype used by receive operation
144+
* @param count number of elements to associate with the status
145+
* @throws MPIException Signals that an MPI exception of some sort has occurred.
146+
*/
147+
public void setElements(Datatype datatype, int count) throws MPIException
148+
{
149+
MPI.check();
150+
int i = 0;
151+
int source = (int)data[i++];
152+
int tag = (int)data[i++];
153+
int error = (int)data[i++];
154+
int cancelled = (int)data[i++];
155+
long ucount = data[i++];
156+
data[4] = setElements(source, tag, error, cancelled, ucount, datatype.handle, count);
157+
}
158+
159+
private native int setElements(
160+
int source, int tag, int error,
161+
int cancelled, long ucount, long datatype, int count) throws MPIException;
162+
163+
/**
164+
* Sets the cancelled flag.
165+
* <p>Java binding of the MPI operation {@code MPI_STATUS_SET_CANCELLED}.
166+
* @param flag if true indicates request was cancelled
167+
* @throws MPIException Signals that an MPI exception of some sort has occurred.
168+
*/
169+
public void setCancelled(boolean flag) throws MPIException
170+
{
171+
MPI.check();
172+
int i = 0;
173+
int source = (int)data[i++];
174+
int tag = (int)data[i++];
175+
int error = (int)data[i++];
176+
int cancelled = (int)data[i++];
177+
long ucount = data[i++];
178+
179+
if(flag) {
180+
setCancelled(source, tag, error, cancelled, ucount, 1);
181+
data[3] = 1;
182+
} else {
183+
setCancelled(source, tag, error, cancelled, ucount, 0);
184+
data[3] = 0;
185+
}
186+
187+
}
188+
189+
private native void setCancelled(
190+
int source, int tag, int error,
191+
int cancelled, long ucount, int flag) throws MPIException;
192+
140193
/**
141194
* Returns the "source" of message.
142195
* <p>Java binding of the MPI value {@code MPI_SOURCE}.

0 commit comments

Comments
 (0)