Пример #1
0
def exit():
    """Exit OP2 and clean up"""
    if configuration['print_cache_size'] and COMM_WORLD.rank == 0:
        from caching import report_cache, Cached, ObjectCached
        print '**** PyOP2 cache sizes at exit ****'
        report_cache(typ=ObjectCached)
        report_cache(typ=Cached)
    configuration.reset()

    if backends.get_backend() != 'pyop2.void':
        backends.unset_backend()
Пример #2
0
def init(**kwargs):
    """Initialise PyOP2: select the backend and potentially other configuration
    options.

    :arg backend:   Set the hardware-specific backend. Current choices are
                    ``"sequential"``, ``"openmp"``, ``"opencl"``, ``"cuda"``.
    :arg debug:     The level of debugging output.
    :arg comm:      The MPI communicator to use for parallel communication,
                    defaults to `MPI_COMM_WORLD`
    :arg log_level: The log level. Options: DEBUG, INFO, WARNING, ERROR, CRITICAL

    For debugging purposes, `init` accepts all keyword arguments
    accepted by the PyOP2 :class:`Configuration` object, see
    :meth:`Configuration.__init__` for details of further accepted
    options.

    .. note::
       Calling ``init`` again with a different backend raises an exception.
       Changing the backend is not possible. Calling ``init`` again with the
       same backend or not specifying a backend will update the configuration.
       Calling ``init`` after ``exit`` has been called is an error and will
       raise an exception.
    """
    backend = backends.get_backend()
    if backend == 'pyop2.finalised':
        raise RuntimeError("Calling init() after exit() is illegal.")

    if backend != 'pyop2.void' and \
            "backend" in kwargs and \
            backend != "pyop2.%s" % kwargs["backend"]:
        raise RuntimeError("Calling init() for a different backend is illegal.")

    configuration.reconfigure(**kwargs)

    set_log_level(configuration['log_level'])
    if backend == 'pyop2.void':
        try:
            backends.set_backend(configuration["backend"])
        except:
            configuration.reset()
            raise

        backends._BackendSelector._backend._setup()
        if 'comm' in kwargs:
            backends._BackendSelector._backend.MPI.comm = kwargs['comm']
        global MPI
        MPI = backends._BackendSelector._backend.MPI  # noqa: backend override

    init_coffee(configuration['simd_isa'], configuration['compiler'],
                configuration['blas'])
Пример #3
0
def exit():
    """Exit OP2 and clean up"""
    if configuration['print_cache_size'] and MPI.comm.rank == 0:
        from caching import report_cache, Cached, ObjectCached
        print '**** PyOP2 cache sizes at exit ****'
        report_cache(typ=ObjectCached)
        report_cache(typ=Cached)
    if configuration['print_summary'] and MPI.comm.rank == 0:
        from profiling import summary
        print '**** PyOP2 timings summary ****'
        summary()
    configuration.reset()

    if backends.get_backend() != 'pyop2.void':
        backends.unset_backend()
Пример #4
0
def exit():
    """Exit OP2 and clean up"""
    configuration.reset()

    if backends.get_backend() != "pyop2.void":
        backends.unset_backend()