File: test_mpi.py

package info (click to toggle)
fenics-dolfinx 1%3A0.9.0-10
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 5,376 kB
  • sloc: cpp: 33,701; python: 22,338; makefile: 230; sh: 170; xml: 55
file content (35 lines) | stat: -rw-r--r-- 868 bytes parent folder | download | duplicates (2)
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
# Copyright (C) 2017 Garth N. Wells
#
# This file is part of DOLFINx (https://www.fenicsproject.org)
#
# SPDX-License-Identifier:    LGPL-3.0-or-later
"""Unit tests for MPI facilities"""

import sys

from mpi4py import MPI

from dolfinx.mesh import create_unit_square


def test_mpi_comm_wrapper():
    """Test MPICommWrapper <-> mpi4py.MPI.Comm conversion"""
    comm0 = MPI.COMM_WORLD
    m = create_unit_square(comm0, 4, 4)
    comm1 = m.comm
    assert isinstance(comm0, MPI.Comm)
    assert isinstance(comm1, MPI.Comm)


def test_mpi_comm_refcount():
    """Test MPICommWrapper <-> mpi4py.MPI.Comm reference counting"""
    comm0 = MPI.COMM_WORLD
    m = create_unit_square(comm0, 4, 4)
    comm1 = m.comm
    assert comm1 != comm0
    comm2 = m.comm
    assert comm2 == comm1

    del m
    assert sys.getrefcount(comm1) == 2
    assert comm1.rank == comm0.rank