Merge pull request #1176 from igor-ivanov/pr/oshmem-rm-java
oshmem: Remove JAVA support
Этот коммит содержится в:
Коммит
a25cf8065d
1
README
1
README
@ -1561,7 +1561,6 @@ Here's how we apply those rules specifically to Open MPI:
|
||||
* libmpi_cxx
|
||||
* libmpi_java
|
||||
* liboshmem
|
||||
* liboshmem_java
|
||||
|
||||
===========================================================================
|
||||
|
||||
|
1
VERSION
1
VERSION
@ -91,7 +91,6 @@ libopen_rte_so_version=0:0:0
|
||||
libopen_pal_so_version=0:0:0
|
||||
libmpi_java_so_version=0:0:0
|
||||
liboshmem_so_version=0:0:0
|
||||
liboshmem_java_so_version=0:0:0
|
||||
|
||||
# "Common" components install standalone libraries that are run-time
|
||||
# linked by one or more components. So they need to be versioned as
|
||||
|
@ -1,101 +0,0 @@
|
||||
dnl -*- shell-script -*-
|
||||
dnl
|
||||
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
||||
dnl University Research and Technology
|
||||
dnl Corporation. All rights reserved.
|
||||
dnl Copyright (c) 2004-2006 The University of Tennessee and The University
|
||||
dnl of Tennessee Research Foundation. All rights
|
||||
dnl reserved.
|
||||
dnl Copyright (c) 2004-2008 High Performance Computing Center Stuttgart,
|
||||
dnl University of Stuttgart. All rights reserved.
|
||||
dnl Copyright (c) 2004-2006 The Regents of the University of California.
|
||||
dnl All rights reserved.
|
||||
dnl Copyright (c) 2006-2012 Los Alamos National Security, LLC. All rights
|
||||
dnl reserved.
|
||||
dnl Copyright (c) 2007-2012 Oracle and/or its affiliates. All rights reserved.
|
||||
dnl Copyright (c) 2008-2012 Cisco Systems, Inc. All rights reserved.
|
||||
dnl Copyright (c) 2015 Research Organization for Information Science
|
||||
dnl and Technology (RIST). All rights reserved.
|
||||
dnl $COPYRIGHT$
|
||||
dnl
|
||||
dnl Additional copyrights may follow
|
||||
dnl
|
||||
dnl $HEADER$
|
||||
dnl
|
||||
|
||||
# This macro is necessary to get the title to be displayed first. :-)
|
||||
AC_DEFUN([OSHMEM_SETUP_JAVA_BINDINGS_BANNER],[
|
||||
opal_show_subtitle "Java OSHMEM bindings"
|
||||
])
|
||||
|
||||
# OSHMEM_SETUP_JAVA_BINDINGS()
|
||||
# ----------------
|
||||
# Do everything required to setup the Java OSHMEM bindings. Safe to AC_REQUIRE
|
||||
# this macro.
|
||||
AC_DEFUN([OSHMEM_SETUP_JAVA_BINDINGS],[
|
||||
# must have Java setup
|
||||
AC_REQUIRE([OPAL_SETUP_JAVA])
|
||||
|
||||
AC_REQUIRE([OSHMEM_SETUP_JAVA_BINDINGS_BANNER])
|
||||
|
||||
AC_MSG_CHECKING([if want Java bindings])
|
||||
AC_ARG_ENABLE(oshmem-java,
|
||||
AC_HELP_STRING([--enable-oshmem-java],
|
||||
[enable Java OSHMEM bindings (default: disabled)]))
|
||||
|
||||
# check for required support
|
||||
if test "$opal_java_happy" = "no" && test "$enable_oshmem_java" = "yes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
AC_MSG_WARN([Java bindings requested but no Java support found])
|
||||
AC_MSG_ERROR([cannot continue])
|
||||
fi
|
||||
|
||||
# Only build the Java bindings if requested
|
||||
if test "$opal_java_happy" = "yes" && test "$enable_oshmem_java" = "yes"; then
|
||||
AC_MSG_RESULT([yes])
|
||||
WANT_OSHMEM_JAVA_SUPPORT=1
|
||||
AC_MSG_CHECKING([if shared libraries are enabled])
|
||||
AS_IF([test "$enable_shared" != "yes"],
|
||||
[AC_MSG_RESULT([no])
|
||||
AC_MSG_WARN([Java bindings cannot be built without shared libraries])
|
||||
AC_MSG_WARN([Please reconfigure with --enable-shared])
|
||||
AC_MSG_ERROR([Cannot continue])],
|
||||
[AC_MSG_RESULT([yes])])
|
||||
# must have Java support
|
||||
AC_MSG_CHECKING([if Java support was found])
|
||||
AS_IF([test "$opal_java_happy" = "yes"],
|
||||
[AC_MSG_RESULT([yes])],
|
||||
[AC_MSG_WARN([Java OSHMEM bindings requested, but Java support was not found])
|
||||
AC_MSG_WARN([Please reconfigure the --with-jdk options to where Java])
|
||||
AC_MSG_WARN([support can be found])
|
||||
AC_MSG_ERROR([Cannot continue])])
|
||||
|
||||
# Mac Java requires this file (i.e., some other Java-related
|
||||
# header file needs this file, so we need to check for
|
||||
# it/include it in our sources when compiling on Mac).
|
||||
AC_CHECK_HEADERS([TargetConditionals.h])
|
||||
else
|
||||
AC_MSG_RESULT([no])
|
||||
WANT_OSHMEM_JAVA_SUPPORT=0
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([OSHMEM_WANT_JAVA_BINDINGS], [$WANT_OSHMEM_JAVA_SUPPORT],
|
||||
[do we want java oshmem bindings])
|
||||
AM_CONDITIONAL(OSHMEM_WANT_JAVA_BINDINGS, test "$WANT_OSHMEM_JAVA_SUPPORT" = "1")
|
||||
|
||||
# Are we happy?
|
||||
AS_IF([test "$WANT_OSHMEM_JAVA_SUPPORT" = "1"],
|
||||
[AC_MSG_WARN([******************************************************])
|
||||
AC_MSG_WARN([*** Java OSHMEM bindings are provided on a provisional])
|
||||
AC_MSG_WARN([*** basis. They are NOT part of the current or])
|
||||
AC_MSG_WARN([*** proposed OSHMEM standard. Continued inclusion of])
|
||||
AC_MSG_WARN([*** the Java OSHMEM bindings OSHMEM is contingent])
|
||||
AC_MSG_WARN([*** upon user interest and developer support.])
|
||||
AC_MSG_WARN([******************************************************])
|
||||
])
|
||||
|
||||
AC_CONFIG_FILES([
|
||||
oshmem/shmem/java/Makefile
|
||||
oshmem/shmem/java/java/Makefile
|
||||
oshmem/shmem/java/c/Makefile
|
||||
])
|
||||
])
|
@ -136,8 +136,7 @@ m4_ifdef([project_ompi],
|
||||
m4_ifdef([project_orte],
|
||||
[AC_SUBST(libopen_rte_so_version)])
|
||||
m4_ifdef([project_oshmem],
|
||||
[AC_SUBST(liboshmem_so_version)
|
||||
AC_SUBST(liboshmem_java_so_version)])
|
||||
[AC_SUBST(liboshmem_so_version)])
|
||||
AC_SUBST(libopen_pal_so_version)
|
||||
# It's icky that we have to hard-code the names of the
|
||||
# common components here. :-( This could probably be done
|
||||
@ -524,7 +523,6 @@ OPAL_CHECK_COMPILER_VERSION_ID
|
||||
##################################
|
||||
# Only needed for OMPI
|
||||
m4_ifdef([project_ompi], [OMPI_SETUP_JAVA_BINDINGS])
|
||||
m4_ifdef([project_oshmem], [OSHMEM_SETUP_JAVA_BINDINGS])
|
||||
|
||||
|
||||
##################################
|
||||
|
@ -1,12 +0,0 @@
|
||||
import shmem.*;
|
||||
|
||||
public class Hello_oshmem
|
||||
{
|
||||
public static void main(String[] args)
|
||||
{
|
||||
ShMem.startPEs(0);
|
||||
int nproc = ShMem.getNumPEs();
|
||||
int proc = ShMem.getMyPE();
|
||||
System.out.println("Hello, world, I am "+ proc +" of "+ nproc);
|
||||
}
|
||||
}
|
@ -53,8 +53,7 @@ EXAMPLES = \
|
||||
hello_oshmem \
|
||||
hello_oshmemfh \
|
||||
Hello.class \
|
||||
Hello_oshmem.class \
|
||||
ring_c \
|
||||
ring_c \
|
||||
ring_cxx \
|
||||
ring_mpifh \
|
||||
ring_usempi \
|
||||
@ -62,17 +61,12 @@ EXAMPLES = \
|
||||
ring_oshmem \
|
||||
ring_oshmemfh \
|
||||
Ring.class \
|
||||
Ring_oshmem.class \
|
||||
connectivity_c \
|
||||
oshmem_shmalloc \
|
||||
oshmem_circular_shift \
|
||||
oshmem_circular_shift.class \
|
||||
oshmem_max_reduction \
|
||||
oshmem_max_reduction.class \
|
||||
oshmem_strided_puts \
|
||||
oshmem_strided_puts.class \
|
||||
oshmem_symmetric_data \
|
||||
oshmem_symmetric_data.class
|
||||
oshmem_symmetric_data
|
||||
|
||||
|
||||
# Default target. Always build the C MPI examples. Only build the
|
||||
@ -122,14 +116,6 @@ oshmem:
|
||||
$(MAKE) hello_oshmemfh; \
|
||||
$(MAKE) ring_oshmemfh; \
|
||||
fi
|
||||
@ if oshmem_info --parsable | grep bindings:java:yes >/dev/null; then \
|
||||
$(MAKE) Hello_oshmem.class; \
|
||||
$(MAKE) Ring_oshmem.class; \
|
||||
$(MAKE) oshmem_circular_shift.class; \
|
||||
$(MAKE) oshmem_max_reduction.class; \
|
||||
$(MAKE) oshmem_strided_puts.class; \
|
||||
$(MAKE) oshmem_symmetric_data.class; \
|
||||
fi
|
||||
|
||||
# The usual "clean" target
|
||||
|
||||
@ -162,35 +148,23 @@ hello_oshmem: hello_oshmem_c.c
|
||||
$(SHMEMCC) $(CFLAGS) $? -o $@
|
||||
hello_oshmemfh: hello_oshmemfh.f90
|
||||
$(SHMEMFC) $(FCFLAGS) $? -o $@
|
||||
Hello_oshmem.class: Hello_oshmem.java
|
||||
$(JAVAC) Hello_oshmem.java
|
||||
|
||||
ring_oshmem: ring_oshmem_c.c
|
||||
$(SHMEMCC) $(CFLAGS) $? -o $@
|
||||
ring_oshmemfh: ring_oshmemfh.f90
|
||||
$(SHMEMFC) $(FCFLAGS) $? -o $@
|
||||
Ring_oshmem.class: Ring_oshmem.java
|
||||
$(JAVAC) Ring_oshmem.java
|
||||
|
||||
oshmem_shmalloc: oshmem_shmalloc.c
|
||||
$(SHMEMCC) $(CCFLAGS) $? -o $@
|
||||
|
||||
oshmem_circular_shift: oshmem_circular_shift.c
|
||||
$(SHMEMCC) $(CFLAGS) $? -o $@
|
||||
oshmem_circular_shift.class: oshmem_circular_shift.java
|
||||
$(JAVAC) oshmem_circular_shift.java
|
||||
|
||||
oshmem_max_reduction: oshmem_max_reduction.c
|
||||
$(SHMEMCC) $(CFLAGS) $? -o $@
|
||||
oshmem_max_reduction.class: oshmem_max_reduction.java
|
||||
$(JAVAC) oshmem_max_reduction.java
|
||||
|
||||
oshmem_strided_puts: oshmem_strided_puts.c
|
||||
$(SHMEMCC) $(CFLAGS) $? -o $@
|
||||
oshmem_strided_puts.class: oshmem_strided_puts.java
|
||||
$(JAVAC) oshmem_strided_puts.java
|
||||
|
||||
oshmem_symmetric_data: oshmem_symmetric_data.c
|
||||
$(SHMEMCC) $(CFLAGS) $? -o $@
|
||||
oshmem_symmetric_data.class: oshmem_symmetric_data.java
|
||||
$(JAVAC) oshmem_symmetric_data.java
|
||||
|
@ -54,10 +54,4 @@ EXTRA_DIST += \
|
||||
examples/oshmem_strided_puts.c \
|
||||
examples/oshmem_symmetric_data.c \
|
||||
examples/Hello.java \
|
||||
examples/Ring.java \
|
||||
examples/Hello_oshmem.java \
|
||||
examples/Ring_oshmem.java \
|
||||
examples/oshmem_circular_shift.java \
|
||||
examples/oshmem_max_reduction.java \
|
||||
examples/oshmem_strided_puts.java \
|
||||
examples/oshmem_symmetric_data.java
|
||||
examples/Ring.java
|
||||
|
@ -1,54 +0,0 @@
|
||||
import shmem.*;
|
||||
|
||||
public class Ring_oshmem
|
||||
{
|
||||
public static void main(String[] args) throws ShMemException
|
||||
{
|
||||
ShMem.startPEs(0);
|
||||
int nproc = ShMem.getNumPEs();
|
||||
int proc = ShMem.getMyPE();
|
||||
Addr rbuf = new Addr(4); // One integer value.
|
||||
rbuf.putInt(-1);
|
||||
int message = 10;
|
||||
|
||||
// Calculate the PE number of the next process in the ring. Use the
|
||||
// modulus operator so that the last process "wraps around" to PE 0.
|
||||
int next = (proc + 1) % nproc;
|
||||
|
||||
if(proc == 0)
|
||||
{
|
||||
System.out.println("Process 0 puts message "+ message +" to "+
|
||||
next +" ("+ nproc +" processes in ring)");
|
||||
|
||||
rbuf.putInt(message, next);
|
||||
}
|
||||
|
||||
// Pass the message around the ring. The exit mechanism works as
|
||||
// follows: the message (a positive integer) is passed around the
|
||||
// ring. Each time it passes PE 0, it is decremented. When each
|
||||
// processes receives a message containing a 0 value, it passes the
|
||||
// message on to the next process and then quits. By passing the 0
|
||||
// message first, every process gets the 0 message and can quit
|
||||
// normally.
|
||||
|
||||
while(message > 0)
|
||||
{
|
||||
rbuf.waitUntilInt(ShMem.CMP_EQ, message);
|
||||
|
||||
if(proc == 0)
|
||||
{
|
||||
message--;
|
||||
System.out.println("Process 0 decremented value: "+ message);
|
||||
}
|
||||
|
||||
rbuf.putInt(message, next);
|
||||
|
||||
if(proc != 0)
|
||||
message--;
|
||||
}
|
||||
|
||||
// All done
|
||||
rbuf.free();
|
||||
System.out.println("Process "+ proc +" exiting");
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
import shmem.*;
|
||||
|
||||
public class oshmem_circular_shift
|
||||
{
|
||||
public static void main(String[] args) throws ShMemException
|
||||
{
|
||||
ShMem.startPEs(0);
|
||||
|
||||
int numPEs = ShMem.getNumPEs(),
|
||||
myPE = ShMem.getMyPE(),
|
||||
peer = (myPE + 1) % numPEs;
|
||||
|
||||
int[] aaa = new int[1];
|
||||
Addr bbb = new Addr(4);
|
||||
|
||||
System.out.println("Process "+ myPE +" gets message from "+
|
||||
peer +" ("+ numPEs +" processes in ring)");
|
||||
|
||||
bbb.getInt(aaa, peer);
|
||||
ShMem.barrierAll();
|
||||
bbb.free();
|
||||
System.out.println("Process "+ myPE +" exiting");
|
||||
}
|
||||
}
|
@ -1,43 +0,0 @@
|
||||
import shmem.*;
|
||||
import java.nio.*;
|
||||
|
||||
public class oshmem_max_reduction
|
||||
{
|
||||
private static final int N = 3;
|
||||
|
||||
public static void main(String[] args) throws ShMemException
|
||||
{
|
||||
ShMem.startPEs(0);
|
||||
|
||||
int numPEs = ShMem.getNumPEs(),
|
||||
myPE = ShMem.getMyPE();
|
||||
|
||||
Addr src = new Addr(8 * N), // long is 8 bytes.
|
||||
dst = new Addr(8 * N),
|
||||
pWrk = new Addr(8 * ShMem.REDUCE_SYNC_SIZE);
|
||||
PSync pSync = new PSync(ShMem.BCAST_SYNC_SIZE);
|
||||
|
||||
LongBuffer srcBuf = src.asLongBuffer(),
|
||||
dstBuf = dst.asLongBuffer();
|
||||
|
||||
for(int i = 0; i < N; i++)
|
||||
srcBuf.put(i, myPE + i);
|
||||
|
||||
ShMem.barrierAll();
|
||||
dst.maxToAllLong(src, N, 0, 0, numPEs, pWrk, pSync);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(myPE +"/"+ numPEs +" dst =");
|
||||
|
||||
for(int i = 0; i < N; i++)
|
||||
sb.append(" "+ dstBuf.get(i));
|
||||
|
||||
sb.append("\n");
|
||||
System.out.print(sb);
|
||||
|
||||
src.free();
|
||||
dst.free();
|
||||
pWrk.free();
|
||||
pSync.free();
|
||||
}
|
||||
}
|
@ -1,33 +0,0 @@
|
||||
import shmem.*;
|
||||
import java.nio.*;
|
||||
|
||||
public class oshmem_strided_puts
|
||||
{
|
||||
public static void main(String[] args) throws ShMemException
|
||||
{
|
||||
ShMem.startPEs(0);
|
||||
int me = ShMem.getMyPE();
|
||||
|
||||
short[] source = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
|
||||
Addr target = new Addr(2 * 10); // short is 2 bytes.
|
||||
|
||||
if(me == 0)
|
||||
{
|
||||
/* put 10 words into target on PE 1 */
|
||||
target.iPutShort(source, 1, 2, 5, 1);
|
||||
}
|
||||
|
||||
ShMem.barrierAll(); // sync sender and receiver
|
||||
|
||||
if(me == 1)
|
||||
{
|
||||
ShortBuffer buf = target.asShortBuffer();
|
||||
System.out.printf("target on PE %d is %d %d %d %d %d\n", me,
|
||||
buf.get(0), buf.get(1), buf.get(2),
|
||||
buf.get(3), buf.get(4));
|
||||
}
|
||||
|
||||
ShMem.barrierAll(); // sync before exiting
|
||||
target.free();
|
||||
}
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
import shmem.*;
|
||||
import java.nio.*;
|
||||
|
||||
public class oshmem_symmetric_data
|
||||
{
|
||||
private static final int SIZE = 16;
|
||||
|
||||
public static void main(String[] args) throws ShMemException
|
||||
{
|
||||
ShMem.startPEs(0);
|
||||
|
||||
int numPE = ShMem.getNumPEs(),
|
||||
myPE = ShMem.getMyPE();
|
||||
|
||||
int[] source = new int[SIZE];
|
||||
Addr target = new Addr(4 * SIZE); // int is 4 bytes
|
||||
|
||||
if(myPE == 0)
|
||||
{
|
||||
// initialize array
|
||||
for(int i = 0; i < SIZE; i++)
|
||||
source[i] = i;
|
||||
|
||||
// local, not symmetric
|
||||
// static makes it symmetric
|
||||
// put "size" words into target on each PE
|
||||
for(int i = 1; i < numPE; i++)
|
||||
target.putInt(source, i);
|
||||
}
|
||||
|
||||
ShMem.barrierAll(); // sync sender and receiver
|
||||
|
||||
if(myPE != 0)
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Target on PE "+ myPE +" is \t");
|
||||
IntBuffer buf = target.asIntBuffer();
|
||||
|
||||
for(int i = 0; i < SIZE; i++)
|
||||
sb.append(buf.get(i) +" \t");
|
||||
|
||||
sb.append('\n');
|
||||
System.out.print(sb);
|
||||
}
|
||||
|
||||
ShMem.barrierAll(); // sync before exiting
|
||||
target.free();
|
||||
}
|
||||
}
|
@ -43,8 +43,7 @@ SUBDIRS += \
|
||||
$(MCA_oshmem_FRAMEWORKS_SUBDIRS) \
|
||||
$(MCA_oshmem_FRAMEWORK_COMPONENT_STATIC_SUBDIRS) \
|
||||
. \
|
||||
$(MCA_oshmem_FRAMEWORK_COMPONENT_DSO_SUBDIRS) \
|
||||
shmem/java
|
||||
$(MCA_oshmem_FRAMEWORK_COMPONENT_DSO_SUBDIRS)
|
||||
endif
|
||||
|
||||
DIST_SUBDIRS = \
|
||||
@ -52,8 +51,7 @@ DIST_SUBDIRS = \
|
||||
shmem/c \
|
||||
shmem/fortran \
|
||||
$(MCA_oshmem_FRAMEWORKS_SUBDIRS) \
|
||||
$(MCA_oshmem_FRAMEWORK_COMPONENT_ALL_SUBDIRS) \
|
||||
shmem/java
|
||||
$(MCA_oshmem_FRAMEWORK_COMPONENT_ALL_SUBDIRS)
|
||||
|
||||
# Build The main OSHMEM library, but only if we're building OSHMEM
|
||||
lib_LTLIBRARIES =
|
||||
|
@ -1 +0,0 @@
|
||||
SUBDIRS = java c
|
@ -1,33 +0,0 @@
|
||||
# -*- makefile -*-
|
||||
#
|
||||
# Copyright (c) 2011-2013 Cisco Systems, Inc. All rights reserved.
|
||||
# Copyright (c) 2012 Oracle and/or its affiliates. All rights reserved.
|
||||
# $COPYRIGHT$
|
||||
#
|
||||
# Additional copyrights may follow
|
||||
#
|
||||
# $HEADER$
|
||||
#
|
||||
|
||||
if OMPI_WANT_JAVA_BINDINGS
|
||||
|
||||
# Get the include files that were generated from the .java source files
|
||||
AM_CPPFLAGS = -I$(OSHMEM_TOP_BUILDDIR)/oshmem/shmem/java/java $(OPAL_JDK_CPPFLAGS) -DOPAL_DYN_LIB_SUFFIX=\"$(OPAL_DYN_LIB_SUFFIX)\"
|
||||
|
||||
headers = \
|
||||
shmemJava.h
|
||||
oshmemdir = $(oshmemincludedir)/oshmem/shmem/java
|
||||
oshmem_HEADERS = \
|
||||
$(headers)
|
||||
|
||||
lib_LTLIBRARIES = liboshmem_java.la
|
||||
liboshmem_java_la_SOURCES = \
|
||||
shmem_Addr.c \
|
||||
shmem_Constant.c \
|
||||
shmem_PSync.c \
|
||||
shmem_ShMem.c
|
||||
|
||||
liboshmem_java_la_LIBADD = $(OSHMEM_TOP_BUILDDIR)/oshmem/liboshmem.la
|
||||
liboshmem_java_la_LDFLAGS = -version-info $(liboshmem_java_so_version)
|
||||
|
||||
endif
|
@ -1,99 +0,0 @@
|
||||
#ifndef _SHMEMJAVA_H_
|
||||
#define _SHMEMJAVA_H_
|
||||
|
||||
#include "shmem.h"
|
||||
#include "opal/class/opal_free_list.h"
|
||||
|
||||
typedef struct {
|
||||
jfieldID AddrHandle;
|
||||
jclass ExceptionClass;
|
||||
} shmem_java_globals_t;
|
||||
|
||||
extern shmem_java_globals_t shmem_java;
|
||||
|
||||
typedef struct shmem_java_buffer_t
|
||||
{
|
||||
opal_free_list_item_t super;
|
||||
void *buffer;
|
||||
} shmem_java_buffer_t;
|
||||
|
||||
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(shmem_java_buffer_t);
|
||||
|
||||
void* shmem_java_getBuffer(shmem_java_buffer_t **item, JNIEnv *env, int size);
|
||||
void shmem_java_releaseBuffer(void *ptr, shmem_java_buffer_t *item);
|
||||
|
||||
jbyte* shmem_java_getReadByteArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jbyteArray array, int off, int len);
|
||||
jshort* shmem_java_getReadShortArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jshortArray array, int off, int len);
|
||||
jint* shmem_java_getReadIntArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jintArray array, int off, int len);
|
||||
jlong* shmem_java_getReadLongArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jlongArray array, int off, int len);
|
||||
jfloat* shmem_java_getReadFloatArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jfloatArray array, int off, int len);
|
||||
jdouble* shmem_java_getReadDoubleArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jdoubleArray array, int off, int len);
|
||||
|
||||
void shmem_java_releaseWriteByteArray(
|
||||
void *ptr, shmem_java_buffer_t *item,
|
||||
JNIEnv *env, jbyteArray array, int off, int len);
|
||||
void shmem_java_releaseWriteShortArray(
|
||||
void *ptr, shmem_java_buffer_t *item,
|
||||
JNIEnv *env, jshortArray array, int off, int len);
|
||||
void shmem_java_releaseWriteIntArray(
|
||||
void *ptr, shmem_java_buffer_t *item,
|
||||
JNIEnv *env, jintArray array, int off, int len);
|
||||
void shmem_java_releaseWriteLongArray(
|
||||
void *ptr, shmem_java_buffer_t *item,
|
||||
JNIEnv *env, jlongArray array, int off, int len);
|
||||
void shmem_java_releaseWriteFloatArray(
|
||||
void *ptr, shmem_java_buffer_t *item,
|
||||
JNIEnv *env, jfloatArray array, int off, int len);
|
||||
void shmem_java_releaseWriteDoubleArray(
|
||||
void *ptr, shmem_java_buffer_t *item,
|
||||
JNIEnv *env, jdoubleArray array, int off, int len);
|
||||
|
||||
void* shmem_java_iGetBuffer(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
int stride, int len, int elementSize);
|
||||
|
||||
jshort* shmem_java_iGetReadShortArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jshortArray array, int off, int stride, int len);
|
||||
jint* shmem_java_iGetReadIntArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jintArray array, int off, int stride, int len);
|
||||
jlong* shmem_java_iGetReadLongArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jlongArray array, int off, int stride, int len);
|
||||
jfloat* shmem_java_iGetReadFloatArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jfloatArray array, int off, int stride, int len);
|
||||
jdouble* shmem_java_iGetReadDoubleArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jdoubleArray array, int off, int stride, int len);
|
||||
|
||||
void shmem_java_iReleaseWriteShortArray(
|
||||
jshort *ptr, shmem_java_buffer_t *item, JNIEnv *env,
|
||||
jshortArray array, int off, int stride, int len);
|
||||
void shmem_java_iReleaseWriteIntArray(
|
||||
jint *ptr, shmem_java_buffer_t *item, JNIEnv *env,
|
||||
jintArray array, int off, int stride, int len);
|
||||
void shmem_java_iReleaseWriteLongArray(
|
||||
jlong *ptr, shmem_java_buffer_t *item, JNIEnv *env,
|
||||
jlongArray array, int off, int stride, int len);
|
||||
void shmem_java_iReleaseWriteFloatArray(
|
||||
jfloat *ptr, shmem_java_buffer_t *item, JNIEnv *env,
|
||||
jfloatArray array, int off, int stride, int len);
|
||||
void shmem_java_iReleaseWriteDoubleArray(
|
||||
jdouble *ptr, shmem_java_buffer_t *item, JNIEnv *env,
|
||||
jdoubleArray array, int off, int stride, int len);
|
||||
|
||||
#endif /* _SHMEMJAVA_H_ */
|
@ -1,951 +0,0 @@
|
||||
#include "oshmem_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#ifdef HAVE_TARGETCONDITIONALS_H
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
#include "shmem.h"
|
||||
#include "shmem_Addr.h"
|
||||
#include "shmemJava.h"
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_init(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
shmem_java.AddrHandle = (*env)->GetFieldID(env, clazz, "handle", "J");
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_shmem_Addr_malloc(
|
||||
JNIEnv *env, jobject jthis, jint size)
|
||||
{
|
||||
void *addr = shmalloc(size);
|
||||
(*env)->SetLongField(env, jthis, shmem_java.AddrHandle, (jlong)addr);
|
||||
return addr ? (*env)->NewDirectByteBuffer(env, addr, size) : NULL;
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_shmem_Addr_memalign(
|
||||
JNIEnv *env, jobject jthis, jint align, jint size)
|
||||
{
|
||||
void *addr = shmemalign(align, size);
|
||||
(*env)->SetLongField(env, jthis, shmem_java.AddrHandle, (jlong)addr);
|
||||
return addr ? (*env)->NewDirectByteBuffer(env, addr, size) : NULL;
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_shmem_Addr_realloc(
|
||||
JNIEnv *env, jobject jthis, jlong jaddr, jint size)
|
||||
{
|
||||
void *addr = shrealloc((void*)jaddr, size);
|
||||
(*env)->SetLongField(env, jthis, shmem_java.AddrHandle, (jlong)addr);
|
||||
return addr ? (*env)->NewDirectByteBuffer(env, addr, size) : NULL;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_shmem_Addr_isAccessible(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint pe)
|
||||
{
|
||||
return shmem_addr_accessible((void*)addr, pe) ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_free(
|
||||
JNIEnv *env, jobject jthis, jlong addr)
|
||||
{
|
||||
shfree((void*)addr);
|
||||
}
|
||||
|
||||
JNIEXPORT jobject JNICALL Java_shmem_Addr_getAddr(
|
||||
JNIEnv *env, jobject jthis, jobject buff, jint pe, jobject obj)
|
||||
{
|
||||
void *addr = (*env)->GetDirectBufferAddress(env, buff);
|
||||
jlong size = (*env)->GetDirectBufferCapacity(env, buff);
|
||||
void *ptr = shmem_ptr(addr, pe);
|
||||
(*env)->SetLongField(env, obj, shmem_java.AddrHandle, (jlong)ptr);
|
||||
return ptr ? (*env)->NewDirectByteBuffer(env, ptr, size) : NULL;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putByte(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jbyte value, jint pe)
|
||||
{
|
||||
shmem_char_p((char*)addr, (char)value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putShort(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jshort value, jint pe)
|
||||
{
|
||||
shmem_int16_p((int16_t*)addr, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putInt(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint value, jint pe)
|
||||
{
|
||||
shmem_int32_p((int32_t*)addr, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putLong(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jlong value, jint pe)
|
||||
{
|
||||
shmem_int64_p((int64_t*)addr, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putFloat(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jfloat value, jint pe)
|
||||
{
|
||||
shmem_float_p((float*)addr, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putDouble(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jdouble value, jint pe)
|
||||
{
|
||||
shmem_double_p((double*)addr, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putByteBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint len, jint pe)
|
||||
{
|
||||
void *source = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_char_put((char*)addr, source, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putByteArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jbyteArray array, jint off, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *source = shmem_java_getReadByteArray(&item, env, array, off, len);
|
||||
shmem_char_put((char*)addr, source, len, pe);
|
||||
shmem_java_releaseBuffer(source, item);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putShortBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint len, jint pe)
|
||||
{
|
||||
void *source = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_put16((void*)addr, source, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putShortArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jshortArray array, jint off, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *source = shmem_java_getReadShortArray(&item, env, array, off, len);
|
||||
shmem_put16((void*)addr, source, len, pe);
|
||||
shmem_java_releaseBuffer(source, item);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putIntBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint len, jint pe)
|
||||
{
|
||||
void *source = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_put32((void*)addr, source, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putIntArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jintArray array, jint off, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *source = shmem_java_getReadIntArray(&item, env, array, off, len);
|
||||
shmem_put32((void*)addr, source, len, pe);
|
||||
shmem_java_releaseBuffer(source, item);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putLongBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint len, jint pe)
|
||||
{
|
||||
void *source = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_put64((void*)addr, source, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putLongArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jlongArray array, jint off, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *source = shmem_java_getReadLongArray(&item, env, array, off, len);
|
||||
shmem_put64((void*)addr, source, len, pe);
|
||||
shmem_java_releaseBuffer(source, item);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putFloatBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint len, jint pe)
|
||||
{
|
||||
void *source = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_float_put((float*)addr, source, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putFloatArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jfloatArray array, jint off, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *source = shmem_java_getReadFloatArray(&item, env, array, off, len);
|
||||
shmem_float_put((float*)addr, source, len, pe);
|
||||
shmem_java_releaseBuffer(source, item);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putDoubleBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint len, jint pe)
|
||||
{
|
||||
void *source = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_double_put((double*)addr, source, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_putDoubleArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jdoubleArray array, jint off, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *source = shmem_java_getReadDoubleArray(&item, env, array, off, len);
|
||||
shmem_double_put((double*)addr, source, len, pe);
|
||||
shmem_java_releaseBuffer(source, item);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iPutShortBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
void *source = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_iput16((void*)addr, source, tst, sst, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iPutShortArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jshortArray array, jint off, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *source = shmem_java_iGetReadShortArray(&item,env,array,off,sst,len);
|
||||
shmem_iput16((void*)addr, source, tst, sst, len, pe);
|
||||
shmem_java_releaseBuffer(source, item);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iPutIntBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
void *source = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_iput32((void*)addr, source, tst, sst, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iPutIntArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jintArray array, jint off, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *source = shmem_java_iGetReadIntArray(&item,env,array,off,sst,len);
|
||||
shmem_iput32((void*)addr, source, tst, sst, len, pe);
|
||||
shmem_java_releaseBuffer(source, item);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iPutLongBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
void *source = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_iput64((void*)addr, source, tst, sst, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iPutLongArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jlongArray array, jint off, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *source = shmem_java_iGetReadLongArray(&item,env,array,off,sst,len);
|
||||
shmem_iput64((void*)addr, source, tst, sst, len, pe);
|
||||
shmem_java_releaseBuffer(source, item);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iPutFloatBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
void *source = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_float_iput((float*)addr, source, tst, sst, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iPutFloatArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jfloatArray array, jint off, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *source = shmem_java_iGetReadFloatArray(&item,env,array,off,sst,len);
|
||||
shmem_float_iput((float*)addr, source, tst, sst, len, pe);
|
||||
shmem_java_releaseBuffer(source, item);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iPutDoubleBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
void *source = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_double_iput((double*)addr, source, tst, sst, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iPutDoubleArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jdoubleArray array, jint off, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *source = shmem_java_iGetReadDoubleArray(&item,env,array,off,sst,len);
|
||||
shmem_double_iput((double*)addr, source, tst, sst, len, pe);
|
||||
shmem_java_releaseBuffer(source, item);
|
||||
}
|
||||
|
||||
JNIEXPORT jbyte JNICALL Java_shmem_Addr_getByte(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint pe)
|
||||
{
|
||||
return shmem_char_g((char*)addr, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jshort JNICALL Java_shmem_Addr_getShort(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint pe)
|
||||
{
|
||||
return shmem_int16_g((int16_t*)addr, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_shmem_Addr_getInt(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint pe)
|
||||
{
|
||||
return shmem_int32_g((int32_t*)addr, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_shmem_Addr_getLong(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint pe)
|
||||
{
|
||||
return shmem_int64_g((int64_t*)addr, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jfloat JNICALL Java_shmem_Addr_getFloat(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint pe)
|
||||
{
|
||||
return shmem_float_g((float*)addr, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jdouble JNICALL Java_shmem_Addr_getDouble(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint pe)
|
||||
{
|
||||
return shmem_double_g((double*)addr, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_getByteBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint len, jint pe)
|
||||
{
|
||||
void *target = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_char_get(target, (char*)addr, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_getByteArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jbyteArray array, jint off, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *target = shmem_java_getBuffer(&item, env, len);
|
||||
shmem_char_get(target, (char*)addr, len, pe);
|
||||
shmem_java_releaseWriteByteArray(target, item, env, array, off, len);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_getShortBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint len, jint pe)
|
||||
{
|
||||
void *target = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_get16(target, (void*)addr, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_getShortArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jshortArray array, jint off, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *target = shmem_java_getBuffer(&item, env, len * 2);
|
||||
shmem_get16(target, (void*)addr, len, pe);
|
||||
shmem_java_releaseWriteShortArray(target, item, env, array, off, len);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_getIntBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint len, jint pe)
|
||||
{
|
||||
void *target = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_get32(target, (void*)addr, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_getIntArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jintArray array, jint off, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *target = shmem_java_getBuffer(&item, env, len * 4);
|
||||
shmem_get32(target, (void*)addr, len, pe);
|
||||
shmem_java_releaseWriteIntArray(target, item, env, array, off, len);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_getLongBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint len, jint pe)
|
||||
{
|
||||
void *target = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_get64(target, (void*)addr, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_getLongArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jlongArray array, jint off, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *target = shmem_java_getBuffer(&item, env, len * 8);
|
||||
shmem_get64(target, (void*)addr, len, pe);
|
||||
shmem_java_releaseWriteLongArray(target, item, env, array, off, len);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_getFloatBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint len, jint pe)
|
||||
{
|
||||
void *target = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_float_get(target, (float*)addr, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_getFloatArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jfloatArray array, jint off, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *target = shmem_java_getBuffer(&item, env, len * 4);
|
||||
shmem_float_get(target, (float*)addr, len, pe);
|
||||
shmem_java_releaseWriteFloatArray(target, item, env, array, off, len);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_getDoubleBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint len, jint pe)
|
||||
{
|
||||
void *target = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_double_get(target, (double*)addr, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_getDoubleArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jdoubleArray array, jint off, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *target = shmem_java_getBuffer(&item, env, len * 8);
|
||||
shmem_double_get(target, (double*)addr, len, pe);
|
||||
shmem_java_releaseWriteDoubleArray(target, item, env, array, off, len);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iGetShortBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
void *target = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_iget16(target, (void*)addr, tst, sst, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iGetShortArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jshortArray array, jint off, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *target = shmem_java_iGetBuffer(&item, env, tst, len, 2);
|
||||
shmem_iget16(target, (void*)addr, tst, sst, len, pe);
|
||||
shmem_java_iReleaseWriteShortArray(target, item, env, array, off, tst, len);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iGetIntBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
void *target = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_iget32(target, (void*)addr, tst, sst, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iGetIntArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jintArray array, jint off, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *target = shmem_java_iGetBuffer(&item, env, tst, len, 4);
|
||||
shmem_iget32(target, (void*)addr, tst, sst, len, pe);
|
||||
shmem_java_iReleaseWriteIntArray(target, item, env, array, off, tst, len);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iGetLongBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
void *target = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_iget64(target, (void*)addr, tst, sst, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iGetLongArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jlongArray array, jint off, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *target = shmem_java_iGetBuffer(&item, env, tst, len, 8);
|
||||
shmem_iget64(target, (void*)addr, tst, sst, len, pe);
|
||||
shmem_java_iReleaseWriteLongArray(target, item, env, array, off, tst, len);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iGetFloatBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
void *target = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_float_iget(target, (float*)addr, tst, sst, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iGetFloatArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jfloatArray array, jint off, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *target = shmem_java_iGetBuffer(&item, env, tst, len, 4);
|
||||
shmem_float_iget(target, (void*)addr, tst, sst, len, pe);
|
||||
shmem_java_iReleaseWriteFloatArray(target, item, env, array, off, tst, len);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iGetDoubleBuffer(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jobject buffer, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
void *target = (*env)->GetDirectBufferAddress(env, buffer);
|
||||
shmem_double_iget(target, (double*)addr, tst, sst, len, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_iGetDoubleArray(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jdoubleArray array, jint off, jint tst, jint sst, jint len, jint pe)
|
||||
{
|
||||
shmem_java_buffer_t *item;
|
||||
void *target = shmem_java_iGetBuffer(&item, env, tst, len, 8);
|
||||
shmem_double_iget(target, (void*)addr, tst, sst, len, pe);
|
||||
shmem_java_iReleaseWriteDoubleArray(target,item, env, array, off, tst, len);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_shmem_Addr_swapInt(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint value, jint pe)
|
||||
{
|
||||
return shmem_int32_swap((int32_t*)addr, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_shmem_Addr_swapLong(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jlong value, jint pe)
|
||||
{
|
||||
return shmem_int64_swap((int64_t*)addr, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jfloat JNICALL Java_shmem_Addr_swapFloat(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jfloat value, jint pe)
|
||||
{
|
||||
return shmem_float_swap((float*)addr, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jdouble JNICALL Java_shmem_Addr_swapDouble(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jdouble value, jint pe)
|
||||
{
|
||||
return shmem_double_swap((double*)addr, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_shmem_Addr_cSwapInt(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint cond, jint value, jint pe)
|
||||
{
|
||||
return shmem_int32_cswap((int32_t*)addr, cond, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_shmem_Addr_cSwapLong(
|
||||
JNIEnv *env, jobject jthis, jlong addr,
|
||||
jlong cond, jlong value, jint pe)
|
||||
{
|
||||
return shmem_int64_cswap((int64_t*)addr, cond, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_shmem_Addr_fAddInt(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint value, jint pe)
|
||||
{
|
||||
return shmem_int32_fadd((int32_t*)addr, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_shmem_Addr_fAddLong(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jlong value, jint pe)
|
||||
{
|
||||
return shmem_int64_fadd((int64_t*)addr, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_shmem_Addr_fIncInt(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint pe)
|
||||
{
|
||||
return shmem_int32_finc((int32_t*)addr, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_shmem_Addr_fIncLong(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint pe)
|
||||
{
|
||||
return shmem_int64_finc((int64_t*)addr, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_addInt(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint value, jint pe)
|
||||
{
|
||||
shmem_int32_add((int32_t*)addr, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_addLong(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jlong value, jint pe)
|
||||
{
|
||||
shmem_int64_add((int64_t*)addr, value, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_incInt(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint pe)
|
||||
{
|
||||
shmem_int32_inc((int32_t*)addr, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_incLong(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint pe)
|
||||
{
|
||||
shmem_int64_inc((int64_t*)addr, pe);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_setLock(
|
||||
JNIEnv *env, jobject jthis, jlong addr)
|
||||
{
|
||||
shmem_set_lock((long*)addr);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_clearLock(
|
||||
JNIEnv *env, jobject jthis, jlong addr)
|
||||
{
|
||||
shmem_clear_lock((long*)addr);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL Java_shmem_Addr_testLock(
|
||||
JNIEnv *env, jobject jthis, jlong addr)
|
||||
{
|
||||
int r = shmem_test_lock((long*)addr);
|
||||
|
||||
if (0 == r) {
|
||||
return JNI_FALSE;
|
||||
} else if (1 == r) {
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
/* Should never get here */
|
||||
opal_output(0, "*** Java lock is neither true nor false; something is very wrong!");
|
||||
abort();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_waitInt(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint value)
|
||||
{
|
||||
shmem_int32_wait((void*)addr, value);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_waitLong(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jlong value)
|
||||
{
|
||||
shmem_int64_wait((void*)addr, value);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_waitUntilInt(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint cmp, jint value)
|
||||
{
|
||||
shmem_int32_wait_until((void*)addr, cmp, value);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_waitUntilLong(
|
||||
JNIEnv *env, jobject jthis, jlong addr, jint cmp, jlong value)
|
||||
{
|
||||
shmem_int64_wait_until((void*)addr, cmp, value);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_broadcast32(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source,
|
||||
jint nlong, jint PE_root, jint PE_start, jint logPE_stride,
|
||||
jint PE_size, jlong pSync)
|
||||
{
|
||||
shmem_broadcast32((void*)target, (void*)source, nlong, PE_root,
|
||||
PE_start, logPE_stride, PE_size, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_broadcast64(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source,
|
||||
jint nlong, jint PE_root, jint PE_start, jint logPE_stride,
|
||||
jint PE_size, jlong pSync)
|
||||
{
|
||||
shmem_broadcast64((void*)target, (void*)source, nlong, PE_root,
|
||||
PE_start, logPE_stride, PE_size, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_collect32(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nlong,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pSync)
|
||||
{
|
||||
shmem_collect32((void*)target, (void*)source, nlong,
|
||||
PE_start, logPE_stride, PE_size, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_collect64(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nlong,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pSync)
|
||||
{
|
||||
shmem_collect64((void*)target, (void*)source, nlong,
|
||||
PE_start, logPE_stride, PE_size, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_fcollect32(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nlong,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pSync)
|
||||
{
|
||||
shmem_fcollect32((void*)target, (void*)source, nlong,
|
||||
PE_start, logPE_stride, PE_size, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_fcollect64(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nlong,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pSync)
|
||||
{
|
||||
shmem_fcollect64((void*)target, (void*)source, nlong,
|
||||
PE_start, logPE_stride, PE_size, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_andToAllShort(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int16_and_to_all((int16_t*)target, (int16_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int16_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_andToAllInt(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int32_and_to_all((int32_t*)target, (int32_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int32_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_andToAllLong(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int64_and_to_all((int64_t*)target, (int64_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int64_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_orToAllShort(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int16_or_to_all((int16_t*)target, (int16_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int16_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_orToAllInt(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int32_or_to_all((int32_t*)target, (int32_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int32_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_orToAllLong(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int64_or_to_all((int64_t*)target, (int64_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int64_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_xorToAllShort(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int16_xor_to_all((int16_t*)target, (int16_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int16_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_xorToAllInt(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int32_xor_to_all((int32_t*)target, (int32_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int32_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_xorToAllLong(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int64_xor_to_all((int64_t*)target, (int64_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int64_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_maxToAllShort(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int16_max_to_all((int16_t*)target, (int16_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int16_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_maxToAllInt(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int32_max_to_all((int32_t*)target, (int32_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int32_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_maxToAllLong(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int64_max_to_all((int64_t*)target, (int64_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int64_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_maxToAllFloat(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_float_max_to_all((float*)target, (float*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (float*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_maxToAllDouble(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_double_max_to_all((double*)target, (double*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (double*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_minToAllShort(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int16_min_to_all((int16_t*)target, (int16_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int16_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_minToAllInt(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int32_min_to_all((int32_t*)target, (int32_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int32_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_minToAllLong(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int64_min_to_all((int64_t*)target, (int64_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int64_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_minToAllFloat(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_float_min_to_all((float*)target, (float*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (float*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_minToAllDouble(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_double_min_to_all((double*)target, (double*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (double*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_sumToAllShort(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int16_sum_to_all((int16_t*)target, (int16_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int16_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_sumToAllInt(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int32_sum_to_all((int32_t*)target, (int32_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int32_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_sumToAllLong(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int64_sum_to_all((int64_t*)target, (int64_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int64_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_sumToAllFloat(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_float_sum_to_all((float*)target, (float*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (float*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_sumToAllDouble(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_double_sum_to_all((double*)target, (double*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (double*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_prodToAllShort(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int16_prod_to_all((int16_t*)target, (int16_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int16_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_prodToAllInt(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int32_prod_to_all((int32_t*)target, (int32_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int32_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_prodToAllLong(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_int64_prod_to_all((int64_t*)target, (int64_t*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (int64_t*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_prodToAllFloat(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_float_prod_to_all((float*)target, (float*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (float*)pWrk, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Addr_prodToAllDouble(
|
||||
JNIEnv *env, jobject jthis, jlong target, jlong source, jint nreduce,
|
||||
jint PE_start, jint logPE_stride, jint PE_size, jlong pWrk, jlong pSync)
|
||||
{
|
||||
shmem_double_prod_to_all((double*)target, (double*)source, nreduce, PE_start,
|
||||
logPE_stride, PE_size, (double*)pWrk, (long*)pSync);
|
||||
}
|
@ -1,44 +0,0 @@
|
||||
#include "oshmem_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#ifdef HAVE_TARGETCONDITIONALS_H
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
#include "shmem.h"
|
||||
#include "shmem_Constant.h"
|
||||
#include "shmemJava.h" /* must come AFTER the related .h so JNI is included */
|
||||
|
||||
static void setIntField(JNIEnv *env, jclass c, jobject obj,
|
||||
char *field, jint value)
|
||||
{
|
||||
jfieldID id = (*env)->GetFieldID(env, c, field, "I");
|
||||
(*env)->SetIntField(env, obj, id, value);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_Constant_setConstant(JNIEnv *env, jobject obj)
|
||||
{
|
||||
jclass c = (*env)->GetObjectClass(env, obj);
|
||||
setIntField(env, c, obj, "CMP_EQ", SHMEM_CMP_EQ);
|
||||
setIntField(env, c, obj, "CMP_GE", SHMEM_CMP_GE);
|
||||
setIntField(env, c, obj, "CMP_GT", SHMEM_CMP_GT);
|
||||
setIntField(env, c, obj, "CMP_LE", SHMEM_CMP_LE);
|
||||
setIntField(env, c, obj, "CMP_LT", SHMEM_CMP_LT);
|
||||
setIntField(env, c, obj, "CMP_NE", SHMEM_CMP_NE);
|
||||
|
||||
setIntField(env, c, obj, "BARRIER_SYNC_SIZE",
|
||||
SHMEM_BARRIER_SYNC_SIZE);
|
||||
setIntField(env, c, obj, "BCAST_SYNC_SIZE",
|
||||
SHMEM_BCAST_SYNC_SIZE);
|
||||
setIntField(env, c, obj, "COLLECT_SYNC_SIZE",
|
||||
SHMEM_COLLECT_SYNC_SIZE);
|
||||
setIntField(env, c, obj, "REDUCE_SYNC_SIZE",
|
||||
SHMEM_REDUCE_SYNC_SIZE);
|
||||
setIntField(env, c, obj, "REDUCE_MIN_WRKDATA_SIZE",
|
||||
SHMEM_REDUCE_MIN_WRKDATA_SIZE);
|
||||
setIntField(env, c, obj, "SYNC_VALUE",
|
||||
SHMEM_SYNC_VALUE);
|
||||
}
|
@ -1,31 +0,0 @@
|
||||
#include "oshmem_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#ifdef HAVE_TARGETCONDITIONALS_H
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
#include "shmem.h"
|
||||
#include "shmem_PSync.h"
|
||||
#include "shmemJava.h"
|
||||
|
||||
JNIEXPORT jlong JNICALL Java_shmem_PSync_newPSync(
|
||||
JNIEnv *env, jobject jthis, jint size)
|
||||
{
|
||||
long *pSync = shmalloc(size * sizeof(long));
|
||||
int i;
|
||||
|
||||
for(i = 0; i < size; i++)
|
||||
pSync[i] = _SHMEM_SYNC_VALUE;
|
||||
|
||||
return (jlong)pSync;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_PSync_free(
|
||||
JNIEnv *env, jobject jthis, jlong handle)
|
||||
{
|
||||
shfree((void*)handle);
|
||||
}
|
@ -1,488 +0,0 @@
|
||||
#include "oshmem_config.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dlfcn.h>
|
||||
|
||||
#ifdef HAVE_TARGETCONDITIONALS_H
|
||||
#include <TargetConditionals.h>
|
||||
#endif
|
||||
|
||||
#include "shmem.h"
|
||||
#include "shmem_ShMem.h"
|
||||
#include "shmemJava.h" /* must come AFTER the related .h so JNI is included */
|
||||
|
||||
shmem_java_globals_t shmem_java;
|
||||
int oshmem_shmem_java_eager = 65536;
|
||||
opal_free_list_t shmem_java_buffers;
|
||||
static void *liboshmem = NULL;
|
||||
|
||||
static void bufferConstructor(shmem_java_buffer_t *item)
|
||||
{
|
||||
item->buffer = malloc(oshmem_shmem_java_eager);
|
||||
}
|
||||
|
||||
static void bufferDestructor(shmem_java_buffer_t *item)
|
||||
{
|
||||
free(item->buffer);
|
||||
}
|
||||
|
||||
OBJ_CLASS_INSTANCE(shmem_java_buffer_t,
|
||||
opal_free_list_item_t,
|
||||
bufferConstructor,
|
||||
bufferDestructor);
|
||||
|
||||
static void initFreeList(void)
|
||||
{
|
||||
mca_base_var_register("oshmem", "shmem", "java", "eager",
|
||||
"Java buffers eager size",
|
||||
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
|
||||
OPAL_INFO_LVL_5,
|
||||
MCA_BASE_VAR_SCOPE_READONLY,
|
||||
&oshmem_shmem_java_eager);
|
||||
|
||||
OBJ_CONSTRUCT(&shmem_java_buffers, opal_free_list_t);
|
||||
|
||||
int r = opal_free_list_init(&shmem_java_buffers,
|
||||
sizeof(shmem_java_buffer_t),
|
||||
opal_cache_line_size,
|
||||
OBJ_CLASS(shmem_java_buffer_t),
|
||||
0, /* payload size */
|
||||
0, /* payload align */
|
||||
2, /* initial elements to alloc */
|
||||
-1, /* max elements */
|
||||
2, /* num elements per alloc */
|
||||
NULL, /* mpool */
|
||||
0, /* mpool reg flags */
|
||||
NULL, /* unused0 */
|
||||
NULL, /* item_init */
|
||||
NULL /* inem_init context */);
|
||||
if(r != OPAL_SUCCESS)
|
||||
{
|
||||
fprintf(stderr, "Unable to initialize shmem_java_buffers.\n");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
static jclass findClass(JNIEnv *env, const char *className)
|
||||
{
|
||||
jclass c = (*env)->FindClass(env, className),
|
||||
r = (*env)->NewGlobalRef(env, c);
|
||||
|
||||
(*env)->DeleteLocalRef(env, c);
|
||||
return r;
|
||||
}
|
||||
|
||||
jint JNI_OnLoad(JavaVM *vm, void *reserved)
|
||||
{
|
||||
/* These are the equivalences between the Java and C types. */
|
||||
if( sizeof(jbyte) != sizeof(char) ||
|
||||
sizeof(jshort) != sizeof(int16_t) ||
|
||||
sizeof(jint) != sizeof(int32_t) ||
|
||||
sizeof(jlong) != sizeof(int64_t))
|
||||
{
|
||||
fprintf(stderr, "C types not match with Java.\n");
|
||||
exit(1);
|
||||
}
|
||||
|
||||
liboshmem = dlopen("liboshmem." OPAL_DYN_LIB_SUFFIX,
|
||||
RTLD_NOW | RTLD_GLOBAL);
|
||||
|
||||
if(liboshmem == NULL)
|
||||
{
|
||||
fprintf(stderr, "Java bindings failed to load liboshmem: %s\n",dlerror());
|
||||
exit(1);
|
||||
}
|
||||
|
||||
initFreeList();
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
|
||||
void JNI_OnUnload(JavaVM *vm, void *reserved)
|
||||
{
|
||||
OBJ_DESTRUCT(&shmem_java_buffers);
|
||||
JNIEnv *env;
|
||||
(*vm)->GetEnv(vm, (void**)&env, 6);
|
||||
(*env)->DeleteGlobalRef(env, shmem_java.ExceptionClass);
|
||||
dlclose(liboshmem);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_ShMem_init(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
shmem_java.ExceptionClass = findClass(env, "shmem/ShMemException");
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_ShMem_startPEs(
|
||||
JNIEnv *env, jclass clazz, jint i)
|
||||
{
|
||||
start_pes(i);
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_shmem_ShMem_getNumPEs(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
return _num_pes();
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL Java_shmem_ShMem_getMyPE(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
return _my_pe();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_ShMem_barrier(
|
||||
JNIEnv *env, jclass clazz, jint PE_start,
|
||||
jint logPE_stride, jint PE_size, jlong pSync)
|
||||
{
|
||||
shmem_barrier(PE_start, logPE_stride, PE_size, (long*)pSync);
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_ShMem_barrierAll(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
shmem_barrier_all();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_ShMem_fence(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
shmem_fence();
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL Java_shmem_ShMem_quiet(JNIEnv *env, jclass clazz)
|
||||
{
|
||||
shmem_quiet();
|
||||
}
|
||||
|
||||
void* shmem_java_getBuffer(shmem_java_buffer_t **item, JNIEnv *env, int size)
|
||||
{
|
||||
if(size > oshmem_shmem_java_eager)
|
||||
{
|
||||
*item = NULL;
|
||||
return malloc(size);
|
||||
}
|
||||
else
|
||||
{
|
||||
opal_free_list_item_t *freeListItem;
|
||||
OPAL_FREE_LIST_GET(&shmem_java_buffers, freeListItem);
|
||||
|
||||
if (NULL == item) {
|
||||
(*env)->ThrowNew(env, shmem_java.ExceptionClass,
|
||||
"Error in OPAL_FREE_LIST_GET");
|
||||
}
|
||||
|
||||
*item = (shmem_java_buffer_t*)freeListItem;
|
||||
return (*item)->buffer;
|
||||
}
|
||||
}
|
||||
|
||||
void shmem_java_releaseBuffer(void *ptr, shmem_java_buffer_t *item)
|
||||
{
|
||||
if(item == NULL)
|
||||
{
|
||||
free(ptr);
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(item->buffer == ptr);
|
||||
OPAL_FREE_LIST_RETURN(&shmem_java_buffers, (opal_free_list_item_t*)item);
|
||||
}
|
||||
}
|
||||
|
||||
jbyte* shmem_java_getReadByteArray(shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jbyteArray array, int off, int len)
|
||||
{
|
||||
jbyte *ptr = shmem_java_getBuffer(item, env, len);
|
||||
(*env)->GetByteArrayRegion(env, array, off, len, ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
jshort* shmem_java_getReadShortArray(shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jshortArray array, int off, int len)
|
||||
{
|
||||
jshort *ptr = shmem_java_getBuffer(item, env, len * 2);
|
||||
(*env)->GetShortArrayRegion(env, array, off, len, ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
jint* shmem_java_getReadIntArray(shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jintArray array, int off, int len)
|
||||
{
|
||||
jint *ptr = shmem_java_getBuffer(item, env, len * 4);
|
||||
(*env)->GetIntArrayRegion(env, array, off, len, ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
jlong* shmem_java_getReadLongArray(shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jlongArray array, int off, int len)
|
||||
{
|
||||
jlong *ptr = shmem_java_getBuffer(item, env, len * 8);
|
||||
(*env)->GetLongArrayRegion(env, array, off, len, ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
jfloat* shmem_java_getReadFloatArray(shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jfloatArray array, int off, int len)
|
||||
{
|
||||
jfloat *ptr = shmem_java_getBuffer(item, env, len * 4);
|
||||
(*env)->GetFloatArrayRegion(env, array, off, len, ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
jdouble* shmem_java_getReadDoubleArray(shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jdoubleArray array, int off, int len)
|
||||
{
|
||||
jdouble *ptr = shmem_java_getBuffer(item, env, len * 8);
|
||||
(*env)->GetDoubleArrayRegion(env, array, off, len, ptr);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void shmem_java_releaseWriteByteArray(
|
||||
void *ptr, shmem_java_buffer_t *item,
|
||||
JNIEnv *env, jbyteArray array, int off, int len)
|
||||
{
|
||||
(*env)->SetByteArrayRegion(env, array, off, len, ptr);
|
||||
shmem_java_releaseBuffer(ptr, item);
|
||||
}
|
||||
|
||||
void shmem_java_releaseWriteShortArray(
|
||||
void *ptr, shmem_java_buffer_t *item,
|
||||
JNIEnv *env, jshortArray array, int off, int len)
|
||||
{
|
||||
(*env)->SetShortArrayRegion(env, array, off, len, ptr);
|
||||
shmem_java_releaseBuffer(ptr, item);
|
||||
}
|
||||
|
||||
void shmem_java_releaseWriteIntArray(
|
||||
void *ptr, shmem_java_buffer_t *item,
|
||||
JNIEnv *env, jintArray array, int off, int len)
|
||||
{
|
||||
(*env)->SetIntArrayRegion(env, array, off, len, ptr);
|
||||
shmem_java_releaseBuffer(ptr, item);
|
||||
}
|
||||
|
||||
void shmem_java_releaseWriteLongArray(
|
||||
void *ptr, shmem_java_buffer_t *item,
|
||||
JNIEnv *env, jlongArray array, int off, int len)
|
||||
{
|
||||
(*env)->SetLongArrayRegion(env, array, off, len, ptr);
|
||||
shmem_java_releaseBuffer(ptr, item);
|
||||
}
|
||||
|
||||
void shmem_java_releaseWriteFloatArray(
|
||||
void *ptr, shmem_java_buffer_t *item,
|
||||
JNIEnv *env, jfloatArray array, int off, int len)
|
||||
{
|
||||
(*env)->SetFloatArrayRegion(env, array, off, len, ptr);
|
||||
shmem_java_releaseBuffer(ptr, item);
|
||||
}
|
||||
|
||||
void shmem_java_releaseWriteDoubleArray(
|
||||
void *ptr, shmem_java_buffer_t *item,
|
||||
JNIEnv *env, jdoubleArray array, int off, int len)
|
||||
{
|
||||
(*env)->SetDoubleArrayRegion(env, array, off, len, ptr);
|
||||
shmem_java_releaseBuffer(ptr, item);
|
||||
}
|
||||
|
||||
void* shmem_java_iGetBuffer(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
int stride, int len, int elementSize)
|
||||
{
|
||||
int size = (stride * (len - 1) + 1) * elementSize;
|
||||
assert(size >= 0);
|
||||
return shmem_java_getBuffer(item, env, size);
|
||||
}
|
||||
|
||||
jshort* shmem_java_iGetReadShortArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jshortArray array, int off, int stride, int len)
|
||||
{
|
||||
jshort *ptr = shmem_java_iGetBuffer(item, env, stride, len, 2),
|
||||
*des = ptr,
|
||||
*arr = (*env)->GetPrimitiveArrayCritical(env, array, NULL),
|
||||
*src = arr + off;
|
||||
int i;
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
*des = *src;
|
||||
des += stride;
|
||||
src += stride;
|
||||
}
|
||||
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, array, arr, JNI_ABORT);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
jint* shmem_java_iGetReadIntArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jintArray array, int off, int stride, int len)
|
||||
{
|
||||
jint *ptr = shmem_java_iGetBuffer(item, env, stride, len, 4),
|
||||
*des = ptr,
|
||||
*arr = (*env)->GetPrimitiveArrayCritical(env, array, NULL),
|
||||
*src = arr + off;
|
||||
|
||||
int i;
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
*des = *src;
|
||||
des += stride;
|
||||
src += stride;
|
||||
}
|
||||
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, array, arr, JNI_ABORT);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
jlong* shmem_java_iGetReadLongArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jlongArray array, int off, int stride, int len)
|
||||
{
|
||||
jlong *ptr = shmem_java_iGetBuffer(item, env, stride, len, 8),
|
||||
*des = ptr,
|
||||
*arr = (*env)->GetPrimitiveArrayCritical(env, array, NULL),
|
||||
*src = arr + off;
|
||||
int i;
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
*des = *src;
|
||||
des += stride;
|
||||
src += stride;
|
||||
}
|
||||
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, array, arr, JNI_ABORT);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
jfloat* shmem_java_iGetReadFloatArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jfloatArray array, int off, int stride, int len)
|
||||
{
|
||||
jfloat *ptr = shmem_java_iGetBuffer(item, env, stride, len, 4),
|
||||
*des = ptr,
|
||||
*arr = (*env)->GetPrimitiveArrayCritical(env, array, NULL),
|
||||
*src = arr + off;
|
||||
int i;
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
*des = *src;
|
||||
des += stride;
|
||||
src += stride;
|
||||
}
|
||||
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, array, arr, JNI_ABORT);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
jdouble* shmem_java_iGetReadDoubleArray(
|
||||
shmem_java_buffer_t **item, JNIEnv *env,
|
||||
jdoubleArray array, int off, int stride, int len)
|
||||
{
|
||||
jdouble *ptr = shmem_java_iGetBuffer(item, env, stride, len, 8),
|
||||
*des = ptr,
|
||||
*arr = (*env)->GetPrimitiveArrayCritical(env, array, NULL),
|
||||
*src = arr + off;
|
||||
int i;
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
*des = *src;
|
||||
des += stride;
|
||||
src += stride;
|
||||
}
|
||||
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, array, arr, JNI_ABORT);
|
||||
return ptr;
|
||||
}
|
||||
|
||||
void shmem_java_iReleaseWriteShortArray(
|
||||
jshort *ptr, shmem_java_buffer_t *item, JNIEnv *env,
|
||||
jshortArray array, int off, int stride, int len)
|
||||
{
|
||||
jshort *src = ptr,
|
||||
*arr = (*env)->GetPrimitiveArrayCritical(env, array, NULL),
|
||||
*des = arr + off;
|
||||
int i;
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
*des = *src;
|
||||
des += stride;
|
||||
src += stride;
|
||||
}
|
||||
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, array, arr, 0);
|
||||
shmem_java_releaseBuffer(ptr, item);
|
||||
}
|
||||
|
||||
void shmem_java_iReleaseWriteIntArray(
|
||||
jint *ptr, shmem_java_buffer_t *item, JNIEnv *env,
|
||||
jintArray array, int off, int stride, int len)
|
||||
{
|
||||
jint *src = ptr,
|
||||
*arr = (*env)->GetPrimitiveArrayCritical(env, array, NULL),
|
||||
*des = arr + off;
|
||||
|
||||
int i;
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
*des = *src;
|
||||
des += stride;
|
||||
src += stride;
|
||||
}
|
||||
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, array, arr, 0);
|
||||
shmem_java_releaseBuffer(ptr, item);
|
||||
}
|
||||
|
||||
void shmem_java_iReleaseWriteLongArray(
|
||||
jlong *ptr, shmem_java_buffer_t *item, JNIEnv *env,
|
||||
jlongArray array, int off, int stride, int len)
|
||||
{
|
||||
jlong *src = ptr,
|
||||
*arr = (*env)->GetPrimitiveArrayCritical(env, array, NULL),
|
||||
*des = arr + off;
|
||||
int i;
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
*des = *src;
|
||||
des += stride;
|
||||
src += stride;
|
||||
}
|
||||
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, array, arr, 0);
|
||||
shmem_java_releaseBuffer(ptr, item);
|
||||
}
|
||||
|
||||
void shmem_java_iReleaseWriteFloatArray(
|
||||
jfloat *ptr, shmem_java_buffer_t *item, JNIEnv *env,
|
||||
jfloatArray array, int off, int stride, int len)
|
||||
{
|
||||
jfloat *src = ptr,
|
||||
*arr = (*env)->GetPrimitiveArrayCritical(env, array, NULL),
|
||||
*des = arr + off;
|
||||
int i;
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
*des = *src;
|
||||
des += stride;
|
||||
src += stride;
|
||||
}
|
||||
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, array, arr, 0);
|
||||
shmem_java_releaseBuffer(ptr, item);
|
||||
}
|
||||
|
||||
void shmem_java_iReleaseWriteDoubleArray(
|
||||
jdouble *ptr, shmem_java_buffer_t *item, JNIEnv *env,
|
||||
jdoubleArray array, int off, int stride, int len)
|
||||
{
|
||||
jdouble *src = ptr,
|
||||
*arr = (*env)->GetPrimitiveArrayCritical(env, array, NULL),
|
||||
*des = arr + off;
|
||||
int i;
|
||||
for(i = 0; i < len; i++)
|
||||
{
|
||||
*des = *src;
|
||||
des += stride;
|
||||
src += stride;
|
||||
}
|
||||
|
||||
(*env)->ReleasePrimitiveArrayCritical(env, array, arr, 0);
|
||||
shmem_java_releaseBuffer(ptr, item);
|
||||
}
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
@ -1,21 +0,0 @@
|
||||
package shmem;
|
||||
|
||||
class Constant
|
||||
{
|
||||
protected int CMP_EQ, CMP_GE, CMP_GT, CMP_LE, CMP_LT, CMP_NE;
|
||||
|
||||
protected int BARRIER_SYNC_SIZE,
|
||||
BCAST_SYNC_SIZE,
|
||||
COLLECT_SYNC_SIZE,
|
||||
REDUCE_SYNC_SIZE,
|
||||
REDUCE_MIN_WRKDATA_SIZE,
|
||||
SYNC_VALUE;
|
||||
|
||||
protected Constant()
|
||||
{
|
||||
setConstant();
|
||||
}
|
||||
|
||||
private native void setConstant();
|
||||
|
||||
} // Constant
|
@ -1,152 +0,0 @@
|
||||
#
|
||||
# We generate three general things in this directory:
|
||||
#
|
||||
# 1. *.java files get compiled into shmem/*.class files.
|
||||
# 2. The shmem/*.class files are then assembled into an shmem.jar file.
|
||||
# 3. The shmem/*.class files are analyzed to make *.h JNI files.
|
||||
#
|
||||
|
||||
# These are the Java source files. However, Automake doesn't directly
|
||||
# know about them, and we compile them via *.java below (ick!). So we
|
||||
# just list them here in EXTRA_DIST so that they get picked up by
|
||||
# "make dist".
|
||||
JAVA_SRC_FILES = \
|
||||
Addr.java \
|
||||
Constant.java \
|
||||
PSync.java \
|
||||
ShMem.java \
|
||||
ShMemException.java
|
||||
|
||||
EXTRA_DIST = $(JAVA_SRC_FILES)
|
||||
|
||||
# Only do this stuff if we want the Java bindings
|
||||
if OMPI_WANT_JAVA_BINDINGS
|
||||
|
||||
# These files get generated. They have a 1:1 correspondence to .java
|
||||
# files, but there is not a .h file for every .java file. That's why
|
||||
# we have a specific list of files here, as opposed to deriving them
|
||||
# from JAVA_SRC_FILES.
|
||||
JAVA_H = \
|
||||
shmem_Addr.h \
|
||||
shmem_Constant.h \
|
||||
shmem_PSync.h \
|
||||
shmem_ShMem.h
|
||||
|
||||
# A little verbosity magic; "make" will show the terse output. "make
|
||||
# V=1" will show the actual commands used (just like the other
|
||||
# Automake-generated compilation/linker rules).
|
||||
V=0
|
||||
OMPI_V_JAVAC = $(ompi__v_JAVAC_$V)
|
||||
ompi__v_JAVAC_ = $(ompi__v_JAVAC_$AM_DEFAULT_VERBOSITY)
|
||||
ompi__v_JAVAC_0 = @echo " JAVAC " `basename $@`;
|
||||
|
||||
OMPI_V_JAVAH = $(ompi__v_JAVAH_$V)
|
||||
ompi__v_JAVAH_ = $(ompi__v_JAVAH_$AM_DEFAULT_VERBOSITY)
|
||||
ompi__v_JAVAH_0 = @echo " JAVAH " `basename $@`;
|
||||
|
||||
OMPI_V_JAR = $(ompi__v_JAR_$V)
|
||||
ompi__v_JAR_ = $(ompi__v_JAR_$AM_DEFAULT_VERBOSITY)
|
||||
ompi__v_JAR_0 = @echo " JAR " `basename $@`;
|
||||
|
||||
OMPI_V_JAVADOC = $(ompi__v_JAVADOC_$V)
|
||||
ompi__v_JAVADOC_ = $(ompi__v_JAVADOC_$AM_DEFAULT_VERBOSITY)
|
||||
ompi__v_JAVADOC_0 = @echo "JAVADOC " `basename $@`;
|
||||
|
||||
OMPI_V_JAVADOC_QUIET = $(ompi__v_JAVADOC_QUIET_$V)
|
||||
ompi__v_JAVADOC_QUIET_ = $(ompi__v_JAVADOC_QUIET_$AM_DEFAULT_VERBOSITY)
|
||||
ompi__v_JAVADOC_QUIET_0 = -quiet
|
||||
|
||||
OMPI_V_MKDIR = $(ompi__v_MKDIR_$V)
|
||||
ompi__v_MKDIR_ = $(ompi__v_MKDIR_$AM_DEFAULT_VERBOSITY)
|
||||
ompi__v_MKDIR_0 = @echo " MKDIR " $@;
|
||||
|
||||
# All the .java files seem to have circular references, such that I
|
||||
# can't figure out a linear order in which to compile them
|
||||
# sequentially that does not generate dependency errors. Hence, the
|
||||
# only way I can figure out how to compile them is via *.java -- this
|
||||
# could well be due to my own misunderstanding of Java or the
|
||||
# compiler. Shrug.
|
||||
#
|
||||
# So instead of listing all the .class files, since the rule below
|
||||
# will generate *all* the .class files simulanteously, just use
|
||||
# shmem/ShMem.class as a token class file for both the rule and all the
|
||||
# dependencies below.
|
||||
#
|
||||
# Note too, that all of them will be recompiled if any of them change,
|
||||
# since Automake doesn't know how to automatically generate
|
||||
# dependencies for Java source files. So I made the token ShMem.class
|
||||
# file dependent upon *all* the .java source files.
|
||||
#
|
||||
# Note that the javac compile will generate all the .class files in
|
||||
# the "shmem" subdirectory, because that's the java package that they're
|
||||
# in. This, along with the fact that the .java files seem to have
|
||||
# circular references, prevents us from using a .foo.bar: generic
|
||||
# Makefile rule. :-(
|
||||
shmem/ShMem.class: $(JAVA_SRC_FILES)
|
||||
$(OMPI_V_JAVAC) CLASSPATH=. ; \
|
||||
export CLASSPATH ; \
|
||||
$(JAVAC) -d . $(OSHMEM_TOP_SRCDIR)/oshmem/shmem/java/java/*.java
|
||||
|
||||
# Similar to above, all the generated .h files are dependent upon the
|
||||
# token shmem/ShMem.class file. Hence, all the classes will be generated
|
||||
# first, then we'll individually generate each of the .h files.
|
||||
$(JAVA_H): shmem/ShMem.class
|
||||
$(OMPI_V_JAVAH) sourcename=shmem.`echo $@ | sed -e s/^shmem_// -e s/.h$$//`; \
|
||||
CLASSPATH=. ; \
|
||||
export CLASSPATH ; \
|
||||
$(JAVAH) -d . -jni $$sourcename
|
||||
|
||||
# Generate the .jar file from all the class files. List shmem/ShMem.class
|
||||
# as a dependency so that it fires the rule above that will generate
|
||||
# *all* the shmem/*.class files.
|
||||
shmem.jar: shmem/ShMem.class
|
||||
$(OMPI_V_JAR) $(JAR) cf shmem.jar shmem/*.class
|
||||
|
||||
# Install the jar file into libdir. Use the DATA Automake primary,
|
||||
# because Automake will complain if you try to use LIBRARIES with a
|
||||
# filename that doesn't fit the lib<foo>.* format. Also use an
|
||||
# indirection to get to the libdir -- Automake does not allow putting
|
||||
# libdir for the DATA primary.
|
||||
javadir = $(libdir)
|
||||
java_DATA = shmem.jar
|
||||
|
||||
# List all the header files in BUILT_SOURCES so that Automake's "all"
|
||||
# target will build them. This will also force the building of the
|
||||
# shmem/*.class files (for the jar file).
|
||||
BUILT_SOURCES = $(JAVA_H) doc
|
||||
|
||||
# Convenience for building Javadoc docs
|
||||
jdoc: doc
|
||||
|
||||
# Make the "doc" target (and subdir) dependent upon shmem/ShMem.class; if
|
||||
# shmem.jar is ever rebuilt, then also make the docs eligible to be
|
||||
# rebuilt.
|
||||
doc: shmem/ShMem.class
|
||||
$(OMPI_V_JAVADOC) javadoc $(OMPI_V_JAVADOC_QUIET) -d doc $(srcdir)/*.java
|
||||
@touch doc
|
||||
|
||||
jdoc-install: doc
|
||||
-$(MKDIR_P) $(DESTDIR)$(docdir)/javadoc-oshmem
|
||||
cp -rp doc/* $(DESTDIR)$(docdir)/javadoc-oshmem
|
||||
|
||||
jdoc-uninstall:
|
||||
-rm -rf $(DESTDIR)$(docdir)/../oshmem/javadoc
|
||||
|
||||
install-data-hook: jdoc-install
|
||||
uninstall-local: jdoc-uninstall
|
||||
|
||||
# Clean up all the things that this Makefile.am generates.
|
||||
CLEANFILES += $(JAVA_H) shmem.jar
|
||||
|
||||
# Can only put *files* in CLEANFILES; need to remove the generated doc
|
||||
# and shmem directories separately.
|
||||
clean-local:
|
||||
-rm -rf doc shmem
|
||||
|
||||
# Conditionally install the header files
|
||||
if WANT_INSTALL_HEADERS
|
||||
oshmemdir = $(oshmemincludedir)/$(subdir)
|
||||
oshmem_HEADERS = $(headers)
|
||||
endif
|
||||
|
||||
endif
|
@ -1,40 +0,0 @@
|
||||
package shmem;
|
||||
|
||||
/**
|
||||
* Symmetric work array.
|
||||
*/
|
||||
public final class PSync
|
||||
{
|
||||
private long handle;
|
||||
|
||||
/**
|
||||
* Allocates a symmetric work array.
|
||||
* @param size Number of elements in the work array.
|
||||
* @throws ShMemException Allocation error.
|
||||
*/
|
||||
public PSync(int size) throws ShMemException
|
||||
{
|
||||
handle = newPSync(size);
|
||||
|
||||
if(handle == 0)
|
||||
throw new ShMemException("Allocation error.");
|
||||
}
|
||||
|
||||
private native long newPSync(int size);
|
||||
|
||||
/**
|
||||
* Frees a work array.
|
||||
*/
|
||||
public void free()
|
||||
{
|
||||
free(handle);
|
||||
}
|
||||
|
||||
private native void free(long handle);
|
||||
|
||||
protected long addr()
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
|
||||
} // PSync
|
@ -1,496 +0,0 @@
|
||||
package shmem;
|
||||
|
||||
import java.nio.*;
|
||||
|
||||
/**
|
||||
* Java bindings of OpenSHMEM.
|
||||
*/
|
||||
public final class ShMem
|
||||
{
|
||||
private static final ByteOrder nativeOrder = ByteOrder.nativeOrder();
|
||||
|
||||
public static final int CMP_EQ, CMP_GE, CMP_GT, CMP_LE, CMP_LT, CMP_NE;
|
||||
|
||||
public static final int BARRIER_SYNC_SIZE,
|
||||
BCAST_SYNC_SIZE,
|
||||
COLLECT_SYNC_SIZE,
|
||||
REDUCE_SYNC_SIZE,
|
||||
REDUCE_MIN_WRKDATA_SIZE,
|
||||
SYNC_VALUE;
|
||||
static
|
||||
{
|
||||
System.loadLibrary("oshmem_java");
|
||||
init();
|
||||
Constant c = new Constant();
|
||||
|
||||
CMP_EQ = c.CMP_EQ;
|
||||
CMP_GE = c.CMP_GE;
|
||||
CMP_GT = c.CMP_GT;
|
||||
CMP_LE = c.CMP_LE;
|
||||
CMP_LT = c.CMP_LT;
|
||||
CMP_NE = c.CMP_NE;
|
||||
|
||||
BARRIER_SYNC_SIZE = c.BARRIER_SYNC_SIZE;
|
||||
BCAST_SYNC_SIZE = c.BCAST_SYNC_SIZE;
|
||||
COLLECT_SYNC_SIZE = c.COLLECT_SYNC_SIZE;
|
||||
REDUCE_SYNC_SIZE = c.REDUCE_SYNC_SIZE;
|
||||
REDUCE_MIN_WRKDATA_SIZE = c.REDUCE_MIN_WRKDATA_SIZE;
|
||||
SYNC_VALUE = c.SYNC_VALUE;
|
||||
}
|
||||
|
||||
private static native void init();
|
||||
|
||||
/**
|
||||
* Initializes OpenSHMEM.
|
||||
* <p>Java binding of {@code start_pes}.
|
||||
* @param npes Unused. Should be set to 0.
|
||||
*/
|
||||
public static native void startPEs(int npes);
|
||||
|
||||
/**
|
||||
* Returns the number of processing elements (PEs) used to run the application.
|
||||
* <p>Java binding of {@code num_pes}.
|
||||
* @return Number of processing elements (PEs) used to run the application.
|
||||
*/
|
||||
public static native int getNumPEs();
|
||||
|
||||
/**
|
||||
* Returns the PE number of the calling PE.
|
||||
* <p>Java binding of {@code shmem_my_pe}.
|
||||
* @return PE number of the calling PE.
|
||||
*/
|
||||
public static native int getMyPE();
|
||||
|
||||
/**
|
||||
* Determines if a target PE is reachable from the calling PE.
|
||||
* <p>Java binding of {@code shmem_pe_accessible}.
|
||||
* @param pe PE number of the target PE.
|
||||
* @return true if the target PE is reachable, false otherwise.
|
||||
*/
|
||||
public static boolean isPEAccessible(int pe)
|
||||
{
|
||||
return isPEAccessible_jni(pe);
|
||||
}
|
||||
|
||||
private static native boolean isPEAccessible_jni(int pe);
|
||||
|
||||
/**
|
||||
* Performs a barrier operation on a subset of PEs.
|
||||
* <p>Java binding of {@code shmem_barrier}.
|
||||
* @param PE_start Lowest PE number of the active set of PEs.
|
||||
* @param logPE_stride Log (base 2) of the stride between consecutive
|
||||
* PE numbers in the active set.
|
||||
* @param PE_size Number of PEs in the active set.
|
||||
* @param pSync Symmetric {@code long} work array.
|
||||
*/
|
||||
public static void barrier(
|
||||
int PE_start, int logPE_stride, int PE_size, Addr pSync)
|
||||
{
|
||||
barrier(PE_start, logPE_stride, PE_size, pSync.addr());
|
||||
}
|
||||
|
||||
private static native void barrier(
|
||||
int PE_start, int logPE_stride, int PE_size, long pSync);
|
||||
|
||||
/**
|
||||
* Suspends the execution of the calling PE until all other
|
||||
* PEs issue a call to this statement.
|
||||
* <p>Java binding of {@code shmem_barrier_all}.
|
||||
*/
|
||||
public static native void barrierAll();
|
||||
|
||||
/**
|
||||
* Provides a separate ordering on the sequence of puts issued
|
||||
* by this PE to each destination PE.
|
||||
* <p>Java binding of {@code shmem_fence}.
|
||||
*/
|
||||
public static native void fence();
|
||||
|
||||
/**
|
||||
* Provides an ordering on the sequence of puts issued by this
|
||||
* PE across all destination PEs.
|
||||
* <p>Java binding of {@code shmem_quiet}.
|
||||
*/
|
||||
public static native void quiet();
|
||||
|
||||
/**
|
||||
* Allocates a new direct byte buffer.
|
||||
* @param capacity The new buffer's capacity, in bytes
|
||||
* @return The new byte buffer
|
||||
*/
|
||||
public static ByteBuffer newByteBuffer(int capacity)
|
||||
{
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(capacity);
|
||||
buf.order(nativeOrder);
|
||||
return buf;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a new direct short buffer.
|
||||
* @param capacity The new buffer's capacity, in shorts
|
||||
* @return The new short buffer
|
||||
*/
|
||||
public static ShortBuffer newShortBuffer(int capacity)
|
||||
{
|
||||
assert capacity <= Integer.MAX_VALUE / 2;
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(capacity * 2);
|
||||
buf.order(nativeOrder);
|
||||
return buf.asShortBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a new direct int buffer.
|
||||
* @param capacity The new buffer's capacity, in ints
|
||||
* @return The new int buffer
|
||||
*/
|
||||
public static IntBuffer newIntBuffer(int capacity)
|
||||
{
|
||||
assert capacity <= Integer.MAX_VALUE / 4;
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(capacity * 4);
|
||||
buf.order(nativeOrder);
|
||||
return buf.asIntBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a new direct long buffer.
|
||||
* @param capacity The new buffer's capacity, in longs
|
||||
* @return The new long buffer
|
||||
*/
|
||||
public static LongBuffer newLongBuffer(int capacity)
|
||||
{
|
||||
assert capacity <= Integer.MAX_VALUE / 8;
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(capacity * 8);
|
||||
buf.order(nativeOrder);
|
||||
return buf.asLongBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a new direct float buffer.
|
||||
* @param capacity The new buffer's capacity, in floats
|
||||
* @return The new float buffer
|
||||
*/
|
||||
public static FloatBuffer newFloatBuffer(int capacity)
|
||||
{
|
||||
assert capacity <= Integer.MAX_VALUE / 4;
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(capacity * 4);
|
||||
buf.order(nativeOrder);
|
||||
return buf.asFloatBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocates a new direct double buffer.
|
||||
* @param capacity The new buffer's capacity, in doubles
|
||||
* @return The new double buffer
|
||||
*/
|
||||
public static DoubleBuffer newDoubleBuffer(int capacity)
|
||||
{
|
||||
assert capacity <= Integer.MAX_VALUE / 8;
|
||||
ByteBuffer buf = ByteBuffer.allocateDirect(capacity * 8);
|
||||
buf.order(nativeOrder);
|
||||
return buf.asDoubleBuffer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static ByteBuffer slice(ByteBuffer buf, int offset)
|
||||
{
|
||||
return ((ByteBuffer)buf.clear().position(offset))
|
||||
.slice().order(nativeOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @param length length
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static ByteBuffer slice(ByteBuffer buf, int offset, int length)
|
||||
{
|
||||
return ((ByteBuffer)buf.limit(offset + length)
|
||||
.position(offset)).slice().order(nativeOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static ShortBuffer slice(ShortBuffer buf, int offset)
|
||||
{
|
||||
return ((ShortBuffer)buf.clear().position(offset)).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @param length length
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static ShortBuffer slice(ShortBuffer buf, int offset, int length)
|
||||
{
|
||||
return ((ShortBuffer)buf.limit(offset + length).position(offset)).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static IntBuffer slice(IntBuffer buf, int offset)
|
||||
{
|
||||
return ((IntBuffer)buf.clear().position(offset)).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @param length length
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static IntBuffer slice(IntBuffer buf, int offset, int length)
|
||||
{
|
||||
return ((IntBuffer)buf.limit(offset + length).position(offset)).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static LongBuffer slice(LongBuffer buf, int offset)
|
||||
{
|
||||
return ((LongBuffer)buf.clear().position(offset)).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @param length length
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static LongBuffer slice(LongBuffer buf, int offset, int length)
|
||||
{
|
||||
return ((LongBuffer)buf.limit(offset + length).position(offset)).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static FloatBuffer slice(FloatBuffer buf, int offset)
|
||||
{
|
||||
return ((FloatBuffer)buf.clear().position(offset)).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @param length length
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static FloatBuffer slice(FloatBuffer buf, int offset, int length)
|
||||
{
|
||||
return ((FloatBuffer)buf.limit(offset + length).position(offset)).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static DoubleBuffer slice(DoubleBuffer buf, int offset)
|
||||
{
|
||||
return ((DoubleBuffer)buf.clear().position(offset)).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @param length length
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static DoubleBuffer slice(DoubleBuffer buf, int offset, int length)
|
||||
{
|
||||
return ((DoubleBuffer)buf.limit(offset + length).position(offset)).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static ByteBuffer slice(byte[] buf, int offset)
|
||||
{
|
||||
return ByteBuffer.wrap(buf, offset, buf.length - offset)
|
||||
.slice().order(nativeOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @param length length
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static ByteBuffer slice(byte[] buf, int offset, int length)
|
||||
{
|
||||
return ByteBuffer.wrap(buf, offset, length).slice().order(nativeOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static ShortBuffer slice(short[] buf, int offset)
|
||||
{
|
||||
return ShortBuffer.wrap(buf, offset, buf.length - offset).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @param length length
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static ShortBuffer slice(short[] buf, int offset, int length)
|
||||
{
|
||||
return ShortBuffer.wrap(buf, offset, length).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static IntBuffer slice(int[] buf, int offset)
|
||||
{
|
||||
return IntBuffer.wrap(buf, offset, buf.length - offset).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @param length length
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static IntBuffer slice(int[] buf, int offset, int length)
|
||||
{
|
||||
return IntBuffer.wrap(buf, offset, length).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static LongBuffer slice(long[] buf, int offset)
|
||||
{
|
||||
return LongBuffer.wrap(buf, offset, buf.length - offset).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @param length length
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static LongBuffer slice(long[] buf, int offset, int length)
|
||||
{
|
||||
return LongBuffer.wrap(buf, offset, length).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static FloatBuffer slice(float[] buf, int offset)
|
||||
{
|
||||
return FloatBuffer.wrap(buf, offset, buf.length - offset).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @param length length
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static FloatBuffer slice(float[] buf, int offset, int length)
|
||||
{
|
||||
return FloatBuffer.wrap(buf, offset, length).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static DoubleBuffer slice(double[] buf, int offset)
|
||||
{
|
||||
return DoubleBuffer.wrap(buf, offset, buf.length - offset).slice();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new buffer whose content is a shared subsequence of a buffer.
|
||||
* <p>The content of the new buffer will start at the specified offset.
|
||||
* @param buf buffer
|
||||
* @param offset offset
|
||||
* @param length length
|
||||
* @return the new buffer.
|
||||
*/
|
||||
public static DoubleBuffer slice(double[] buf, int offset, int length)
|
||||
{
|
||||
return DoubleBuffer.wrap(buf, offset, length).slice();
|
||||
}
|
||||
|
||||
} // ShMem
|
@ -1,17 +0,0 @@
|
||||
package shmem;
|
||||
|
||||
/**
|
||||
* Signals that an SHMEM exception of some sort has occurred.
|
||||
*/
|
||||
public final class ShMemException extends Exception
|
||||
{
|
||||
/**
|
||||
* Creates an exception.
|
||||
* @param message message associated to the exception
|
||||
*/
|
||||
public ShMemException(String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
} // ShMemException
|
@ -30,10 +30,6 @@ install-exec-hook:
|
||||
(cd $(DESTDIR)$(bindir); rm -f oshcc$(EXEEXT); $(LN_S) mpicc$(EXEEXT) oshcc$(EXEEXT))
|
||||
(cd $(DESTDIR)$(bindir); rm -f shmemfort$(EXEEXT); $(LN_S) mpifort$(EXEEXT) shmemfort$(EXEEXT))
|
||||
(cd $(DESTDIR)$(bindir); rm -f oshfort$(EXEEXT); $(LN_S) mpifort$(EXEEXT) oshfort$(EXEEXT))
|
||||
if OSHMEM_WANT_JAVA_BINDINGS
|
||||
(cd $(DESTDIR)$(bindir); rm -f shmemjavac$(EXEEXT); $(LN_S) mpijavac$(EXEEXT) shmemjavac$(EXEEXT))
|
||||
(cd $(DESTDIR)$(bindir); rm -f oshjavac$(EXEEXT); $(LN_S) mpijavac$(EXEEXT) oshjavac$(EXEEXT))
|
||||
endif
|
||||
|
||||
install-data-hook:
|
||||
(cd $(DESTDIR)$(pkgdatadir); rm -f oshcc-wrapper-data.txt; $(LN_S) shmemcc-wrapper-data.txt oshcc-wrapper-data.txt)
|
||||
@ -46,14 +42,10 @@ uninstall-local:
|
||||
$(DESTDIR)$(bindir)/oshcc$(EXEEXT) \
|
||||
$(DESTDIR)$(bindir)/shmemfort$(EXEEXT) \
|
||||
$(DESTDIR)$(bindir)/oshfort$(EXEEXT) \
|
||||
$(DESTDIR)$(bindir)/shmemjavac$(EXEEXT) \
|
||||
$(DESTDIR)$(bindir)/oshjavac$(EXEEXT) \
|
||||
$(DESTDIR)$(pkgdatadir)/shmemcc-wrapper-data.txt \
|
||||
$(DESTDIR)$(pkgdatadir)/oshcc-wrapper-data.txt \
|
||||
$(DESTDIR)$(pkgdatadir)/shmemfort-wrapper-data.txt \
|
||||
$(DESTDIR)$(pkgdatadir)/oshfort-wrapper-data.txt \
|
||||
$(DESTDIR)$(bindir)/oshjavac \
|
||||
$(DESTDIR)$(bindir)/shmemjavac
|
||||
$(DESTDIR)$(pkgdatadir)/oshfort-wrapper-data.txt
|
||||
|
||||
|
||||
########################################################
|
||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user