Skip to content

Commit ea6f5b3

Browse files
committed
Merge pull request #749 from nrgraham23/additional_comm_java_bindings
Additional java bindings for the Comm class
2 parents 477083b + 59c43f4 commit ea6f5b3

File tree

7 files changed

+103
-2
lines changed

7 files changed

+103
-2
lines changed

ompi/mpi/java/c/mpi_Comm.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,15 @@ JNIEXPORT jlongArray JNICALL Java_mpi_Comm_iDup(
214214
return jcr;
215215
}
216216

217+
JNIEXPORT jlong JNICALL Java_mpi_Comm_dupWithInfo(
218+
JNIEnv *env, jobject jthis, jlong comm, jlong info)
219+
{
220+
MPI_Comm newcomm;
221+
int rc = MPI_Comm_dup_with_info((MPI_Comm)comm, (MPI_Info)info, &newcomm);
222+
ompi_java_exceptionCheck(env, rc);
223+
return (jlong)newcomm;
224+
}
225+
217226
JNIEXPORT jint JNICALL Java_mpi_Comm_getSize(
218227
JNIEnv *env, jobject jthis, jlong comm)
219228
{

ompi/mpi/java/c/mpi_Intracomm.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,15 @@ JNIEXPORT jlong JNICALL Java_mpi_Intracomm_create(
8686
return (jlong)newcomm;
8787
}
8888

89+
JNIEXPORT jlong JNICALL Java_mpi_Intracomm_createGroup(
90+
JNIEnv *env, jobject jthis, jlong comm, jlong group, int tag)
91+
{
92+
MPI_Comm newcomm;
93+
int rc = MPI_Comm_create_group((MPI_Comm)comm, (MPI_Group)group, tag, &newcomm);
94+
ompi_java_exceptionCheck(env, rc);
95+
return (jlong)newcomm;
96+
}
97+
8998
JNIEXPORT jlong JNICALL Java_mpi_Intracomm_createCart(
9099
JNIEnv *env, jobject jthis, jlong comm,
91100
jintArray dims, jbooleanArray periods, jboolean reorder)

ompi/mpi/java/java/CartComm.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ protected CartComm(long[] commRequest)
114114
return new CartComm(iDup(handle));
115115
}
116116

117+
/**
118+
* Duplicates this communicator with the info object used in the call.
119+
* <p>Java binding of {@code MPI_COMM_DUP_WITH_INFO}.
120+
* @param info info object to associate with the new communicator
121+
* @return copy of this communicator
122+
* @throws MPIException Signals that an MPI exception of some sort has occurred.
123+
*/
124+
@Override public CartComm dupWithInfo(Info info) throws MPIException
125+
{
126+
MPI.check();
127+
return new CartComm(dupWithInfo(handle, info.handle));
128+
}
129+
117130
/**
118131
* Returns cartesian topology information.
119132
* <p>Java binding of the MPI operations {@code MPI_CARTDIM_GET} and

ompi/mpi/java/java/Comm.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,22 @@ public Comm iDup() throws MPIException
152152
}
153153

154154
protected final native long[] iDup(long comm) throws MPIException;
155+
156+
/**
157+
* Duplicates this communicator with the info object used in the call.
158+
* <p>Java binding of {@code MPI_COMM_DUP_WITH_INFO}.
159+
* @param info info object to associate with the new communicator
160+
* @return copy of this communicator
161+
* @throws MPIException Signals that an MPI exception of some sort has occurred.
162+
*/
163+
public Comm dupWithInfo(Info info) throws MPIException
164+
{
165+
MPI.check();
166+
return new Comm(dupWithInfo(handle, info.handle));
167+
}
155168

169+
protected final native long dupWithInfo(long comm, long info) throws MPIException;
170+
156171
/**
157172
* Returns the associated request to this communicator if it was
158173
* created using {@link #iDup}.

ompi/mpi/java/java/GraphComm.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,19 @@ protected GraphComm(long[] commRequest)
114114
return new GraphComm(iDup(handle));
115115
}
116116

117+
/**
118+
* Duplicates this communicator with the info object used in the call.
119+
* <p>Java binding of {@code MPI_COMM_DUP_WITH_INFO}.
120+
* @param info info object to associate with the new communicator
121+
* @return copy of this communicator
122+
* @throws MPIException Signals that an MPI exception of some sort has occurred.
123+
*/
124+
@Override public GraphComm dupWithInfo(Info info) throws MPIException
125+
{
126+
MPI.check();
127+
return new GraphComm(dupWithInfo(handle, info.handle));
128+
}
129+
117130
/**
118131
* Returns graph topology information.
119132
* <p>Java binding of the MPI operations {@code MPI_GRAPHDIMS_GET}

ompi/mpi/java/java/Intercomm.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,20 @@ protected Intercomm(long[] commRequest)
106106
MPI.check();
107107
return new Intercomm(iDup(handle));
108108
}
109-
109+
110+
/**
111+
* Duplicates this communicator with the info object used in the call.
112+
* <p>Java binding of {@code MPI_COMM_DUP_WITH_INFO}.
113+
* @param info info object to associate with the new communicator
114+
* @return copy of this communicator
115+
* @throws MPIException Signals that an MPI exception of some sort has occurred.
116+
*/
117+
@Override public Intercomm dupWithInfo(Info info) throws MPIException
118+
{
119+
MPI.check();
120+
return new Intercomm(dupWithInfo(handle, info.handle));
121+
}
122+
110123
// Inter-Communication
111124

112125
/**

ompi/mpi/java/java/Intracomm.java

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,20 @@ protected Intracomm(long[] commRequest)
123123
MPI.check();
124124
return new Intracomm(iDup(handle));
125125
}
126-
126+
127+
/**
128+
* Duplicates this communicator with the info object used in the call.
129+
* <p>Java binding of {@code MPI_COMM_DUP_WITH_INFO}.
130+
* @param info info object to associate with the new communicator
131+
* @return copy of this communicator
132+
* @throws MPIException Signals that an MPI exception of some sort has occurred.
133+
*/
134+
@Override public Intracomm dupWithInfo(Info info) throws MPIException
135+
{
136+
MPI.check();
137+
return new Intracomm(dupWithInfo(handle, info.handle));
138+
}
139+
127140
/**
128141
* Partition the group associated with this communicator and create
129142
* a new communicator within each subgroup.
@@ -173,7 +186,23 @@ public final Intracomm create(Group group) throws MPIException
173186
}
174187

175188
private native long create(long comm, long group);
189+
190+
/**
191+
* Create a new intracommunicator for the given group.
192+
* <p>Java binding of the MPI operation {@code MPI_COMM_CREATE_GROUP}.
193+
* @param group group which is a subset of the group of this communicator
194+
* @param tag an integer tag
195+
* @return new communicator
196+
* @throws MPIException Signals that an MPI exception of some sort has occurred.
197+
*/
198+
public final Intracomm createGroup(Group group, int tag) throws MPIException
199+
{
200+
MPI.check();
201+
return new Intracomm(createGroup(handle, group.handle, tag));
202+
}
176203

204+
private native long createGroup(long comm, long group, int tag);
205+
177206
// Topology Constructors
178207

179208
/**

0 commit comments

Comments
 (0)