1 /* 2 * Copyright (c) 2004-2007 The Trustees of Indiana University and Indiana 3 * University Research and Technology 4 * Corporation. All rights reserved. 5 * Copyright (c) 2004-2005 The University of Tennessee and The University 6 * of Tennessee Research Foundation. All rights 7 * reserved. 8 * Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, 9 * University of Stuttgart. All rights reserved. 10 * Copyright (c) 2004-2005 The Regents of the University of California. 11 * All rights reserved. 12 * Copyright (c) 2015 Los Alamos National Security, LLC. All rights 13 * reserved. 14 * $COPYRIGHT$ 15 * 16 * Additional copyrights may follow 17 * 18 * $HEADER$ 19 */ 20 21 #ifndef _MPIJAVA_H_ 22 #define _MPIJAVA_H_ 23 24 #include "mpi.h" 25 #include "opal/class/opal_free_list.h" 26 27 typedef struct { 28 jfieldID CommHandle; 29 jfieldID GroupHandle; 30 jclass CartParmsClass; 31 jmethodID CartParmsInit; 32 jclass ShiftParmsClass; 33 jmethodID ShiftParmsInit; 34 jclass VersionClass; 35 jmethodID VersionInit; 36 jclass CountClass; 37 jmethodID CountInit; 38 jclass GraphParmsClass; 39 jmethodID GraphParmsInit; 40 jclass DistGraphNeighborsClass; 41 jmethodID DistGraphNeighborsInit; 42 jfieldID DatatypeHandle; 43 jfieldID DatatypeBaseType; 44 jfieldID DatatypeBaseSize; 45 jfieldID MessageHandle; 46 jfieldID OpHandle; 47 jfieldID OpCommute; 48 jmethodID OpCall; 49 jfieldID ReqHandle; 50 jclass StatusClass; 51 jfieldID StatusData; 52 jclass ExceptionClass; 53 jmethodID ExceptionInit; 54 jclass IntegerClass; 55 jmethodID IntegerValueOf; 56 jclass LongClass; 57 jmethodID LongValueOf; 58 } ompi_java_globals_t; 59 60 extern ompi_java_globals_t ompi_java; 61 62 typedef struct ompi_java_buffer_t 63 { 64 opal_free_list_item_t super; 65 void *buffer; 66 } ompi_java_buffer_t; 67 68 OMPI_DECLSPEC OBJ_CLASS_DECLARATION(ompi_java_buffer_t); 69 70 void* ompi_java_getArrayCritical(void** bufBase, JNIEnv *env, 71 jobject buf, int offset); 72 73 void* ompi_java_getDirectBufferAddress(JNIEnv *env, jobject buf); 74 75 /* Gets a buffer pointer for reading (copy from Java). */ 76 void ompi_java_getReadPtr( 77 void **ptr, ompi_java_buffer_t **item, JNIEnv *env, jobject buf, 78 jboolean db, int offset, int count, MPI_Datatype type, int baseType); 79 80 /* Gets a buffer pointer for reading. 81 * It only copies from java the rank data. 82 * 'size' is the number of processes. */ 83 void ompi_java_getReadPtrRank( 84 void **ptr, ompi_java_buffer_t **item, JNIEnv *env, 85 jobject buf, jboolean db, int offset, int count, int size, 86 int rank, MPI_Datatype type, int baseType); 87 88 /* Gets a buffer pointer for reading, but it 89 * 'size' is the number of processes. 90 * if rank == -1 it copies all data from Java. 91 * if rank != -1 it only copies from Java the rank data. */ 92 void ompi_java_getReadPtrv( 93 void **ptr, ompi_java_buffer_t **item, JNIEnv *env, 94 jobject buf, jboolean db, int off, int *counts, int *displs, 95 int size, int rank, MPI_Datatype type, int baseType); 96 97 /* Releases a buffer used for reading. */ 98 void ompi_java_releaseReadPtr( 99 void *ptr, ompi_java_buffer_t *item, jobject buf, jboolean db); 100 101 /* Gets a buffer pointer for writing. */ 102 void ompi_java_getWritePtr( 103 void **ptr, ompi_java_buffer_t **item, JNIEnv *env, 104 jobject buf, jboolean db, int count, MPI_Datatype type); 105 106 /* Gets a buffer pointer for writing. 107 * 'size' is the number of processes. */ 108 void ompi_java_getWritePtrv( 109 void **ptr, ompi_java_buffer_t **item, JNIEnv *env, jobject buf, 110 jboolean db, int *counts, int *displs, int size, MPI_Datatype type); 111 112 /* Releases a buffer used for writing. 113 * It copies data to Java. */ 114 void ompi_java_releaseWritePtr( 115 void *ptr, ompi_java_buffer_t *item, JNIEnv *env, jobject buf, 116 jboolean db, int offset, int count, MPI_Datatype type, int baseType); 117 118 /* Releases a buffer used for writing. 119 * It copies data to Java. 120 * 'size' is the number of processes. */ 121 void ompi_java_releaseWritePtrv( 122 void *ptr, ompi_java_buffer_t *item, JNIEnv *env, 123 jobject buf, jboolean db, int off, int *counts, int *displs, 124 int size, MPI_Datatype type, int baseType); 125 126 void ompi_java_setStaticLongField(JNIEnv *env, jclass c, 127 char *field, jlong value); 128 129 void ompi_java_setIntField(JNIEnv *env, jclass c, jobject obj, 130 char *field, jint value); 131 132 jobject ompi_java_Integer_valueOf(JNIEnv *env, jint i); 133 jobject ompi_java_Long_valueOf(JNIEnv *env, jlong i); 134 135 void ompi_java_getIntArray( 136 JNIEnv *env, jintArray array, jint **jptr, int **cptr); 137 void ompi_java_releaseIntArray( 138 JNIEnv *env, jintArray array, jint *jptr, int *cptr); 139 void ompi_java_forgetIntArray( 140 JNIEnv *env, jintArray array, jint *jptr, int *cptr); 141 142 void ompi_java_getDatatypeArray( 143 JNIEnv *env, jlongArray array, jlong **jptr, MPI_Datatype **cptr); 144 void ompi_java_forgetDatatypeArray( 145 JNIEnv *env, jlongArray array, jlong *jptr, MPI_Datatype *cptr); 146 147 void ompi_java_getBooleanArray( 148 JNIEnv *env, jbooleanArray array, jboolean **jptr, int **cptr); 149 void ompi_java_releaseBooleanArray( 150 JNIEnv *env, jbooleanArray array, jboolean *jptr, int *cptr); 151 void ompi_java_forgetBooleanArray( 152 JNIEnv *env, jbooleanArray array, jboolean *jptr, int *cptr); 153 154 void ompi_java_getPtrArray( 155 JNIEnv *env, jlongArray array, jlong **jptr, void ***cptr); 156 void ompi_java_releasePtrArray( 157 JNIEnv *env, jlongArray array, jlong *jptr, void **cptr); 158 159 jboolean ompi_java_exceptionCheck(JNIEnv *env, int rc); 160 161 void* ompi_java_attrSet(JNIEnv *env, jbyteArray jval); 162 jbyteArray ompi_java_attrGet(JNIEnv *env, void *cval); 163 int ompi_java_attrCopy(void *attrValIn, void *attrValOut, int *flag); 164 int ompi_java_attrDelete(void *attrVal); 165 166 MPI_Op ompi_java_op_getHandle( 167 JNIEnv *env, jobject jOp, jlong hOp, int baseType); 168 169 jobject ompi_java_status_new(JNIEnv *env, MPI_Status *status); 170 jobject ompi_java_status_newIndex(JNIEnv *env, MPI_Status *status, int index); 171 172 void ompi_java_status_set( 173 JNIEnv *env, jlongArray jData, MPI_Status *status); 174 void ompi_java_status_setIndex( 175 JNIEnv *env, jlongArray jData, MPI_Status *status, int index); 176 177 #endif /* _MPIJAVA_H_ */ 178