Beispiel #1
0
def profile_start(menuitem, filename, fudge):
    global prof
##    import hotshot
##    prof = hotshot.Profile(filename)
##    prof.start()
    if thread_enable.enabled():
        reporter.warn("Multithreaded profiling is unreliable!\nUse the --unthreaded startup option.")
    from ooflib.common.EXTRA import profiler
    prof = profiler.Profiler(filename, fudge=fudge)
Beispiel #2
0
def profile_start(menuitem, filename, fudge):
    global prof
##    import hotshot
##    prof = hotshot.Profile(filename)
##    prof.start()
    if thread_enable.enabled():
        reporter.warn("Multithreaded profiling is unreliable!\nUse the --unthreaded startup option.")
    from ooflib.common.EXTRA import profiler
    prof = profiler.Profiler(filename, fudge=fudge)
Beispiel #3
0
 def hireWorker(self, argtuple=(), argdict={}, workerclass=None):
     # Create and start the appropriate kind of Worker to perform
     # the menu item.  If menuItem is threadable create a threaded
     # Worker and launch the thread.  There are different kinds of
     # threaded Workers.  getThreadedWorker returns the appropriate
     # one.
     if workerclass is None: # TODO: Is the workerclass arg ever not None?
         # It is tempting to put "if parallel_enable.enabled():..." but
         # threadable can carry more options than just
         # PARALLEL_THREADABLE and PARALLEL_UNTHREADABLE.
         if (self.threadable is PARALLEL_UNTHREADABLE and 
             parallel_enable.enabled()):
             workerclass = worker.ParallelWorker
         elif (self.threadable is PARALLEL_THREADABLE and
               parallel_enable.enabled()):
             if thread_enable.enabled():
                 workerclass = worker.getThreadedParallelWorker
             else:
                 workerclass = worker.ParallelWorker
         elif (self.threadable is UNTHREADABLE or
               not thread_enable.enabled() or
               (self.threadable is THREADABLE_GUI and not guitop.top()) or
               (self.threadable is THREADABLE_TEXT and guitop.top())
               ):
             workerclass = worker.NonThreadedWorker
         else:
             # worker.getThreadedWorker returns a
             # TextThreadedWorker in text mode, and either a
             # ThreadedWorker of GUIThreadedWorkerBlock in GUI
             # mode.
             workerclass = worker.getThreadedWorker
     the_worker = workerclass(self, argtuple, argdict)
     garbage.collect()
     # Launch the thread (and wait for it to finish if in text
     # mode).
     the_worker.start()
Beispiel #4
0
def start(messages=[]):
    debug.mainthreadTest()
    guitop.setMainLoop(True)
    # gui.show() can be run only after the main loop has started.
    # Some gui components need to have the whole threading machinery
    # available when they're starting up.  run_gui() installs
    # gui.show() as an idle callback which will run once the main loop
    # is running.
    mainthreadGUI.run_gui(gui.show, (messages, ))
    if thread_enable.enabled():
        gtk.gdk.threads_init()
        ## We used to call gtk.gdk.threads_enter() and threads_leave()
        ## here, but they appear not to be necessary on OS X or Linux
        ## and to be detrimental on NetBSD.
        # gtk.gdk.threads_enter()
    try:
        gtk.main()
    finally:
        guitop.setMainLoop(False)
Beispiel #5
0
def start(messages=[]):
    debug.mainthreadTest()
    guitop.setMainLoop(True)
    # gui.show() can be run only after the main loop has started.
    # Some gui components need to have the whole threading machinery
    # available when they're starting up.  run_gui() installs
    # gui.show() as an idle callback which will run once the main loop
    # is running.
    mainthreadGUI.run_gui(gui.show, (messages,))
    if thread_enable.enabled():
        gtk.gdk.threads_init()
        ## We used to call gtk.gdk.threads_enter() and threads_leave()
        ## here, but they appear not to be necessary on OS X or Linux
        ## and to be detrimental on NetBSD.
        # gtk.gdk.threads_enter()
    try:
        gtk.main()
    finally:
        guitop.setMainLoop(False)
Beispiel #6
0
def start(messages=[], files=[]):
    debug.mainthreadTest()

    ## See parameter.ParameterMetaClass
    # from ooflib.common.IO import parameter
    # parameter.checkMakeWidget()

    # Only call gui.show() afer the main loop has started.  Some gui
    # components need to have the whole threading machinery available
    # when they're starting up.
    mainthreadGUI.run_gui(gui.show, (messages, ))
    guitop.setMainLoop(True)
    if thread_enable.enabled():
        gtk.gdk.threads_init()
        ## We used to call gtk.gdk.threads_enter() and threads_leave()
        ## here, but they appear not to be necessary on OS X or Linux
        ## and to be detrimental on NetBSD.
        #gtk.gdk.threads_enter()
    try:
        ## The startup files must be loaded *after* the GUI
        ## starts, but this routine doesn't regain control once it
        ## starts the GUI. So we have to install the file loader
        ## (loadStartUpFiles) as an idle callback, which will run on
        ## the main thread.  loadStartUpFiles just issues menu
        ## commands that load the files, and if it runs on the main
        ## thread those menu commands will run by Workers on
        ## subthreads, and won't be run sequentially.  So, instead of
        ## installing loadStartUpFiles as an idle callback, we install
        ## subthread.execute and have it call loadStartUpFiles, since
        ## workers on subthreads don't create additional subthreads to
        ## run their menu items.
        from ooflib.common import subthread
        mainthread.run(subthread.execute_immortal,
                       (loadStartUpFiles, (files, )))
        gtk.main()
    finally:
        guitop.setMainLoop(False)
Beispiel #7
0
def run(no_interp=None):
    global _rank
    global startupfiles

    process_inline_options()  # execute well-formed oof options

    # Look for .oof2rc in the user's home directory.
    if not no_rc:
        oofrcpath = os.path.join(os.path.expanduser("~"), ".oof2rc")
        if os.path.exists(oofrcpath):
            startupfiles = [StartUpScriptNoLog(oofrcpath)] + startupfiles

    if thread_enable.query() and not (runtimeflags.text_mode
                                      or config.no_gui()):
        # TODO: Is this still necessary?
        garbage.disable()  # work-around for gtk bug?

    start_parallel_machine()  # start parallel suite (if available)

    if _rank == 0:
        if parallel_enable.enabled():
            from ooflib.SWIG.common import mpitools
            _size = mpitools.Size()
            mpitools.Isend_Bool(thread_enable.enabled(), range(1, _size))

        if parallel_enable.enabled():
            from ooflib.common.IO import socket2me

        if config.petsc():
            print "Going to InitPETSc"
            from ooflib.SWIG.engine.PETSc.petsc_solverdriver import InitPETSc
            InitPETSc(sys.argv)
            for s in sys.argv:
                print s

        start_sockets_Front_End()
        # Import mainmenu only *after* processing command line options, so
        # that the options can affect which menus are loaded.
        global mainmenu
        from ooflib.common.IO import mainmenu
        front_end(no_interp)  # all non-parallel menu items are executed here.
    else:
        # parallel back-end
        parallel_enable.set(True)  # notify back-end of its parallel status

        # thread status at the back-ends
        from ooflib.SWIG.common import mpitools
        thread_enable.set(mpitools.Recv_Bool(0))
        if not thread_enable.enabled():
            lock.disable_all()

        if parallel_enable.enabled():
            from ooflib.common.IO import socket2me

        if config.petsc():
            print "Going to InitPETSc"
            from ooflib.SWIG.engine.PETSc.petsc_solverdriver import InitPETSc
            InitPETSc(sys.argv)
            for s in sys.argv:
                print s

        debug.set_debug_mode()  # set for debugging parallel mode
        from ooflib.common import quit
        quit.set_quiet()  ## back-end exits quietly.
        start_sockets_Back_End()  # socket initialization
        from ooflib.common import backEnd  # import back end machine
        # The back end shouldn't run the gui!
        runtimeflags.text_mode = True
        backEnd.back_end()  # back-end awaits for your command
Beispiel #8
0
def run(no_interp=None):
    global _rank
    global startupfiles

    process_inline_options()  # execute well-formed oof options

    # Look for .oof2rc in the user's home directory.
    if not no_rc:
        oofrcpath = os.path.join(os.path.expanduser("~"), ".oof2rc")
        if os.path.exists(oofrcpath):
            startupfiles = [StartUpScriptNoLog(oofrcpath)]+startupfiles


    if thread_enable.query() and not (runtimeflags.text_mode or config.no_gui()):
        # TODO: Is this still necessary?
        garbage.disable()               # work-around for gtk bug?

    start_parallel_machine()  # start parallel suite (if available)

    if _rank == 0:
        if parallel_enable.enabled():
            from ooflib.SWIG.common import mpitools
            _size = mpitools.Size()
            mpitools.Isend_Bool(thread_enable.enabled(), range(1,_size))
            
        if parallel_enable.enabled():
            from ooflib.common.IO import socket2me

        if config.petsc():
            print "Going to InitPETSc"
            from ooflib.SWIG.engine.PETSc.petsc_solverdriver import InitPETSc
            InitPETSc(sys.argv)
            for s in sys.argv:
                print s

        start_sockets_Front_End()
        # Import mainmenu only *after* processing command line options, so
        # that the options can affect which menus are loaded.
        global mainmenu
        from ooflib.common.IO import mainmenu
        front_end(no_interp)  # all non-parallel menu items are executed here.
    else:
        # parallel back-end
        parallel_enable.set(True)  # notify back-end of its parallel status

        # thread status at the back-ends
        from ooflib.SWIG.common import mpitools
        thread_enable.set(mpitools.Recv_Bool(0))
        if not thread_enable.enabled():
            lock.disable_all()
        
        if parallel_enable.enabled():
            from ooflib.common.IO import socket2me

        if config.petsc():
            print "Going to InitPETSc"
            from ooflib.SWIG.engine.PETSc.petsc_solverdriver import InitPETSc
            InitPETSc(sys.argv)
            for s in sys.argv:
                print s

        debug.set_debug_mode()  # set for debugging parallel mode
        from ooflib.common import quit
        quit.set_quiet() ## back-end exits quietly.
        start_sockets_Back_End()  # socket initialization
        from ooflib.common import backEnd  # import back end machine
        # The back end shouldn't run the gui!
        runtimeflags.text_mode = True
        backEnd.back_end()  # back-end awaits for your command