Merge pull request #740 from nrgraham23/environment_java_bindings
Java Environment Variable Bindings
Этот коммит содержится в:
Коммит
1631ad7d63
@ -31,6 +31,8 @@ typedef struct {
|
||||
jmethodID CartParmsInit;
|
||||
jclass ShiftParmsClass;
|
||||
jmethodID ShiftParmsInit;
|
||||
jclass VersionClass;
|
||||
jmethodID VersionInit;
|
||||
jclass GraphParmsClass;
|
||||
jmethodID GraphParmsInit;
|
||||
jclass DistGraphNeighborsClass;
|
||||
|
@ -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);
|
||||
@ -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)
|
||||
{
|
||||
@ -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)
|
||||
{
|
||||
|
@ -394,6 +394,8 @@ static
|
||||
ERR_WIN = c.ERR_WIN;
|
||||
ERR_LASTCODE = c.ERR_LASTCODE;
|
||||
ERR_SYSRESOURCE = c.ERR_SYSRESOURCE;
|
||||
|
||||
initVersion();
|
||||
}
|
||||
|
||||
private static native Int2 newInt2();
|
||||
@ -401,6 +403,7 @@ 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
|
||||
{
|
||||
@ -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}.
|
||||
|
@ -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
|
||||
@ -56,6 +58,7 @@ JAVA_SRC_FILES = \
|
||||
Status.java \
|
||||
Struct.java \
|
||||
UserFunction.java \
|
||||
Version.java \
|
||||
Win.java
|
||||
|
||||
EXTRA_DIST = $(JAVA_SRC_FILES)
|
||||
@ -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.
|
||||
|
68
ompi/mpi/java/java/Version.java
Обычный файл
68
ompi/mpi/java/java/Version.java
Обычный файл
@ -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;
|
||||
|
||||
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
|
Загрузка…
Ссылка в новой задаче
Block a user