From e3b21de5630e009f130d2e160a6fc125b5f84e31 Mon Sep 17 00:00:00 2001 From: "Michael Hirsch, Ph.D" <10931741+scivision@users.noreply.github.com> Date: Fri, 23 Aug 2019 19:33:54 -0400 Subject: Intel-Cl tests: increase robustness of Windows Intel compilers detection (#5828) * intel-cl tests: more rigorous detection of intent to use Intel Windows compilers * fortran coarray test: make skipping more robust in that underlying MPI stack is .run() This is useful for any Fortran coarray work, and especially for intel-cl where multiple Intel compiler versions are often installed, and the wrong underlying MPI library may be dynamically linked, and so a runtime check is needed to exercise the MPI stack underlying Fortran coarray. This is done by fc.run('sync all; end', dependencies: coarray) * pep8 --- run_tests.py | 30 +++++++++++++++++++++++++++--- test cases/fortran/13 coarray/meson.build | 12 ++++++++++-- 2 files changed, 37 insertions(+), 5 deletions(-) diff --git a/run_tests.py b/run_tests.py index 7e95643..dbb21df 100755 --- a/run_tests.py +++ b/run_tests.py @@ -38,9 +38,7 @@ def guess_backend(backend, msbuild_exe: str): # Auto-detect backend if unspecified backend_flags = [] if backend is None: - if (msbuild_exe is not None and - mesonlib.is_windows() and not - (os.environ.get('CC') == 'icl' or os.environ.get('CXX') == 'icl' or os.environ.get('FC') == 'ifort')): + if msbuild_exe is not None and (mesonlib.is_windows() and not _using_intelcl()): backend = 'vs' # Meson will auto-detect VS version to use else: backend = 'ninja' @@ -59,6 +57,32 @@ def guess_backend(backend, msbuild_exe: str): return (backend, backend_flags) +def _using_intelcl() -> bool: + """ + detect if intending to using Intel-Cl compilers (Intel compilers on Windows) + Sufficient evidence of intent is that user is working in the Intel compiler + shell environment, otherwise this function returns False + """ + if not mesonlib.is_windows(): + return False + # handle where user tried to "blank" MKLROOT and left space(s) + if not os.environ.get('MKLROOT', '').strip(): + return False + if (os.environ.get('CC') == 'icl' or + os.environ.get('CXX') == 'icl' or + os.environ.get('FC') == 'ifort'): + return True + # Intel-Cl users might not have the CC,CXX,FC envvars set, + # but because they're in Intel shell, the exe's below are on PATH + if shutil.which('icl') or shutil.which('ifort'): + return True + mlog.warning('It appears you might be intending to use Intel compiler on Windows ' + 'since non-empty environment variable MKLROOT is set to {} ' + 'However, Meson cannot find the Intel WIndows compiler executables (icl,ifort).' + 'Please try using the Intel shell.'.format(os.environ.get('MKLROOT'))) + return False + + # Fake classes and objects for mocking class FakeBuild: def __init__(self, env): diff --git a/test cases/fortran/13 coarray/meson.build b/test cases/fortran/13 coarray/meson.build index 3e52dde..23c7a55 100644 --- a/test cases/fortran/13 coarray/meson.build +++ b/test cases/fortran/13 coarray/meson.build @@ -9,10 +9,18 @@ if ['pgi', 'flang'].contains(fcid) endif # coarray is required because single-image fallback is an intrinsic feature -coarray = dependency('coarray', required : true) +coarray = dependency('coarray') + +# check coarray, because user might not have all the library stack installed correctly +# for example, conflicting library/compiler versions on PATH +# this has to invoke a run of "sync all" to verify the MPI stack is functioning, +# particularly for dynamic linking +coarray_ok = fc.run('sync all; end', dependencies: coarray, name: 'Coarray link & run').returncode() == 0 +if not coarray_ok + error('MESON_SKIP_TEST: The coarray stack (including MPI) did not link correctly so that a simple test could run.') +endif exe = executable('hello', 'main.f90', dependencies : coarray) test('Coarray hello world', exe) - -- cgit v1.1