1
1

Java: improve access to Java arrays.

This commit was SVN r31391.
Этот коммит содержится в:
Oscar Vega-Gisbert 2014-04-14 21:29:13 +00:00
родитель a3f83616fc
Коммит 5a21790caa
11 изменённых файлов: 1377 добавлений и 777 удалений

Просмотреть файл

@ -20,6 +20,7 @@
#define _MPIJAVA_H_
#include "mpi.h"
#include "opal/class/opal_free_list.h"
typedef struct {
jfieldID CommHandle;
@ -52,18 +53,70 @@ typedef struct {
extern ompi_java_globals_t ompi_java;
void* ompi_java_getBufPtr(
void** bufBase, JNIEnv *env,
jobject buf, jboolean db, int baseType, int offset);
typedef struct ompi_java_buffer_t
{
opal_free_list_item_t super;
void *buffer;
} ompi_java_buffer_t;
void ompi_java_releaseBufPtr(
JNIEnv *env, jobject buf, jboolean db, void* bufBase, int baseType);
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(ompi_java_buffer_t);
void ompi_java_releaseReadBufPtr(
JNIEnv *env, jobject buf, jboolean db, void *bufBase, int baseType);
void* ompi_java_getArrayCritical(void** bufBase, JNIEnv *env,
jobject buf, int offset);
void* ompi_java_getDirectBufferAddress(JNIEnv *env, jobject buf);
/* Gets a buffer pointer for reading (copy from Java). */
void ompi_java_getReadPtr(
void **ptr, ompi_java_buffer_t **item, JNIEnv *env, jobject buf,
jboolean db, int offset, int count, MPI_Datatype type, int baseType);
/* Gets a buffer pointer for reading.
* It only copies from java the rank data.
* 'size' is the number of processes. */
void ompi_java_getReadPtrRank(
void **ptr, ompi_java_buffer_t **item, JNIEnv *env,
jobject buf, jboolean db, int offset, int count, int size,
int rank, MPI_Datatype type, int baseType);
/* Gets a buffer pointer for reading, but it
* 'size' is the number of processes.
* if rank == -1 it copies all data from Java.
* if rank != -1 it only copies from Java the rank data. */
void ompi_java_getReadPtrv(
void **ptr, ompi_java_buffer_t **item, JNIEnv *env,
jobject buf, jboolean db, int off, int *counts, int *displs,
int size, int rank, MPI_Datatype type, int baseType);
/* Releases a buffer used for reading. */
void ompi_java_releaseReadPtr(
void *ptr, ompi_java_buffer_t *item, jobject buf, jboolean db);
/* Gets a buffer pointer for writing. */
void ompi_java_getWritePtr(
void **ptr, ompi_java_buffer_t **item, JNIEnv *env,
jobject buf, jboolean db, int count, MPI_Datatype type);
/* Gets a buffer pointer for writing.
* 'size' is the number of processes. */
void ompi_java_getWritePtrv(
void **ptr, ompi_java_buffer_t **item, JNIEnv *env, jobject buf,
jboolean db, int *counts, int *displs, int size, MPI_Datatype type);
/* Releases a buffer used for writing.
* It copies data to Java. */
void ompi_java_releaseWritePtr(
void *ptr, ompi_java_buffer_t *item, JNIEnv *env, jobject buf,
jboolean db, int offset, int count, MPI_Datatype type, int baseType);
/* Releases a buffer used for writing.
* It copies data to Java.
* 'size' is the number of processes. */
void ompi_java_releaseWritePtrv(
void *ptr, ompi_java_buffer_t *item, JNIEnv *env,
jobject buf, jboolean db, int off, int *counts, int *displs,
int size, MPI_Datatype type, int baseType);
void ompi_java_setStaticLongField(JNIEnv *env, jclass c,
char *field, jlong value);

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -134,69 +134,77 @@ JNIEXPORT void JNICALL Java_mpi_File_setView(
JNIEXPORT void JNICALL Java_mpi_File_readAt(
JNIEnv *env, jobject jthis, jlong fh, jlong fileOffset,
jobject buf, jboolean db, jint offset, jint count,
jlong type, jint bType, jlongArray stat)
jobject buf, jboolean db, jint off, jint count,
jlong jType, jint bType, jlongArray stat)
{
void *ptr, *base;
ptr = ompi_java_getBufPtr(&base, env, buf, db, bType, offset);
MPI_Datatype type = (MPI_Datatype)jType;
void *ptr;
ompi_java_buffer_t *item;
ompi_java_getWritePtr(&ptr, &item, env, buf, db, count, type);
MPI_Status status;
int rc = MPI_File_read_at((MPI_File)fh, (MPI_Offset)fileOffset,
ptr, count, (MPI_Datatype)type, &status);
ptr, count, type, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseBufPtr(env, buf, db, base, bType);
ompi_java_releaseWritePtr(ptr, item, env, buf, db, off, count, type, bType);
ompi_java_status_set(env, stat, &status);
}
JNIEXPORT void JNICALL Java_mpi_File_readAtAll(
JNIEnv *env, jobject jthis, jlong fh, jlong fileOffset,
jobject buf, jboolean db, jint offset, jint count,
jlong type, jint bType, jlongArray stat)
jobject buf, jboolean db, jint off, jint count,
jlong jType, jint bType, jlongArray stat)
{
void *ptr, *base;
ptr = ompi_java_getBufPtr(&base, env, buf, db, bType, offset);
MPI_Datatype type = (MPI_Datatype)jType;
void *ptr;
ompi_java_buffer_t *item;
ompi_java_getWritePtr(&ptr, &item, env, buf, db, count, type);
MPI_Status status;
int rc = MPI_File_read_at_all((MPI_File)fh, (MPI_Offset)fileOffset,
ptr, count, (MPI_Datatype)type, &status);
ptr, count, type, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseBufPtr(env, buf, db, base, bType);
ompi_java_releaseWritePtr(ptr, item, env, buf, db, off, count, type, bType);
ompi_java_status_set(env, stat, &status);
}
JNIEXPORT void JNICALL Java_mpi_File_writeAt(
JNIEnv *env, jobject jthis, jlong fh, jlong fileOffset,
jobject buf, jboolean db, jint offset, jint count,
jlong type, jint bType, jlongArray stat)
jobject buf, jboolean db, jint off, jint count,
jlong jType, jint bType, jlongArray stat)
{
void *ptr, *base;
ptr = ompi_java_getBufPtr(&base, env, buf, db, bType, offset);
MPI_Datatype type = (MPI_Datatype)jType;
void *ptr;
ompi_java_buffer_t *item;
ompi_java_getReadPtr(&ptr, &item, env, buf, db, off, count, type, bType);
MPI_Status status;
int rc = MPI_File_write_at((MPI_File)fh, (MPI_Offset)fileOffset,
ptr, count, (MPI_Datatype)type, &status);
ptr, count, type, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseReadBufPtr(env, buf, db, base, bType);
ompi_java_releaseReadPtr(ptr, item, buf, db);
ompi_java_status_set(env, stat, &status);
}
JNIEXPORT void JNICALL Java_mpi_File_writeAtAll(
JNIEnv *env, jobject jthis, jlong fh, jlong fileOffset,
jobject buf, jboolean db, jint offset, jint count,
jlong type, jint bType, jlongArray stat)
jobject buf, jboolean db, jint off, jint count,
jlong jType, jint bType, jlongArray stat)
{
void *ptr, *base;
ptr = ompi_java_getBufPtr(&base, env, buf, db, bType, offset);
MPI_Datatype type = (MPI_Datatype)jType;
void *ptr;
ompi_java_buffer_t *item;
ompi_java_getReadPtr(&ptr, &item, env, buf, db, off, count, type, bType);
MPI_Status status;
int rc = MPI_File_write_at_all((MPI_File)fh, (MPI_Offset)fileOffset,
ptr, count, (MPI_Datatype)type, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseReadBufPtr(env, buf, db, base, bType);
ompi_java_releaseReadPtr(ptr, item, buf, db);
ompi_java_status_set(env, stat, &status);
}
@ -230,65 +238,61 @@ JNIEXPORT jlong JNICALL Java_mpi_File_iWriteAt(
JNIEXPORT void JNICALL Java_mpi_File_read(
JNIEnv *env, jobject jthis, jlong fh, jobject buf, jboolean db,
jint offset, jint count, jlong type, jint bType, jlongArray stat)
jint off, jint count, jlong jType, jint bType, jlongArray stat)
{
void *ptr, *base;
ptr = ompi_java_getBufPtr(&base, env, buf, db, bType, offset);
MPI_Datatype type = (MPI_Datatype)jType;
void *ptr;
ompi_java_buffer_t *item;
ompi_java_getWritePtr(&ptr, &item, env, buf, db, count, type);
MPI_Status status;
int rc = MPI_File_read((MPI_File)fh, ptr, count,
(MPI_Datatype)type, &status);
int rc = MPI_File_read((MPI_File)fh, ptr, count, type, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseBufPtr(env, buf, db, base, bType);
ompi_java_releaseWritePtr(ptr, item, env, buf, db, off, count, type, bType);
ompi_java_status_set(env, stat, &status);
}
JNIEXPORT void JNICALL Java_mpi_File_readAll(
JNIEnv *env, jobject jthis, jlong fh, jobject buf, jboolean db,
jint offset, jint count, jlong type, jint bType, jlongArray stat)
jint off, jint count, jlong jType, jint bType, jlongArray stat)
{
void *ptr, *base;
ptr = ompi_java_getBufPtr(&base, env, buf, db, bType, offset);
MPI_Datatype type = (MPI_Datatype)jType;
void *ptr;
ompi_java_buffer_t *item;
ompi_java_getWritePtr(&ptr, &item, env, buf, db, count, type);
MPI_Status status;
int rc = MPI_File_read_all((MPI_File)fh, ptr, count,
(MPI_Datatype)type, &status);
int rc = MPI_File_read_all((MPI_File)fh, ptr, count, type, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseBufPtr(env, buf, db, base, bType);
ompi_java_releaseWritePtr(ptr, item, env, buf, db, off, count, type, bType);
ompi_java_status_set(env, stat, &status);
}
JNIEXPORT void JNICALL Java_mpi_File_write(
JNIEnv *env, jobject jthis, jlong fh, jobject buf, jboolean db,
jint offset, jint count, jlong type, jint bType, jlongArray stat)
jint off, jint count, jlong jType, jint bType, jlongArray stat)
{
void *ptr, *base;
ptr = ompi_java_getBufPtr(&base, env, buf, db, bType, offset);
MPI_Datatype type = (MPI_Datatype)jType;
void *ptr;
ompi_java_buffer_t *item;
ompi_java_getReadPtr(&ptr, &item, env, buf, db, off, count, type, bType);
MPI_Status status;
int rc = MPI_File_write((MPI_File)fh, ptr, count,
(MPI_Datatype)type, &status);
int rc = MPI_File_write((MPI_File)fh, ptr, count, type, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseReadBufPtr(env, buf, db, base, bType);
ompi_java_releaseReadPtr(ptr, item, buf, db);
ompi_java_status_set(env, stat, &status);
}
JNIEXPORT void JNICALL Java_mpi_File_writeAll(
JNIEnv *env, jobject jthis, jlong fh, jobject buf, jboolean db,
jint offset, jint count, jlong type, jint bType, jlongArray stat)
jint off, jint count, jlong jType, jint bType, jlongArray stat)
{
void *ptr, *base;
ptr = ompi_java_getBufPtr(&base, env, buf, db, bType, offset);
MPI_Datatype type = (MPI_Datatype)jType;
void *ptr;
ompi_java_buffer_t *item;
ompi_java_getReadPtr(&ptr, &item, env, buf, db, off, count, type, bType);
MPI_Status status;
int rc = MPI_File_write_all((MPI_File)fh, ptr, count,
(MPI_Datatype)type, &status);
int rc = MPI_File_write_all((MPI_File)fh, ptr, count, type, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseReadBufPtr(env, buf, db, base, bType);
ompi_java_releaseReadPtr(ptr, item, buf, db);
ompi_java_status_set(env, stat, &status);
}
@ -347,33 +351,31 @@ JNIEXPORT jlong JNICALL Java_mpi_File_getByteOffset(
JNIEXPORT void JNICALL Java_mpi_File_readShared(
JNIEnv *env, jobject jthis, jlong fh, jobject buf, jboolean db,
jint offset, jint count, jlong type, jint bType, jlongArray stat)
jint off, jint count, jlong jType, jint bType, jlongArray stat)
{
void *ptr, *base;
ptr = ompi_java_getBufPtr(&base, env, buf, db, bType, offset);
MPI_Datatype type = (MPI_Datatype)jType;
void *ptr;
ompi_java_buffer_t *item;
ompi_java_getWritePtr(&ptr, &item, env, buf, db, count, type);
MPI_Status status;
int rc = MPI_File_read_shared((MPI_File)fh, ptr, count,
(MPI_Datatype)type, &status);
int rc = MPI_File_read_shared((MPI_File)fh, ptr, count, type, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseBufPtr(env, buf, db, base, bType);
ompi_java_releaseWritePtr(ptr, item, env, buf, db, off, count, type, bType);
ompi_java_status_set(env, stat, &status);
}
JNIEXPORT void JNICALL Java_mpi_File_writeShared(
JNIEnv *env, jobject jthis, jlong fh, jobject buf, jboolean db,
jint offset, jint count, jlong type, jint bType, jlongArray stat)
jint off, jint count, jlong jType, jint bType, jlongArray stat)
{
void *ptr, *base;
ptr = ompi_java_getBufPtr(&base, env, buf, db, bType, offset);
MPI_Datatype type = (MPI_Datatype)jType;
void *ptr;
ompi_java_buffer_t *item;
ompi_java_getReadPtr(&ptr, &item, env, buf, db, off, count, type, bType);
MPI_Status status;
int rc = MPI_File_write_shared((MPI_File)fh, ptr, count,
(MPI_Datatype)type, &status);
int rc = MPI_File_write_shared((MPI_File)fh, ptr, count, type, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseReadBufPtr(env, buf, db, base, bType);
ompi_java_releaseReadPtr(ptr, item, buf, db);
ompi_java_status_set(env, stat, &status);
}
@ -407,33 +409,31 @@ JNIEXPORT jlong JNICALL Java_mpi_File_iWriteShared(
JNIEXPORT void JNICALL Java_mpi_File_readOrdered(
JNIEnv *env, jobject jthis, jlong fh, jobject buf, jboolean db,
jint offset, jint count, jlong type, jint bType, jlongArray stat)
jint off, jint count, jlong jType, jint bType, jlongArray stat)
{
void *ptr, *base;
ptr = ompi_java_getBufPtr(&base, env, buf, db, bType, offset);
MPI_Datatype type = (MPI_Datatype)jType;
void *ptr;
ompi_java_buffer_t *item;
ompi_java_getWritePtr(&ptr, &item, env, buf, db, count, type);
MPI_Status status;
int rc = MPI_File_read_ordered((MPI_File)fh, ptr, count,
(MPI_Datatype)type, &status);
int rc = MPI_File_read_ordered((MPI_File)fh, ptr, count, type, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseBufPtr(env, buf, db, base, bType);
ompi_java_releaseWritePtr(ptr, item, env, buf, db, off, count, type, bType);
ompi_java_status_set(env, stat, &status);
}
JNIEXPORT void JNICALL Java_mpi_File_writeOrdered(
JNIEnv *env, jobject jthis, jlong fh, jobject buf, jboolean db,
jint offset, jint count, jlong type, jint bType, jlongArray stat)
jint off, jint count, jlong jType, jint bType, jlongArray stat)
{
void *ptr, *base;
ptr = ompi_java_getBufPtr(&base, env, buf, db, bType, offset);
MPI_Datatype type = (MPI_Datatype)jType;
void *ptr;
ompi_java_buffer_t *item;
ompi_java_getReadPtr(&ptr, &item, env, buf, db, off, count, type, bType);
MPI_Status status;
int rc = MPI_File_write_ordered((MPI_File)fh, ptr, count,
(MPI_Datatype)type, &status);
int rc = MPI_File_write_ordered((MPI_File)fh, ptr, count, type, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseReadBufPtr(env, buf, db, base, bType);
ompi_java_releaseReadPtr(ptr, item, buf, db);
ompi_java_status_set(env, stat, &status);
}

Просмотреть файл

@ -198,29 +198,36 @@ JNIEXPORT jlong JNICALL Java_mpi_Intracomm_createDistGraphAdjacent(
}
JNIEXPORT void JNICALL Java_mpi_Intracomm_scan(
JNIEnv *env, jobject jthis, jlong comm,
jobject sendBuf, jboolean sdb, jint sendOff,
jobject recvBuf, jboolean rdb, jint recvOff, jint count,
jlong type, jint baseType, jobject jOp, jlong hOp)
JNIEnv *env, jobject jthis, jlong jComm,
jobject sBuf, jboolean sdb, jint sOff,
jobject rBuf, jboolean rdb, jint rOff, jint count,
jlong jType, jint bType, jobject jOp, jlong hOp)
{
void *sPtr, *sBase, *rPtr, *rBase;
MPI_Comm comm = (MPI_Comm)jComm;
MPI_Datatype type = (MPI_Datatype)jType;
if(sendBuf == NULL)
void *sPtr, *rPtr;
ompi_java_buffer_t *sItem, *rItem;
if(sBuf == NULL)
{
sPtr = MPI_IN_PLACE;
ompi_java_getReadPtr(&rPtr,&rItem,env,rBuf,rdb,rOff,count,type,bType);
}
else
sPtr = ompi_java_getBufPtr(&sBase, env, sendBuf, sdb, baseType, sendOff);
rPtr = ompi_java_getBufPtr(&rBase, env, recvBuf, rdb, baseType, recvOff);
int rc = MPI_Scan(sPtr, rPtr, count, (MPI_Datatype)type,
ompi_java_op_getHandle(env, jOp, hOp, baseType),
(MPI_Comm)comm);
{
ompi_java_getReadPtr(&sPtr,&sItem,env,sBuf,sdb,sOff,count,type,bType);
ompi_java_getWritePtr(&rPtr, &rItem, env, rBuf, rdb, count, type);
}
MPI_Op op = ompi_java_op_getHandle(env, jOp, hOp, bType);
int rc = MPI_Scan(sPtr, rPtr, count, type, op, comm);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseBufPtr(env, recvBuf, rdb, rBase, baseType);
if(sendBuf != NULL)
ompi_java_releaseReadBufPtr(env, sendBuf, sdb, sBase, baseType);
if(sBuf != NULL)
ompi_java_releaseReadPtr(sPtr, sItem, sBuf, sdb);
ompi_java_releaseWritePtr(rPtr,rItem,env,rBuf,rdb,rOff,count,type,bType);
}
JNIEXPORT jlong JNICALL Java_mpi_Intracomm_iScan(
@ -247,29 +254,36 @@ JNIEXPORT jlong JNICALL Java_mpi_Intracomm_iScan(
}
JNIEXPORT void JNICALL Java_mpi_Intracomm_exScan(
JNIEnv *env, jobject jthis, jlong comm,
jobject sendBuf, jboolean sdb, jint sendOff,
jobject recvBuf, jboolean rdb, jint recvOff, jint count,
jlong type, int bType, jobject jOp, jlong hOp)
JNIEnv *env, jobject jthis, jlong jComm,
jobject sBuf, jboolean sdb, jint sOff,
jobject rBuf, jboolean rdb, jint rOff, jint count,
jlong jType, int bType, jobject jOp, jlong hOp)
{
void *sPtr, *sBase, *rPtr, *rBase;
MPI_Comm comm = (MPI_Comm)jComm;
MPI_Datatype type = (MPI_Datatype)jType;
if(sendBuf == NULL)
void *sPtr, *rPtr;
ompi_java_buffer_t *sItem, *rItem;
if(sBuf == NULL)
{
sPtr = MPI_IN_PLACE;
ompi_java_getReadPtr(&rPtr,&rItem,env,rBuf,rdb,rOff,count,type,bType);
}
else
sPtr = ompi_java_getBufPtr(&sBase, env, sendBuf, sdb, bType, sendOff);
rPtr = ompi_java_getBufPtr(&rBase, env, recvBuf, rdb, bType, recvOff);
int rc = MPI_Exscan(sPtr, rPtr, count, (MPI_Datatype)type,
ompi_java_op_getHandle(env, jOp, hOp, bType),
(MPI_Comm)comm);
{
ompi_java_getReadPtr(&sPtr,&sItem,env,sBuf,sdb,sOff,count,type,bType);
ompi_java_getWritePtr(&rPtr, &rItem, env, rBuf, rdb, count, type);
}
MPI_Op op = ompi_java_op_getHandle(env, jOp, hOp, bType);
int rc = MPI_Exscan(sPtr, rPtr, count, type, op, comm);
ompi_java_exceptionCheck(env, rc);
ompi_java_releaseBufPtr(env, recvBuf, rdb, rBase, bType);
if(sendBuf != NULL)
ompi_java_releaseReadBufPtr(env, sendBuf, sdb, sBase, bType);
if(sBuf != NULL)
ompi_java_releaseReadPtr(sPtr, sItem, sBuf, sdb);
ompi_java_releaseWritePtr(rPtr,rItem,env,rBuf,rdb,rOff,count,type,bType);
}
JNIEXPORT jlong JNICALL Java_mpi_Intracomm_iExScan(

Просмотреть файл

@ -64,20 +64,35 @@
#include <dlfcn.h>
#include "opal/util/output.h"
#include "opal/datatype/opal_convertor.h"
#include "opal/mca/base/mca_base_var.h"
#include "mpi.h"
#include "ompi/errhandler/errcode.h"
#include "ompi/datatype/ompi_datatype.h"
#include "mpi_MPI.h"
#include "mpiJava.h"
int ompi_mpi_java_eager = 65536;
ompi_java_globals_t ompi_java;
static int len = 0;
static char **sargs = 0;
int ompi_mpi_java_eager = 65536;
opal_free_list_t ompi_java_buffers;
static void *libmpi = NULL;
static void bufferConstructor(ompi_java_buffer_t *item)
{
item->buffer = malloc(ompi_mpi_java_eager);
}
static void bufferDestructor(ompi_java_buffer_t *item)
{
free(item->buffer);
}
OBJ_CLASS_INSTANCE(ompi_java_buffer_t,
opal_free_list_item_t,
bufferConstructor,
bufferDestructor);
/*
* Class: mpi_MPI
* Method: loadGlobalLibraries
@ -130,6 +145,19 @@ void JNI_OnUnload(JavaVM *vm, void *reserved)
dlclose(libmpi);
}
static void initFreeList(void)
{
OBJ_CONSTRUCT(&ompi_java_buffers, opal_free_list_t);
int r = opal_free_list_init(&ompi_java_buffers, sizeof(ompi_java_buffer_t),
OBJ_CLASS(ompi_java_buffer_t), 4, -1, 4);
if(r != OPAL_SUCCESS)
{
fprintf(stderr, "Unable to initialize ompi_java_buffers.\n");
exit(1);
}
}
static jclass findClass(JNIEnv *env, const char *className)
{
jclass c = (*env)->FindClass(env, className),
@ -228,15 +256,16 @@ JNIEXPORT jobjectArray JNICALL Java_mpi_MPI_Init_1jni(
jclass string;
jobject value;
len = (*env)->GetArrayLength(env,argv);
sargs = (char**)calloc(len+1, sizeof(char*));
int len = (*env)->GetArrayLength(env, argv);
char **sargs = (char**)calloc(len+1, sizeof(char*));
for(i = 0; i < len; i++)
{
jstring jc = (jstring)(*env)->GetObjectArrayElement(env, argv, i);
const char *s = (*env)->GetStringUTFChars(env, jc, 0);
const char *s = (*env)->GetStringUTFChars(env, jc, NULL);
sargs[i] = (char*)calloc(strlen(s) + 1, sizeof(char));
strcpy(sargs[i], s);
(*env)->ReleaseStringUTFChars(env, jc, s);
(*env)->DeleteLocalRef(env, jc);
}
@ -254,6 +283,7 @@ JNIEXPORT jobjectArray JNICALL Java_mpi_MPI_Init_1jni(
}
findClasses(env);
initFreeList();
return value;
}
@ -261,8 +291,8 @@ JNIEXPORT jint JNICALL Java_mpi_MPI_InitThread_1jni(
JNIEnv *env, jclass clazz, jobjectArray argv, jint required)
{
jsize i;
len = (*env)->GetArrayLength(env,argv);
sargs = (char**)calloc(len+1, sizeof(char*));
int len = (*env)->GetArrayLength(env,argv);
char **sargs = (char**)calloc(len+1, sizeof(char*));
for(i = 0; i < len; i++)
{
@ -270,6 +300,7 @@ JNIEXPORT jint JNICALL Java_mpi_MPI_InitThread_1jni(
const char *s = (*env)->GetStringUTFChars(env, jc, 0);
sargs[i] = (char*)calloc(strlen(s) + 1, sizeof(char));
strcpy(sargs[i], s);
(*env)->ReleaseStringUTFChars(env, jc, s);
(*env)->DeleteLocalRef(env, jc);
}
@ -278,6 +309,7 @@ JNIEXPORT jint JNICALL Java_mpi_MPI_InitThread_1jni(
ompi_java_exceptionCheck(env, rc);
findClasses(env);
initFreeList();
return provided;
}
@ -300,6 +332,7 @@ JNIEXPORT jboolean JNICALL Java_mpi_MPI_isThreadMain_1jni(
JNIEXPORT void JNICALL Java_mpi_MPI_Finalize_1jni(JNIEnv *env, jclass obj)
{
OBJ_DESTRUCT(&ompi_java_buffers);
int rc = MPI_Finalize();
ompi_java_exceptionCheck(env, rc);
deleteClasses(env);
@ -363,138 +396,11 @@ JNIEXPORT void JNICALL Java_mpi_MPI_detachBuffer_1jni(
(*env)->ReleaseByteArrayElements(env,buf,bufptr,0);
}
static void* getArrayPtr(void** bufBase, JNIEnv *env,
jobject buf, int baseType, int offset)
void* ompi_java_getArrayCritical(void** bufBase, JNIEnv *env,
jobject buf, int offset)
{
switch(baseType)
{
case 0: /* NULL */
*bufBase = NULL;
return NULL;
case 1: {
jbyte* els = (*env)->GetByteArrayElements(env, buf, NULL);
*bufBase = els;
return els + offset;
}
case 2: {
jchar* els = (*env)->GetCharArrayElements(env, buf, NULL);
*bufBase = els;
return els + offset;
}
case 3: {
jshort* els = (*env)->GetShortArrayElements(env, buf, NULL);
*bufBase = els;
return els + offset;
}
case 4: {
jboolean* els = (*env)->GetBooleanArrayElements(env, buf, NULL);
*bufBase = els;
return els + offset;
}
case 5: {
jint* els = (*env)->GetIntArrayElements(env, buf, NULL);
*bufBase = els;
return els + offset;
}
case 6: {
jlong* els = (*env)->GetLongArrayElements(env, buf, NULL);
*bufBase = els;
return els + offset;
}
case 7: {
jfloat* els = (*env)->GetFloatArrayElements(env, buf, NULL);
*bufBase = els;
return els + offset;
}
case 8: {
jdouble* els = (*env)->GetDoubleArrayElements(env, buf, NULL);
*bufBase = els;
return els + offset;
}
case 9: {
jbyte* els = (*env)->GetByteArrayElements(env, buf, NULL);
*bufBase = els;
return els + offset;
}
default:
*bufBase = NULL;
return NULL; /* 'UNDEFINED' */
}
}
static void releaseArrayPtr(JNIEnv *e, jobject buf, void *bufBase,
int baseType, jint mode)
{
switch(baseType)
{
case 0:
break;
case 1:
(*e)->ReleaseByteArrayElements(e, buf, (jbyte*)bufBase, mode);
break;
case 2:
(*e)->ReleaseCharArrayElements(e, buf, (jchar*)bufBase, mode);
break;
case 3:
(*e)->ReleaseShortArrayElements(e, buf, (jshort*)bufBase, mode);
break;
case 4:
(*e)->ReleaseBooleanArrayElements(e, buf, (jboolean*)bufBase, mode);
break;
case 5:
(*e)->ReleaseIntArrayElements(e, buf, (jint*)bufBase, mode);
break;
case 6:
(*e)->ReleaseLongArrayElements(e, buf, (jlong*)bufBase, mode);
break;
case 7:
(*e)->ReleaseFloatArrayElements(e, buf, (jfloat*)bufBase, mode);
break;
case 8:
(*e)->ReleaseDoubleArrayElements(e, buf, (jdouble*)bufBase, mode);
break;
case 9:
(*e)->ReleaseByteArrayElements(e, buf, (jbyte*)bufBase, mode);
break;
default:
break;
}
}
void* ompi_java_getBufPtr(void** bufBase, JNIEnv *env, jobject buf,
jboolean db, int baseType, int offset)
{
if(buf == NULL)
{
/* Allow NULL buffers to send/recv 0 items as control messages. */
*bufBase = NULL;
return NULL;
}
else if(db)
{
*bufBase = (*env)->GetDirectBufferAddress(env, buf);
assert(offset == 0);
return *bufBase;
}
else
{
return getArrayPtr(bufBase, env, buf, baseType, offset);
}
}
void ompi_java_releaseBufPtr(JNIEnv *env, jobject buf, jboolean db,
void* bufBase, int baseType)
{
if(!db && buf)
releaseArrayPtr(env, buf, bufBase, baseType, 0);
}
void ompi_java_releaseReadBufPtr(JNIEnv *env, jobject buf, jboolean db,
void *bufBase, int baseType)
{
if(!db && buf)
releaseArrayPtr(env, buf, bufBase, baseType, JNI_ABORT);
*bufBase = (jbyte*)(*env)->GetPrimitiveArrayCritical(env, buf, NULL);
return ((jbyte*)*bufBase) + offset;
}
void* ompi_java_getDirectBufferAddress(JNIEnv *env, jobject buf)
@ -503,6 +409,496 @@ void* ompi_java_getDirectBufferAddress(JNIEnv *env, jobject buf)
return buf == NULL ? NULL : (*env)->GetDirectBufferAddress(env, buf);
}
static int getTypeExtent(JNIEnv *env, MPI_Datatype type)
{
MPI_Aint lb, extent;
int rc = MPI_Type_get_extent(type, &lb, &extent);
ompi_java_exceptionCheck(env, rc);
int value = extent;
assert(((MPI_Aint)value) == extent);
return value;
}
static void getArrayRegion(JNIEnv *env, jobject buf, int baseType,
int offset, int length, void *ptr)
{
switch(baseType)
{
case 0:
break;
case 1:
(*env)->GetByteArrayRegion(env, buf, offset, length, ptr);
break;
case 2:
(*env)->GetCharArrayRegion(env, buf, offset / 2, length / 2, ptr);
break;
case 3:
(*env)->GetShortArrayRegion(env, buf, offset / 2, length / 2, ptr);
break;
case 4:
(*env)->GetBooleanArrayRegion(env, buf, offset, length, ptr);
break;
case 5:
(*env)->GetIntArrayRegion(env, buf, offset / 4, length / 4, ptr);
break;
case 6:
(*env)->GetLongArrayRegion(env, buf, offset / 8, length / 8, ptr);
break;
case 7:
(*env)->GetFloatArrayRegion(env, buf, offset / 4, length / 4, ptr);
break;
case 8:
(*env)->GetDoubleArrayRegion(env, buf, offset / 8, length / 8, ptr);
break;
case 9:
(*env)->GetByteArrayRegion(env, buf, offset, length, ptr);
break;
default:
assert(0);
}
}
static void setArrayRegion(JNIEnv *env, jobject buf, int baseType,
int offset, int length, void *ptr)
{
switch(baseType)
{
case 0:
break;
case 1:
(*env)->SetByteArrayRegion(env, buf, offset, length, ptr);
break;
case 2:
(*env)->SetCharArrayRegion(env, buf, offset / 2, length / 2, ptr);
break;
case 3:
(*env)->SetShortArrayRegion(env, buf, offset / 2, length / 2, ptr);
break;
case 4:
(*env)->SetBooleanArrayRegion(env, buf, offset, length, ptr);
break;
case 5:
(*env)->SetIntArrayRegion(env, buf, offset / 4, length / 4, ptr);
break;
case 6:
(*env)->SetLongArrayRegion(env, buf, offset / 8, length / 8, ptr);
break;
case 7:
(*env)->SetFloatArrayRegion(env, buf, offset / 4, length / 4, ptr);
break;
case 8:
(*env)->SetDoubleArrayRegion(env, buf, offset / 8, length / 8, ptr);
break;
case 9:
(*env)->SetByteArrayRegion(env, buf, offset, length, ptr);
break;
default:
assert(0);
}
}
static void* getBuffer(JNIEnv *env, ompi_java_buffer_t **item, int size)
{
if(size > ompi_mpi_java_eager)
{
*item = NULL;
return malloc(size);
}
else
{
int rc;
opal_free_list_item_t *freeListItem;
OPAL_FREE_LIST_GET(&ompi_java_buffers, freeListItem, rc);
ompi_java_exceptionCheck(env,
rc==OPAL_SUCCESS ? OMPI_SUCCESS : OMPI_ERROR);
*item = (ompi_java_buffer_t*)freeListItem;
return (*item)->buffer;
}
}
static void releaseBuffer(void *ptr, ompi_java_buffer_t *item)
{
if(item == NULL)
{
free(ptr);
}
else
{
assert(item->buffer == ptr);
OPAL_FREE_LIST_RETURN(&ompi_java_buffers, (opal_free_list_item_t*)item);
}
}
static int getCountv(int *counts, int *displs, int size)
{
/* Maybe displs is not ordered. */
int i, max = 0;
for(i = 1; i < size; i++)
{
if(displs[max] < displs[i])
max = i;
}
return displs[max] * counts[max];
}
static void* getReadPtr(ompi_java_buffer_t **item, JNIEnv *env, jobject buf,
int offset, int count, MPI_Datatype type, int baseType)
{
int length = count * getTypeExtent(env, type);
void *ptr = getBuffer(env, item, length);
if(opal_datatype_is_contiguous_memory_layout(&type->super, count))
{
getArrayRegion(env, buf, baseType, offset, length, ptr);
}
else
{
void *inBuf, *inBase;
inBuf = ompi_java_getArrayCritical(&inBase, env, buf, offset);
int rc = opal_datatype_copy_content_same_ddt(
&type->super, count, ptr, inBuf);
ompi_java_exceptionCheck(env,
rc==OPAL_SUCCESS ? OMPI_SUCCESS : OMPI_ERROR);
(*env)->ReleasePrimitiveArrayCritical(env, buf, inBase, JNI_ABORT);
}
return ptr;
}
static void* getReadPtrRank(
ompi_java_buffer_t **item, JNIEnv *env, jobject buf, int offset,
int count, int size, int rank, MPI_Datatype type, int baseType)
{
int extent = getTypeExtent(env, type),
rLen = extent * count,
length = rLen * size,
rDispl = rLen * rank,
rOff = offset + rDispl;
void *ptr = getBuffer(env, item, length);
void *rPtr = (char*)ptr + rDispl;
if(opal_datatype_is_contiguous_memory_layout(&type->super, count))
{
getArrayRegion(env, buf, baseType, rOff, rLen, rPtr);
}
else
{
void *bufPtr, *bufBase;
bufPtr = ompi_java_getArrayCritical(&bufBase, env, buf, rOff);
int rc = opal_datatype_copy_content_same_ddt(
&type->super, count, rPtr, bufPtr);
ompi_java_exceptionCheck(env,
rc==OPAL_SUCCESS ? OMPI_SUCCESS : OMPI_ERROR);
(*env)->ReleasePrimitiveArrayCritical(env, buf, bufBase, JNI_ABORT);
}
return ptr;
}
static void* getReadPtrvRank(
ompi_java_buffer_t **item, JNIEnv *env, jobject buf,
int offset, int *counts, int *displs, int size,
int rank, MPI_Datatype type, int baseType)
{
int extent = getTypeExtent(env, type),
length = extent * getCountv(counts, displs, size);
void *ptr = getBuffer(env, item, length);
int rootOff = offset + extent * displs[rank];
if(opal_datatype_is_contiguous_memory_layout(&type->super, counts[rank]))
{
int rootLength = extent * counts[rank];
void *rootPtr = (char*)ptr + extent * displs[rank];
getArrayRegion(env, buf, baseType, rootOff, rootLength, rootPtr);
}
else
{
void *inBuf, *inBase;
inBuf = ompi_java_getArrayCritical(&inBase, env, buf, rootOff);
int rc = opal_datatype_copy_content_same_ddt(
&type->super, counts[rank], ptr, inBuf);
ompi_java_exceptionCheck(env,
rc==OPAL_SUCCESS ? OMPI_SUCCESS : OMPI_ERROR);
(*env)->ReleasePrimitiveArrayCritical(env, buf, inBase, JNI_ABORT);
}
return ptr;
}
static void* getReadPtrvAll(
ompi_java_buffer_t **item, JNIEnv *env, jobject buf,
int offset, int *counts, int *displs, int size,
MPI_Datatype type, int baseType)
{
int i,
extent = getTypeExtent(env, type),
length = extent * getCountv(counts, displs, size);
void *ptr = getBuffer(env, item, length);
if(opal_datatype_is_contiguous_memory_layout(&type->super, 2))
{
for(i = 0; i < size; i++)
{
int iOff = offset + extent * displs[i],
iLen = extent * counts[i];
void *iPtr = (char*)ptr + extent * displs[i];
getArrayRegion(env, buf, baseType, iOff, iLen, iPtr);
}
}
else
{
void *bufPtr, *bufBase;
bufPtr = ompi_java_getArrayCritical(&bufBase, env, buf, offset);
for(i = 0; i < size; i++)
{
int iOff = extent * displs[i];
char *iBuf = iOff + (char*)bufPtr,
*iPtr = iOff + (char*)ptr;
int rc = opal_datatype_copy_content_same_ddt(
&type->super, counts[i], iPtr, iBuf);
ompi_java_exceptionCheck(env,
rc==OPAL_SUCCESS ? OMPI_SUCCESS : OMPI_ERROR);
}
(*env)->ReleasePrimitiveArrayCritical(env, buf, bufBase, JNI_ABORT);
}
return ptr;
}
static void* getWritePtr(ompi_java_buffer_t **item, JNIEnv *env,
int count, MPI_Datatype type)
{
int extent = getTypeExtent(env, type),
length = count * extent;
return getBuffer(env, item, length);
}
static void* getWritePtrv(ompi_java_buffer_t **item, JNIEnv *env,
int *counts, int *displs, int size, MPI_Datatype type)
{
int extent = getTypeExtent(env, type),
count = getCountv(counts, displs, size),
length = extent * count;
return getBuffer(env, item, length);
}
void ompi_java_getReadPtr(
void **ptr, ompi_java_buffer_t **item, JNIEnv *env, jobject buf,
jboolean db, int offset, int count, MPI_Datatype type, int baseType)
{
if(buf == NULL || baseType == 0)
{
/* Allow NULL buffers to send/recv 0 items as control messages. */
*ptr = NULL;
*item = NULL;
}
else if(db)
{
assert(offset == 0);
*ptr = (*env)->GetDirectBufferAddress(env, buf);
*item = NULL;
}
else
{
*ptr = getReadPtr(item, env, buf, offset, count, type, baseType);
}
}
void ompi_java_getReadPtrRank(
void **ptr, ompi_java_buffer_t **item, JNIEnv *env,
jobject buf, jboolean db, int offset, int count, int size,
int rank, MPI_Datatype type, int baseType)
{
if(buf == NULL || baseType == 0)
{
/* Allow NULL buffers to send/recv 0 items as control messages. */
*ptr = NULL;
*item = NULL;
}
else if(db)
{
assert(offset == 0);
*ptr = (*env)->GetDirectBufferAddress(env, buf);
*item = NULL;
}
else
{
*ptr = getReadPtrRank(item, env, buf, offset, count,
size, rank, type, baseType);
}
}
void ompi_java_getReadPtrv(
void **ptr, ompi_java_buffer_t **item, JNIEnv *env,
jobject buf, jboolean db, int offset, int *counts, int *displs,
int size, int rank, MPI_Datatype type, int baseType)
{
if(buf == NULL)
{
/* Allow NULL buffers to send/recv 0 items as control messages. */
*ptr = NULL;
*item = NULL;
}
else if(db)
{
assert(offset == 0);
*ptr = (*env)->GetDirectBufferAddress(env, buf);
*item = NULL;
}
else if(rank == -1)
{
*ptr = getReadPtrvAll(item, env, buf, offset, counts,
displs, size, type, baseType);
}
else
{
*ptr = getReadPtrvRank(item, env, buf, offset, counts,
displs, size, rank, type, baseType);
}
}
void ompi_java_releaseReadPtr(
void *ptr, ompi_java_buffer_t *item, jobject buf, jboolean db)
{
if(!db && buf && ptr)
releaseBuffer(ptr, item);
}
void ompi_java_getWritePtr(
void **ptr, ompi_java_buffer_t **item, JNIEnv *env,
jobject buf, jboolean db, int count, MPI_Datatype type)
{
if(buf == NULL)
{
/* Allow NULL buffers to send/recv 0 items as control messages. */
*ptr = NULL;
*item = NULL;
}
else if(db)
{
*ptr = (*env)->GetDirectBufferAddress(env, buf);
*item = NULL;
}
else
{
*ptr = getWritePtr(item, env, count, type);
}
}
void ompi_java_getWritePtrv(
void **ptr, ompi_java_buffer_t **item, JNIEnv *env, jobject buf,
jboolean db, int *counts, int *displs, int size, MPI_Datatype type)
{
if(buf == NULL)
{
/* Allow NULL buffers to send/recv 0 items as control messages. */
*ptr = NULL;
*item = NULL;
}
else if(db)
{
*ptr = (*env)->GetDirectBufferAddress(env, buf);
*item = NULL;
}
else
{
*ptr = getWritePtrv(item, env, counts, displs, size, type);
}
}
void ompi_java_releaseWritePtr(
void *ptr, ompi_java_buffer_t *item, JNIEnv *env, jobject buf,
jboolean db, int offset, int count, MPI_Datatype type, int baseType)
{
if(db || !buf || !ptr)
return;
if(opal_datatype_is_contiguous_memory_layout(&type->super, count))
{
int length = count * getTypeExtent(env, type);
setArrayRegion(env, buf, baseType, offset, length, ptr);
}
else
{
void *inBuf, *inBase;
inBuf = ompi_java_getArrayCritical(&inBase, env, buf, offset);
int rc = opal_datatype_copy_content_same_ddt(
&type->super, count, inBuf, ptr);
ompi_java_exceptionCheck(env,
rc==OPAL_SUCCESS ? OMPI_SUCCESS : OMPI_ERROR);
(*env)->ReleasePrimitiveArrayCritical(env, buf, inBase, 0);
}
releaseBuffer(ptr, item);
}
void ompi_java_releaseWritePtrv(
void *ptr, ompi_java_buffer_t *item, JNIEnv *env,
jobject buf, jboolean db, int offset, int *counts, int *displs,
int size, MPI_Datatype type, int baseType)
{
if(db || !buf || !ptr)
return;
int i;
int extent = getTypeExtent(env, type);
if(opal_datatype_is_contiguous_memory_layout(&type->super, 2))
{
for(i = 0; i < size; i++)
{
int iOff = offset + extent * displs[i],
iLen = extent * counts[i];
void *iPtr = (char*)ptr + extent * displs[i];
setArrayRegion(env, buf, baseType, iOff, iLen, iPtr);
}
}
else
{
void *bufPtr, *bufBase;
bufPtr = ompi_java_getArrayCritical(&bufBase, env, buf, offset);
for(i = 0; i < size; i++)
{
int iOff = extent * displs[i];
char *iBuf = iOff + (char*)bufPtr,
*iPtr = iOff + (char*)ptr;
int rc = opal_datatype_copy_content_same_ddt(
&type->super, counts[i], iBuf, iPtr);
ompi_java_exceptionCheck(env,
rc==OPAL_SUCCESS ? OMPI_SUCCESS : OMPI_ERROR);
}
(*env)->ReleasePrimitiveArrayCritical(env, buf, bufBase, 0);
}
releaseBuffer(ptr, item);
}
jobject ompi_java_Integer_valueOf(JNIEnv *env, jint i)
{
return (*env)->CallStaticObjectMethod(env,

Просмотреть файл

@ -64,20 +64,21 @@ JNIEXPORT jobject JNICALL Java_mpi_Message_imProbe(
JNIEXPORT jlong JNICALL Java_mpi_Message_mRecv(
JNIEnv *env, jobject jthis, jlong jMessage, jobject buf, jboolean db,
jint offset, jint count, jlong jType, jint bType, jlongArray jStatus)
jint off, jint count, jlong jType, jint bType, jlongArray jStatus)
{
MPI_Message message = (MPI_Message)jMessage;
MPI_Datatype type = (MPI_Datatype)jType;
void *bufPtr, *bufBase;
bufPtr = ompi_java_getBufPtr(&bufBase, env, buf, db, bType, offset);
void *ptr;
ompi_java_buffer_t *item;
ompi_java_getWritePtr(&ptr, &item, env, buf, db, count, type);
MPI_Status status;
int rc = MPI_Mrecv(bufPtr, count, type, &message, &status);
int rc = MPI_Mrecv(ptr, count, type, &message, &status);
ompi_java_exceptionCheck(env, rc);
ompi_java_status_set(env, jStatus, &status);
ompi_java_releaseBufPtr(env, buf, db, bufBase, bType);
ompi_java_releaseWritePtr(ptr, item, env, buf, db, off, count, type, bType);
return (jlong)message;
}

Просмотреть файл

@ -350,7 +350,7 @@ public final void send(Object buf, int count, Datatype type, int dest, int tag)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -382,7 +382,7 @@ public final Status recv(Object buf, int count,
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -434,13 +434,13 @@ public final Status sendRecv(
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -488,7 +488,7 @@ public final Status sendRecvReplace(
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -527,7 +527,7 @@ public final void bSend(Object buf, int count, Datatype type, int dest, int tag)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -558,7 +558,7 @@ public final void sSend(Object buf, int count, Datatype type, int dest, int tag)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -589,7 +589,7 @@ public final void rSend(Object buf, int count, Datatype type, int dest, int tag)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -883,18 +883,17 @@ public final int pack(Object inbuf, int incount, Datatype type,
if(inbuf instanceof Buffer && !(indb = ((Buffer)inbuf).isDirect()))
{
offset = ((Buffer)inbuf).arrayOffset();
offset = type.getOffset(inbuf);
inbuf = ((Buffer)inbuf).array();
}
return pack(handle, inbuf, indb, offset, incount,
type.handle, type.baseType, outbuf, position);
type.handle, outbuf, position);
}
private native int pack(
long comm, Object inbuf, boolean indb, int offset, int incount,
long type, int baseType, byte[] outbuf, int position)
throws MPIException;
long type, byte[] outbuf, int position) throws MPIException;
/**
* Unpacks message in receive buffer {@code outbuf} into space specified in
@ -922,17 +921,17 @@ public final int unpack(byte[] inbuf, int position,
if(outbuf instanceof Buffer && !(outdb = ((Buffer)outbuf).isDirect()))
{
offset = ((Buffer)outbuf).arrayOffset();
offset = type.getOffset(outbuf);
outbuf = ((Buffer)outbuf).array();
}
return unpack(handle, inbuf, position, outbuf, outdb,
offset, outcount, type.handle, type.baseType);
offset, outcount, type.handle);
}
private native int unpack(
long comm, byte[] inbuf, int position, Object outbuf, boolean outdb,
int offset, int outcount, long type, int baseType) throws MPIException;
int offset, int outcount, long type) throws MPIException;
/**
* Returns an upper bound on the increment of {@code position} effected
@ -1205,7 +1204,7 @@ public final void bcast(Object buf, int count, Datatype type, int root)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -1266,13 +1265,13 @@ public final void gather(
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -1303,7 +1302,7 @@ public final void gather(Object buf, int count, Datatype type, int root)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -1400,13 +1399,13 @@ public final void gatherv(Object sendbuf, int sendcount, Datatype sendtype,
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -1439,7 +1438,7 @@ public final void gatherv(Object recvbuf, int[] recvcount, int[] displs,
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -1469,7 +1468,7 @@ public final void gatherv(Object sendbuf, int sendcount,
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
@ -1595,13 +1594,13 @@ public final void scatter(
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -1632,7 +1631,7 @@ public final void scatter(Object buf, int count, Datatype type, int root)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -1727,13 +1726,13 @@ public final void scatterv(
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -1765,7 +1764,7 @@ public final void scatterv(Object sendbuf, int[] sendcount, int[] displs,
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
@ -1795,7 +1794,7 @@ public final void scatterv(Object recvbuf, int recvcount,
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -1915,13 +1914,13 @@ public final void allGather(Object sendbuf, int sendcount, Datatype sendtype,
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -1949,7 +1948,7 @@ public final void allGather(Object buf, int count, Datatype type)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -2036,13 +2035,13 @@ public final void allGatherv(
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -2072,7 +2071,7 @@ public final void allGatherv(Object recvbuf, int[] recvcount,
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -2166,13 +2165,13 @@ public final void allToAll(Object sendbuf, int sendcount, Datatype sendtype,
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -2246,13 +2245,13 @@ public final void allToAllv(
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -2328,13 +2327,13 @@ public final void neighborAllGather(
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -2406,13 +2405,13 @@ public final void neighborAllGatherv(
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -2483,13 +2482,13 @@ public final void neighborAllToAll(
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -2561,13 +2560,13 @@ public final void neighborAllToAllv(
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = sendtype.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = recvtype.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -2650,13 +2649,13 @@ public final void reduce(Object sendbuf, Object recvbuf, int count,
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = type.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = type.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -2687,7 +2686,7 @@ public final void reduce(Object buf, int count, Datatype type, Op op, int root)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -2786,13 +2785,13 @@ public final void allReduce(Object sendbuf, Object recvbuf,
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = type.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = type.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -2821,7 +2820,7 @@ public final void allReduce(Object buf, int count, Datatype type, Op op)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -2913,13 +2912,13 @@ public final void reduceScatter(Object sendbuf, Object recvbuf,
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = type.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = type.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -2949,7 +2948,7 @@ public final void reduceScatter(Object buf, int[] counts, Datatype type, Op op)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -3043,13 +3042,13 @@ public final void reduceScatterBlock(Object sendbuf, Object recvbuf,
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = type.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = type.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -3078,7 +3077,7 @@ public final void reduceScatterBlock(
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -3170,20 +3169,20 @@ public static void reduceLocal(
if(inBuf instanceof Buffer && !(idb = ((Buffer)inBuf).isDirect()))
{
inOff = ((Buffer)inBuf).arrayOffset();
inOff = type.getOffset(inBuf);
inBuf = ((Buffer)inBuf).array();
}
if(inOutBuf instanceof Buffer && !(iodb = ((Buffer)inOutBuf).isDirect()))
{
inOutOff = ((Buffer)inOutBuf).arrayOffset();
inOutOff = type.getOffset(inOutBuf);
inOutBuf = ((Buffer)inOutBuf).array();
}
if(op.uf == null)
{
reduceLocal(inBuf, idb, inOff, inOutBuf, iodb, inOutOff,
count, type.handle, type.baseType, op.handle);
count, type.handle, op.handle);
}
else
{
@ -3195,7 +3194,7 @@ public static void reduceLocal(
private static native void reduceLocal(
Object inBuf, boolean idb, int inOff,
Object inOutBuf, boolean iodb, int inOutOff, int count,
long type, int baseType, long op) throws MPIException;
long type, long op) throws MPIException;
private static native void reduceLocalUf(
Object inBuf, boolean idb, int inOff,

Просмотреть файл

@ -45,6 +45,8 @@
package mpi;
import java.nio.*;
/**
* The {@code Datatype} class represents {@code MPI_Datatype} handles.
*/
@ -562,4 +564,14 @@ public void deleteAttr(int keyval) throws MPIException
private native void deleteAttr(long type, int keyval) throws MPIException;
/**
* Gets the offset of a buffer in bytes.
* @param buffer buffer
* @return offset in bytes
*/
protected int getOffset(Object buffer)
{
return baseSize * ((Buffer)buffer).arrayOffset();
}
} // Datatype

Просмотреть файл

@ -267,7 +267,7 @@ public Status readAt(long offset, Object buf, int count, Datatype type)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -300,7 +300,7 @@ public Status readAtAll(long offset, Object buf, int count, Datatype type)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -333,7 +333,7 @@ public Status writeAt(long offset, Object buf, int count, Datatype type)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -366,7 +366,7 @@ public Status writeAtAll(long offset, Object buf, int count, Datatype type)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -439,7 +439,7 @@ public Status read(Object buf, int count, Datatype type) throws MPIException
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -468,7 +468,7 @@ public Status readAll(Object buf, int count, Datatype type) throws MPIException
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -497,7 +497,7 @@ public Status write(Object buf, int count, Datatype type) throws MPIException
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -526,7 +526,7 @@ public Status writeAll(Object buf, int count, Datatype type) throws MPIException
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -633,7 +633,7 @@ public Status readShared(Object buf, int count, Datatype type)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -665,7 +665,7 @@ public Status writeShared(Object buf, int count, Datatype type)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -735,7 +735,7 @@ public Status readOrdered(Object buf, int count, Datatype type)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -767,7 +767,7 @@ public Status writeOrdered(Object buf, int count, Datatype type)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -833,7 +833,7 @@ public void readAtAllBegin(long offset, Object buf, int count, Datatype type)
if(isHeapBuffer(buf))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -897,7 +897,7 @@ public void writeAtAllBegin(long offset, Object buf, int count, Datatype type)
if(isHeapBuffer(buf))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -960,7 +960,7 @@ public void readAllBegin(Object buf, int count, Datatype type)
if(isHeapBuffer(buf))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -1022,7 +1022,7 @@ public void writeAllBegin(Object buf, int count, Datatype type)
if(isHeapBuffer(buf))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -1084,7 +1084,7 @@ public void readOrderedBegin(Object buf, int count, Datatype type)
if(isHeapBuffer(buf))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}
@ -1146,7 +1146,7 @@ public void writeOrderedBegin(Object buf, int count, Datatype type)
if(isHeapBuffer(buf))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}

Просмотреть файл

@ -351,13 +351,13 @@ public final void scan(Object sendbuf, Object recvbuf,
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = type.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = type.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -386,7 +386,7 @@ public final void scan(Object recvbuf, int count, Datatype type, Op op)
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = type.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -475,13 +475,13 @@ public final void exScan(Object sendbuf, Object recvbuf,
if(sendbuf instanceof Buffer && !(sdb = ((Buffer)sendbuf).isDirect()))
{
sendoff = ((Buffer)sendbuf).arrayOffset();
sendoff = type.getOffset(sendbuf);
sendbuf = ((Buffer)sendbuf).array();
}
if(recvbuf instanceof Buffer && !(rdb = ((Buffer)recvbuf).isDirect()))
{
recvoff = ((Buffer)recvbuf).arrayOffset();
recvoff = type.getOffset(recvbuf);
recvbuf = ((Buffer)recvbuf).array();
}
@ -510,7 +510,7 @@ public final void exScan(Object buf, int count, Datatype type, Op op)
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}

Просмотреть файл

@ -122,7 +122,7 @@ public Status mRecv(Object buf, int count, Datatype type) throws MPIException
if(buf instanceof Buffer && !(db = ((Buffer)buf).isDirect()))
{
off = ((Buffer)buf).arrayOffset();
off = type.getOffset(buf);
buf = ((Buffer)buf).array();
}