示例#1
0
    def testNoGoodDecompositionForMultipleGpus(self):
        # with 2 gpus and 3 cpus, the only decomposition is the original
        self.config.cpu_ids = [0, 1, 2]
        self.config.gpu_ids = [0, 1]

        result = generateConfigSplitOptions(self.config)
        self.assertCountEqual(self.expected_base, result)
示例#2
0
    def testOnlyPrimeDivision(self):
        self.config.cpu_ids = [0, 1, 2]
        self.config.gpu_ids = [0]

        options = [HardwareConfig(cpu_ids=[i], gpu_ids=[0]) for i in range(3)]
        self.expected_base.append(options)
        result = generateConfigSplitOptions(self.config)
        self.assertCountEqual(self.expected_base, result)
示例#3
0
 def testMultipleDecompositionWithOddRankOption(self):
     # with 6 cpus and 3 gpus, the 3x option exists but not the 2x
     self.config.cpu_ids = [0, 1, 2, 3, 4, 5]
     self.config.gpu_ids = [0, 1, 2]
     single_cpu_option = [HardwareConfig(cpu_ids=[i], gpu_ids=[math.floor(i / 2)]) for i in range(6)]
     two_cpu_option = [HardwareConfig(cpu_ids=[i, i+1], gpu_ids=[gpu_id]) for gpu_id, i in enumerate((0, 2, 4))]
     self.expected_base.append(single_cpu_option)
     self.expected_base.append(two_cpu_option)
     result = generateConfigSplitOptions(self.config)
     self.assertCountEqual(self.expected_base, result)
示例#4
0
    def testMultipleDecompositionWithOneGpu(self):
        self.config.cpu_ids = [0, 1, 2, 3]
        self.config.gpu_ids = [0]

        single_cpu_option = [HardwareConfig(cpu_ids=[i], gpu_ids=[0]) for i in range(4)]
        double_cpu_option = [HardwareConfig(cpu_ids=[i, i + 1], gpu_ids=[0]) for i in (0, 2)]
        self.expected_base.append(single_cpu_option)
        self.expected_base.append(double_cpu_option)
        result = generateConfigSplitOptions(self.config)
        self.assertCountEqual(self.expected_base, result)
示例#5
0
    def testMultipleDecompositionWithMultipleGpus(self):
        # with 6 cpus and 2 gpus, the 3x option should not exist
        self.config.cpu_ids = [0, 1, 2, 3, 4, 5]
        self.config.gpu_ids = [0, 1]

        single_cpu_option = [HardwareConfig(cpu_ids=[i], gpu_ids=[math.floor(i / 3)]) for i in range(6)]
        three_cpu_option = [HardwareConfig(cpu_ids=[i, i+1, i+2], gpu_ids=[gpu_id]) for gpu_id, i in enumerate((0, 3))]
        self.expected_base.append(single_cpu_option)
        self.expected_base.append(three_cpu_option)
        result = generateConfigSplitOptions(self.config)
        self.assertCountEqual(self.expected_base, result)
示例#6
0
 def testLimitSimsPerGpuDefault(self):
     # This case tests that there is no config with 1 CPU - there would be 6, which
     # violates the max of 4.
     self.config.cpu_ids = [0, 1, 2, 3, 4, 5]
     self.config.gpu_ids = [0]
     self.expected_base.append([HardwareConfig(cpu_ids=[0, 1, 2], gpu_ids=[0]),
                                HardwareConfig(cpu_ids=[3, 4, 5], gpu_ids=[0])])
     self.expected_base.append([HardwareConfig(cpu_ids=[0, 1], gpu_ids=[0]),
                                HardwareConfig(cpu_ids=[2, 3], gpu_ids=[0]),
                                HardwareConfig(cpu_ids=[4, 5], gpu_ids=[0])])
     result = generateConfigSplitOptions(self.config)
     self.assertCountEqual(self.expected_base, result)
示例#7
0
文件: main.py 项目: sli259/gromax
def _executeGenerateWorkflow(args: argparse.Namespace) -> None:
    logger: logging.Logger = logging.getLogger("gromax")
    logger.info("Generating run options.")
    # Assign hardware config
    cpu_ids: List[int] = parseIDString(args.cpu_ids)
    logger.info("CPU IDs: {}".format(cpu_ids))
    num_cpus: int = len(cpu_ids)
    if num_cpus % 2 == 1:
        logger.warning(
            "Detected an odd number of CPU IDs ({}), this is atypical.".format(
                num_cpus))
    gpu_ids: List[int] = parseIDString(args.gpu_ids)
    logger.info("GPU IDs: {}".format(gpu_ids))
    num_gpus: int = len(gpu_ids)
    modval: int = num_cpus % num_gpus
    if modval != 0:
        logger.warning(
            "Number of CPUs({}) is not divisible by the number of GPUs({}), will only use {} CPUs."
            .format(num_cpus, num_gpus, num_cpus - modval))
        cpu_ids = cpu_ids[:-modval]
    hw_config: HardwareConfig = HardwareConfig(cpu_ids=cpu_ids,
                                               gpu_ids=gpu_ids)

    generate_options: GenerateOptions = _populateGenerateOptions(args)
    if args.single_sim_only:
        config_splits: List[List[HardwareConfig]] = [[hw_config]]
    else:
        config_splits: List[List[HardwareConfig]] = generateConfigSplitOptions(
            hw_config, max_sims_per_gpu=generate_options.max_sims_per_gpu)
    logger.debug("Generated {} hardware config breakdowns".format(
        len(config_splits)))
    run_opts: List[List[Dict]] = []
    for config_split in config_splits:
        run_opts.extend(
            createRunOptionsForConfigGroup(config_split, args.gmx_version,
                                           generate_options))
    # Serialize options.
    out_file: str = args.run_file
    # TODO Make this configurable and robust
    gmx: str = args.gmx_executable + " mdrun"
    tpr: str = args.tpr
    num_trials: int = args.trials_per_group
    WriteRunScript(out_file, ParamsToString(run_opts, tpr, gmx, num_trials))
示例#8
0
    def testNoGpu(self):
        self.config.cpu_ids = [0, 1, 2, 3]
        self.config.gpu_ids = []

        result = generateConfigSplitOptions(self.config)
        self.assertCountEqual(self.expected_base, result)