Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions ompi/mpi/java/c/mpiJava.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ typedef struct {
jmethodID CartParmsInit;
jclass ShiftParmsClass;
jmethodID ShiftParmsInit;
jclass VersionClass;
jmethodID VersionInit;
jclass GraphParmsClass;
jmethodID GraphParmsInit;
jclass DistGraphNeighborsClass;
Expand Down
27 changes: 27 additions & 0 deletions ompi/mpi/java/c/mpi_MPI.c
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ static void deleteClasses(JNIEnv *env)
{
(*env)->DeleteGlobalRef(env, ompi_java.CartParmsClass);
(*env)->DeleteGlobalRef(env, ompi_java.ShiftParmsClass);
(*env)->DeleteGlobalRef(env, ompi_java.VersionClass);
(*env)->DeleteGlobalRef(env, ompi_java.GraphParmsClass);
(*env)->DeleteGlobalRef(env, ompi_java.DistGraphNeighborsClass);
(*env)->DeleteGlobalRef(env, ompi_java.StatusClass);
Expand Down Expand Up @@ -257,6 +258,12 @@ JNIEXPORT jobject JNICALL Java_mpi_MPI_newDoubleInt(JNIEnv *env, jclass clazz)
return (*env)->NewObject(env, c, m, iOff, sizeof(int));
}

JNIEXPORT void JNICALL Java_mpi_MPI_initVersion(JNIEnv *env, jclass jthis)
{
ompi_java.VersionClass = findClass(env, "mpi/Version");
ompi_java.VersionInit = (*env)->GetMethodID(env, ompi_java.VersionClass, "<init>", "(II)V");
}

JNIEXPORT jobjectArray JNICALL Java_mpi_MPI_Init_1jni(
JNIEnv *env, jclass clazz, jobjectArray argv)
{
Expand Down Expand Up @@ -353,6 +360,26 @@ JNIEXPORT void JNICALL Java_mpi_MPI_Finalize_1jni(JNIEnv *env, jclass obj)
deleteClasses(env);
}

JNIEXPORT jobject JNICALL Java_mpi_MPI_getVersionJNI(JNIEnv *env, jclass jthis)
{
int version, subversion;
int rc = MPI_Get_version(&version, &subversion);
ompi_java_exceptionCheck(env, rc);

return (*env)->NewObject(env, ompi_java.VersionClass,
ompi_java.VersionInit, version, subversion);
}

JNIEXPORT jstring JNICALL Java_mpi_MPI_getLibVersionJNI(JNIEnv *env, jclass jthis)
{
int length;
char version[MPI_MAX_LIBRARY_VERSION_STRING];
int rc = MPI_Get_library_version(version, &length);
ompi_java_exceptionCheck(env, rc);

return (*env)->NewStringUTF(env, version);
}

JNIEXPORT jint JNICALL Java_mpi_MPI_getProcessorName(
JNIEnv *env, jclass obj, jbyteArray buf)
{
Expand Down
25 changes: 25 additions & 0 deletions ompi/mpi/java/java/MPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -394,13 +394,16 @@ public final class MPI
ERR_WIN = c.ERR_WIN;
ERR_LASTCODE = c.ERR_LASTCODE;
ERR_SYSRESOURCE = c.ERR_SYSRESOURCE;

initVersion();
}

private static native Int2 newInt2();
private static native ShortInt newShortInt();
private static native LongInt newLongInt();
private static native FloatInt newFloatInt();
private static native DoubleInt newDoubleInt();
private static native void initVersion();

private static void initCommon() throws MPIException
{
Expand Down Expand Up @@ -538,6 +541,28 @@ public static double wtick() throws MPIException

private static native double wtick_jni();

/**
* Returns a version object representing the version of MPI being used.
* <p>Java binding of the MPI operation {@code MPI_GET_VERSION}.
* @return A version object representing the version and subversion of MPI being used.
*/
public static Version getVersion() {
return getVersionJNI();
}

private static native Version getVersionJNI();

/**
* Returns the version of the MPI Library
* <p>Java binding of the MPI operation {@code MPI_GET_LIBRARY_VERSION}.
* @return A string representation of the MPI Library
*/
public static String getLibVersion() {
return getLibVersionJNI();
}

private static native String getLibVersionJNI();

/**
* Returns the name of the processor on which it is called.
* <p>Java binding of the MPI operation {@code MPI_GET_PROCESSOR_NAME}.
Expand Down
4 changes: 4 additions & 0 deletions ompi/mpi/java/java/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# -*- makefile -*-
#
# Copyright (c) 2011-2014 Cisco Systems, Inc. All rights reserved.
# Copyright (c) 2015 Los Alamos National Security, LLC. All rights
# reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
Expand Down Expand Up @@ -56,6 +58,7 @@ JAVA_SRC_FILES = \
Status.java \
Struct.java \
UserFunction.java \
Version.java \
Win.java

EXTRA_DIST = $(JAVA_SRC_FILES)
Expand Down Expand Up @@ -88,6 +91,7 @@ JAVA_H = \
mpi_Request.h \
mpi_ShiftParms.h \
mpi_Status.h \
mpi_Version.h \
mpi_Win.h

# A little verbosity magic; see Makefile.ompi-rules for an explanation.
Expand Down
68 changes: 68 additions & 0 deletions ompi/mpi/java/java/Version.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* Copyright (c) 2015 Los Alamos National Security, LLC. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*
*
* This file is almost a complete re-write for Open MPI compared to the
* original mpiJava package. Its license and copyright are listed below.
* See <path to ompi/mpi/java/README> for more information.
*
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*
* File : Version.java
* Author : Nathaniel Graham
* Created : Thu Jul 23 09:25 2015
*/

package mpi;

/**
* Version and Subversion for MPI
*/
public final class Version
{
private final int version;
private final int subVersion;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor comment: Seems like weird indenting...?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is weird indenting, but I believe it follows the indenting of the rest of the java files. If you like I can easily change it.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could also fix the indenting for all of the other Java files if you
like. Its very very simple in eclipse.

On Thu, Jul 23, 2015 at 3:03 PM, Jeff Squyres notifications@github.com
wrote:

In ompi/mpi/java/java/Version.java
#740 (comment):

  • * File : Version.java
  • * Author : Nathaniel Graham
  • * Created : Thu Jul 23 09:25 2015
  • /
    +
    +package mpi;
    +
    +/
    *
  • * Version and Subversion for MPI
  • */
    +public final class Version
    +{
    +private final int version;
    +private final int subVersion;

Minor comment: Seems like weird indenting...?


Reply to this email directly or view it on GitHub
https://github.com/open-mpi/ompi/pull/740/files#r35371038.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the "Normal" Java way? To my C-trained eye, this looks weird. But if it's The Way Java People Do It, it's fine.

If it's not the normal way java people do it, then you might as well keep the indenting here in this PR and make a separate PR for just all the whitespace/indenting changes. Cool?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not the normal way. The normal way indents everything inside the class as well. I will fix the indentation in a separate PR.


protected Version(int version, int subVersion)
{
this.version = version;
this.subVersion = subVersion;
}

/**
* Gets the MPI version.
* @return MPI version
*/
public int getVersion()
{
return version;
}

/**
* Gets the MPI subversion.
* @return MPI subversion
*/
public int getSubVersion()
{
return subVersion;
}

} // Version