Logo  0.95.0-final
Finite Element Embedded Library and Language in C++
Feel++ Feel++ on Github Feel++ community
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mpicompat.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; coding: utf-8; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; show-trailing-whitespace: t -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4
2 
3  This file is part of the Feel library
4 
5  Author(s): Christophe Prud'homme <christophe.prudhomme@feelpp.org>
6  Date: 2010-02-06
7 
8  Copyright (C) 2010 Université Joseph Fourier (Grenoble I)
9 
10  This library is free software; you can redistribute it and/or
11  modify it under the terms of the GNU Lesser General Public
12  License as published by the Free Software Foundation; either
13  version 2.1 of the License, or (at your option) any later version.
14 
15  This library is distributed in the hope that it will be useful,
16  but WITHOUT ANY WARRANTY; without even the implied warranty of
17  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18  Lesser General Public License for more details.
19 
20  You should have received a copy of the GNU Lesser General Public
21  License along with this library; if not, write to the Free Software
22  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 */
29 #ifndef _COMPAT_MPI_H
30 #define _COMPAT_MPI_H
31 
32 #if defined(OPEN_MPI)
33 
34 #ifndef OPENMPI_DLOPEN_LIBMPI
35 #define OPENMPI_DLOPEN_LIBMPI 1
36 #endif
37 
38 #if OPENMPI_DLOPEN_LIBMPI
39 #if FEELPP_HAS_DLOPEN
40 
41 #if FEELPP_HAS_DLFCN_H
42 #include <dlfcn.h>
43 #else
44 #if defined(__CYGWIN__)
45 #define RTLD_LAZY 1
46 #define RTLD_NOW 2
47 #define RTLD_LOCAL 0
48 #define RTLD_GLOBAL 4
49 #define RTLD_NOLOAD 0
50 #define RTLD_NODELETE 0
51 #elif defined(__APPLE__)
52 #define RTLD_LAZY 0x1
53 #define RTLD_NOW 0x2
54 #define RTLD_LOCAL 0x4
55 #define RTLD_GLOBAL 0x8
56 #define RTLD_NOLOAD 0x10
57 #define RTLD_NODELETE 0x80
58 #elif defined(__linux__)
59 #define RTLD_LAZY 0x00001
60 #define RTLD_NOW 0x00002
61 #define RTLD_LOCAL 0x00000
62 #define RTLD_GLOBAL 0x00100
63 #define RTLD_NOLOAD 0x00004
64 #define RTLD_NODELETE 0x01000
65 #endif
66 #if defined(c_plusplus) || defined(__cplusplus)
67 extern "C" {
68 #endif
69  extern void *dlopen( const char *, int );
70 #if defined(c_plusplus) || defined(__cplusplus)
71 }
72 #endif
73 #endif
74 
75 #ifndef RTLD_LAZY
76 #define RTLD_LAZY 1
77 #endif
78 #ifndef RTLD_NOW
79 #define RTLD_NOW RTLD_LAZY
80 #endif
81 #ifndef RTLD_LOCAL
82 #define RTLD_LOCAL 0
83 #endif
84 #ifndef RTLD_GLOBAL
85 #define RTLD_GLOBAL RTLD_LOCAL
86 #endif
87 #ifndef RTLD_NOLOAD
88 #define RTLD_NOLOAD 0
89 #endif
90 
91 /*
92 static void * my_dlopen(const char *name, int mode) {
93  void *handle;
94  static int called = 0;
95  if (!called) {
96  called = 1;
97  #if FEELPP_HAS_DLFCN_H
98  printf("FEELPP_HAS_DLFCN_H: yes\n");
99  #else
100  printf("FEELPP_HAS_DLFCN_H: no\n");
101  #endif
102  printf("\n");
103  printf("RTLD_LAZY: 0x%X\n", RTLD_LAZY );
104  printf("RTLD_NOW: 0x%X\n", RTLD_NOW );
105  printf("RTLD_LOCAL: 0x%X\n", RTLD_LOCAL );
106  printf("RTLD_GLOBAL: 0x%X\n", RTLD_GLOBAL );
107  printf("RTLD_NOLOAD: 0x%X\n", RTLD_NOLOAD );
108  printf("\n");
109  }
110  handle = dlopen(name, mode);
111  printf("dlopen(\"%s\",0x%X) -> %p\n", name, mode, handle);
112  printf("dlerror() -> %s\n\n", dlerror());
113  return handle;
114 }
115 #define dlopen my_dlopen
116 */
117 
118 static void OPENMPI_dlopen_libmpi( void )
119 {
120  int mode = RTLD_NOW | RTLD_GLOBAL | RTLD_NOLOAD;
121  void *handle = 0;
122 #if defined(__CYGWIN__)
123 
124  if ( !handle )
125  handle = dlopen( "cygmpi.dll", mode );
126 
127  if ( !handle )
128  handle = dlopen( "mpi.dll", mode );
129 
130 #elif defined(__APPLE__)
131 
132  /* Mac OS X */
133  if ( !handle )
134  handle = dlopen( "libmpi.1.dylib", mode );
135 
136  if ( !handle )
137  handle = dlopen( "libmpi.0.dylib", mode );
138 
139  if ( !handle )
140  handle = dlopen( "libmpi.dylib", mode );
141 
142 #else
143 
144  /* GNU/Linux and others */
145  if ( !handle )
146  handle = dlopen( "libmpi.so.1", mode );
147 
148  if ( !handle )
149  handle = dlopen( "libmpi.so.0", mode );
150 
151  if ( !handle )
152  handle = dlopen( "libmpi.so", mode );
153 
154 #endif
155 }
156 #if 0
157 static PetscErrorCode
158 PyPetsc_PetscInitialize( int *argc,char ***args,
159  const char file[],
160  const char help[] )
161 {
162  OPENMPI_dlopen_libmpi();
163  return PetscInitialize( argc,args,file,help );
164 }
165 #undef PetscInitialize
166 #define PetscInitialize PyPetsc_PetscInitialize
167 #endif
168 
169 #endif /* FEELPP_HAS_DLOPEN */
170 #endif /* OPENMPI_DLOPEN_LIBMPI */
171 
172 #endif /* OPEN_MPI */
173 
174 #endif /* _COMPAT_MPI_H */

Generated on Fri Oct 25 2013 14:24:19 for Feel++ by doxygen 1.8.4