Example #1
0
def test_run_fail(num_tasks):
    pytest.importorskip("mpi4py")
    mpi_exec = get_some_executor()
    with pytest.raises(ProcessError):
        mpi_exec.run("from mpi4py import MPI; MPI.COMM_WORLD.Barrier(); " +
                     "assert False",
                     exec_params=ExecParams(num_tasks=num_tasks))
Example #2
0
def test_call_with_args_and_kwargs(num_tasks):
    pytest.importorskip("mpi4py")
    mpi_exec = get_some_executor()
    mpi_exec.call(_test_func,
                  "he",
                  arg2="llo",
                  exec_params=ExecParams(num_tasks=num_tasks))
Example #3
0
def test_unsupported_param():
    pytest.importorskip("mpi4py")
    mpi_exec = get_some_executor()
    try:
        mpi_exec(["true"],
                 exec_params=ExecParams(num_tasks=2, gpus_per_task=1))
        pytest.skip("Oops. Unsupported param is actually supported.")
    except ExecParamError as e:
        assert e.param_name == "gpus_per_task"
Example #4
0
__copyright__ = "Copyright (C) 2020 University of Illinos Board of Trustees"

__license__ = """
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
"""

from squirm.execution import get_some_executor, ExecParams

if __name__ == "__main__":
    mpi_exec = get_some_executor()
    mpi_exec.run("from mpi4py import MPI; MPI.COMM_WORLD.Barrier(); print(" +
                 '"Hello, world!")',
                 exec_params=ExecParams(num_tasks=4))
Example #5
0
def test_execute_success(num_tasks):
    pytest.importorskip("mpi4py")
    mpi_exec = get_some_executor()
    mpi_exec(["true"], exec_params=ExecParams(num_tasks=num_tasks))
Example #6
0
def test_call_fail(num_tasks):
    pytest.importorskip("mpi4py")
    mpi_exec = get_some_executor()
    with pytest.raises(ProcessError):
        mpi_exec.call(partial(_test_func, "good", "bye"),
                      exec_params=ExecParams(num_tasks=num_tasks))
Example #7
0
def test_call_success(num_tasks):
    pytest.importorskip("mpi4py")
    mpi_exec = get_some_executor()
    mpi_exec.call(partial(_test_func, "he", "llo"),
                  exec_params=ExecParams(num_tasks=num_tasks))
Example #8
0
def test_run_success(num_tasks):
    pytest.importorskip("mpi4py")
    mpi_exec = get_some_executor()
    mpi_exec.run(
        "from mpi4py import MPI; MPI.COMM_WORLD.Barrier(); assert True",
        exec_params=ExecParams(num_tasks=num_tasks))
Example #9
0
def test_execute_fail(num_tasks):
    pytest.importorskip("mpi4py")
    mpi_exec = get_some_executor()
    with pytest.raises(ProcessError):
        mpi_exec(["false"], exec_params=ExecParams(num_tasks=num_tasks))