Example #1
0
 def __init__(self):
     Timer.__init__(self)
     import pytau
     self.pytau = pytau
     self.tau_timers = {}
     pytau.setNode(mpi.rank)
     self.tau_timers[self.top_level] = pytau.profileTimer(self.top_level)
     pytau.start(self.tau_timers[self.top_level])
Example #2
0
 def runcall_with_node(self, node, func, *args, **kw):
     self.enable()
     try:
         import pytau
         pytau.setNode(node)
         return func(*args, **kw)
     finally:
         self.disable()
Example #3
0
 def __init__(self):
     Timer.__init__(self)
     import pytau
     self.pytau = pytau
     self.tau_timers = {}
     pytau.setNode(mpi.rank)
     self.tau_timers[self.top_level] = pytau.profileTimer(self.top_level)
     pytau.start(self.tau_timers[self.top_level])
Example #4
0
 def __init__(self):
     Timer.__init__(self)
     self.tau_timers = {}
     pytau.setNode(mpi.rank)
     self.start("PAW_calc")
Example #5
0
    def __run__(self):
        """
        Set (and possibly create) the working directory for the component
        and change the working directory to the (possibly newly created)
        directory.
        Wait for incoming commands delivered via the *invocation_q*, and
        dispatch the incoming methods accordingly.
        """
        # timer = pytau.profileTimer(self.component_id.__str__() + ".__run__", "", str(os.getpid()))
        # pytau.start(timer)

        tmp = sys.exit
        sys.exit = self.__my_exit__
        self.sys_exit = tmp
        try:
            redirect = self.services.sim_conf['OUT_REDIRECT']
        except KeyError:
            pass
        else:
            if str(redirect).strip() != '':
                if ('OUT_REDIRECT_FNAME') not in list(
                        self.services.sim_conf.keys()):
                    fname = "%s.out" % (self.services.sim_conf['SIM_NAME'])
                    fname = os.path.join(self.services.sim_conf['PWD'], fname)
                    print('Redirecting stdout to ', fname)
                else:
                    fname = self.services.sim_conf['OUT_REDIRECT_FNAME']
                original_stdout_fd = sys.stdout.fileno()
                original_stderr_fd = sys.stderr.fileno()
                outf = open(fname, "a")
                outf_fno = outf.fileno()
                # sys.stdout.close()
                os.dup2(outf_fno, original_stdout_fd)
                os.dup2(outf_fno, original_stderr_fd)
                # Use line buffered for stderr/stdout redirected files
                sys.stdout = os.fdopen(sys.stdout.fileno(), 'w', 1)
                sys.stderr = os.fdopen(sys.stderr.fileno(), 'w', 1)

        # SIMYAN: reversed changes that took directory creation in work out of
        # a component's hands. Now this class creates the directory and changes
        # into it as before.
        workdir = self.services.get_working_dir()

        try:
            os.chdir(workdir)
        except OSError:
            self.services.debug(
                'Working directory %s does not exist - will attempt creation',
                workdir)
            try:
                os.makedirs(workdir)
            except OSError as oserr:
                (errno, strerror) = oserr.args
                self.services.exception('Error creating directory %s : %s',
                                        workdir, strerror)
                # pytau.stop(timer)
                raise
            os.chdir(workdir)
        self.services.debug('Running - CompID =  %s',
                            self.component_id.get_serialization())

        if (self.services.profile):
            self.services.debug('Instrumenting - CompID =  %s',
                                self.component_id.get_serialization())
            pytau.setNode(int(self.component_id.get_seq_num()))
            pytau.dbPurge()
            self.services._make_timers()
        self.services._init_event_service()

        while True:
            msg = self.invocation_q.get()
            self.services.log('Received Message ')
            sender_id = msg.sender_id
            call_id = msg.call_id
            method_name = msg.target_method
            args = msg.args
            keywords = msg.keywords
            formatted_args = [
                '%.3f' % (x) if isinstance(x, float) else str(x) for x in args
            ]
            if keywords:
                formatted_args += [
                    " %s=" % k + str(v) for (k, v) in keywords.items()
                ]

            self.services.debug('Calling method ' + method_name + "(" +
                                ' ,'.join(formatted_args) + ")")
            try:
                method = getattr(self, method_name)
                retval = method(*args, **keywords)
            except Exception as e:
                self.services.exception(
                    'Uncaught Exception in component method.')
                response_msg = MethodResultMessage(self.component_id,
                                                   sender_id, call_id,
                                                   Message.FAILURE, e)
            else:
                response_msg = MethodResultMessage(self.component_id,
                                                   sender_id, call_id,
                                                   Message.SUCCESS, retval)
            self.services.fwk_in_q.put(response_msg)
Example #6
0
 def __init__(self):
     Timer.__init__(self)
     self.tau_timers = {}
     pytau.setNode(mpi.rank)
     self.start('PAW_calc')
Example #7
0
                workdir)
            try:
                os.makedirs(workdir)
            except OSError, (errno, strerror):
                self.services.exception('Error creating directory %s : %s',
                                        workdir, strerror)
                #pytau.stop(timer)
                raise
            os.chdir(workdir)
        self.services.debug('Running - CompID =  %s',
                            self.component_id.get_serialization())

        if (self.services.profile):
            self.services.debug('Instrumenting - CompID =  %s',
                                self.component_id.get_serialization())
            pytau.setNode(int(self.component_id.get_seq_num()))
            pytau.dbPurge()
            self.services._make_timers()
        self.services._init_event_service()

        while True:
            msg = self.invocation_q.get()
            self.services.log('Received Message ')
            sender_id = msg.sender_id
            call_id = msg.call_id
            method_name = msg.target_method
            args = msg.args
            keywords = msg.keywords
            formatted_args = [
                '%.3f' % (x) if isinstance(x, float) else str(x) for x in args
            ]