def run(self, build_handle, benchmarks, run_directory, cuda_version,
            libdir):
        for dir_bench in benchmarks:
            exec_dir, data_dir, benchmark, self.command_line_args_list = dir_bench
            full_exec_dir = os.path.join(this_directory, exec_dir)
            full_data_dir = os.path.join(this_directory, data_dir,
                                         benchmark.replace('/', '_'))

            self.benchmark_args_subdirs = {}
            for args in self.command_line_args_list:
                self.benchmark_args_subdirs[args] = common.get_argfoldername(
                    args)

            for args in self.command_line_args_list:
                appargs_run_subdir = os.path.join(
                    benchmark.replace('/', '_'),
                    self.benchmark_args_subdirs[args])
                this_run_dir = os.path.join(run_directory, appargs_run_subdir,
                                            self.run_subdir)
                self.setup_run_directory(full_data_dir, this_run_dir, data_dir,
                                         appargs_run_subdir)

                self.text_replace_torque_sim(full_data_dir, this_run_dir,
                                             benchmark, cuda_version, args,
                                             libdir, full_exec_dir,
                                             build_handle)
                self.append_gpgpusim_config(benchmark, this_run_dir,
                                            self.config_file)

                # Submit the job to torque and dump the output to a file
                if not options.no_launch:
                    torque_out_filename = this_directory + "torque_out.{0}.txt".format(
                        os.getpid())
                    torque_out_file = open(torque_out_filename, 'w+')
                    saved_dir = os.getcwd()
                    os.chdir(this_run_dir)
                    if subprocess.call([job_submit_call,\
                                       os.path.join(this_run_dir , job_template)],\
                                       stdout=torque_out_file) < 0:
                        exit("Error Launching Torque Job")
                    else:
                        # Parse the torque output for just the numeric ID
                        torque_out_file.seek(0)
                        torque_out = re.sub(r"[^\d]*(\d*).*", r"\1",
                                            torque_out_file.read().strip())
                        print("Job " + torque_out + " queued (" +\
                            benchmark + "-" + self.benchmark_args_subdirs[args] +\
                            " " + self.run_subdir + ")")
                    torque_out_file.close()
                    os.remove(torque_out_filename)
                    os.chdir(saved_dir)

                    if len(torque_out) > 0:
                        # Dump the benchmark description to the logfile
                        if not os.path.exists(this_directory + "logfiles/"):
                            # In the very rare case that concurrent builds try to make the directory at the same time
                            # (after the test to os.path.exists -- this has actually happened...)
                            try:
                                os.makedirs(this_directory + "logfiles/")
                            except:
                                pass
                        now_time = datetime.datetime.now()
                        day_string = now_time.strftime("%y.%m.%d-%A")
                        time_string = now_time.strftime("%H:%M:%S")
                        log_name = "sim_log.{0}".format(options.launch_name)
                        logfile = open(this_directory +\
                                       "logfiles/"+ log_name + "." +\
                                       day_string + ".txt",'a')
                        print >> logfile, "%s %6s %-22s %-100s %-25s %s.%s" %\
                               ( time_string ,\
                               torque_out ,\
                               benchmark ,\
                               self.benchmark_args_subdirs[args] ,\
                               self.run_subdir,\
                               benchmark,\
                               build_handle )
                        logfile.close()
            self.benchmark_args_subdirs.clear()
Пример #2
0
benchmarks = []
benchmarks = common.gen_apps_from_suite_list(options.benchmark_list.split(","))

cuda_version = common.get_cuda_version( this_directory )
now_time = datetime.datetime.now()
day_string = now_time.strftime("%y.%m.%d-%A")
time_string = now_time.strftime("%H:%M:%S")
logfile = day_string + "--" + time_string + ".csv"

nvbit_path = os.path.join(this_directory, "..", "..", "..", "nvbit")

for bench in benchmarks:
    edir, ddir, exe, argslist = bench
    ddir = os.path.join(this_directory,ddir,exe)
    for args in argslist:
        run_name = os.path.join( exe, common.get_argfoldername( args ) )

        this_run_dir = os.path.join(this_directory, "..", "..", "run_hw", "device-" + options.device_num, cuda_version, run_name)
        if not os.path.exists(this_run_dir):
            os.makedirs(this_run_dir)

        # link the data directory
        if os.path.isdir(os.path.join(ddir, "data")):
            if os.path.lexists(os.path.join(this_run_dir, "data")):
                os.remove(os.path.join(this_run_dir, "data"))
            os.symlink(os.path.join(ddir, "data"), os.path.join(this_run_dir,"data"))

        if args == None:
            args = ""

        sh_contents = ""
configs = []
apps_and_args = []
exes_and_args = []
specific_jobIds = {}

stats_to_pull = {}
stats_yaml = yaml.load(open(options.stats_yml))
stats= {}
for stat in stats_yaml['collect']:
    stats_to_pull[stat] = re.compile(stat)

if options.configs_list != "" and options.benchmark_list != "":
    for app in common.gen_apps_from_suite_list(options.benchmark_list.split(",")):
        a,b,exe_name,args_list = app
        for args in args_list:
            apps_and_args.append( os.path.join(exe_name, common.get_argfoldername(args) ) )
    for config, params, gpuconf_file in common.gen_configs_from_list( options.configs_list.split(",") ):
        configs.append( config )
else:
    # This code gets the logfiles to pull the stats from if you are using the "-l" or "-N" option
    parsed_logfiles = []
    logfiles_directory = this_directory + "../job_launching/logfiles/"
    if options.logfile == "":
        if not os.path.exists(logfiles_directory):
            exit("No logfile specified and the default logfile directory cannot be found")
        all_logfiles = [os.path.join(logfiles_directory, f) \
                           for f in os.listdir(logfiles_directory) if(re.match(r'sim_log.*',f))]
        if len(all_logfiles) == 0:
            exit("ERROR - No Logfiles in " + logfiles_directory)
        if options.sim_name != "":
            named_sim = []