From 64bc644d6df3b8dff496a66a2688fcd809c07971 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Mon, 14 Oct 2024 11:01:48 +0200 Subject: [PATCH 1/8] set processor_arch to EASYBUILD_GENERIC for generic builds --- easybuild/easyblocks/l/lammps.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 9e8d286194..1fbc42c790 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -34,6 +34,7 @@ import os import re import tempfile +import textwrap import copy from easybuild.tools import LooseVersion @@ -46,6 +47,7 @@ from easybuild.tools.modules import get_software_root, get_software_version from easybuild.tools.run import run_cmd from easybuild.tools.systemtools import get_shared_lib_ext +from easybuild.tools.toolchain.compiler import OPTARCH_GENERIC from easybuild.easyblocks.generic.cmakemake import CMakeMake @@ -579,7 +581,14 @@ def get_kokkos_arch(kokkos_cpu_mapping, cuda_cc, kokkos_arch, cuda=None): processor_arch = None - if kokkos_arch: + if build_option('optarch') == OPTARCH_GENERIC: + processor_arch = 'EASYBUILD_GENERIC' + warning_msg = "Generic build requested, so setting CPU ARCH to " + warning_msg += "custom value EASYBUILD_GENERIC to prevent CPU optimizations." + if kokkos_arch: + warning_msg += " The specified kokkos_arch (%s) will be ignored." % kokkos_arch + print_warning(warning_msg) + elif kokkos_arch: if kokkos_arch not in KOKKOS_CPU_ARCH_LIST: warning_msg = "Specified CPU ARCH (%s) " % kokkos_arch warning_msg += "was not found in listed options [%s]." % KOKKOS_CPU_ARCH_LIST From 3c3fd7aeea2574bcf44f0c5cdb99307b9bae2fdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Mon, 14 Oct 2024 11:07:15 +0200 Subject: [PATCH 2/8] remove textwrap import --- easybuild/easyblocks/l/lammps.py | 1 - 1 file changed, 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 1fbc42c790..9de8da51b8 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -34,7 +34,6 @@ import os import re import tempfile -import textwrap import copy from easybuild.tools import LooseVersion From 64060fa9b6a4d444406cc403ae00fbbc3f36c416 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Mon, 14 Oct 2024 15:24:42 +0200 Subject: [PATCH 3/8] add exception for Arm and add some comments --- easybuild/easyblocks/l/lammps.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 9de8da51b8..6fa66d823b 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -38,6 +38,7 @@ from easybuild.tools import LooseVersion import easybuild.tools.environment as env +import easybuild.tools.systemtools as systemtools import easybuild.tools.toolchain as toolchain from easybuild.framework.easyconfig import CUSTOM, MANDATORY from easybuild.tools.build_log import EasyBuildError, print_warning, print_msg @@ -45,7 +46,7 @@ from easybuild.tools.filetools import copy_dir, mkdir from easybuild.tools.modules import get_software_root, get_software_version from easybuild.tools.run import run_cmd -from easybuild.tools.systemtools import get_shared_lib_ext +from easybuild.tools.systemtools import get_cpu_architecture, get_shared_lib_ext from easybuild.tools.toolchain.compiler import OPTARCH_GENERIC from easybuild.easyblocks.generic.cmakemake import CMakeMake @@ -581,9 +582,16 @@ def get_kokkos_arch(kokkos_cpu_mapping, cuda_cc, kokkos_arch, cuda=None): processor_arch = None if build_option('optarch') == OPTARCH_GENERIC: - processor_arch = 'EASYBUILD_GENERIC' - warning_msg = "Generic build requested, so setting CPU ARCH to " - warning_msg += "custom value EASYBUILD_GENERIC to prevent CPU optimizations." + # For generic Arm builds we use an existing target; + # this ensures that KOKKOS_ARCH_ARM_NEON is enabled (Neon is required for armv8-a). + # For other architectures we set a custom/non-existent type, which will disable all optimizations, + # and it should use the compiler (optimization) flags set by EasyBuild for this architecture. + if get_cpu_architecture() == systemtools.AARCH64: + processor_arch = 'ARMV80' + else: + processor_arch = 'EASYBUILD_GENERIC' + + warning_msg = "Generic build requested, setting CPU ARCH to %s." % processor_arch if kokkos_arch: warning_msg += " The specified kokkos_arch (%s) will be ignored." % kokkos_arch print_warning(warning_msg) From 520714ef371f3f50eca4ba3ec5c8f51fe32af9da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Fri, 18 Oct 2024 09:20:04 +0200 Subject: [PATCH 4/8] Update easybuild/easyblocks/l/lammps.py Co-authored-by: Kenneth Hoste --- easybuild/easyblocks/l/lammps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 6fa66d823b..322a85f33a 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -586,7 +586,7 @@ def get_kokkos_arch(kokkos_cpu_mapping, cuda_cc, kokkos_arch, cuda=None): # this ensures that KOKKOS_ARCH_ARM_NEON is enabled (Neon is required for armv8-a). # For other architectures we set a custom/non-existent type, which will disable all optimizations, # and it should use the compiler (optimization) flags set by EasyBuild for this architecture. - if get_cpu_architecture() == systemtools.AARCH64: + if get_cpu_architecture() == AARCH64: processor_arch = 'ARMV80' else: processor_arch = 'EASYBUILD_GENERIC' From 4ee671ad850ef0d8f24b40eaaf6ea49e5c56512d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Fri, 18 Oct 2024 09:20:10 +0200 Subject: [PATCH 5/8] Update easybuild/easyblocks/l/lammps.py Co-authored-by: Kenneth Hoste --- easybuild/easyblocks/l/lammps.py | 1 - 1 file changed, 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 322a85f33a..6b0206fb8f 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -38,7 +38,6 @@ from easybuild.tools import LooseVersion import easybuild.tools.environment as env -import easybuild.tools.systemtools as systemtools import easybuild.tools.toolchain as toolchain from easybuild.framework.easyconfig import CUSTOM, MANDATORY from easybuild.tools.build_log import EasyBuildError, print_warning, print_msg From 502a2bc1f261243815ab3236cc222e19b83d31ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Fri, 18 Oct 2024 09:20:16 +0200 Subject: [PATCH 6/8] Update easybuild/easyblocks/l/lammps.py Co-authored-by: Kenneth Hoste --- easybuild/easyblocks/l/lammps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 6b0206fb8f..3444c5b607 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -45,7 +45,7 @@ from easybuild.tools.filetools import copy_dir, mkdir from easybuild.tools.modules import get_software_root, get_software_version from easybuild.tools.run import run_cmd -from easybuild.tools.systemtools import get_cpu_architecture, get_shared_lib_ext +from easybuild.tools.systemtools import AARCH64, get_cpu_architecture, get_shared_lib_ext from easybuild.tools.toolchain.compiler import OPTARCH_GENERIC from easybuild.easyblocks.generic.cmakemake import CMakeMake From bf14cbb3e7bbae727b9c5bc3302e06499677693a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Fri, 18 Oct 2024 09:20:43 +0200 Subject: [PATCH 7/8] Update easybuild/easyblocks/l/lammps.py Co-authored-by: Kenneth Hoste --- easybuild/easyblocks/l/lammps.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 3444c5b607..289cd57e97 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -590,10 +590,11 @@ def get_kokkos_arch(kokkos_cpu_mapping, cuda_cc, kokkos_arch, cuda=None): else: processor_arch = 'EASYBUILD_GENERIC' - warning_msg = "Generic build requested, setting CPU ARCH to %s." % processor_arch + self.log.info("Generic build requested, setting CPU ARCH to %s." % processor_arch) if kokkos_arch: - warning_msg += " The specified kokkos_arch (%s) will be ignored." % kokkos_arch - print_warning(warning_msg) + msg = "The specified kokkos_arch (%s) will be ignored " % kokkos_arch + msg += "because a generic build was requested (via --optarch=GENERIC)" + print_warning(msg) elif kokkos_arch: if kokkos_arch not in KOKKOS_CPU_ARCH_LIST: warning_msg = "Specified CPU ARCH (%s) " % kokkos_arch From 2d160c3f22e3eb2770a4a09e55ccc74cf405bc74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bob=20Dr=C3=B6ge?= Date: Fri, 18 Oct 2024 10:11:24 +0200 Subject: [PATCH 8/8] use fancylogger.getLogger to be able to print to the log --- easybuild/easyblocks/l/lammps.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/easybuild/easyblocks/l/lammps.py b/easybuild/easyblocks/l/lammps.py index 289cd57e97..cbbf7d49f3 100644 --- a/easybuild/easyblocks/l/lammps.py +++ b/easybuild/easyblocks/l/lammps.py @@ -39,6 +39,7 @@ import easybuild.tools.environment as env import easybuild.tools.toolchain as toolchain +from easybuild.base import fancylogger from easybuild.framework.easyconfig import CUSTOM, MANDATORY from easybuild.tools.build_log import EasyBuildError, print_warning, print_msg from easybuild.tools.config import build_option @@ -154,6 +155,8 @@ # lammps version, which caused the most changes. This may not be precise, but it does work with existing easyconfigs ref_version = '29Sep2021' +_log = fancylogger.getLogger('easyblocks.lammps') + def translate_lammps_version(version): """Translate the LAMMPS version into something that can be used in a comparison""" @@ -590,7 +593,7 @@ def get_kokkos_arch(kokkos_cpu_mapping, cuda_cc, kokkos_arch, cuda=None): else: processor_arch = 'EASYBUILD_GENERIC' - self.log.info("Generic build requested, setting CPU ARCH to %s." % processor_arch) + _log.info("Generic build requested, setting CPU ARCH to %s." % processor_arch) if kokkos_arch: msg = "The specified kokkos_arch (%s) will be ignored " % kokkos_arch msg += "because a generic build was requested (via --optarch=GENERIC)"