File: test_mpi.py

package info (click to toggle)
fenics-dolfinx 1%3A0.10.0.post4-1exp1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 6,028 kB
  • sloc: cpp: 36,535; python: 25,391; makefile: 226; sh: 171; xml: 55
file content (35 lines) | stat: -rw-r--r-- 902 bytes parent folder | download | duplicates (3)
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) == 1 + int(sys.version_info < (3, 14))
    assert comm1.rank == comm0.rank