Commit efd48da4 authored by Martin Reinecke's avatar Martin Reinecke
Browse files

communicator passing seems to work

parent b54488ad
Pipeline #85842 failed with stages
in 32 seconds
......@@ -22,6 +22,7 @@
#include "python/healpix.cc"
#include "python/misc.cc"
#include "python/pointingprovider.cc"
#include "python/mpi.cc"
using namespace ducc0;
......@@ -36,4 +37,5 @@ PYBIND11_MODULE(PKGNAME, m)
add_healpix(m);
add_misc(m);
add_pointingprovider(m);
add_mpi(m);
}
/*
* This code is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This code is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this code; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
/* Copyright (C) 2019-2020 Max-Planck-Society
Author: Martin Reinecke */
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
#include "ducc0/bindings/pybind_utils.h"
#include "ducc0/infra/communication.h"
namespace ducc0 {
namespace detail_pymodule_mpi {
using namespace std;
namespace py = pybind11;
auto None = py::none();
Communicator getComm(const py::object &comm_)
{
auto pyMPI = py::module_::import("mpi4py.MPI");
auto func = pyMPI.attr("_addressof");
auto res = reinterpret_cast<const MPI_Comm *>(func(comm_).cast<size_t>());
return Communicator(*res);
}
void Pytest_comm(const py::object &comm_)
{
auto comm = getComm(comm_);
cout << comm.rank() << "/" << comm.num_ranks() << endl;
}
void add_mpi(py::module &msup)
{
using namespace pybind11::literals;
auto m = msup.def_submodule("mpi");
m.def("test_comm", &Pytest_comm, "comm"_a);
}
}
using detail_pymodule_mpi::add_mpi;
}
......@@ -10,6 +10,10 @@ pkgname = 'ducc0'
version = '0.6.0'
mpi_compile_args = os.popen("mpiCC --showme:compile").read().strip().split(' ')
mpi_compile_args.append("-DDUCC0_USE_MPI")
mpi_link_args = os.popen("mpiCC --showme:link").read().strip().split(' ')
def _get_files_by_suffix(directory, suffix):
path = directory
iterable_sources = (iglob(os.path.join(root, '*.'+suffix))
......@@ -21,7 +25,7 @@ include_dirs = ['.', './src/',
pybind11.get_include(True),
pybind11.get_include(False)]
extra_compile_args = ['-std=c++17', '-march=native', '-ffast-math', '-O3']
extra_compile_args = ['-std=c++17', '-march=native', '-ffast-math', '-O0']
python_module_link_args = []
......@@ -52,8 +56,11 @@ else:
python_module_link_args += ['-march=native',
'-Wl,-rpath,$ORIGIN',
'-s']
# if you want debugging info, remove the "-s" from python_module_link_args
extra_compile_args+=mpi_compile_args
python_module_link_args+=mpi_link_args
depfiles = (_get_files_by_suffix('.', 'h') +
_get_files_by_suffix('.', 'cc') +
['setup.py'])
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment