Skip to content

Commit 36d7855

Browse files
committed
Merge pull request #763 from nrgraham23/status_x_java_bindings
Status x java bindings
2 parents 2fa8f4d + 17c606b commit 36d7855

File tree

8 files changed

+277
-47
lines changed

8 files changed

+277
-47
lines changed

ompi/mpi/java/c/Makefile.am

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#
33
# Copyright (c) 2011-2013 Cisco Systems, Inc. All rights reserved.
44
# Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
5+
# Copyright (c) 2015 Los Alamos National Security, LLC. All rights
6+
# reserved.
57
# $COPYRIGHT$
68
#
79
# Additional copyrights may follow
@@ -22,23 +24,24 @@ ompi_HEADERS = \
2224

2325
lib_LTLIBRARIES = libmpi_java.la
2426
libmpi_java_la_SOURCES = \
25-
mpi_CartComm.c \
26-
mpi_Comm.c \
27+
mpi_CartComm.c \
28+
mpi_Comm.c \
2729
mpi_Constant.c \
28-
mpi_Datatype.c \
29-
mpi_Errhandler.c \
30+
mpi_Count.c \
31+
mpi_Datatype.c \
32+
mpi_Errhandler.c \
3033
mpi_File.c \
31-
mpi_GraphComm.c \
32-
mpi_Group.c \
34+
mpi_GraphComm.c \
35+
mpi_Group.c \
3336
mpi_Info.c \
34-
mpi_Intercomm.c \
35-
mpi_Intracomm.c \
37+
mpi_Intercomm.c \
38+
mpi_Intracomm.c \
3639
mpi_Message.c \
37-
mpi_MPI.c \
38-
mpi_Op.c \
39-
mpi_Request.c \
40-
mpi_Prequest.c \
41-
mpi_Status.c \
40+
mpi_MPI.c \
41+
mpi_Op.c \
42+
mpi_Request.c \
43+
mpi_Prequest.c \
44+
mpi_Status.c \
4245
mpi_Win.c
4346

4447
libmpi_java_la_LIBADD = $(top_builddir)/ompi/libmpi.la

ompi/mpi/java/c/mpiJava.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ typedef struct {
3333
jmethodID ShiftParmsInit;
3434
jclass VersionClass;
3535
jmethodID VersionInit;
36+
jclass CountClass;
37+
jmethodID CountInit;
3638
jclass GraphParmsClass;
3739
jmethodID GraphParmsInit;
3840
jclass DistGraphNeighborsClass;

ompi/mpi/java/c/mpi_Count.c

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/*
2+
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
3+
* reserved.
4+
* $COPYRIGHT$
5+
*
6+
* Additional copyrights may follow
7+
*
8+
* $HEADER$
9+
*
10+
*
11+
* This file is almost a complete re-write for Open MPI compared to the
12+
* original mpiJava package. Its license and copyright are listed below.
13+
* See <path to ompi/mpi/java/README> for more information.
14+
*
15+
*
16+
* Licensed under the Apache License, Version 2.0 (the "License");
17+
* you may not use this file except in compliance with the License.
18+
* You may obtain a copy of the License at
19+
*
20+
* http://www.apache.org/licenses/LICENSE-2.0
21+
*
22+
* Unless required by applicable law or agreed to in writing, software
23+
* distributed under the License is distributed on an "AS IS" BASIS,
24+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25+
* See the License for the specific language governing permissions and
26+
* limitations under the License.
27+
*
28+
*
29+
* File : Version.java
30+
* Author : Nathaniel Graham
31+
* Created : Thu Jul 30 09:34 2015
32+
*/
33+
34+
#include "ompi_config.h"
35+
36+
#include <stdlib.h>
37+
#ifdef HAVE_TARGETCONDITIONALS_H
38+
#include <TargetConditionals.h>
39+
#endif
40+
41+
#include "mpi.h"
42+
#include "mpi_Count.h"
43+
#include "mpiJava.h"
44+
45+
JNIEXPORT void JNICALL Java_mpi_Count_initCount(JNIEnv *env, jclass jthis)
46+
{
47+
jclass c = (*env)->FindClass(env, "mpi/Count");
48+
ompi_java.CountClass = (*env)->NewGlobalRef(env, c);
49+
ompi_java.CountInit = (*env)->GetMethodID(env, ompi_java.CountClass, "<init>", "(J)V");
50+
51+
(*env)->DeleteLocalRef(env, c);
52+
}

ompi/mpi/java/c/mpi_MPI.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ static void deleteClasses(JNIEnv *env)
205205
(*env)->DeleteGlobalRef(env, ompi_java.CartParmsClass);
206206
(*env)->DeleteGlobalRef(env, ompi_java.ShiftParmsClass);
207207
(*env)->DeleteGlobalRef(env, ompi_java.VersionClass);
208+
(*env)->DeleteGlobalRef(env, ompi_java.CountClass);
208209
(*env)->DeleteGlobalRef(env, ompi_java.GraphParmsClass);
209210
(*env)->DeleteGlobalRef(env, ompi_java.DistGraphNeighborsClass);
210211
(*env)->DeleteGlobalRef(env, ompi_java.StatusClass);

ompi/mpi/java/c/mpi_Status.c

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

112+
JNIEXPORT jobject JNICALL Java_mpi_Status_getElementsX(
113+
JNIEnv *env, jobject jthis, jint source, jint tag,
114+
jint error, jint cancelled, jlong ucount, jlong jType)
115+
{
116+
MPI_Count count;
117+
MPI_Status stat;
118+
getStatus(&stat, source, tag, error, cancelled, ucount);
119+
MPI_Datatype datatype = (MPI_Datatype)jType;
120+
int rc = MPI_Get_elements_x(&stat, datatype, &count);
121+
ompi_java_exceptionCheck(env, rc);
122+
123+
return (*env)->NewObject(env, ompi_java.CountClass,
124+
ompi_java.CountInit, (jlong)count);
125+
}
126+
112127
JNIEXPORT jint JNICALL Java_mpi_Status_setElements(
113128
JNIEnv *env, jobject jthis, jint source, jint tag,
114129
jint error, jint cancelled, jlong ucount, jlong jType, int count)
@@ -121,6 +136,19 @@ JNIEXPORT jint JNICALL Java_mpi_Status_setElements(
121136
return stat._ucount;
122137
}
123138

139+
JNIEXPORT jlong JNICALL Java_mpi_Status_setElementsX(
140+
JNIEnv *env, jobject jthis, jint source, jint tag,
141+
jint error, jint cancelled, jlong ucount, jlong jType, jlong jcount)
142+
{
143+
MPI_Status stat;
144+
MPI_Count count = (long)jcount;
145+
getStatus(&stat, source, tag, error, cancelled, ucount);
146+
MPI_Datatype datatype = (MPI_Datatype)jType;
147+
int rc = MPI_Status_set_elements_x(&stat, datatype, count);
148+
ompi_java_exceptionCheck(env, rc);
149+
return (jlong)stat._ucount;
150+
}
151+
124152
JNIEXPORT void JNICALL Java_mpi_Status_setCancelled(
125153
JNIEnv *env, jobject jthis, jint source, jint tag,
126154
jint error, jint cancelled, jlong ucount, int flag)

ompi/mpi/java/java/Count.java

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
/*
2+
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
3+
* reserved.
4+
* $COPYRIGHT$
5+
*
6+
* Additional copyrights may follow
7+
*
8+
* $HEADER$
9+
*
10+
*
11+
* This file is almost a complete re-write for Open MPI compared to the
12+
* original mpiJava package. Its license and copyright are listed below.
13+
* See <path to ompi/mpi/java/README> for more information.
14+
*
15+
*
16+
* Licensed under the Apache License, Version 2.0 (the "License");
17+
* you may not use this file except in compliance with the License.
18+
* You may obtain a copy of the License at
19+
*
20+
* http://www.apache.org/licenses/LICENSE-2.0
21+
*
22+
* Unless required by applicable law or agreed to in writing, software
23+
* distributed under the License is distributed on an "AS IS" BASIS,
24+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25+
* See the License for the specific language governing permissions and
26+
* limitations under the License.
27+
*
28+
*
29+
* File : Count.java
30+
* Author : Nathaniel Graham
31+
* Created : Thu Jul 29 17:13 2015
32+
*/
33+
34+
package mpi;
35+
36+
/**
37+
* This class represents {@code MPI_Count}.
38+
*/
39+
public final class Count implements Comparable
40+
{
41+
private long count;
42+
43+
static
44+
{
45+
System.loadLibrary("mpi_java");
46+
initCount();
47+
}
48+
49+
private static native void initCount();
50+
51+
public Count(long count)
52+
{
53+
this.count = count;
54+
}
55+
56+
/**
57+
* Gets value associated with this Count object.
58+
* @return Count value
59+
*/
60+
public long getCount()
61+
{
62+
return this.count;
63+
}
64+
65+
/**
66+
* Sets the value associated with this Count object.
67+
* @param count the value to set for this count object
68+
*/
69+
public void setCount(long count)
70+
{
71+
this.count = count;
72+
}
73+
74+
@Override
75+
public boolean equals(Object obj)
76+
{
77+
if(obj instanceof Count) {
78+
if(this.count == ((Count)obj).getCount()) {
79+
return true;
80+
}
81+
}
82+
return false;
83+
}
84+
85+
public int compareTo(Object obj)
86+
{
87+
if(obj instanceof Count) {
88+
if(this.count - ((Count)obj).getCount() > 0) {
89+
return 1;
90+
} else if(this.count - ((Count)obj).getCount() == 0) {
91+
return 0;
92+
}
93+
}
94+
return -1;
95+
}
96+
} // Count

ompi/mpi/java/java/Makefile.am

Lines changed: 36 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -25,37 +25,38 @@ include $(top_srcdir)/Makefile.ompi-rules
2525
# just list them here in EXTRA_DIST so that they get picked up by
2626
# "make dist".
2727
JAVA_SRC_FILES = \
28-
CartComm.java \
29-
CartParms.java \
30-
Comm.java \
28+
CartComm.java \
29+
CartParms.java \
30+
Comm.java \
3131
Constant.java \
32-
Datatype.java \
32+
Count.java \
33+
Datatype.java \
3334
DistGraphNeighbors.java \
3435
DoubleInt.java \
3536
DoubleComplex.java \
36-
Errhandler.java \
37+
Errhandler.java \
3738
FloatComplex.java \
3839
FloatInt.java \
3940
File.java \
4041
FileView.java \
41-
Freeable.java \
42-
GraphComm.java \
43-
GraphParms.java \
44-
Group.java \
42+
Freeable.java \
43+
GraphComm.java \
44+
GraphParms.java \
45+
Group.java \
4546
Info.java \
4647
Int2.java \
47-
Intercomm.java \
48-
Intracomm.java \
48+
Intercomm.java \
49+
Intracomm.java \
4950
LongInt.java \
5051
Message.java \
51-
MPI.java \
52-
MPIException.java \
53-
Op.java \
54-
Prequest.java \
55-
Request.java \
56-
ShiftParms.java \
52+
MPI.java \
53+
MPIException.java \
54+
Op.java \
55+
Prequest.java \
56+
Request.java \
57+
ShiftParms.java \
5758
ShortInt.java \
58-
Status.java \
59+
Status.java \
5960
Struct.java \
6061
UserFunction.java \
6162
Version.java \
@@ -71,26 +72,27 @@ if OMPI_WANT_JAVA_BINDINGS
7172
# we have a specific list of files here, as opposed to deriving them
7273
# from JAVA_SRC_FILES.
7374
JAVA_H = \
74-
mpi_MPI.h \
75-
mpi_CartParms.h \
76-
mpi_CartComm.h \
77-
mpi_Comm.h \
75+
mpi_MPI.h \
76+
mpi_CartParms.h \
77+
mpi_CartComm.h \
78+
mpi_Comm.h \
7879
mpi_Constant.h \
79-
mpi_Datatype.h \
80-
mpi_Errhandler.h \
80+
mpi_Count.h \
81+
mpi_Datatype.h \
82+
mpi_Errhandler.h \
8183
mpi_File.h \
82-
mpi_GraphParms.h \
83-
mpi_GraphComm.h \
84-
mpi_Group.h \
84+
mpi_GraphParms.h \
85+
mpi_GraphComm.h \
86+
mpi_Group.h \
8587
mpi_Info.h \
86-
mpi_Intercomm.h \
87-
mpi_Intracomm.h \
88+
mpi_Intercomm.h \
89+
mpi_Intracomm.h \
8890
mpi_Message.h \
89-
mpi_Op.h \
90-
mpi_Prequest.h \
91-
mpi_Request.h \
92-
mpi_ShiftParms.h \
93-
mpi_Status.h \
91+
mpi_Op.h \
92+
mpi_Prequest.h \
93+
mpi_Request.h \
94+
mpi_ShiftParms.h \
95+
mpi_Status.h \
9496
mpi_Version.h \
9597
mpi_Win.h
9698

0 commit comments

Comments
 (0)