Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable CPU-specific optimizations for generic builds (by using a custom processor_arch) in LAMMPS easyblock #3484

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

bedroge
Copy link
Contributor

@bedroge bedroge commented Oct 14, 2024

LAMMPS uses archspec to determine the CPU type and it will enable optimizations for this CPU accordingly, even if optarch is set to GENERIC. See for instance this EESSI issue which demonstrates/explains it in some more detail:
EESSI/software-layer#545

This PR tries to solve that by overriding the CPU mapping for generic builds and using a custom CPU target EASYBUILD_GENERIC for these builds. By using a non-existent CPU type, all CPU-specific optimizations in these IF(KOKKOS_ARCH_*) statements in https://github.com/lammps/lammps/blob/stable_29Aug2024/lib/kokkos/cmake/kokkos_arch.cmake will be skipped, and hence no compiler optimization should be enabled. By default, they're all disabled. Furthermore, the compiler flags set by Easybuild, including the optimization flags for generic builds defined at https://github.com/easybuilders/easybuild-framework/blob/develop/easybuild/toolchains/compiler/gcc.py#L101, should be forwarded to the build step, which should result in properly built generic binaries.

I had to make one exception here for Arm, since Neon seems to be (sort of?) required for armv8-a, see https://developer.arm.com/documentation/ka005463/latest/. If we would use EASYBUILD_GENERIC for Arm as well, LAMMPS would automatically set KOKKOS_ARCH_ARM_NEON=OFF, which will disable Neon include statements. By using the existing ARMV80 target (which is basically a generic Arm build anyway), this feature is enabled, see https://github.com/lammps/lammps/blob/stable_29Aug2024/lib/kokkos/cmake/kokkos_arch.cmake#L246.

Note: I have only tested this with the latest LAMMPS version on x86_64 and riscv64 so far (and will upload test reports), but I'll try to do some additional tests builds on at least Arm as well.

@bedroge
Copy link
Contributor Author

bedroge commented Oct 14, 2024

Test report by @bedroge

Overview of tested easyconfigs (in order)

  • SUCCESS LAMMPS-29Aug2024-foss-2023b-kokkos.eb

Build succeeded for 1 out of 1 (1 easyconfigs in total)
bob-Latitude-5300 - Linux Ubuntu 24.04.1 LTS (Noble Numbat), x86_64, Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz (skylake), Python 3.11.4
See https://gist.github.com/bedroge/aab7a2ee8da6f78d7f1d048ee1eb81c5 for a full test report.

Edit: this was done with --optarch=GENERIC, and a grep on the build log shows that (only) -march=x86_64 and -mtune=generic were used.

@bedroge bedroge changed the title disable optimizations for generic builds (by using a custom processor_arch) in LAMMPS easyblock disable CPU-specific optimizations for generic builds (by using a custom processor_arch) in LAMMPS easyblock Oct 14, 2024
@bedroge
Copy link
Contributor Author

bedroge commented Oct 14, 2024

@boegelbot please test @ jsc-zen3
EB_ARGS="--installpath /tmp/3484 --optarch=GENERIC LAMMPS-23Jun2022-foss-2021a-kokkos.eb LAMMPS-23Jun2022-foss-2021b-kokkos.eb LAMMPS-23Jun2022-foss-2022a-kokkos.eb LAMMPS-2Aug2023_update2-foss-2023a-kokkos.eb LAMMPS-29Aug2024-foss-2023b-kokkos.eb"

@boegelbot
Copy link

@bedroge: Request for testing this PR well received on jsczen3l1.int.jsc-zen3.fz-juelich.de

PR test command 'if [[ develop != 'develop' ]]; then EB_BRANCH=develop ./easybuild_develop.sh 2> /dev/null 1>&2; EB_PREFIX=/home/boegelbot/easybuild/develop source init_env_easybuild_develop.sh; fi; EB_PR=3484 EB_ARGS="--installpath /tmp/3484 --optarch=GENERIC LAMMPS-23Jun2022-foss-2021a-kokkos.eb LAMMPS-23Jun2022-foss-2021b-kokkos.eb LAMMPS-23Jun2022-foss-2022a-kokkos.eb LAMMPS-2Aug2023_update2-foss-2023a-kokkos.eb LAMMPS-29Aug2024-foss-2023b-kokkos.eb" EB_REPO=easybuild-easyblocks EB_BRANCH=develop /opt/software/slurm/bin/sbatch --job-name test_PR_3484 --ntasks=8 ~/boegelbot/eb_from_pr_upload_jsc-zen3.sh' executed!

  • exit code: 0
  • output:
Submitted batch job 5072

Test results coming soon (I hope)...

- notification for comment with ID 2411513509 processed

Message to humans: this is just bookkeeping information for me,
it is of no use to you (unless you think I have a bug, which I don't).

@bedroge
Copy link
Contributor Author

bedroge commented Oct 14, 2024

Test report by @bedroge

Overview of tested easyconfigs (in order)

  • SUCCESS LAMMPS-2Aug2023_update2-foss-2023a-kokkos.eb

Build succeeded for 1 out of 1 (1 easyconfigs in total)
bob-Latitude-5300 - Linux Ubuntu 24.04.1 LTS (Noble Numbat), x86_64, Intel(R) Core(TM) i7-8665U CPU @ 1.90GHz (skylake), Python 3.11.4
See https://gist.github.com/bedroge/fe6980c1a0ac3af9c746b9f288f07eb2 for a full test report.

Edit: this was also done with --optarch=GENERIC.

@boegelbot
Copy link

Test report by @boegelbot

Overview of tested easyconfigs (in order)

  • SUCCESS LAMMPS-2Aug2023_update2-foss-2023a-kokkos.eb
  • SUCCESS LAMMPS-29Aug2024-foss-2023b-kokkos.eb
  • SUCCESS kim-api-2.2.1-GCC-10.3.0.eb
  • SUCCESS kim-api-2.3.0-GCC-11.2.0.eb
  • SUCCESS kim-api-2.3.0-GCC-11.3.0.eb
  • SUCCESS LAMMPS-23Jun2022-foss-2022a-kokkos.eb
  • SUCCESS ScaFaCoS-1.0.1-foss-2021a.eb
  • SUCCESS VTK-9.1.0-foss-2021b.eb
  • SUCCESS LAMMPS-23Jun2022-foss-2021a-kokkos.eb
  • SUCCESS LAMMPS-23Jun2022-foss-2021b-kokkos.eb

Build succeeded for 10 out of 10 (5 easyconfigs in total)
jsczen3c1.int.jsc-zen3.fz-juelich.de - Linux Rocky Linux 9.4, x86_64, AMD EPYC-Milan Processor (zen3), Python 3.9.18
See https://gist.github.com/boegelbot/9d8a228487d85f7c5e668bdbc094c914 for a full test report.

@bedroge
Copy link
Contributor Author

bedroge commented Oct 14, 2024

@boegelbot please test @ jsc-zen3
EB_ARGS="--installpath /tmp/3484 LAMMPS-23Jun2022-foss-2021a-kokkos.eb LAMMPS-23Jun2022-foss-2021b-kokkos.eb LAMMPS-23Jun2022-foss-2022a-kokkos.eb LAMMPS-2Aug2023_update2-foss-2023a-kokkos.eb LAMMPS-29Aug2024-foss-2023b-kokkos.eb"

@boegelbot
Copy link

@bedroge: Request for testing this PR well received on jsczen3l1.int.jsc-zen3.fz-juelich.de

PR test command 'if [[ develop != 'develop' ]]; then EB_BRANCH=develop ./easybuild_develop.sh 2> /dev/null 1>&2; EB_PREFIX=/home/boegelbot/easybuild/develop source init_env_easybuild_develop.sh; fi; EB_PR=3484 EB_ARGS="--installpath /tmp/3484 LAMMPS-23Jun2022-foss-2021a-kokkos.eb LAMMPS-23Jun2022-foss-2021b-kokkos.eb LAMMPS-23Jun2022-foss-2022a-kokkos.eb LAMMPS-2Aug2023_update2-foss-2023a-kokkos.eb LAMMPS-29Aug2024-foss-2023b-kokkos.eb" EB_REPO=easybuild-easyblocks EB_BRANCH=develop /opt/software/slurm/bin/sbatch --job-name test_PR_3484 --ntasks=8 ~/boegelbot/eb_from_pr_upload_jsc-zen3.sh' executed!

  • exit code: 0
  • output:
Submitted batch job 5073

Test results coming soon (I hope)...

- notification for comment with ID 2411839250 processed

Message to humans: this is just bookkeeping information for me,
it is of no use to you (unless you think I have a bug, which I don't).

@boegelbot
Copy link

Test report by @boegelbot

Overview of tested easyconfigs (in order)

  • SUCCESS LAMMPS-2Aug2023_update2-foss-2023a-kokkos.eb
  • SUCCESS LAMMPS-29Aug2024-foss-2023b-kokkos.eb
  • SUCCESS kim-api-2.2.1-GCC-10.3.0.eb
  • SUCCESS kim-api-2.3.0-GCC-11.2.0.eb
  • SUCCESS kim-api-2.3.0-GCC-11.3.0.eb
  • SUCCESS LAMMPS-23Jun2022-foss-2022a-kokkos.eb
  • SUCCESS ScaFaCoS-1.0.1-foss-2021a.eb
  • SUCCESS VTK-9.1.0-foss-2021b.eb
  • SUCCESS LAMMPS-23Jun2022-foss-2021a-kokkos.eb
  • SUCCESS LAMMPS-23Jun2022-foss-2021b-kokkos.eb

Build succeeded for 10 out of 10 (5 easyconfigs in total)
jsczen3c1.int.jsc-zen3.fz-juelich.de - Linux Rocky Linux 9.4, x86_64, AMD EPYC-Milan Processor (zen3), Python 3.9.18
See https://gist.github.com/boegelbot/90d094bc5e8898e14eca89c1cfadbe60 for a full test report.

easybuild/easyblocks/l/lammps.py Outdated Show resolved Hide resolved
easybuild/easyblocks/l/lammps.py Outdated Show resolved Hide resolved
easybuild/easyblocks/l/lammps.py Outdated Show resolved Hide resolved
easybuild/easyblocks/l/lammps.py Outdated Show resolved Hide resolved
@bedroge
Copy link
Contributor Author

bedroge commented Oct 18, 2024

@boegelbot please test @ jsc-zen3
EB_ARGS="--installpath /tmp/3484 --optarch=GENERIC LAMMPS-23Jun2022-foss-2021a-kokkos.eb LAMMPS-23Jun2022-foss-2021b-kokkos.eb LAMMPS-23Jun2022-foss-2022a-kokkos.eb LAMMPS-2Aug2023_update2-foss-2023a-kokkos.eb LAMMPS-29Aug2024-foss-2023b-kokkos.eb"

@boegelbot
Copy link

@bedroge: Request for testing this PR well received on jsczen3l1.int.jsc-zen3.fz-juelich.de

PR test command 'if [[ develop != 'develop' ]]; then EB_BRANCH=develop ./easybuild_develop.sh 2> /dev/null 1>&2; EB_PREFIX=/home/boegelbot/easybuild/develop source init_env_easybuild_develop.sh; fi; EB_PR=3484 EB_ARGS="--installpath /tmp/3484 --optarch=GENERIC LAMMPS-23Jun2022-foss-2021a-kokkos.eb LAMMPS-23Jun2022-foss-2021b-kokkos.eb LAMMPS-23Jun2022-foss-2022a-kokkos.eb LAMMPS-2Aug2023_update2-foss-2023a-kokkos.eb LAMMPS-29Aug2024-foss-2023b-kokkos.eb" EB_REPO=easybuild-easyblocks EB_BRANCH=develop /opt/software/slurm/bin/sbatch --job-name test_PR_3484 --ntasks=8 ~/boegelbot/eb_from_pr_upload_jsc-zen3.sh' executed!

  • exit code: 0
  • output:
Submitted batch job 5122

Test results coming soon (I hope)...

- notification for comment with ID 2421792355 processed

Message to humans: this is just bookkeeping information for me,
it is of no use to you (unless you think I have a bug, which I don't).

@boegelbot
Copy link

Test report by @boegelbot

Overview of tested easyconfigs (in order)

  • SUCCESS LAMMPS-2Aug2023_update2-foss-2023a-kokkos.eb
  • SUCCESS LAMMPS-29Aug2024-foss-2023b-kokkos.eb
  • SUCCESS kim-api-2.2.1-GCC-10.3.0.eb
  • SUCCESS kim-api-2.3.0-GCC-11.2.0.eb
  • SUCCESS kim-api-2.3.0-GCC-11.3.0.eb
  • SUCCESS LAMMPS-23Jun2022-foss-2022a-kokkos.eb
  • SUCCESS ScaFaCoS-1.0.1-foss-2021a.eb
  • SUCCESS VTK-9.1.0-foss-2021b.eb
  • SUCCESS LAMMPS-23Jun2022-foss-2021a-kokkos.eb
  • SUCCESS LAMMPS-23Jun2022-foss-2021b-kokkos.eb

Build succeeded for 10 out of 10 (5 easyconfigs in total)
jsczen3c1.int.jsc-zen3.fz-juelich.de - Linux Rocky Linux 9.4, x86_64, AMD EPYC-Milan Processor (zen3), Python 3.9.18
See https://gist.github.com/boegelbot/aa72670672ccb2501807e9fbf6aaaa6f for a full test report.

Copy link
Member

@boegel boegel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug fix EESSI Related to EESSI project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants