Skip to content

Commit

Permalink
Merge branch 'master' of github.com:erdc-cm/mpi4py
Browse files Browse the repository at this point in the history
Conflicts:
	mpi.cfg
  • Loading branch information
cekees committed Jun 2, 2013
2 parents 3383ce1 + 0339f42 commit cf9bace
Show file tree
Hide file tree
Showing 102 changed files with 4,688 additions and 3,193 deletions.
2 changes: 1 addition & 1 deletion LICENSE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ LICENSE: MPI for Python
:Address: CCT CONICET, 3000 Santa Fe, Argentina


Copyright (c) 2012, Lisandro Dalcin.
Copyright (c) 2013, Lisandro Dalcin.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
5 changes: 3 additions & 2 deletions conf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ FILE(GLOB mpi4py_HEADER_FILES
${mpi4py_SOURCE_DIR}/include/mpi4py/*.px[di]
${mpi4py_SOURCE_DIR}/include/mpi4py/*.pyx
${mpi4py_SOURCE_DIR}/include/mpi4py/*.[hi]
${mpi4py_SOURCE_DIR}/*.pxd
)

FOREACH(file
Expand Down Expand Up @@ -183,7 +184,7 @@ TARGET_LINK_LIBRARIES(pmpi-vt ${MPI_LIBRARIES})
# --- mpi4py/lib-pmpi/libvt-mpi.so ---
ADD_LIBRARY(pmpi-vt-mpi MODULE "${mpi4py_SOURCE_DIR}/pmpi-vt-mpi.c")
SET_TARGET_PROPERTIES(
pmpi-vt PROPERTIES
pmpi-vt-mpi PROPERTIES
OUTPUT_NAME "vt-mpi"
LIBRARY_OUTPUT_DIRECTORY "${mpi4py_BINARY_DIR}/lib-pmpi"
RUNTIME_OUTPUT_DIRECTORY "${mpi4py_BINARY_DIR}/lib-pmpi"
Expand All @@ -195,7 +196,7 @@ TARGET_LINK_LIBRARIES(pmpi-vt-mpi ${MPI_LIBRARIES})
# --- mpi4py/lib-pmpi/libvt-hyb.so ---
ADD_LIBRARY(pmpi-vt-hyb MODULE "${mpi4py_SOURCE_DIR}/pmpi-vt-hyb.c")
SET_TARGET_PROPERTIES(
pmpi-vt PROPERTIES
pmpi-vt-hyb PROPERTIES
OUTPUT_NAME "vt-hyb"
LIBRARY_OUTPUT_DIRECTORY "${mpi4py_BINARY_DIR}/lib-pmpi"
RUNTIME_OUTPUT_DIRECTORY "${mpi4py_BINARY_DIR}/lib-pmpi"
Expand Down
2 changes: 2 additions & 0 deletions conf/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Author: Lisandro Dalcin
# Contact: [email protected]
24 changes: 15 additions & 9 deletions conf/mpiconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,26 @@ def _setup_posix(self):
def _setup_windows(self):
from glob import glob
ProgramFiles = os.environ.get('ProgramFiles', '')
for (name, install_suffix) in (
('mpich2', 'MPICH2'),
('openmpi', 'OpenMPI'),
('openmpi', 'OpenMPI*'),
('deinompi', 'DeinoMPI'),
('msmpi', 'Microsoft HPC Pack 2008 R2'),
('msmpi', 'Microsoft HPC Pack 2008 SDK'),
CCP_HOME = os.environ.get('CCP_HOME', '')
for (name, prefix, suffix) in (
('mpich3', ProgramFiles, 'MPICH'),
('mpich2', ProgramFiles, 'MPICH2'),
('openmpi', ProgramFiles, 'OpenMPI'),
('openmpi', ProgramFiles, 'OpenMPI*'),
('deinompi', ProgramFiles, 'DeinoMPI'),
('msmpi', CPP_HOME, ''),
('msmpi', ProgramFiles, 'Microsoft HPC Pack 2012'),
('msmpi', ProgramFiles, 'Microsoft HPC Pack 2012 SDK'),
('msmpi', ProgramFiles, 'Microsoft HPC Pack 2008 R2'),
('msmpi', ProgramFiles, 'Microsoft HPC Pack 2008'),
('msmpi', ProgramFiles, 'Microsoft HPC Pack 2008 SDK'),
):
mpi_dir = os.path.join(ProgramFiles, install_suffix)
mpi_dir = os.path.join(prefix, suffix)
if '*' in mpi_dir:
dirs = glob(mpi_dir)
if dirs:
mpi_dir = max(dirs)
if not os.path.isdir(mpi_dir):
if not (mpi_dir and os.path.isdir(mpi_dir)):
continue
define_macros = []
include_dirs = [os.path.join(mpi_dir, 'include')]
Expand Down
6 changes: 5 additions & 1 deletion conf/mpidistutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,15 @@ def fix_config_vars(names, values):
if 'ARCHFLAGS' in os.environ:
ARCHFLAGS = os.environ['ARCHFLAGS']
for i, flag in enumerate(list(values)):
if flag is None: continue
flag, count = re.subn('-arch\s+\w+', ' ', flag)
if count and ARCHFLAGS:
flag = flag + ' ' + ARCHFLAGS
values[i] = flag
if 'SDKROOT' in os.environ:
SDKROOT = os.environ['SDKROOT']
for i, flag in enumerate(list(values)):
if flag is None: continue
flag, count = re.subn('-isysroot [^ \t]*', ' ', flag)
if count and SDKROOT:
flag = flag + ' ' + '-isysroot ' + SDKROOT
Expand Down Expand Up @@ -135,6 +137,8 @@ def customize_compiler(compiler, lang=None,
basecflags = '-Wall -Wimplicit'
if not ccshared: ccshared = '-fPIC'
if not ldshared: ldshared = '-shared'
if sys.platform == 'darwin':
ldshared += ' -Wl,-undefined,dynamic_lookup'
# Compiler command overriding
if not mpild and (mpicc or mpicxx):
if lang == 'c':
Expand Down Expand Up @@ -288,7 +292,7 @@ def parse_file(self, *args):
class ConfigureMPI(object):

SRCDIR = 'src'
SOURCES = [os.path.join('include', 'mpi4py', 'mpi.pxi')]
SOURCES = [os.path.join('include', 'mpi4py', 'libmpi.pxd')]
DESTDIR = 'src'
CONFIG_H = 'config.h'
MISSING_H = 'missing.h'
Expand Down
16 changes: 10 additions & 6 deletions conf/mpiscanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def match(self, line):
HEADER = None

HEADER_HEAD = """\
#ifdef PyMPI_MISSING_%(name)s
#ifndef PyMPI_HAVE_%(name)s
#undef %(cname)s
"""
HEADER_TAIL = """
Expand Down Expand Up @@ -253,7 +253,7 @@ def itertests(self):
#define PyMPI_CONFIG_H
"""
CONFIG_MACRO = '#define PyMPI_MISSING_%s 1\n'
CONFIG_MACRO = 'PyMPI_HAVE_%s'
CONFIG_TAIL = """\
#endif /* !PyMPI_CONFIG_H */
Expand All @@ -270,12 +270,16 @@ def dump_config_h(self, fileobj, suite):
fileobj.write(head)
if suite is None:
for node in self:
fileobj.write(macro % node.name)
line = "#undef %s\n" % ((macro % node.name))
fileobj.write(line)
else:
for name, result in suite:
assert name in self.nodemap
if not result:
fileobj.write(macro % name)
if result:
line = "#define %s 1\n" % ((macro % name))
else:
line = "#undef %s\n" % ((macro % name))
fileobj.write(line)
fileobj.write(tail)

MISSING_HEAD = """\
Expand Down Expand Up @@ -331,7 +335,7 @@ def dump_missing_h(self, fileobj, suite):

if __name__ == '__main__':
import sys, os
sources = [os.path.join('src', 'include', 'mpi4py', 'mpi.pxi')]
sources = [os.path.join('src', 'include', 'mpi4py', 'libmpi.pxd')]
log = lambda msg: sys.stderr.write(msg + '\n')
scanner = Scanner()
for filename in sources:
Expand Down
4 changes: 3 additions & 1 deletion demo/cython/helloworld.pyx
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cdef extern from "mpi-compat.h": pass

# ---------


Expand Down Expand Up @@ -41,7 +43,7 @@ cdef IntracommType SELF = MPI.COMM_SELF
# with namespace-protection (stuff accessed as mpi.XXX)
# (file: mpi4py/include/mpi4py/mpi_c.pxd)

from mpi4py cimport mpi_c as mpi
from mpi4py cimport libmpi as mpi

cdef mpi.MPI_Comm world1 = WORLD.ob_mpi

Expand Down
23 changes: 14 additions & 9 deletions demo/cython/makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,34 @@
.PHONY: default src build test clean

.PHONY: default
default: build test clean

PYTHON = python

PYTHON_INCLUDE = ${shell ${PYTHON} -c 'from distutils import sysconfig; print( sysconfig.get_python_inc() )'}
MPI4PY_INCLUDE = ${shell ${PYTHON} -c 'import mpi4py; print( mpi4py.get_include() )'}
PYTHON = python
PYTHON_CONFIG = ${PYTHON} ../python-config
MPI4PY_INCLUDE = -I${shell ${PYTHON} -c 'import mpi4py; print( mpi4py.get_include() )'}

CYTHON = cython
.PHONY: src
src: helloworld.c
helloworld.c: helloworld.pyx
${CYTHON} -I${MPI4PY_INCLUDE} $<
${CYTHON} ${MPI4PY_INCLUDE} $<


MPICC = mpicc -shared -fPIC
CFLAGS = -shared -fPIC
SO = ${shell ${PYTHON} -c 'import imp; print (imp.get_suffixes()[0][0])'}
MPICC = mpicc
CFLAGS = -fPIC ${shell ${PYTHON_CONFIG} --includes}
LDFLAGS = -shared ${shell ${PYTHON_CONFIG} --libs}
SO = ${shell ${PYTHON_CONFIG} --extension-suffix}
.PHONY: build
build: helloworld${SO}
helloworld${SO}: helloworld.c
${MPICC} ${CFLAGS} -I${PYTHON_INCLUDE} -I${MPI4PY_INCLUDE} -o $@ $<
${MPICC} ${CFLAGS} -I${MPI4PY_INCLUDE} -o $@ $< ${LDFLAGS}


.PHONY: test
test: build
${PYTHON} -c 'import helloworld'


.PHONY: clean
clean:
${RM} helloworld.c helloworld${SO}
14 changes: 14 additions & 0 deletions demo/cython/mpi-compat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/* Author: Lisandro Dalcin */
/* Contact: [email protected] */

#ifndef MPI_COMPAT_H
#define MPI_COMPAT_H

#include <mpi.h>

#if (MPI_VERSION < 3) && !defined(PyMPI_HAVE_MPI_Message)
typedef void *PyMPI_MPI_Message;
#define MPI_Message PyMPI_MPI_Message
#endif

#endif/*MPI_COMPAT_H*/
4 changes: 2 additions & 2 deletions demo/embedding/helloworld.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ int main(int argc, char *argv[])

Py_Initialize();
PyRun_SimpleString(helloworld);
MPI_Finalize();
Py_Finalize();
MPI_Finalize(); /* MPI should be finalized */
Py_Finalize(); /* after finalizing Python */

Py_Initialize();
PyRun_SimpleString("from mpi4py import MPI\n");
Expand Down
14 changes: 6 additions & 8 deletions demo/embedding/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,22 @@
default: build test clean

PYTHON = python
PYTHON_PERFIX = ${shell ${PYTHON} -c 'import sys; print(sys.exec_prefix)'}
PYTHON_VERSION = ${shell ${PYTHON} -c 'import sys; print(sys.version[:3])'}
PYTHON_CONFIG = ${PYTHON_PERFIX}/bin/python$(PYTHON_VERSION)-config
PYTHON_CONFIG = ${PYTHON} ../python-config

MPICC = mpicc
CFLAGS = ${shell ${PYTHON_CONFIG} --cflags}
LDFLAGS = ${shell ${PYTHON_CONFIG} --ldflags}
LDLAST = -Xlinker -export-dynamic
build: helloworld.exe
helloworld.exe: helloworld.c
${MPICC} ${CFLAGS} ${LDFLAGS} ${LDLAST} -o $@ $<
${MPICC} ${CFLAGS} -o $@ $< ${LDFLAGS}


MPIEXEC = mpiexec
NP = -n 5
NP_FLAG = -n
NP = 5
test: build
${MPIEXEC} ${NP} ./helloworld.exe
${MPIEXEC} ${NP_FLAG} ${NP} ./helloworld.exe


clean:
${RM} helloworld.exe
${RM} -r helloworld.exe helloworld.exe.dSYM
80 changes: 80 additions & 0 deletions demo/python-config
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
#!/usr/bin/env python
# -*- python -*-

import sys, os
import getopt
try:
import sysconfig
except ImportError:
from distutils import sysconfig

valid_opts = ['help', 'prefix', 'exec-prefix', 'includes', 'libs', 'cflags',
'ldflags', 'extension-suffix', 'abiflags', 'configdir']

def exit_with_usage(code=1):
sys.stderr.write("Usage: %s [%s]\n" % (
sys.argv[0], '|'.join('--'+opt for opt in valid_opts)))
sys.exit(code)

try:
opts, args = getopt.getopt(sys.argv[1:], '', valid_opts)
except getopt.error:
exit_with_usage()

if not opts:
exit_with_usage()

getvar = sysconfig.get_config_var
pyver = getvar('VERSION')
try:
abiflags = sys.abiflags
except AttributeError:
abiflags = ''

opt_flags = [flag for (flag, val) in opts]

if '--help' in opt_flags:
exit_with_usage(code=0)

for opt in opt_flags:
if opt == '--prefix':
print(getvar('prefix'))

elif opt == '--exec-prefix':
print(getvar('exec_prefix'))

elif opt in ('--includes', '--cflags'):
try:
include = sysconfig.get_path('include')
platinclude = sysconfig.get_path('platinclude')
except AttributeError:
include = sysconfig.get_python_inc()
platinclude = sysconfig.get_python_inc(plat_specific=True)
flags = ['-I' + include]
if include != platinclude:
flags.append('-I' + platinclude)
if opt == '--cflags':
flags.extend(getvar('CFLAGS').split())
print(' '.join(flags))

elif opt in ('--libs', '--ldflags'):
libs = getvar('LIBS').split() + getvar('SYSLIBS').split()
libs.append('-lpython' + pyver + abiflags)
if opt == '--ldflags':
if not getvar('Py_ENABLE_SHARED'):
libs.insert(0, '-L' + getvar('LIBPL'))
if not getvar('PYTHONFRAMEWORK'):
libs.extend(getvar('LINKFORSHARED').split())
print(' '.join(libs))

elif opt == '--extension-suffix':
ext_suffix = getvar('EXT_SUFFIX')
if ext_suffix is None:
ext_suffix = getvar('SO')
print(ext_suffix)

elif opt == '--abiflags':
print(abiflags)

elif opt == '--configdir':
print(getvar('LIBPL'))
1 change: 1 addition & 0 deletions demo/vampirtrace/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,4 @@ test: run
.PHONY: clean
clean:
${RM} *.otf *.uctl *.*.def.z *.*.events.z *.*.marker.z
${RM} *.thumb *.*.def *.*.events
18 changes: 11 additions & 7 deletions demo/wrap-boost/makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,28 @@
default: build test clean

PYTHON = python
PYTHON_INCLUDE = ${shell ${PYTHON} -c 'from distutils import sysconfig; print( sysconfig.get_python_inc() )'}
PYTHON_CONFIG = ${PYTHON} ../python-config
MPI4PY_INCLUDE = ${shell ${PYTHON} -c 'import mpi4py; print( mpi4py.get_include() )'}
BOOST_FLAGS = -lboost_python -lboost_python-mt
BOOST_INCS =
BOOST_LIBS = -lboost_python -lboost_python-mt


MPICXX = mpicxx
CXXFLAGS = -shared -fPIC
SO = ${shell ${PYTHON} -c 'import imp; print (imp.get_suffixes()[0][0])'}
CXXFLAGS = -fPIC ${shell ${PYTHON_CONFIG} --includes} ${BOOST_INCS}
LDFLAGS = -shared ${shell ${PYTHON_CONFIG} --libs} ${BOOST_LIBS}
SO = ${shell ${PYTHON_CONFIG} --extension-suffix}
.PHONY: build
build: helloworld${SO}
helloworld${SO}: helloworld.cxx
${MPICXX} ${CXXFLAGS} -I${PYTHON_INCLUDE} -I${MPI4PY_INCLUDE} -I${BOOST_FLAGS} -o $@ $<
${MPICXX} ${CXXFLAGS} -I${MPI4PY_INCLUDE} -o $@ $< ${LDFLAGS}


MPIEXEC = mpiexec
NP = -n 5
NP_FLAG = -n
NP = 5
.PHONY: test
test: build
${MPIEXEC} ${NP} ${PYTHON} test.py
${MPIEXEC} ${NP_FLAG} ${NP} ${PYTHON} test.py


.PHONY: clean
Expand Down
Loading

0 comments on commit cf9bace

Please sign in to comment.