Package mpi4py :: Module rc
[hide private]
[frames] | no frames]

Source Code for Module mpi4py.rc

 1  # Author:  Lisandro Dalcin 
 2  # Contact: dalcinl@gmail.com 
 3  """ 
 4  Runtime configuration parameters. 
 5  """ 
 6   
 7  initialize = True 
 8  """ 
 9  Automatic MPI initialization at import time 
10   
11  * Any of ``{True  | 1 | "yes" }``: initialize MPI at import time 
12  * Any of ``{False | 0 | "no"  }``: do not initialize MPI at import time 
13  """ 
14   
15   
16  threaded = True 
17  """ 
18  Request for thread support at MPI initialization 
19   
20  * Any of ``{True  | 1 | "yes" }``: initialize MPI with ``MPI_Init_thread()`` 
21  * Any of ``{False | 0 | "no"  }``: initialize MPI with ``MPI_Init()`` 
22  """ 
23   
24   
25  thread_level = "multiple" 
26  """ 
27  Level of thread support to request at MPI initialization 
28   
29  * ``"single"``     : use ``MPI_THREAD_SINGLE`` 
30  * ``"funneled"``   : use ``MPI_THREAD_FUNNELED`` 
31  * ``"serialized"`` : use ``MPI_THREAD_SERIALIZED`` 
32  * ``"multiple"``   : use ``MPI_THREAD_MULTIPLE`` 
33  """ 
34   
35   
36  finalize = True 
37  """ 
38  Automatic MPI finalization at exit time 
39   
40  * Any of ``{True  | 1 | "yes" }``: call ``MPI_Finalize()`` at exit time 
41  * Any of ``{False | 0 | "no"  }``: do not call ``MPI_Finalize()`` at exit time 
42  """ 
43   
44   
45  _pmpi_ = [] 
46   
47 -def profile(name='MPE', **kargs):
48 """ 49 MPI profiling interface 50 """ 51 import sys, os, imp 52 # 53 try: 54 from mpi4py.dl import dlopen, RTLD_NOW, RTLD_GLOBAL 55 except ImportError: 56 from ctypes import CDLL as dlopen, RTLD_GLOBAL 57 try: 58 from DLFCN import RTLD_NOW 59 except ImportError: 60 RTLD_NOW = 2 61 # 62 prefix = os.path.dirname(__file__) 63 so = imp.get_suffixes()[0][0] 64 if name == 'MPE': # special case 65 filename = os.path.join(prefix, name + so) 66 if 'MPE_LOGFILE_PREFIX' not in os.environ: 67 logfile = kargs.pop('logfile', None) 68 if logfile: 69 os.environ['MPE_LOGFILE_PREFIX'] = logfile 70 else: 71 format = [('', so)] 72 if sys.platform.startswith('win'): 73 format.append(('', '.dll')) 74 elif sys.platform == 'darwin': 75 format.append(('lib', '.dylib')) 76 elif os.name == 'posix': 77 format.append(('lib', '.so')) 78 for (lib, _so) in format: 79 basename = lib + name + _so 80 filename = os.path.join(prefix, 'lib-pmpi', basename) 81 if not os.path.isfile(filename): 82 filename = None 83 else: 84 break 85 if filename is None: 86 relpath = os.path.join(os.path.basename(prefix), 'lib-pmpi') 87 raise ValueError( 88 "profiler '%s' not found in '%s'" % (name, relpath)) 89 # 90 global _pmpi_ 91 handle = dlopen(filename, RTLD_NOW|RTLD_GLOBAL) 92 _pmpi_.append( (handle, filename) ) 93 # 94 return filename
95