Exemple #1
0
def start(mode=None, profile_flag=False):
    """Execute relax.

    @keyword mode:          Force a relax mode, overriding the command line.
    @type mode:             str
    @keyword profile_flag:  Change this flag to True for code profiling.
    @type profile_flag:     bool
    """

    # Normal relax operation.
    relax = Relax()

    # Override normal operation.
    if mode:
        # Override the mode.
        relax.mode = mode

        # Some defaults.
        relax.script_file = None
        relax.log_file = None
        relax.tee_file = None
        relax.multiprocessor_type = 'uni'
        relax.n_processors = 1

    # Process the command line arguments.
    else:
        relax.arguments()

    # Store some start up info in the status object.
    status.relax_mode = relax.mode

    # Set up the multi-processor elements.
    callbacks = Application_callback(master=relax)
    verbosity = 0
    if status.debug:
        verbosity = 1
    processor = load_multiprocessor(relax.multiprocessor_type, callbacks, processor_size=relax.n_processors, verbosity=verbosity)

    # Place the processor fabric intro string into the info box.
    info = Info_box()
    info.multi_processor_string = processor.get_intro_string()

    # Normal relax operation.
    if not profile_flag:
        # Execute relax in multi-processor mode (this includes the uni-processor for normal operation).
        processor.run()

    # relax in profiling mode.
    else:
        def print_stats(stats, status=0):
            pstats.Stats(stats).sort_stats('time', 'name').print_stats()

        # No profile module.
        if not dep_check.profile_module:
            sys.stderr.write("The profile module is not available, please install the Python development packages for profiling.\n\n")
            sys.exit()

        # Run relax in profiling mode.
        profile.Profile.print_stats = print_stats
        profile.runctx('processor.run()', globals(), locals())
Exemple #2
0
def start(mode=None, profile_flag=False):
    """Execute relax.

    @keyword mode:          Force a relax mode, overriding the command line.
    @type mode:             str
    @keyword profile_flag:  Change this flag to True for code profiling.
    @type profile_flag:     bool
    """

    # Normal relax operation.
    relax = Relax()

    # Override normal operation.
    if mode:
        # Override the mode.
        relax.mode = mode

        # Some defaults.
        relax.script_file = None
        relax.log_file = None
        relax.tee_file = None
        relax.multiprocessor_type = 'uni'
        relax.n_processors = 1

    # Process the command line arguments.
    else:
        relax.arguments()

    # Store some start up info in the status object.
    status.relax_mode = relax.mode

    # Set up the multi-processor elements.
    callbacks = Application_callback(master=relax)
    verbosity = 0
    if status.debug:
        verbosity = 1
    processor = load_multiprocessor(relax.multiprocessor_type,
                                    callbacks,
                                    processor_size=relax.n_processors,
                                    verbosity=verbosity)

    # Place the processor fabric intro string into the info box.
    info = Info_box()
    info.multi_processor_string = processor.get_intro_string()

    # Normal relax operation.
    if not profile_flag:
        # Execute relax in multi-processor mode (this includes the uni-processor for normal operation).
        processor.run()

    # relax in profiling mode.
    else:

        def print_stats(stats, status=0):
            pstats.Stats(stats).sort_stats('time', 'name').print_stats()

        # No profile module.
        if not dep_check.profile_module:
            sys.stderr.write(
                "The profile module is not available, please install the Python development packages for profiling.\n\n"
            )
            sys.exit()

        # Run relax in profiling mode.
        profile.Profile.print_stats = print_stats
        profile.runctx('processor.run()', globals(), locals())