Skip to content

Commit

Permalink
Merge pull request open-mpi#462 from nrgraham23/comm_java_bindings
Browse files Browse the repository at this point in the history
Additional java bindings for the Comm class
  • Loading branch information
hppritcha committed Aug 4, 2015
2 parents d3467f1 + 03b0a42 commit f6a57cc
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 2 deletions.
9 changes: 9 additions & 0 deletions ompi/mpi/java/c/mpi_Comm.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,15 @@ JNIEXPORT jlongArray JNICALL Java_mpi_Comm_iDup(
return jcr;
}

JNIEXPORT jlong JNICALL Java_mpi_Comm_dupWithInfo(
JNIEnv *env, jobject jthis, jlong comm, jlong info)
{
MPI_Comm newcomm;
int rc = MPI_Comm_dup_with_info((MPI_Comm)comm, (MPI_Info)info, &newcomm);
ompi_java_exceptionCheck(env, rc);
return (jlong)newcomm;
}

JNIEXPORT jint JNICALL Java_mpi_Comm_getSize(
JNIEnv *env, jobject jthis, jlong comm)
{
Expand Down
9 changes: 9 additions & 0 deletions ompi/mpi/java/c/mpi_Intracomm.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,15 @@ JNIEXPORT jlong JNICALL Java_mpi_Intracomm_create(
return (jlong)newcomm;
}

JNIEXPORT jlong JNICALL Java_mpi_Intracomm_createGroup(
JNIEnv *env, jobject jthis, jlong comm, jlong group, int tag)
{
MPI_Comm newcomm;
int rc = MPI_Comm_create_group((MPI_Comm)comm, (MPI_Group)group, tag, &newcomm);
ompi_java_exceptionCheck(env, rc);
return (jlong)newcomm;
}

JNIEXPORT jlong JNICALL Java_mpi_Intracomm_createCart(
JNIEnv *env, jobject jthis, jlong comm,
jintArray dims, jbooleanArray periods, jboolean reorder)
Expand Down
13 changes: 13 additions & 0 deletions ompi/mpi/java/java/CartComm.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ protected CartComm(long[] commRequest)
return new CartComm(iDup(handle));
}

/**
* Duplicates this communicator with the info object used in the call.
* <p>Java binding of {@code MPI_COMM_DUP_WITH_INFO}.
* @param info info object to associate with the new communicator
* @return copy of this communicator
* @throws MPIException Signals that an MPI exception of some sort has occurred.
*/
@Override public CartComm dupWithInfo(Info info) throws MPIException
{
MPI.check();
return new CartComm(dupWithInfo(handle, info.handle));
}

/**
* Returns cartesian topology information.
* <p>Java binding of the MPI operations {@code MPI_CARTDIM_GET} and
Expand Down
15 changes: 15 additions & 0 deletions ompi/mpi/java/java/Comm.java
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,22 @@ public Comm iDup() throws MPIException
}

protected final native long[] iDup(long comm) throws MPIException;

/**
* Duplicates this communicator with the info object used in the call.
* <p>Java binding of {@code MPI_COMM_DUP_WITH_INFO}.
* @param info info object to associate with the new communicator
* @return copy of this communicator
* @throws MPIException Signals that an MPI exception of some sort has occurred.
*/
public Comm dupWithInfo(Info info) throws MPIException
{
MPI.check();
return new Comm(dupWithInfo(handle, info.handle));
}

protected final native long dupWithInfo(long comm, long info) throws MPIException;

/**
* Returns the associated request to this communicator if it was
* created using {@link #iDup}.
Expand Down
13 changes: 13 additions & 0 deletions ompi/mpi/java/java/GraphComm.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ protected GraphComm(long[] commRequest)
return new GraphComm(iDup(handle));
}

/**
* Duplicates this communicator with the info object used in the call.
* <p>Java binding of {@code MPI_COMM_DUP_WITH_INFO}.
* @param info info object to associate with the new communicator
* @return copy of this communicator
* @throws MPIException Signals that an MPI exception of some sort has occurred.
*/
@Override public GraphComm dupWithInfo(Info info) throws MPIException
{
MPI.check();
return new GraphComm(dupWithInfo(handle, info.handle));
}

/**
* Returns graph topology information.
* <p>Java binding of the MPI operations {@code MPI_GRAPHDIMS_GET}
Expand Down
15 changes: 14 additions & 1 deletion ompi/mpi/java/java/Intercomm.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,20 @@ protected Intercomm(long[] commRequest)
MPI.check();
return new Intercomm(iDup(handle));
}


/**
* Duplicates this communicator with the info object used in the call.
* <p>Java binding of {@code MPI_COMM_DUP_WITH_INFO}.
* @param info info object to associate with the new communicator
* @return copy of this communicator
* @throws MPIException Signals that an MPI exception of some sort has occurred.
*/
@Override public Intercomm dupWithInfo(Info info) throws MPIException
{
MPI.check();
return new Intercomm(dupWithInfo(handle, info.handle));
}

// Inter-Communication

/**
Expand Down
31 changes: 30 additions & 1 deletion ompi/mpi/java/java/Intracomm.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,20 @@ protected Intracomm(long[] commRequest)
MPI.check();
return new Intracomm(iDup(handle));
}


/**
* Duplicates this communicator with the info object used in the call.
* <p>Java binding of {@code MPI_COMM_DUP_WITH_INFO}.
* @param info info object to associate with the new communicator
* @return copy of this communicator
* @throws MPIException Signals that an MPI exception of some sort has occurred.
*/
@Override public Intracomm dupWithInfo(Info info) throws MPIException
{
MPI.check();
return new Intracomm(dupWithInfo(handle, info.handle));
}

/**
* Partition the group associated with this communicator and create
* a new communicator within each subgroup.
Expand Down Expand Up @@ -173,7 +186,23 @@ public final Intracomm create(Group group) throws MPIException
}

private native long create(long comm, long group);

/**
* Create a new intracommunicator for the given group.
* <p>Java binding of the MPI operation {@code MPI_COMM_CREATE_GROUP}.
* @param group group which is a subset of the group of this communicator
* @param tag an integer tag
* @return new communicator
* @throws MPIException Signals that an MPI exception of some sort has occurred.
*/
public final Intracomm createGroup(Group group, int tag) throws MPIException
{
MPI.check();
return new Intracomm(createGroup(handle, group.handle, tag));
}

private native long createGroup(long comm, long group, int tag);

// Topology Constructors

/**
Expand Down

0 comments on commit f6a57cc

Please sign in to comment.