Example #1
0
    def execute(self, run):
        """
        This function executes the tool with a sourcefile with options.
        It also calls functions for output before and after the run.
        """
        self.output_handler.output_before_run(run)
        benchmark = self.benchmark

        memlimit = benchmark.rlimits.get(MEMLIMIT)

        args = run.cmdline()
        logging.debug("Command line of run is %s", args)
        pqos = Pqos()
        if self.my_cpus:
            pqos.start_monitoring([self.my_cpus])
        run_result = self.run_executor.execute_run(
            args,
            output_filename=run.log_file,
            output_dir=run.result_files_folder,
            result_files_patterns=benchmark.result_files_patterns,
            hardtimelimit=benchmark.rlimits.get(TIMELIMIT),
            softtimelimit=benchmark.rlimits.get(SOFTTIMELIMIT),
            walltimelimit=benchmark.rlimits.get(WALLTIMELIMIT),
            cores=self.my_cpus,
            memory_nodes=self.my_memory_nodes,
            memlimit=memlimit,
            environments=benchmark.environment(),
            workingDir=benchmark.working_directory(),
            maxLogfileSize=benchmark.config.maxLogfileSize,
            files_count_limit=benchmark.config.filesCountLimit,
            files_size_limit=benchmark.config.filesSizeLimit,
        )
        mon_data = pqos.stop_monitoring()
        run_result.update(mon_data)
        if not mon_data:
            logging.debug(
                "Could not monitor cache and memory bandwidth events for run: %s",
                run.identifier,
            )

        if self.run_executor.PROCESS_KILLED:
            # If the run was interrupted, we ignore the result and cleanup.
            try:
                if benchmark.config.debug:
                    os.rename(run.log_file, run.log_file + ".killed")
                else:
                    os.remove(run.log_file)
            except OSError:
                pass
            return 1

        if self.my_cpus:
            run_result["cpuCores"] = self.my_cpus
        if self.my_memory_nodes:
            run_result["memoryNodes"] = self.my_memory_nodes

        run.set_result(run_result)
        self.output_handler.output_after_run(run)
        return None
 def test_pqos_stop_monitoring_error(self, mock_find_executable,
                                     mock_check_output, mock_popen):
     """
     Test for pqos.stop_monitoring, when pqos_wrapper throws an error
     """
     pqos = Pqos()
     pqos.start_monitoring([[0, 1, 2]])
     pqos.mon_process.returncode = 1
     ret = pqos.stop_monitoring()
     self.assertDictEqual(ret, {})
     self.assertEqual(pqos.mon_process, None)
 def test_pqos_stop_monitoring(self, mock_find_executable,
                               mock_check_output, mock_popen):
     """
     Test for pqos.stop_monitoring
     """
     flatten_mon_data = {
         "ipc": 0.987,
         "llc_misses": 10240,
         "llc_avg": 25028,
         "llc_max": 30000,
         "mbm_local_avg": 25028,
         "mbm_local_max": 30000,
     }
     pqos = Pqos()
     pqos.start_monitoring([[0, 1, 2]])
     ret = pqos.stop_monitoring()
     self.assertDictEqual(ret, flatten_mon_data)
     self.assertEqual(pqos.mon_process, None)