File: test_mpi_funcs.py

package info (click to toggle)
python-parsl 2025.11.10%2Bds-1
  • links: PTS, VCS
  • area: main
  • in suites: forky
  • size: 12,124 kB
  • sloc: python: 24,375; makefile: 352; sh: 252; ansic: 45
file content (34 lines) | stat: -rw-r--r-- 886 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
import os

import pytest

import parsl
from parsl.tests.configs.local_radical_mpi import fresh_config as local_config


@parsl.python_app
def some_mpi_func(msg, sleep, comm=None, parsl_resource_specification={}):
    import time
    msg = 'hello %d/%d: %s' % (comm.rank, comm.size, msg)
    time.sleep(sleep)
    print(msg)
    return comm.size


apps = []


@pytest.mark.local
@pytest.mark.radical
@pytest.mark.skipif(
    os.environ.get("RADICAL_CI") != "1",
    reason="Only runs in Radical CI workflow"
)
def test_radical_mpi(n=7):
    # rank size should be > 1 for the
    # radical runtime system to run this function in MPI env
    for i in range(2, n):
        spec = {'ranks': i}
        t = some_mpi_func(msg='mpi.func.%06d' % i, sleep=1, comm=None, parsl_resource_specification=spec)
        apps.append(t)
    assert [len(app.result()) for app in apps] == list(range(2, n))