示例#1
0
def main():
    options = parse_options()

    if options.input_file == "-":
        input_file = sys.stdin
    else:
        input_file = open(options.input_file)

    if options.scheduler == "MultiDimenDoubleEasyScheduler" or options.scheduler == "1":
        scheduler = MultiDimenDoubleEasyScheduler(options.num_processors,
                                                  options.num_memory)

    elif options.scheduler == "MultiDimensionResourceBalanceScheduler" or options.scheduler == "2":
        scheduler = MultiDimensionResourceBalanceScheduler(
            options.num_processors, options.num_memory)

    elif options.scheduler == "MultiDimensionResourceBalanceReverseImprovedScheduler" or options.scheduler == "3":
        scheduler = MultiDimensionResourceBalanceReverseImprovedScheduler(
            options.num_processors, options.num_memory)

    elif options.scheduler == "MultiDimensionResourceBalanceTimeScheduler" or options.scheduler == "4":
        scheduler = MultiDimensionResourceBalanceTimeScheduler(
            options.num_processors, options.num_memory)
    else:
        print "No such scheduler"
        return

    try:
        print "...."
        run_simulator(num_processors=options.num_processors,
                      num_memory=options.num_memory,
                      jobs=_job_inputs_to_jobs(parse_lines(input_file),
                                               options.num_processors,
                                               options.num_memory),
                      scheduler=scheduler)

        print "Num of Processors: ", options.num_processors
        print "Input file: ", options.input_file
        print "Scheduler:", type(scheduler)

    finally:
        if input_file is not sys.stdin:
            input_file.close()
示例#2
0
  def simulate(
      self,
      input_file_path, 
      job_estimated_time, 
      job_required_num_processors, 
      job_submission_time,
      job_user_id,
      job_backlog_days=180):

    input_file = open(input_file_path, 'r')

    parsed_jobs = trace_job_parser(
        resource=self.resource,
        lines=input_file.readlines(),
        backlog_days=job_backlog_days,
        verbose=self.verbose)
    input_file.close()

    if parsed_jobs==None:
      print("Unable to parse jobs. Returning without simulation.")
      return parsed_jobs

    my_job_id = add_job(est_time_secs=job_estimated_time, 
        num_required_processors=job_required_num_processors,
        job_sub_time_secs=job_submission_time,
        user_id=job_user_id, 
        backlog_days=job_backlog_days,
        jobs=parsed_jobs)

    simulator = run_simulator(
        num_processors = self.num_processors, 
        jobs = parsed_jobs,
        scheduler = self.scheduler,
        target_job_id=my_job_id)

    match = [x for x in simulator.terminated_jobs if x.id==my_job_id]
    
    if self.verbose:
      print_simulator_stats(simulator)
      print "Num of Processors: ", options.num_processors
      print "Input file: ", options.input_file
      print "Scheduler:", type(scheduler)

    return match
示例#3
0
def parse_and_run_simulator(options):

	if options["input_file"] is None:
		parser.error("missing input file")


	if options["input_file"] == "-":
		input_file = sys.stdin
	else:
		input_file = open(options["input_file"])

	if options["num_processors"] is None:
		input_file = open(options["input_file"])
		for line in input_file:
			if(line.lstrip().startswith(';')):
				if(line.lstrip().startswith('; MaxProcs:')):
					options["num_processors"] = int(line.strip()[11:])
					break
				else:
					continue
			else:
				break

	if options["num_processors"] is None:
		parser.error("missing num processors")

	if options["stats"] is None:
		options["stats"] = False

	if sys.stdout.isatty():# You're running in a real terminal
		options["scheduler"]["progressbar"] = True
	else:# You're being piped or redirected
		options["scheduler"]["progressbar"] = False

	if options["scheduler"] is None:
		parser.error("missing scheduler")

	if options["scheduler"]["name"] is None:
		parser.error("missing scheduler name")



	my_module = options["scheduler"]["name"]
	my_class = module_to_class(my_module)

	#load module(or file)
	package = __import__ ('schedulers', fromlist=[my_module])
	if my_module not in package.__dict__:
		print "No such scheduler (module file not found)."
		return
	if my_class not in package.__dict__[my_module].__dict__:
		print "No such scheduler (class within the module file not found)."
		return
	#load the class
	scheduler_non_instancied = package.__dict__[my_module].__dict__[my_class]

	if my_module in ('maui_scheduler', 'l2r_maui_scheduler', 'online_l2r_maui_scheduler'):
		scheduler = scheduler_non_instancied(options, \
			# weights_list=options["weights"], \
			weights_backfill=options["weights"])
	else:
		scheduler = scheduler_non_instancied(options)

	# scheduler = scheduler_non_instancied(options\
	# 	, weights_list=options["weights"], weights_backfill=options["weights"])


	#if hasattr(scheduler_non_instancied, 'I_NEED_A_PREDICTOR'):

	try:
		# print "...."

		starttime = datetime.today()
		sim = run_simulator(
			num_processors = options["num_processors"],
			jobs = _job_inputs_to_jobs(parse_lines(input_file), options["num_processors"]),
			scheduler = scheduler,
			output_swf = options["output_swf"] if "output_swf" in options else None,
			input_file = options["input_file"],
			no_stats = not(options["stats"]),
			options = options
			)
		end_time = datetime.today() - starttime

		options["terminated_jobs"] = sim.get_terminated_jobs()

		print "\b" * 50

		if options.get("verbose", False):
			print "\n"
			print "Num of Processors: ", options["num_processors"]
			print "Input file: ", options["input_file"]
			print "Scheduler:", type(scheduler)
			print "Elapsed Time:", end_time

	finally:
		if input_file is not sys.stdin:
			input_file.close()

	return end_time
示例#4
0
def main():
    options = parse_options()

    if options.input_file == "-":
        input_file = sys.stdin
    else:
        input_file = open(options.input_file)

    if options.scheduler == "FcfsScheduler" or options.scheduler == "1":
        scheduler = FcfsScheduler(options.num_processors)

    elif options.scheduler == "ConservativeScheduler" or options.scheduler == "2":
        scheduler = ConservativeScheduler(options.num_processors)

    elif options.scheduler == "DoubleConservativeScheduler" or options.scheduler == "3":
        scheduler = DoubleConservativeScheduler(options.num_processors)

    elif options.scheduler == "EasyBackfillScheduler" or options.scheduler == "4":
        scheduler = EasyBackfillScheduler(options.num_processors)

    elif options.scheduler == "DoubleEasyBackfillScheduler" or options.scheduler == "5":
        scheduler = DoubleEasyBackfillScheduler(options.num_processors)

    elif options.scheduler == "GreedyEasyBackfillScheduler" or options.scheduler == "6":
        scheduler = GreedyEasyBackfillScheduler(options.num_processors)

    elif options.scheduler == "EasyPlusPlusScheduler" or options.scheduler == "7":
        scheduler = EasyPlusPlusScheduler(options.num_processors)

    elif options.scheduler == "ShrinkingEasyScheduler" or options.scheduler == "8":
        scheduler = ShrinkingEasyScheduler(options.num_processors)

    elif options.scheduler == "LookAheadEasyBackFillScheduler" or options.scheduler == "9":
        scheduler = LookAheadEasyBackFillScheduler(options.num_processors)

    elif options.scheduler == "EasySJBFScheduler" or options.scheduler == "10":
        scheduler = EasySJBFScheduler(options.num_processors)

    elif options.scheduler == "HeadDoubleEasyScheduler" or options.scheduler == "11":
        scheduler = HeadDoubleEasyScheduler(options.num_processors)

    elif options.scheduler == "TailDoubleEasyScheduler" or options.scheduler == "12":
        scheduler = TailDoubleEasyScheduler(options.num_processors)

    elif options.scheduler == "OrigProbabilisticEasyScheduler" or options.scheduler == "13":
        scheduler = OrigProbabilisticEasyScheduler(options.num_processors)

    elif options.scheduler == "ReverseEasyScheduler" or options.scheduler == "14":
        scheduler = ReverseEasyScheduler(options.num_processors)

    elif options.scheduler == "PerfectEasyBackfillScheduler" or options.scheduler == "15":
        scheduler = PerfectEasyBackfillScheduler(options.num_processors)

    elif options.scheduler == "DoublePerfectEasyBackfillScheduler" or options.scheduler == "16":
        scheduler = DoublePerfectEasyBackfillScheduler(options.num_processors)

    elif options.scheduler == "AlphaEasyScheduler" or options.scheduler == "18":
        scheduler = AlphaEasyScheduler(options.num_processors)

    elif options.scheduler == "CommonDistEasyPlusPlusScheduler" or options.scheduler == "28":
        scheduler = CommonDistEasyPlusPlusScheduler(options.num_processors)

    else:
        print "No such scheduler"
        return

    try:
        print "...."
        run_simulator(num_processors=options.num_processors,
                      jobs=_job_inputs_to_jobs(parse_lines(input_file),
                                               options.num_processors),
                      scheduler=scheduler)

        print "Num of Processors: ", options.num_processors
        print "Input file: ", options.input_file
        print "Scheduler:", type(scheduler)

    finally:
        if input_file is not sys.stdin:
            input_file.close()
示例#5
0
def main():
    options = parse_options()

    if options.input_file == "-":
        input_file = sys.stdin
    else:
        input_file = open(options.input_file)

    if options.scheduler == "FcfsScheduler" or options.scheduler == "1":
        scheduler = FcfsScheduler(options.num_processors)

    elif options.scheduler == "ConservativeScheduler" or options.scheduler =="2":
        scheduler = ConservativeScheduler(options.num_processors)

    elif options.scheduler == "DoubleConservativeScheduler" or options.scheduler == "3":
        scheduler = DoubleConservativeScheduler(options.num_processors)

    elif options.scheduler == "EasyBackfillScheduler" or options.scheduler == "4":
        scheduler = EasyBackfillScheduler(options.num_processors)
        
    elif options.scheduler == "DoubleEasyBackfillScheduler" or options.scheduler == "5":
        scheduler = DoubleEasyBackfillScheduler(options.num_processors)

    elif options.scheduler == "GreedyEasyBackfillScheduler" or options.scheduler == "6":
        scheduler = GreedyEasyBackfillScheduler(options.num_processors)

    elif options.scheduler == "EasyPlusPlusScheduler" or options.scheduler == "7":
        scheduler = EasyPlusPlusScheduler(options.num_processors)
        
    elif options.scheduler == "ShrinkingEasyScheduler" or options.scheduler == "8":
        scheduler = ShrinkingEasyScheduler(options.num_processors)

    elif options.scheduler == "LookAheadEasyBackFillScheduler" or options.scheduler == "9":
        scheduler = LookAheadEasyBackFillScheduler(options.num_processors)

    elif options.scheduler == "EasySJBFScheduler" or options.scheduler == "10":
        scheduler = EasySJBFScheduler(options.num_processors)

    elif options.scheduler == "HeadDoubleEasyScheduler" or options.scheduler == "11":
        scheduler = HeadDoubleEasyScheduler(options.num_processors)
        
    elif options.scheduler == "TailDoubleEasyScheduler" or options.scheduler == "12":
        scheduler = TailDoubleEasyScheduler(options.num_processors)

    elif options.scheduler == "OrigProbabilisticEasyScheduler" or options.scheduler == "13":
        scheduler = OrigProbabilisticEasyScheduler(options.num_processors)    

    elif options.scheduler == "ReverseEasyScheduler" or options.scheduler == "14":
        scheduler = ReverseEasyScheduler(options.num_processors)
        
    elif options.scheduler == "PerfectEasyBackfillScheduler" or options.scheduler == "15":
        scheduler = PerfectEasyBackfillScheduler(options.num_processors)
        
    elif options.scheduler == "DoublePerfectEasyBackfillScheduler" or options.scheduler == "16":
        scheduler = DoublePerfectEasyBackfillScheduler(options.num_processors)

    elif options.scheduler == "AlphaEasyScheduler" or options.scheduler == "18":
        scheduler = AlphaEasyScheduler(options.num_processors)

    elif options.scheduler == "CommonDistEasyPlusPlusScheduler" or options.scheduler == "28":
        scheduler = CommonDistEasyPlusPlusScheduler(options.num_processors)
        

    
    else:
        print "No such scheduler"
        return 

    try:
        print "...." 
        run_simulator(
                num_processors = options.num_processors, 
                jobs = _job_inputs_to_jobs(parse_lines(input_file), options.num_processors),
                scheduler = scheduler 
            )
        
        print "Num of Processors: ", options.num_processors
        print "Input file: ", options.input_file
        print "Scheduler:", type(scheduler)

    finally:
        if input_file is not sys.stdin:
            input_file.close()