Skip to content

Commit

Permalink
Merge pull request #3484 from bedroge/lammps_generic_build
Browse files Browse the repository at this point in the history
disable CPU-specific optimizations for generic builds (by using a custom `processor_arch`) in LAMMPS easyblock
  • Loading branch information
boegel authored Oct 20, 2024
2 parents 5838f1d + 2d160c3 commit 3671c5b
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions easybuild/easyblocks/l/lammps.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,15 @@

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
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 AARCH64, get_cpu_architecture, get_shared_lib_ext
from easybuild.tools.toolchain.compiler import OPTARCH_GENERIC

from easybuild.easyblocks.generic.cmakemake import CMakeMake

Expand Down Expand Up @@ -153,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"""
Expand Down Expand Up @@ -582,7 +586,22 @@ 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:
# 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() == AARCH64:
processor_arch = 'ARMV80'
else:
processor_arch = 'EASYBUILD_GENERIC'

_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)"
print_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
Expand Down

0 comments on commit 3671c5b

Please sign in to comment.