def open(**kwargs): """ Launch VisIt compute engine on the current host. """ args = {"ppn":1,"part":None,"bank":None,"rtime":None,"vdir":None} if not kwargs.has_key("method"): hname = hostname(False) if not hosts().has_key(hname): raise VisItException("Unsupported host: '%s'" % hname) host = hosts(args["vdir"])[hname] # prep args for launch args["host"] = host.name args.update(host.defaults) args.update(host.params) args["method"] = host.launch_method(args["part"]) elif kwargs["method"] == "slurm": args["host"] = hostname(False) if os.environ.has_key("SLURM_JOB_NUM_NODES"): nnodes = int(os.environ["SLURM_JOB_NUM_NODES"]) ppn = int(os.environ["SLURM_CPUS_ON_NODE"]) nprocs = ppn * nnodes args["nprocs"] = nprocs args["ppn"] = ppn kwargs["method"] = "srun" else: args["host"] = hostname(False) args.update(kwargs) return launch(**args)
def open(**kwargs): """ Launch VisIt compute engine on the current host. """ args = {"ppn": 1, "part": None, "bank": None, "rtime": None, "vdir": None} if not kwargs.has_key("method"): hname = hostname(False) if not hosts().has_key(hname): raise VisItException("Unsupported host: '%s'" % hname) host = hosts(args["vdir"])[hname] # prep args for launch args["host"] = host.name args.update(host.defaults) args.update(host.params) args["method"] = host.launch_method(args["part"]) elif kwargs["method"] == "slurm": args["host"] = hostname(False) if os.environ.has_key("SLURM_JOB_NUM_NODES"): nnodes = int(os.environ["SLURM_JOB_NUM_NODES"]) ppn = int(os.environ["SLURM_CPUS_ON_NODE"]) nprocs = ppn * nnodes args["nprocs"] = nprocs args["ppn"] = ppn kwargs["method"] = "srun" else: args["host"] = hostname(False) args.update(kwargs) return launch(**args)
def launch(host,nprocs,ppn,method,part,bank,rtime,vdir,extra_args=None): """ Launch helper. """ msg = "[%s: opening engine" % host if not part is None: msg+= " on %s" % part msg +="]" print msg nnodes = int(math.ceil(float(nprocs) / float(ppn))) ehost = host if host == hostname(False): ehost = "localhost" args = ["-l", method] if not method == "serial": args.extend(["-np",str(nprocs)]) if not vdir is None: args.extend(["-dir",vdir]) if not part is None: args.extend(["-nn",str(nnodes),"-p", part]) if not extra_args is None: args.extend(extra_args) if method == "msub/srun": rtime = str(rtime) if rtime.count(":") == 0: rtime += ":00" args.extend(["-b", bank,"-t", rtime]) if visit.OpenComputeEngine(ehost,args) != 1: raise VisItException("Failed to open compute engine on %s." % host) return visit.GetEngineList()[0]
def launch(host, nprocs, ppn, method, part, bank, rtime, vdir, extra_args=None): """ Launch helper. """ msg = "[%s: opening engine" % host if not part is None: msg += " on %s" % part msg += "]" print msg nnodes = int(math.ceil(float(nprocs) / float(ppn))) ehost = host if host == hostname(False): ehost = "localhost" args = ["-l", method] if not method == "serial": args.extend(["-np", str(nprocs)]) if not vdir is None: args.extend(["-dir", vdir]) if not part is None: args.extend(["-nn", str(nnodes), "-p", part]) if not extra_args is None: args.extend(extra_args) if method == "msub/srun": rtime = str(rtime) if rtime.count(":") == 0: rtime += ":00" args.extend(["-b", bank, "-t", rtime]) if visit.OpenComputeEngine(ehost, args) != 1: raise VisItException("Failed to open compute engine on %s." % host) return visit.GetEngineList()[0]
def open(**kwargs): """ Launch VisIt compute engine on the current host. """ args = {"ppn": 1, "part": None, "bank": None, "rtime": None, "vdir": None} if not kwargs.has_key("method"): hname = hostname(False) # when the visit module is imported (vs used in the CLI), # VISITHOME won't be set, allow user to pass vdir argument # here to locate the host profiles vdir = None if kwargs.has_key("vdir"): vdir = kwargs["vdir"] if not hosts(vdir=vdir).has_key(hname): raise VisItException("Unsupported host: '%s'" % hname) host = hosts(vdir=vdir)[hname] # prep args for launch args["host"] = host.name args.update(host.defaults) args.update(host.params) args["method"] = host.launch_method(args["part"]) elif kwargs["method"] == "slurm": args["host"] = hostname(False) if os.environ.has_key("SLURM_JOB_NUM_NODES"): nnodes = int(os.environ["SLURM_JOB_NUM_NODES"]) ppn = int(os.environ["SLURM_CPUS_ON_NODE"]) nprocs = ppn * nnodes else: raise VisItException( "engine.open(method='slurm') requires " "SLURM_JOB_NUM_NODES and SLURM_CPUS_ON_NODE env vars") args["nprocs"] = nprocs args["ppn"] = ppn kwargs["method"] = "srun" else: args["host"] = hostname(False) args.update(kwargs) return launch(**args)