Example #1
0
def run_benchmark(problem, shape, space_order, tn, fn_perf, fn_norms, op='forward'):
    pyversion = sys.executable
    mpicmd = "mpirun"

    command = []

    # Is it with MPI?
    assert 'MPI_NUM_PROCS' in os.environ
    nprocs = int(os.environ['MPI_NUM_PROCS'])
    if nprocs > 1:
        assert 'DEVITO_MPI' in os.environ
        mpi_distro = sniff_mpi_distro(mpicmd)
        if mpi_distro == "OpenMPI":
            command.extend(['mpirun', '-n', str(nprocs), '--bind-to', 'socket'])
        elif mpi_distro == "MPICH":
            command.extend(['mpirun', '-n', str(nprocs), '--bind-to', 'socket'])
        else:
            raise RuntimeError("Unknown MPI distribution")

    command.extend([pyversion, benchmark.__file__, 'run', '-P', problem])
    command.extend(['-d'] + [str(i) for i in shape])
    command.extend(['-so', str(space_order)])
    command.extend(['--tn', str(tn)])
    command.extend(['--dump-summary', fn_perf])
    command.extend(['--dump-norms', fn_norms])
    command.extend(['--operator', op])
    command.extend(['--autotune', 'off'])  # TODO: Drop me


    check_call(command)
Example #2
0
def parallel(item):
    """
    Run a test in parallel. Readapted from:

        ``https://github.com/firedrakeproject/firedrake/blob/master/tests/conftest.py``
    """
    mpi_exec = 'mpiexec'
    mpi_distro = sniff_mpi_distro(mpi_exec)

    marker = item.get_closest_marker("parallel")
    mode = as_tuple(marker.kwargs.get("mode", 2))
    for m in mode:
        # Parse the `mode`
        if isinstance(m, int):
            nprocs = m
            scheme = 'basic'
            restrain = False
        else:
            if len(m) == 2:
                nprocs, scheme = m
                restrain = False
            elif len(m) == 3:
                nprocs, scheme, restrain = m
            else:
                raise ValueError("Can't run test: unexpected mode `%s`" % m)

        if restrain and os.environ.get('MPI_RESTRAIN', False):
            # A computationally expensive test that would take too long to
            # run on the current machine
            continue

        pyversion = sys.executable
        # Only spew tracebacks on rank 0.
        # Run xfailing tests to ensure that errors are reported to calling process
        if item.cls is not None:
            testname = "%s::%s::%s" % (item.fspath, item.cls.__name__, item.name)
        else:
            testname = "%s::%s" % (item.fspath, item.name)
        args = ["-n", "1", pyversion, "-m", "pytest", "--runxfail", "-s",
                "-q", testname]
        if nprocs > 1:
            args.extend([":", "-n", "%d" % (nprocs - 1), pyversion, "-m", "pytest",
                         "--runxfail", "--tb=no", "-q", testname])
        # OpenMPI requires an explicit flag for oversubscription. We need it as some
        # of the MPI tests will spawn lots of processes
        if mpi_distro == 'OpenMPI':
            call = [mpi_exec, '--oversubscribe'] + args
        else:
            call = [mpi_exec] + args

        # Tell the MPI ranks that they are running a parallel test
        os.environ['DEVITO_MPI'] = scheme
        try:
            check_call(call)
        finally:
            os.environ['DEVITO_MPI'] = '0'
Example #3
0
def parallel(item):
    """
    Run a test in parallel. Readapted from:

        ``https://github.com/firedrakeproject/firedrake/blob/master/tests/conftest.py``
    """
    mpi_exec = 'mpiexec'
    mpi_distro = sniff_mpi_distro(mpi_exec)

    marker = item.get_closest_marker("parallel")
    mode = as_tuple(marker.kwargs.get("mode", 2))
    for m in mode:
        # Parse the `mode`
        if isinstance(m, int):
            nprocs = m
            scheme = 'basic'
            restrain = False
        else:
            if len(m) == 2:
                nprocs, scheme = m
                restrain = False
            elif len(m) == 3:
                nprocs, scheme, restrain = m
            else:
                raise ValueError("Can't run test: unexpected mode `%s`" % m)

        if restrain and os.environ.get('MPI_RESTRAIN', False):
            # A computationally expensive test that would take too long to
            # run on the current machine
            continue

        # Only spew tracebacks on rank 0.
        # Run xfailing tests to ensure that errors are reported to calling process
        if item.cls is not None:
            testname = "%s::%s::%s" % (item.fspath, item.cls.__name__, item.name)
        else:
            testname = "%s::%s" % (item.fspath, item.name)
        args = ["-n", "1", "python", "-m", "pytest", "--runxfail", "-s",
                "-q", testname]
        if nprocs > 1:
            args.extend([":", "-n", "%d" % (nprocs - 1), "python", "-m", "pytest",
                         "--runxfail", "--tb=no", "-q", testname])
        # OpenMPI requires an explicit flag for oversubscription. We need it as some
        # of the MPI tests will spawn lots of processes
        if mpi_distro == 'OpenMPI':
            call = [mpi_exec, '--oversubscribe'] + args
        else:
            call = [mpi_exec] + args

        # Tell the MPI ranks that they are running a parallel test
        os.environ['DEVITO_MPI'] = scheme
        try:
            check_call(call)
        finally:
            os.environ['DEVITO_MPI'] = '0'
Example #4
0
def parallel(item):
    """Run a test in parallel.

    :parameter item: The test item to run.
    """
    # Support to run MPI tests
    # This is partly extracted from:
    # `https://github.com/firedrakeproject/firedrake/blob/master/tests/conftest.py`

    mpi_exec = 'mpiexec'
    mpi_distro = sniff_mpi_distro(mpi_exec)

    marker = item.get_closest_marker("parallel")
    nprocs = as_tuple(marker.kwargs.get("nprocs", 2))
    for i in nprocs:
        # Only spew tracebacks on rank 0.
        # Run xfailing tests to ensure that errors are reported to calling process
        if item.cls is not None:
            testname = "%s::%s::%s" % (item.fspath, item.cls.__name__,
                                       item.name)
        else:
            testname = "%s::%s" % (item.fspath, item.name)
        args = [
            "-n", "1", "python", "-m", "pytest", "--runxfail", "-s", "-q",
            testname
        ]
        if i > 1:
            args.extend([
                ":", "-n",
                "%d" % (i - 1), "python", "-m", "pytest", "--runxfail",
                "--tb=no", "-q", testname
            ])
        # OpenMPI requires an explicit flag for oversubscription. We need it as some
        # of the MPI tests will spawn lots of processes
        if mpi_distro == 'OpenMPI':
            call = [mpi_exec, '--oversubscribe'] + args
        else:
            call = [mpi_exec] + args

        # Tell the MPI ranks that they are running a parallel test
        os.environ['DEVITO_MPI'] = '1'
        try:
            check_call(call)
        finally:
            os.environ['DEVITO_MPI'] = '0'
Example #5
0
            oldvalue = configuration[key]
            configuration[key] = value
            f(*args, **kwargs)
            configuration[key] = oldvalue

        return wrapper

    return dec


# Support to run MPI tests
# This is partly extracted from:
# `https://github.com/firedrakeproject/firedrake/blob/master/tests/conftest.py`

mpi_exec = 'mpiexec'
mpi_distro = sniff_mpi_distro(mpi_exec)


def parallel(item):
    """Run a test in parallel.

    :parameter item: The test item to run.
    """
    marker = item.get_closest_marker("parallel")
    nprocs = as_tuple(marker.kwargs.get("nprocs", 2))
    for i in nprocs:
        # Only spew tracebacks on rank 0.
        # Run xfailing tests to ensure that errors are reported to calling process
        if item.cls is not None:
            testname = "%s::%s::%s" % (item.fspath, item.cls.__name__,
                                       item.name)