@@ -2274,47 +2274,49 @@ def test_independence(self):
22742274 """Test independency of toolchain instances."""
22752275
22762276 # tweaking --optarch is required for Cray toolchains (craypre-<optarch> module must be available)
2277- init_config (build_options = {'optarch' : 'test' , 'silent' : True })
2278-
2279- tc_cflags = {
2280- 'CrayCCE' : "-O2 -g -homp -craype-verbose" ,
2281- 'CrayGNU' : "-O2 -fno-math-errno -g -fopenmp -craype-verbose" ,
2282- 'CrayIntel' : "-O2 -ftz -fp-speculation=safe -fp-model source -g -fopenmp -craype-verbose" ,
2283- 'GCC' : "-O2 -ftree-vectorize -test -fno-math-errno -g -fopenmp" ,
2284- 'iccifort' : "-O2 -test -ftz -fp-speculation=safe -fp-model source -g -fopenmp" ,
2285- 'intel-compilers' : "-O2 -test -ftz -fp-speculation=safe -fp-model precise -g -qopenmp" ,
2286- }
2277+ custom_optarchs = ['test' , '-test' ] # specifying without initial - is deprecated but should still work
2278+ for custom_optarch in custom_optarchs :
2279+ init_config (build_options = {'optarch' : custom_optarch , 'silent' : True })
2280+
2281+ tc_cflags = {
2282+ 'CrayCCE' : "-O2 -g -homp -craype-verbose" ,
2283+ 'CrayGNU' : "-O2 -fno-math-errno -g -fopenmp -craype-verbose" ,
2284+ 'CrayIntel' : "-O2 -ftz -fp-speculation=safe -fp-model source -g -fopenmp -craype-verbose" ,
2285+ 'GCC' : "-O2 -ftree-vectorize -test -fno-math-errno -g -fopenmp" ,
2286+ 'iccifort' : "-O2 -test -ftz -fp-speculation=safe -fp-model source -g -fopenmp" ,
2287+ 'intel-compilers' : "-O2 -test -ftz -fp-speculation=safe -fp-model precise -g -qopenmp" ,
2288+ }
22872289
2288- toolchains = [
2289- ('CrayCCE' , '2015.06-XC' ),
2290- ('CrayGNU' , '2015.06-XC' ),
2291- ('CrayIntel' , '2015.06-XC' ),
2292- ('GCC' , '6.4.0-2.28' ),
2293- ('iccifort' , '2018.1.163' ),
2294- ('intel-compilers' , '2022.1.0' ),
2295- ]
2290+ toolchains = [
2291+ ('CrayCCE' , '2015.06-XC' ),
2292+ ('CrayGNU' , '2015.06-XC' ),
2293+ ('CrayIntel' , '2015.06-XC' ),
2294+ ('GCC' , '6.4.0-2.28' ),
2295+ ('iccifort' , '2018.1.163' ),
2296+ ('intel-compilers' , '2022.1.0' ),
2297+ ]
22962298
2297- # purposely obtain toolchains several times in a row, value for $CFLAGS should not change
2298- for _ in range (3 ):
2299- for tcname , tcversion in toolchains :
2300- # Cray* modules do not unload other Cray* modules thus loading a second Cray* module
2301- # makes environment inconsistent which is not allowed by Environment Modules tool
2302- if isinstance (self .modtool , EnvironmentModules ):
2303- self .modtool .purge ()
2304- tc = get_toolchain ({'name' : tcname , 'version' : tcversion }, {},
2305- mns = ActiveMNS (), modtool = self .modtool )
2306- # also check whether correct compiler flag for OpenMP is used while we're at it
2307- # and options for oneAPI compiler for Intel
2308- if tcname == 'intel-compilers' :
2309- tc .set_options ({'oneapi' : True , 'openmp' : True })
2310- else :
2311- tc .set_options ({'openmp' : True })
2312- with self .mocked_stdout_stderr ():
2313- tc .prepare ()
2314- expected_cflags = tc_cflags [tcname ]
2315- msg = "Expected $CFLAGS found for toolchain %s: %s" % (tcname , expected_cflags )
2316- self .assertEqual (str (tc .variables ['CFLAGS' ]), expected_cflags , msg )
2317- self .assertEqual (os .environ ['CFLAGS' ], expected_cflags , msg )
2299+ # purposely obtain toolchains several times in a row, value for $CFLAGS should not change
2300+ for _ in range (3 ):
2301+ for tcname , tcversion in toolchains :
2302+ # Cray* modules do not unload other Cray* modules thus loading a second Cray* module
2303+ # makes environment inconsistent which is not allowed by Environment Modules tool
2304+ if isinstance (self .modtool , EnvironmentModules ):
2305+ self .modtool .purge ()
2306+ tc = get_toolchain ({'name' : tcname , 'version' : tcversion }, {},
2307+ mns = ActiveMNS (), modtool = self .modtool )
2308+ # also check whether correct compiler flag for OpenMP is used while we're at it
2309+ # and options for oneAPI compiler for Intel
2310+ if tcname == 'intel-compilers' :
2311+ tc .set_options ({'oneapi' : True , 'openmp' : True })
2312+ else :
2313+ tc .set_options ({'openmp' : True })
2314+ with self .mocked_stdout_stderr ():
2315+ tc .prepare ()
2316+ expected_cflags = tc_cflags [tcname ]
2317+ msg = "Expected $CFLAGS found for toolchain %s: %s" % (tcname , expected_cflags )
2318+ self .assertEqual (str (tc .variables ['CFLAGS' ]), expected_cflags , msg )
2319+ self .assertEqual (os .environ ['CFLAGS' ], expected_cflags , msg )
23182320
23192321 def test_pgi_toolchain (self ):
23202322 """Tests for PGI toolchain."""
0 commit comments