Skip to content

Commit 2a156a1

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 60609cb commit 2a156a1

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
@@ -472,3 +472,25 @@ JNIEXPORT void JNICALL Java_mpi_Win_flushLocalAll(JNIEnv *env, jobject jthis, jl
472472
int rc = MPI_Win_flush_local_all((MPI_Win)win);
473473
ompi_java_exceptionCheck(env, rc);
474474
}
475+
476+
JNIEXPORT void JNICALL Java_mpi_Win_setName(
477+
JNIEnv *env, jobject jthis, jlong handle, jstring jname)
478+
{
479+
const char *name = (*env)->GetStringUTFChars(env, jname, NULL);
480+
int rc = MPI_Win_set_name((MPI_Comm)handle, (char*)name);
481+
ompi_java_exceptionCheck(env, rc);
482+
(*env)->ReleaseStringUTFChars(env, jname, name);
483+
}
484+
485+
JNIEXPORT jstring JNICALL Java_mpi_Win_getName(
486+
JNIEnv *env, jobject jthis, jlong handle)
487+
{
488+
char name[MPI_MAX_OBJECT_NAME];
489+
int len;
490+
int rc = MPI_Win_get_name((MPI_Comm)handle, name, &len);
491+
492+
if(ompi_java_exceptionCheck(env, rc))
493+
return NULL;
494+
495+
return (*env)->NewStringUTF(env, name);
496+
}

ompi/mpi/java/java/Win.java

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

875875
private native void flushLocalAll(long win) throws MPIException;
876876

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

0 commit comments

Comments
 (0)