16
16
* Copyright (c) 2015 Intel, Inc. All rights reserved.
17
17
* Copyright (c) 2015 Research Organization for Information Science
18
18
* and Technology (RIST). All rights reserved.
19
- * Copyright (c) 2016 IBM Corporation. All rights reserved.
19
+ * Copyright (c) 2016-2017 IBM Corporation. All rights reserved.
20
20
* $COPYRIGHT$
21
21
*
22
22
* Additional copyrights may follow
87
87
ompi_java_globals_t ompi_java = {0 };
88
88
int ompi_mpi_java_eager = 65536 ;
89
89
opal_free_list_t ompi_java_buffers = {{{0 }}};
90
- static void * libmpi = NULL ;
91
90
92
91
static void bufferConstructor (ompi_java_buffer_t * item )
93
92
{
@@ -108,71 +107,16 @@ OBJ_CLASS_INSTANCE(ompi_java_buffer_t,
108
107
* Class: mpi_MPI
109
108
* Method: loadGlobalLibraries
110
109
*
111
- * Java implementations typically default to loading dynamic
112
- * libraries strictly to a local namespace. This breaks the
113
- * Open MPI model where components reference back up to the
114
- * base libraries (e.g., libmpi) as it requires that the
115
- * symbols in those base libraries be globally available.
116
- *
117
- * One option, of course, is to build with --disable-dlopen.
118
- * However, this would preclude the ability to pickup 3rd-party
119
- * binary plug-ins at time of execution. This is a valuable
120
- * capability that would be a negative factor towards use of
121
- * the Java bindings.
122
- *
123
- * The other option is to explicitly dlopen libmpi ourselves
124
- * and instruct dlopen to add all those symbols to the global
125
- * namespace. This must be done prior to calling any MPI
126
- * function (e.g., MPI_Init) or else Java will have already
127
- * loaded the library to the local namespace. So create a
128
- * special JNI entry point that just loads the required libmpi
129
- * to the global namespace and call it first (see MPI.java),
130
- * thus making all symbols available to subsequent dlopen calls
131
- * when opening OMPI components.
132
110
*/
133
111
jint JNI_OnLoad (JavaVM * vm , void * reserved )
134
112
{
135
113
// Ensure that PSM signal hijacking is disabled *before* loading
136
114
// the library (see comment in the function for more detail).
137
115
opal_init_psm ();
138
116
139
- libmpi = dlopen ("lib" OMPI_LIBMPI_NAME "." OPAL_DYN_LIB_SUFFIX , RTLD_NOW | RTLD_GLOBAL );
140
-
141
- #if defined(HAVE_DL_INFO ) && defined(HAVE_LIBGEN_H )
142
- /*
143
- * OS X El Capitan does not propagate DYLD_LIBRARY_PATH to children any more
144
- * so if previous dlopen failed, try to open libmpi in the same directory
145
- * than the current libmpi_java
146
- */
147
- if (NULL == libmpi ) {
148
- Dl_info info ;
149
- if (0 != dladdr ((void * )JNI_OnLoad , & info )) {
150
- char libmpipath [OPAL_PATH_MAX ];
151
- char * libmpijavapath = strdup (info .dli_fname );
152
- if (NULL != libmpijavapath ) {
153
- snprintf (libmpipath , OPAL_PATH_MAX - 1 , "%s/lib" OMPI_LIBMPI_NAME "." OPAL_DYN_LIB_SUFFIX , dirname (libmpijavapath ));
154
- free (libmpijavapath );
155
- libmpi = dlopen (libmpipath , RTLD_NOW | RTLD_GLOBAL );
156
- }
157
- }
158
- }
159
- #endif
160
-
161
- if (NULL == libmpi )
162
- {
163
- fprintf (stderr , "Java bindings failed to load lib" OMPI_LIBMPI_NAME ": %s\n" ,dlerror ());
164
- exit (1 );
165
- }
166
-
167
117
return JNI_VERSION_1_6 ;
168
118
}
169
119
170
- void JNI_OnUnload (JavaVM * vm , void * reserved )
171
- {
172
- if (libmpi != NULL )
173
- dlclose (libmpi );
174
- }
175
-
176
120
static void initFreeList (void )
177
121
{
178
122
OBJ_CONSTRUCT (& ompi_java_buffers , opal_free_list_t );
0 commit comments