diff --git a/mpcdf_common.py b/mpcdf_common.py index f1dfc5e2dc99c716a0782277435dacbfa252e0fd..3f1ccf1261b4952486288f11d6013ab591f43012 100644 --- a/mpcdf_common.py +++ b/mpcdf_common.py @@ -10,7 +10,27 @@ from xml.etree import ElementTree def valid_mpi(compiler, mpi): - return True + """ + It might be possible to use Intel MPI libararies and compilers from + different Parallel Studio packages, but I currently do not want to support + it. + + Take care to keep this in sync with the file 'macros.obs_cluster' of + the package software:dist / mpcdf_cluster_macros + """ + + valid_intel_impi = { + ("intel_17_0_4", "impi_2017_3"), + ("intel_17_0_7", "impi_2017_4"), + ("intel_18_0_1", "impi_2018_1"), + ("intel_18_0_2", "impi_2018_2"), + ("intel_18_0_3", "impi_2018_3"), + } + + if compiler.startswith("intel") and mpi.startswith("impi"): + return (compiler, mpi) in valid_intel_impi + else: + return True def valid_cuda(cuda, compiler): @@ -117,6 +137,8 @@ def remove_attribute(api_url, project, package, attribute_name): def mpcdf_enable_repositories(api_url, project, package, verbose=False): + from itertools import product + root = ElementTree.fromstringlist(osc.core.show_package_meta(api_url, project, package)) build = root.find("./build") if build is None: @@ -130,6 +152,10 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False): mpis = get_attribute_values(api_url, project, package, "MPCDF:mpi_modules", with_project=True) cudas = get_attribute_values(api_url, project, package, "MPCDF:cuda_modules", with_project=True) + default_compilers = get_attribute_values(api_url, project, None, "MPCDF:default_compiler") + default_mpis = get_attribute_values(api_url, project, None, "MPCDF:default_mpi") + default_cudas = get_attribute_values(api_url, project, None, "MPCDF:default_cuda") + def enable(name): node = ElementTree.Element("enable") node.set("repository", name) @@ -145,34 +171,62 @@ def mpcdf_enable_repositories(api_url, project, package, verbose=False): print("Warning: Could not get attribute MPCDF:enable_repositories for package {0}".format(package)) return False + def actual_compilers(): + for compiler in compilers: + if compiler == "intel": + for intel_compiler in filter(lambda cc: cc.startswith("intel"), compilers): + yield intel_compiler + elif compiler == "gcc": + for gcc_compiler in filter(lambda cc: cc.startswith("gcc"), compilers): + yield gcc_compiler + elif compiler == "default_compiler": + for default_compiler in default_compilers: + yield default_compiler + else: + yield compiler + + def actual_mpis(): + for mpi in mpis: + if mpi == "impi": + for impi in filter(lambda cc: cc.startswith("impi"), mpis): + yield impi + elif mpi == "default_mpi": + for default_mpi in default_mpis: + yield default_mpi + else: + yield mpi + + def actual_cudas(): + for cuda in cudas: + if cuda == "default_cuda": + for default_cuda in default_cudas: + yield default_cuda + else: + yield cuda + for flag in enable_repos: if flag == "system": enable("System") if flag == "compilers": - for compiler in compilers: - enable(compiler) + for compiler in actual_compilers(): + enable(compiler) if flag == "mpi": - for compiler in compilers: - for mpi in mpis: - if valid_mpi(compiler, mpi): - enable(mpi + "_" + compiler) + for mpi, compiler in product(actual_mpis(), actual_compilers()): + if valid_mpi(compiler, mpi): + enable(mpi + "_" + compiler) if flag == "cuda": - for cuda in cudas: - for compiler in all_compilers: - if valid_cuda(cuda, compiler): - enable(cuda + "_" + compiler) + for cuda, compiler in product(actual_cudas(), all_compilers): + if valid_cuda(cuda, compiler): + enable(cuda + "_" + compiler) if flag == "cuda_mpi": - for cuda in cudas: - for compiler in all_compilers: - if valid_cuda(cuda, compiler): - for mpi in mpis: - if valid_mpi(compiler, mpi): - enable(cuda + "_" + mpi + "_" + compiler) + for cuda, mpi, compiler in product(actual_cudas(), actual_mpis(), all_compilers): + if valid_cuda(cuda, compiler) and valid_mpi(compiler, mpi): + enable(cuda + "_" + mpi + "_" + compiler) if len(build.getchildren()) > 0: build.getchildren()[-1].tail = "\n " @@ -332,7 +386,7 @@ def mpcdf_setup_repositories(api_url, project, distribution=None, parent=None, p # Update repositories print("Updating prj meta") - osc.core.edit_meta("prj", project, data=prj) + osc.core.edit_meta("prj", project, data=prj, force=True) print("Updating prjconf meta") osc.core.edit_meta("prjconf", project, data=prjconf) diff --git a/mpcdf_info.py b/mpcdf_info.py index f94521244d3530de2b4ebd4f621217720bb77acc..498e58a07873c350126c267e77ca68c7da489a73 100644 --- a/mpcdf_info.py +++ b/mpcdf_info.py @@ -43,8 +43,11 @@ def do_mpcdf_info(self, subcmd, opts, *args): print() print_attribute("Compilers", "MPCDF:compiler_modules") + print_attribute("Default Compiler", "MPCDF:default_compiler") print_attribute("MPI libraries", "MPCDF:mpi_modules") + print_attribute("Default MPI", "MPCDF:default_mpi") print_attribute("CUDA versions", "MPCDF:cuda_modules") + print_attribute("Default CUDA", "MPCDF:default_cuda") unmanaged = [] @@ -67,13 +70,13 @@ def do_mpcdf_info(self, subcmd, opts, *args): def subset(description, attribute): if mpcdf_common.has_attribute(api_url, project, package, attribute): - return " ({0}: {1})".format(description, ", ".join(mpcdf_common.get_attribute_values(api_url, project, package, attribute))) + return " {0}={1}".format(description, ",".join(mpcdf_common.get_attribute_values(api_url, project, package, attribute))) return "" - print(" " + pkg_name_fmt.format(package), ", ".join(enabled_repos), - subset("compiler subset", "MPCDF:compiler_modules") + - subset("MPI subset", "MPCDF:mpi_modules") + - subset("CUDA subet", "MPCDF:cuda_modules")) + print(" " + pkg_name_fmt.format(package), "--set=" + (",".join(enabled_repos)), + subset("--compiler-modules", "MPCDF:compiler_modules") + + subset("--mpi-modules", "MPCDF:mpi_modules") + + subset("--cuda-modules", "MPCDF:cuda_modules")) print() if unmanaged: