/usr/lib/python2.7/dist-packages/mpi4py/__init__.py is in python-mpi4py 1.3.1+hg20131106-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 | # Author: Lisandro Dalcin
# Contact: dalcinl@gmail.com
"""
This is the **MPI for Python** package.
What is *MPI*?
==============
The *Message Passing Interface*, is a standardized and portable
message-passing system designed to function on a wide variety of
parallel computers. The standard defines the syntax and semantics of
library routines and allows users to write portable programs in the
main scientific programming languages (Fortran, C, or C++). Since
its release, the MPI specification has become the leading standard
for message-passing libraries for parallel computers.
What is *MPI for Python*?
=========================
*MPI for Python* provides MPI bindings for the Python programming
language, allowing any Python program to exploit multiple processors.
This package is constructed on top of the MPI-1/2 specifications and
provides an object oriented interface which closely follows MPI-2 C++
bindings.
"""
__version__ = '1.3.1'
__author__ = 'Lisandro Dalcin'
__credits__ = 'MPI Forum, MPICH Team, Open MPI Team.'
# --------------------------------------------------------------------
__all__ = ['MPI']
# --------------------------------------------------------------------
def get_include():
"""
Return the directory in the package that contains header files.
Extension modules that need to compile against mpi4py should use
this function to locate the appropriate include directory. Using
Python distutils (or perhaps NumPy distutils)::
import mpi4py
Extension('extension_name', ...
include_dirs=[..., mpi4py.get_include()])
"""
from os.path import dirname, join
return join(dirname(__file__), 'include')
# --------------------------------------------------------------------
def get_config():
"""
Return a dictionary with information about MPI.
"""
from os.path import dirname, join
try:
from configparser import ConfigParser
except ImportError:
from ConfigParser import ConfigParser
parser = ConfigParser()
parser.read(join(dirname(__file__), 'mpi.cfg'))
return dict(parser.items('mpi'))
# --------------------------------------------------------------------
def profile(name='MPE', **kargs):
"""
Support for the MPI profiling interface.
Parameters
----------
name : str, optional
Name of the profiler to load.
path : list of str, optional
Additional paths to search for the profiler.
logfile : str, optional
Filename prefix for dumping profiler output.
"""
import sys, os, imp
try:
from mpi4py.dl import dlopen, RTLD_NOW, RTLD_GLOBAL
from mpi4py.dl import dlerror
except ImportError:
from ctypes import CDLL as dlopen, RTLD_GLOBAL
try:
from DLFCN import RTLD_NOW
except ImportError:
RTLD_NOW = 2
dlerror = None
#
def lookup_pymod(name, path):
for pth in path:
for suffix, _, kind in imp.get_suffixes():
if kind == imp.C_EXTENSION:
filename = os.path.join(pth, name + suffix)
if os.path.isfile(filename):
return filename
return None
#
def lookup_dylib(name, path):
format = []
for suffix, _, kind in imp.get_suffixes():
if kind == imp.C_EXTENSION:
format.append(('', suffix))
if sys.platform.startswith('win'):
format.append(('', '.dll'))
elif sys.platform == 'darwin':
format.append(('lib', '.dylib'))
elif os.name == 'posix':
format.append(('lib', '.so'))
format.append(('', ''))
for pth in path:
for (lib, so) in format:
filename = os.path.join(pth, lib + name + so)
if os.path.isfile(filename):
return filename
return None
#
logfile = kargs.pop('logfile', None)
if logfile:
if name in ('mpe', 'MPE'):
if 'MPE_LOGFILE_PREFIX' not in os.environ:
os.environ['MPE_LOGFILE_PREFIX'] = logfile
if name in ('vt', 'vt-mpi', 'vt-hyb'):
if 'VT_FILE_PREFIX' not in os.environ:
os.environ['VT_FILE_PREFIX'] = logfile
path = kargs.pop('path', None)
if path is None:
path = []
elif isinstance(path, str):
path = [path]
else:
path = list(path)
#
if name in ('MPE',):
path.append(os.path.dirname(__file__))
filename = lookup_pymod(name, path)
else:
prefix = os.path.dirname(__file__)
path.append(os.path.join(prefix, 'lib-pmpi'))
filename = lookup_dylib(name, path)
if filename is None:
raise ValueError("profiler '%s' not found" % name)
else:
filename = os.path.abspath(filename)
#
handle = dlopen(filename, RTLD_NOW|RTLD_GLOBAL)
if handle:
profile._registry.append((name, (handle, filename)))
else:
from warnings import warn
if dlerror:
message = dlerror()
else:
message = "error loading '%s'" % filename
warn(message)
profile._registry = []
# --------------------------------------------------------------------
from mpi4py import rc
rc.profile = profile
# --------------------------------------------------------------------
if __name__ == '__main__':
from mpi4py.__main__ import main
main()
# --------------------------------------------------------------------
|