Skip to content

Commit 2e37309

Browse files
author
Nathaniel Graham
committed
Java bindings for window name get and set
Includes bindings for MPI_WIN_GET_NAME and MPI_WIN_SET_NAME. Signed-off-by: Nathaniel Graham <[email protected]>
1 parent 0046754 commit 2e37309

File tree

2 files changed

+48
-0
lines changed

2 files changed

+48
-0
lines changed

ompi/mpi/java/c/mpi_Win.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,3 +468,25 @@ JNIEXPORT void JNICALL Java_mpi_Win_flushLocalAll(JNIEnv *env, jobject jthis, jl
468468
int rc = MPI_Win_flush_local_all((MPI_Win)win);
469469
ompi_java_exceptionCheck(env, rc);
470470
}
471+
472+
JNIEXPORT void JNICALL Java_mpi_Win_setName(
473+
JNIEnv *env, jobject jthis, jlong handle, jstring jname)
474+
{
475+
const char *name = (*env)->GetStringUTFChars(env, jname, NULL);
476+
int rc = MPI_Win_set_name((MPI_Comm)handle, (char*)name);
477+
ompi_java_exceptionCheck(env, rc);
478+
(*env)->ReleaseStringUTFChars(env, jname, name);
479+
}
480+
481+
JNIEXPORT jstring JNICALL Java_mpi_Win_getName(
482+
JNIEnv *env, jobject jthis, jlong handle)
483+
{
484+
char name[MPI_MAX_OBJECT_NAME];
485+
int len;
486+
int rc = MPI_Win_get_name((MPI_Comm)handle, name, &len);
487+
488+
if(ompi_java_exceptionCheck(env, rc))
489+
return NULL;
490+
491+
return (*env)->NewStringUTF(env, name);
492+
}

ompi/mpi/java/java/Win.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -870,4 +870,30 @@ public void flushLocalAll() throws MPIException
870870

871871
private native void flushLocalAll(long win) throws MPIException;
872872

873+
/**
874+
* Java binding of the MPI operation {@code MPI_WIN_GET_NAME}.
875+
* @return the name associated with this window
876+
* @throws MPIException Signals that an MPI exception of some sort has occurred.
877+
*/
878+
public String getName() throws MPIException
879+
{
880+
MPI.check();
881+
return getName(handle);
882+
}
883+
884+
private native String getName(long handle) throws MPIException;
885+
886+
/**
887+
* Java binding of the MPI operation {@code MPI_WIN_SET_NAME}.
888+
* @param name the name to associate with this window
889+
* @throws MPIException Signals that an MPI exception of some sort has occurred.
890+
*/
891+
public void setName(String name) throws MPIException
892+
{
893+
MPI.check();
894+
setName(handle, name);
895+
}
896+
897+
private native void setName(long handle, String name) throws MPIException;
898+
873899
} // Win

0 commit comments

Comments
 (0)