Commit dbf00e74 authored by Kitware Robot's avatar Kitware Robot Committed by Andrew Bauer
Browse files

mpi4py 2018-01-30 (174ce254)

Code extracted from:

    https://gitlab.kitware.com/third-party/mpi4py.git

at commit 174ce25438113e34d4f3cecfe19d7ccfa9b234a0 (for/vtk).
parent bad9c430
......@@ -6,6 +6,48 @@ CHANGES: MPI for Python
:Contact: dalcinl@gmail.com
Release 3.0.0 [2017-11-08]
==========================
* New features:
+ `mpi4py.futures`: Execute computations asynchronously using a pool
of MPI processes. This package is based on ``concurrent.futures``
from the Python standard library.
+ `mpi4py.run`: Run Python code and abort execution in case of
unhandled exceptions to prevent deadlocks.
+ `mpi4py.bench`: Run basic MPI benchmarks and tests.
* Enhancements:
+ Lowercase, pickle-based collective communication calls are now
thread-safe through the use of fine-grained locking.
+ The ``MPI`` module now exposes a ``memory`` type which is a
lightweight variant of the builtin ``memoryview`` type, but
exposes both the legacy Python 2 and the modern Python 3 buffer
interface under a Python 2 runtime.
+ The ``MPI.Comm.Alltoallw()`` method now uses ``count=1`` and
``displ=0`` as defaults, assuming that messages are specified
through user-defined datatypes.
+ The ``Request.Wait[all]()`` methods now return ``True`` to match
the interface of ``Request.Test[all]()``.
+ The ``Win`` class now implements the Python buffer interface.
* Backward-incompatible changes:
+ The ``buf`` argument of the ``MPI.Comm.recv()`` method is
deprecated, passing anything but ``None`` emits a warning.
+ The ``MPI.Win.memory`` property was removed, use the
``MPI.Win.tomemory()`` method instead.
+ Executing ``python -m mpi4py`` in the command line is now
equivalent to ``python -m mpi4py.run``. For the former behavior,
use ``python -m mpi4py.bench``.
+ Python 2.6 and 3.2 are no longer supported. The ``mpi4py.MPI``
module may still build and partially work, but other pure-Python
modules under the ``mpi4py`` namespace will not.
+ Windows: Remove support for legacy MPICH2, Open MPI, and DeinoMPI.
Release 2.0.0 [2015-10-18]
==========================
......
if (WIN32)
message(STATUS "Not building mpi4py on Windows (not supported currently).")
return()
endif()
# Author: Lisandro Dalcin
# Contact: dalcinl@gmail.com
# ** Note this file has been modified from the original to work with ParaView **
cmake_minimum_required(VERSION 2.6)
project(mpi4py)
#------------------------------------------------------------------------------
# Set locations where to install the binaries.
# MPI4PY_INSTALL_PACKAGE_DIR is the location where all mpi4py package is
# installed.
# are to be installed.
if (NOT MPI4PY_INSTALL_PACKAGE_DIR)
set (MPI4PY_INSTALL_PACKAGE_DIR "lib/site-packages")
endif()
if (NOT MPI4PY_PACKAGE_BINARY_DIR)
set (MPI4PY_PACKAGE_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}")
endif()
find_package(PythonInterp ${VTK_PYTHON_VERSION} REQUIRED)
if (VTK_UNDEFINED_SYMBOLS_ALLOWED)
set(_QUIET_LIBRARY "QUIET")
else()
set(_QUIET_LIBRARY "${VTK_PYTHON_VERSION}" "REQUIRED")
endif()
find_package(PythonLibs ${_QUIET_LIBRARY})
find_package(MPI REQUIRED)
# -------------------------------------------------------------------------
# For mpich which is not build with fortran some symbols are not found at
# link time. The following solution prevents this.
check_function_exists(MPI_Type_create_f90_integer f90_integer_defined)
if (NOT f90_integer_defined)
# Assume the other MPI_Type_create_f90_* functions are unavailable
add_definitions(-DPyMPI_MISSING_MPI_Type_create_f90_integer
-DPyMPI_MISSING_MPI_Type_create_f90_real
-DPyMPI_MISSING_MPI_Type_create_f90_complex)
endif()
check_function_exists(MPI_Status_fc2 f2c_defined)
if (NOT f2c_defined)
# Assume MPI_Status_c2f is not defined either
add_definitions(-DPyMPI_MISSING_MPI_Status_f2c
-DPyMPI_MISSING_MPI_Status_c2f)
endif()
# -----------------------------------------------------------------------------
# Note: In ParaView FindPythonLibs.cmake module is additionally defined in VTK
# and overides the default module from CMake. As a consequence PYTHON_ADD_MODULE
# needs to be defined here.
# PYTHON_ADD_MODULE(<name> src1 src2 ... srcN) is used to build modules for python.
# PYTHON_WRITE_MODULES_HEADER(<filename>) writes a header file you can include
# in your sources to initialize the static python modules
function(PYTHON_ADD_MODULE _NAME )
get_property(_TARGET_SUPPORTS_SHARED_LIBS
GLOBAL PROPERTY TARGET_SUPPORTS_SHARED_LIBS)
option(PYTHON_ENABLE_MODULE_${_NAME} "Add module ${_NAME}" TRUE)
option(PYTHON_MODULE_${_NAME}_BUILD_SHARED
"Add module ${_NAME} shared" ${_TARGET_SUPPORTS_SHARED_LIBS})
# Mark these options as advanced
mark_as_advanced(PYTHON_ENABLE_MODULE_${_NAME}
PYTHON_MODULE_${_NAME}_BUILD_SHARED)
if(PYTHON_ENABLE_MODULE_${_NAME})
if(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
set(PY_MODULE_TYPE MODULE)
else()
set(PY_MODULE_TYPE STATIC)
set_property(GLOBAL APPEND PROPERTY PY_STATIC_MODULES_LIST ${_NAME})
endif()
set_property(GLOBAL APPEND PROPERTY PY_MODULES_LIST ${_NAME})
add_library(${_NAME} ${PY_MODULE_TYPE} ${ARGN})
# target_link_libraries(${_NAME} ${PYTHON_LIBRARIES})
if(PYTHON_MODULE_${_NAME}_BUILD_SHARED)
set_target_properties(${_NAME} PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}")
if(WIN32 AND NOT CYGWIN)
set_target_properties(${_NAME} PROPERTIES SUFFIX ".pyd")
endif()
endif()
endif()
endfunction()
# -----------------------------------------------------------------------------
set(mpi4py_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src")
set(mpi4py_BINARY_DIR "${MPI4PY_PACKAGE_BINARY_DIR}/mpi4py")
file(GLOB mpi4py_PYTHON_FILES
RELATIVE ${mpi4py_SOURCE_DIR}
${mpi4py_SOURCE_DIR}/*.py)
file(GLOB mpi4py_HEADER_FILES
RELATIVE ${mpi4py_SOURCE_DIR}
${mpi4py_SOURCE_DIR}/include/mpi4py/*.px[di]
${mpi4py_SOURCE_DIR}/include/mpi4py/*.pyx
${mpi4py_SOURCE_DIR}/include/mpi4py/*.[hi]
)
foreach(file
${mpi4py_PYTHON_FILES}
${mpi4py_HEADER_FILES}
)
set(src "${mpi4py_SOURCE_DIR}/${file}")
set(tgt "${mpi4py_BINARY_DIR}/${file}")
add_custom_command(
DEPENDS ${src}
OUTPUT ${tgt}
COMMAND ${CMAKE_COMMAND} ARGS -E copy ${src} ${tgt}
COMMENT "copy: ${file}"
)
set(mpi4py_OUTPUT_FILES ${mpi4py_OUTPUT_FILES} ${tgt})
endforeach()
foreach(file ${mpi4py_PYTHON_FILES})
set(mpi4py_py ${mpi4py_py} "${mpi4py_BINARY_DIR}/${file}")
set(mpi4py_pyc ${mpi4py_pyc} "${mpi4py_BINARY_DIR}/${file}c")
set(mpi4py_pyo ${mpi4py_pyo} "${mpi4py_BINARY_DIR}/${file}o")
endforeach()
set(CMAKE_CONFIGURABLE_FILE_CONTENT
"from compileall import compile_dir\ncompile_dir(\"${mpi4py_BINARY_DIR}\")")
configure_file(${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in
"${CMAKE_CURRENT_BINARY_DIR}/compile_py" @ONLY)
unset(CMAKE_CONFIGURABLE_FILE_CONTENT)
add_custom_command(
COMMAND ${PYTHON_EXECUTABLE} ARGS compile_py
COMMAND ${PYTHON_EXECUTABLE} ARGS -O compile_py
DEPENDS ${mpi4py_py} ${CMAKE_CURRENT_BINARY_DIR}/compile_py
OUTPUT ${mpi4py_pyc} ${mpi4py_pyo}
)
set(mpi4py_OUTPUT_FILES ${mpi4py_OUTPUT_FILES} ${mpi4py_pyc} ${mpi4py_pyo})
set (mpicc)
set (mpicxx)
set (mpif77)
set (mpif90)
if (MPI_C_FOUND)
set (mpicc ${MPI_C_COMPILER})
endif()
if (MPI_CXX_FOUND)
set (mpicxx ${MPI_CXX_COMPILER})
endif()
# NOTE: We are ignoring the fortran components for now.
foreach(file "mpi.cfg")
set(tgt "${mpi4py_BINARY_DIR}/${file}")
set(CMAKE_CONFIGURABLE_FILE_CONTENT "[mpi]
mpicc = ${mpicc}
mpicxx = ${mpicxx}
mpif77 = ${mpif77}
mpif90 = ${mpif90}")
configure_file(${CMAKE_ROOT}/Modules/CMakeConfigurableFile.in
"${tgt}" @ONLY)
unset(CMAKE_CONFIGURABLE_FILE_CONTENT)
set(mpi4py_OUTPUT_FILES ${mpi4py_OUTPUT_FILES} ${tgt})
endforeach()
add_custom_target(mpi4py ALL DEPENDS ${mpi4py_OUTPUT_FILES})
include_directories(
${MPI_C_INCLUDE_PATH}
${PYTHON_INCLUDE_DIRS}
"${mpi4py_SOURCE_DIR}"
)
# --- mpi4py.MPI ---
PYTHON_ADD_MODULE(mpi4py.MPI MODULE "${mpi4py_SOURCE_DIR}/MPI.c")
set_target_properties(
mpi4py.MPI PROPERTIES
OUTPUT_NAME "MPI" PREFIX ""
COMPILE_FLAGS "${MPI_C_COMPILE_FLAGS}"
LINK_FLAGS "${MPI_C_LINK_FLAGS}"
LIBRARY_OUTPUT_DIRECTORY "${mpi4py_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${mpi4py_BINARY_DIR}"
LINKER_LANGUAGE C
)
target_link_libraries(mpi4py.MPI ${PYTHON_LIBRARY})
target_link_libraries(mpi4py.MPI ${MPI_C_LIBRARIES})
target_link_libraries(mpi4py.MPI ${CMAKE_DL_LIBS})
# --- mpi4py.dl ---
PYTHON_ADD_MODULE(mpi4py.dl MODULE "${mpi4py_SOURCE_DIR}/dynload.c")
set_target_properties(
mpi4py.dl PROPERTIES
OUTPUT_NAME "dl" PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${mpi4py_BINARY_DIR}"
RUNTIME_OUTPUT_DIRECTORY "${mpi4py_BINARY_DIR}"
LINKER_LANGUAGE C
)
target_link_libraries(mpi4py.dl ${PYTHON_LIBRARY})
target_link_libraries(mpi4py.dl ${CMAKE_DL_LIBS})
# --- mpi4py/lib-pmpi/libmpe.so ---
add_library(pmpi-mpe MODULE "${mpi4py_SOURCE_DIR}/lib-pmpi/mpe.c")
set_target_properties(
pmpi-mpe PROPERTIES
OUTPUT_NAME "mpe"
LIBRARY_OUTPUT_DIRECTORY "${mpi4py_BINARY_DIR}/lib-pmpi"
RUNTIME_OUTPUT_DIRECTORY "${mpi4py_BINARY_DIR}/lib-pmpi"
LINKER_LANGUAGE C
INCLUDE_DIRECTORIES "${mpi4py_SOURCE_DIR}/lib-pmpi"
)
target_link_libraries(pmpi-mpe ${MPE_LIBRARIES})
target_link_libraries(pmpi-mpe ${MPI_C_LIBRARIES})
# --- mpi4py/lib-pmpi/libvt.so ---
add_library(pmpi-vt MODULE "${mpi4py_SOURCE_DIR}/lib-pmpi/vt.c")
set_target_properties(
pmpi-vt PROPERTIES
OUTPUT_NAME "vt"
LIBRARY_OUTPUT_DIRECTORY "${mpi4py_BINARY_DIR}/lib-pmpi"
RUNTIME_OUTPUT_DIRECTORY "${mpi4py_BINARY_DIR}/lib-pmpi"
LINKER_LANGUAGE C
INCLUDE_DIRECTORIES "${mpi4py_SOURCE_DIR}/lib-pmpi"
)
target_link_libraries(pmpi-vt ${VT_LIBRARIES})
target_link_libraries(pmpi-vt ${MPI_C_LIBRARIES})
# --- mpi4py/lib-pmpi/libvt-mpi.so ---
add_library(pmpi-vt-mpi MODULE "${mpi4py_SOURCE_DIR}/lib-pmpi/vt-mpi.c")
set_target_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"
LINKER_LANGUAGE C
INCLUDE_DIRECTORIES "${mpi4py_SOURCE_DIR}/lib-pmpi"
)
target_link_libraries(pmpi-vt-mpi ${VT_MPI_LIBRARIES})
target_link_libraries(pmpi-vt-mpi ${MPI_C_LIBRARIES})
# --- mpi4py/lib-pmpi/libvt-hyb.so ---
add_library(pmpi-vt-hyb MODULE "${mpi4py_SOURCE_DIR}/lib-pmpi/vt-hyb.c")
set_target_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"
LINKER_LANGUAGE C
INCLUDE_DIRECTORIES "${mpi4py_SOURCE_DIR}/lib-pmpi"
)
target_link_libraries(pmpi-vt-hyb ${VT_HYB_LIBRARIES})
target_link_libraries(pmpi-vt-hyb ${MPI_C_LIBRARIES})
add_subdirectory(src)
# -----------------------------------------------------------------------------
# Install the paraview module files.
install(DIRECTORY ${mpi4py_BINARY_DIR}
DESTINATION ${MPI4PY_INSTALL_PACKAGE_DIR}
COMPONENT Runtime)
vtk_module_add_module(vtkmpi4py
HEADER_ONLY)
target_include_directories(vtkmpi4py
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/mpi4py/include>"
"$<INSTALL_INTERFACE:${_vtk_build_HEADERS_DESTINATION}/vtkmpi4py>")
......@@ -6,7 +6,7 @@ LICENSE: MPI for Python
:Contact: dalcinl@gmail.com
Copyright (c) 2015, Lisandro Dalcin.
Copyright (c) 2017, Lisandro Dalcin.
All rights reserved.
Redistribution and use in source and binary forms, with or without
......
......@@ -2,14 +2,18 @@
MPI for Python
==============
.. image:: https://anaconda.org/mpi4py/mpi4py/badges/build.svg?
:target: https://anaconda.org/mpi4py/mpi4py/builds
.. image:: https://travis-ci.org/mpi4py/mpi4py.svg?branch=master
:target: https://travis-ci.org/mpi4py/mpi4py
.. image:: https://circleci.com/gh/mpi4py/mpi4py.svg?style=shield
:target: https://circleci.com/gh/mpi4py/mpi4py
.. image:: https://ci.appveyor.com/api/projects/status/whh5xovp217h0f7n?svg=true
:target: https://ci.appveyor.com/project/mpi4py/mpi4py
.. image:: https://scan.coverity.com/projects/mpi4py-mpi4py/badge.svg
:target: https://scan.coverity.com/projects/mpi4py-mpi4py
.. image:: https://codecov.io/gh/mpi4py/mpi4py/branch/master/graph/badge.svg
:target: https://codecov.io/gh/mpi4py/mpi4py
.. image:: https://readthedocs.org/projects/mpi4py/badge/?version=latest
:target: https://mpi4py.readthedocs.org/latest/
:target: https://mpi4py.readthedocs.org/en/latest/
Overview
--------
......@@ -22,7 +26,7 @@ exposes an API which grounds on the standard MPI-2 C++ bindings.
Dependencies
------------
* `Python <http://www.python.org/>`_ 2.6, 2.7, 3.2 or above,
* `Python <http://www.python.org/>`_ 2.7, 3.3 or above,
or `PyPy <http://pypy.org/>`_ 2.0 or above.
* A functional MPI 1.x/2.x/3.x implementation like `MPICH
......@@ -37,10 +41,12 @@ Testsuite
The testsuite is run periodically on
* `Anaconda <https://anaconda.org/mpi4py/mpi4py/builds>`_
* `Travis CI <https://travis-ci.org/mpi4py/mpi4py>`_
* `Circle CI <https://circleci.com/gh/mpi4py/mpi4py>`_
* `AppVeyor <https://ci.appveyor.com/project/mpi4py/mpi4py>`_
* `Bitbucket Pipelines <https://bitbucket.org/mpi4py/mpi4py/addon/pipelines/home>`_
* `Fedora Jenkins <http://jenkins.fedorainfracloud.org/job/mpi4py/>`_
* -whitespace
mpi4py.MPI.c hooks-max-size=8388608
set(mpi4py_install_dir
"${VTK_PYTHON_SITE_PACKAGES_SUFFIX}")
set(mpi4py_build_dir
"${CMAKE_BINARY_DIR}/${mpi4py_install_dir}")
set(python_files
mpi4py/__init__.py
mpi4py/__init__.pxd
mpi4py/MPI.pxd)
set(python_install_files)
foreach (python_file IN LISTS python_files)
set(output_python_file
"${mpi4py_build_dir}/${python_file}")
add_custom_command(
OUTPUT "${output_python_file}"
DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${python_file}"
COMMAND "${CMAKE_COMMAND}" -E copy_if_different
"${CMAKE_CURRENT_SOURCE_DIR}/${python_file}"
"${output_python_file}"
COMMENT "Copying ${python_file} to the binary directory")
list(APPEND python_install_files
"${output_python_file}")
endforeach ()
add_custom_target(vtkmpi4py_python_copy ALL
DEPENDS
${python_install_files})
set(mpi_cfg_content
"[mpi]
mpicc = ${MPI_C_COMPILER}
mpicxx = ${MPI_CXX_COMPILER}
mpif77 =
mpi490 =\n")
file(GENERATE
OUTPUT "${mpi4py_build_dir}/mpi4py/mpi.cfg"
CONTENT "${mpi_cfg_content}")
list(APPEND python_install_files
"${mpi4py_build_dir}/mpi4py/mpi.cfg")
install(
FILES ${python_install_files}
DESTINATION "${mpi4py_install_dir}/mpi4py"
COMPONENT "python")
add_library(vtkmpi4py.MPI MODULE
MPI.c)
set_target_properties(vtkmpi4py.MPI
PROPERTIES
OUTPUT_NAME "MPI"
PREFIX ""
LIBRARY_OUTPUT_DIRECTORY "${mpi4py_build_dir}/mpi4py")
if (WIN32)
set_target_properties(vtkmpi4py.MPI
PROPERTIES
DEBUG_POSTFIX "_d"
SUFFIX ".pyd")
endif ()
# Assume that fortran bindings are not available.
target_compile_definitions(vtkmpi4py.MPI
PRIVATE
PyMPI_MISSING_MPI_Type_create_f90_integer
PyMPI_MISSING_MPI_Type_create_f90_real
PyMPI_MISSING_MPI_Type_create_f90_complex
PyMPI_MISSING_MPI_Status_f2c
PyMPI_MISSING_MPI_Status_c2f)
target_link_libraries(vtkmpi4py.MPI
PRIVATE
vtkmpi
vtkPython)
vtk_module_install_headers(
DIRECTORIES "mpi4py/include/mpi4py/"
SUBDIR "vtkmpi4py/mpi4py")
# -----------------------------------------------------------------------------
cdef dict type_keyval = {}
cdef inline Datatype newtype(MPI_Datatype ob):
cdef Datatype datatype = <Datatype>Datatype.__new__(Datatype)
datatype.ob_mpi = ob
return datatype
cdef inline int type_attr_copy(
MPI_Datatype datatype,
int keyval,
void *extra_state,
void *attrval_in,
void *attrval_out,
int *flag) except -1:
cdef _p_keyval state = <_p_keyval>extra_state
cdef object copy_fn = state.copy_fn
if copy_fn is None:
flag[0] = 0
return 0
cdef object attrval = <object>attrval_in
cdef void **aptr = <void **>attrval_out
cdef Datatype handle
if copy_fn is not True:
handle = newtype(datatype)
try: attrval = copy_fn(handle, keyval, attrval)
finally: handle.ob_mpi = MPI_DATATYPE_NULL
Py_INCREF(attrval)
Py_INCREF(state)
aptr[0] = <void*>attrval
flag[0] = 1
return 0
cdef int type_attr_copy_cb(
MPI_Datatype datatype,
int keyval,
void *extra_state,
void *attrval_in,
void *attrval_out,
int *flag) with gil:
cdef object exc
try:
type_attr_copy(datatype, keyval, extra_state,
attrval_in, attrval_out, flag)
except MPIException, exc:
print_traceback()
return exc.Get_error_code()
except:
print_traceback()
return MPI_ERR_OTHER
return MPI_SUCCESS
cdef inline int type_attr_delete(
MPI_Datatype datatype,
int keyval,
void *attrval,
void *extra_state) except -1:
cdef _p_keyval state = <_p_keyval>extra_state
cdef object delete_fn = state.delete_fn
cdef Datatype handle
if delete_fn is not None:
handle = newtype(datatype)
try: delete_fn(handle, keyval, <object>attrval)
finally: handle.ob_mpi = MPI_DATATYPE_NULL
Py_DECREF(<object>attrval)
Py_DECREF(<object>extra_state)
return 0
cdef int type_attr_delete_cb(
MPI_Datatype datatype,
int keyval,
void *attrval,
void *extra_state) with gil:
cdef object exc
try:
type_attr_delete(datatype, keyval, attrval, extra_state)
except MPIException, exc:
print_traceback()
return exc.Get_error_code()
except:
print_traceback()
return MPI_ERR_OTHER
return MPI_SUCCESS
@cython.callspec("MPIAPI")
cdef int type_attr_copy_fn(MPI_Datatype datatype,
int keyval,
void *extra_state,
void *attrval_in,
void *attrval_out,
int *flag) nogil:
if extra_state == NULL: return MPI_ERR_INTERN
if attrval_in == NULL: return MPI_ERR_INTERN
if attrval_out == NULL: return MPI_ERR_INTERN
flag[0] = 0
if not Py_IsInitialized(): return MPI_SUCCESS
return type_attr_copy_cb(datatype, keyval, extra_state,
attrval_in, attrval_out, flag)
@cython.callspec("MPIAPI")
cdef int type_attr_delete_fn(MPI_Datatype datatype,
int keyval,
void *attrval,
void *extra_state) nogil:
if extra_state == NULL: return MPI_ERR_INTERN
if attrval == NULL: return MPI_ERR_INTERN
if not Py_IsInitialized(): return MPI_SUCCESS
return type_attr_delete_cb(datatype, keyval, attrval, extra_state)
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
cdef dict win_keyval = {}
cdef inline Win newwin(MPI_Win ob):
cdef Win win = <Win>Win.__new__(Win)
win.ob_mpi = ob
return win
cdef int win_attr_copy(
MPI_Win win,
int keyval,
void *extra_state,
void *attrval_in,
void *attrval_out,
int *flag) except -1:
cdef _p_keyval state = <_p_keyval>extra_state
cdef object copy_fn = state.copy_fn
if copy_fn is None:
flag[0] = 0
return 0
cdef object attrval = <object>attrval_in
cdef void **aptr = <void **>attrval_out
cdef Win handle
if copy_fn is not True:
handle = newwin(win)
try: attrval = copy_fn(handle, keyval, attrval)
finally: handle.ob_mpi = MPI_WIN_NULL
Py_INCREF(attrval)
Py_INCREF(state)
aptr[0] = <void*>attrval
flag[0] = 1
return 0
cdef int win_attr_copy_cb(
MPI_Win win,
int keyval,
void *extra_state,
void *attrval_in,
void *attrval_out,
int *flag) with gil:
cdef object exc
try:
win_attr_copy(win, keyval, extra_state,
attrval_in, attrval_out, flag)
except MPIException as exc:
print_traceback()
return exc.Get_error_code()
except:
print_traceback()
return MPI_ERR_OTHER
return MPI_SUCCESS
cdef int win_attr_delete(
MPI_Win win,
int keyval,
void *attrval,
void *extra_state) except -1:
cdef _p_keyval state = <_p_keyval>extra_state
cdef object delete_fn = state.delete_fn
cdef Win handle
if delete_fn is not None:
handle = newwin(win)
try: delete_fn(handle, keyval, <object>attrval)
finally: handle.ob_mpi =