Skip to content
Snippets Groups Projects
Commit 65ee6df5 authored by René Fritze's avatar René Fritze Committed by dune-community-bulldozer[bot]
Browse files

[test] for mpi_comm_wrapper

parent 82bafd41
No related branches found
No related tags found
No related merge requests found
// This file is part of the dune-xt-grid project:
// https://github.com/dune-community/dune-xt-grid
// Copyright 2009-2018 dune-xt-grid developers and contributors. All rights reserved.
// License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
// or GPL-2.0+ (http://opensource.org/licenses/gpl-license)
// with "runtime exception" (http://www.dune-project.org/license.html)
// Authors:
// Rene Milk (2018)
#include <dune/xt/common/test/main.hxx>
#include <dune/common/unused.hh>
#include <dune/xt/common/parallel/mpi_comm_wrapper.hh>
using namespace Dune;
using namespace Dune::XT::Common;
MPIHelper::MPICommunicator implicit_convert(MPI_Comm_Wrapper mpi_comm)
{
return mpi_comm.get();
}
GTEST_TEST(MpiCommWrapper, Global)
{
const auto orig = MPIHelper::getCommunicator();
const auto convert = implicit_convert(orig);
ASSERT_EQ(orig, convert);
}
GTEST_TEST(MpiCommWrapper, Local)
{
const auto orig = MPIHelper::getLocalCommunicator();
const auto convert = implicit_convert(orig);
ASSERT_EQ(orig, convert);
}
......@@ -46,18 +46,6 @@ def test_timings():
timings.output_simple()
def test_mpi_wrapper():
try:
from mpi4py import MPI
except ImportError:
pytest.skip('optional mpi4py is missing')
return
mpi_comm = MPI.COMM_WORLD
from dune.xt.common import CollectiveCommunication
comm_def = CollectiveCommunication()
comm = CollectiveCommunication(mpi_comm)
assert type(comm) is type(comm_def)
assert comm.size > 0
assert comm.rank < comm.size
assert comm.sum(1) == comm.size
if __name__ == '__main__':
from dune.xt.common.test import runmodule
runmodule(__file__)
# ~~~
# This file is part of the dune-xt-common project:
# https://github.com/dune-community/dune-xt-common
# Copyright 2009-2018 dune-xt-common developers and contributors. All rights reserved.
# License: Dual licensed as BSD 2-Clause License (http://opensource.org/licenses/BSD-2-Clause)
# Authors:
# Rene Milk (2018)
# ~~~
import pytest
from dune.xt.common.test import load_all_submodule
def test_mpi4py():
try:
from mpi4py import MPI
except ImportError:
pytest.skip('optional mpi4py is missing')
return
mpi_comm = MPI.COMM_WORLD
from dune.xt.common import CollectiveCommunication
comm_def = CollectiveCommunication()
comm = CollectiveCommunication(mpi_comm)
assert type(comm) is type(comm_def)
assert comm.size > 0
assert comm.rank < comm.size
assert comm.sum(1) == comm.size
def test_wrapper():
try:
from mpi4py import MPI
except ImportError:
pytest.skip('optional mpi4py is missing')
return
mpi_comm = MPI.COMM_WORLD
if __name__ == '__main__':
from dune.xt.common.test import runmodule
runmodule(__file__)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment