spack: ARM compilers do not generate SVE code on a64fx

The default behavior of ARM compilers (I tested 20.3 and the latest 21.0) is not to generate SVE code, even on A64fx platforms. The -march=armv8.2a+sve flag is required in order to generate SVE code.

This is arguably an ARM bug/feature, and a manual workaround is to

export SPACK_CFLAGS=-march=armv8.2a+sve

and friends.

That being said, I believe spack can improve this and automatically set this flag (unless the -march flag is already set by the user/recipe) when building on a SVE capable platform such as a64fx.

I guess a first step would be to have spack export SPACK_ARCH=$(spack arch) or something similar, and enhance the spack compiler wrappers to set the -march flag when needed.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 15 (14 by maintainers)

Commits related to this issue

Most upvoted comments

I just issued the PR archspec/archspec-json#33

Sure, here it is

compilers:
- compiler:
    spec: arm@20.3.0.543
    paths:
      cc: /opt/arm/arm-linux-compiler-20.3_Generic-AArch64_RHEL-8_aarch64-linux/bin/armclang
      cxx: /opt/arm/arm-linux-compiler-20.3_Generic-AArch64_RHEL-8_aarch64-linux/bin/armclang++
      f77: /opt/arm/arm-linux-compiler-20.3_Generic-AArch64_RHEL-8_aarch64-linux/bin/armflang
      fc: /opt/arm/arm-linux-compiler-20.3_Generic-AArch64_RHEL-8_aarch64-linux/bin/armflang
    flags: {}
    operating_system: rhel8
    target: aarch64
    modules: []
    environment: {}
    extra_rpaths: []

fwiw, here is my recipe

import llnl.util.cpu


class TestArmSve(CMakePackage):
    """Test including the <arm_sve.h> header file"""

    homepage = 'https://github.com/ggouaillardet/test-arm_sve'
    url      = 'https://github.com/ggouaillardet/test-arm_sve/archive/v0.1.tar.gz'
    git      = 'https://github.com/ggouaillardet/test-arm_sve.git'
    maintainers = ['ggouaillardet']


    version('0.1', sha256='65ff94bc68823170e6ccb1ff8d44ff169497bbfe30eccddcb379b546e39930d2')
    depends_on('cmake@3.13.0:3.99.99', type='build')
    depends_on('blas')

No problem, I used strace to confirm the flags was not passed to the armclang spack wrapper, nor the “real” armclang compiler. Also, my test failed since it #include <arm_sve.h>, and can only work if -march=armv8...+sve is passed

@alalazo I confirm -march=armv8.2a+sve works for the three compilers armclang, armclang++ and armflang