Skip to content

Commit 025088d

Browse files
committed
relax toolchain test by accepting both -march=native (x86_64) and -mcpu=native (aarch64)
1 parent b6daaac commit 025088d

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

test/framework/options.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4923,7 +4923,7 @@ def test_dump_env_script(self):
49234923
"module load hwloc/1.11.8-GCC-4.6.4", # loading of dependency module
49244924
# defining build env
49254925
"export FC='gfortran'",
4926-
"export CFLAGS='-O2 -ftree-vectorize -march=native -fno-math-errno'",
4926+
"export CFLAGS='-O2 -ftree-vectorize -m(arch|cpu)=native -fno-math-errno'",
49274927
]
49284928
for pattern in patterns:
49294929
regex = re.compile("^%s$" % pattern, re.M)

test/framework/toolchain.py

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
import easybuild.tools.toolchain as toolchain
4444
import easybuild.tools.toolchain.compiler
4545
from easybuild.framework.easyconfig.easyconfig import EasyConfig, ActiveMNS
46+
from easybuild.toolchains.compiler.gcc import Gcc
4647
from easybuild.toolchains.system import SystemToolchain
4748
from easybuild.tools import systemtools as st
4849
from easybuild.tools.build_log import EasyBuildError
@@ -407,8 +408,10 @@ def test_toolchain_compiler_env_vars(self):
407408
self.assertEqual(os.getenv('OMPI_F77'), 'gfortran')
408409
self.assertEqual(os.getenv('OMPI_FC'), 'gfortran')
409410

411+
flags_regex = re.compile(r"-O2 -ftree-vectorize -m(arch|cpu)=native -fno-math-errno")
410412
for key in ['CFLAGS', 'CXXFLAGS', 'F90FLAGS', 'FCFLAGS', 'FFLAGS']:
411-
self.assertEqual(os.getenv(key), "-O2 -ftree-vectorize -march=native -fno-math-errno")
413+
val = os.getenv(key)
414+
self.assertTrue(flags_regex.match(val), "'%s' should match pattern '%s'" % (val, flags_regex.pattern))
412415

413416
def test_get_variable_compilers(self):
414417
"""Test get_variable function to obtain compiler variables."""
@@ -886,27 +889,30 @@ def test_precision_flags(self):
886889
tc = self.get_toolchain('foss', version='2018a')
887890
tc.set_options({})
888891
tc.prepare()
892+
flags_regex = re.compile(r"-O2 -ftree-vectorize -m(arch|cpu)=native -fno-math-errno")
889893
for var in flag_vars:
890-
self.assertEqual(os.getenv(var), "-O2 -ftree-vectorize -march=native -fno-math-errno")
894+
val = os.getenv(var)
895+
self.assertTrue(flags_regex.match(val), "'%s' should match pattern '%s'" % (val, flags_regex.pattern))
891896

892897
# check other precision flags
893-
prec_flags = {
894-
'ieee': "-fno-math-errno -mieee-fp -fno-trapping-math",
895-
'strict': "-mieee-fp -mno-recip",
896-
'precise': "-mno-recip",
897-
'loose': "-fno-math-errno -mrecip -mno-ieee-fp",
898-
'veryloose': "-fno-math-errno -mrecip=all -mno-ieee-fp",
899-
}
898+
precs = ['strict', 'precise', 'loose', 'veryloose']
899+
prec_flags = {}
900+
for prec in precs:
901+
prec_flags[prec] = ' '.join('-%s' % x for x in Gcc.COMPILER_UNIQUE_OPTION_MAP[prec])
902+
900903
for prec in prec_flags:
901904
for enable in [True, False]:
902905
tc = self.get_toolchain('foss', version='2018a')
903906
tc.set_options({prec: enable})
904907
tc.prepare()
905908
for var in flag_vars:
906909
if enable:
907-
self.assertEqual(os.getenv(var), "-O2 -ftree-vectorize -march=native %s" % prec_flags[prec])
910+
regex = re.compile(r"-O2 -ftree-vectorize -m(arch|cpu)=native %s" % prec_flags[prec])
908911
else:
909-
self.assertEqual(os.getenv(var), "-O2 -ftree-vectorize -march=native -fno-math-errno")
912+
regex = flags_regex
913+
val = os.getenv(var)
914+
self.assertTrue(regex.match(val), "%s: '%s' should match pattern '%s'" % (prec, val, regex.pattern))
915+
910916
self.modtool.purge()
911917

912918
def test_cgoolf_toolchain(self):

0 commit comments

Comments
 (0)