Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/additional_compilers_clean' into…
Browse files Browse the repository at this point in the history
… develop
  • Loading branch information
hiker committed Feb 14, 2025
2 parents b8966f9 + e1bfe09 commit 7b49e09
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 34 deletions.
36 changes: 4 additions & 32 deletions source/fab/tools/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -474,21 +474,7 @@ class Nvc(CCompiler):
def __init__(self, name: str = "nvc", exec_name: str = "nvc"):
super().__init__(name, exec_name, suite="nvidia",
openmp_flag="-mp",
version_regex=r"nvc (\d[\d\.-]+\d)")

def run_version_command(
self, version_command: Optional[str] = '--version') -> str:
'''Run the compiler's command to get its version. This implementation
runs the function in the base class, and changes any '-' into a
'.' to support nvidia version numbers which have dashes, e.g. 23.5-0.
:param version_command: The compiler argument used to get version info.
:returns: The output from the version command, with any '-' replaced
with '.'
'''
version_string = super().run_version_command()
return version_string.replace("-", ".")
version_regex=r"nvc (\d[\d\.]+\d)")


# ============================================================================
Expand All @@ -506,21 +492,7 @@ def __init__(self, name: str = "nvfortran", exec_name: str = "nvfortran"):
module_folder_flag="-module",
openmp_flag="-mp",
syntax_only_flag="-Msyntax-only",
version_regex=r"nvfortran (\d[\d\.-]+\d)")

def run_version_command(
self, version_command: Optional[str] = '--version') -> str:
'''Run the compiler's command to get its version. This implementation
runs the function in the base class, and changes any '-' into a
'.' to support nvidia version numbers which have dashes, e.g. 23.5-0.
:param version_command: The compiler argument used to get version info.
:returns: The output from the version command, with any '-' replaced
with '.'
'''
version_string = super().run_version_command()
return version_string.replace("-", ".")
version_regex=r"nvfortran (\d[\d\.]+\d)")


# ============================================================================
Expand All @@ -545,7 +517,7 @@ class Craycc(CCompiler):
def __init__(self, name: str = "craycc-cc", exec_name: str = "cc"):
super().__init__(name, exec_name, suite="cray", mpi=True,
openmp_flag="-homp",
version_regex=r"Cray [Cc][^\d]* (\d[\d\.]+\d) ")
version_regex=r"Cray [Cc][^\d]* (\d[\d\.]+\d)")


# ============================================================================
Expand All @@ -564,4 +536,4 @@ def __init__(self, name: str = "crayftn-ftn", exec_name: str = "ftn"):
openmp_flag="-homp",
syntax_only_flag="-syntax-only",
version_regex=(r"Cray Fortran : Version "
r"(\d[\d\.]+\d) "))
r"(\d[\d\.]+\d)"))
4 changes: 2 additions & 2 deletions tests/unit_tests/tools/test_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -778,7 +778,7 @@ def test_nvc_get_version_23_5_0():
""")
nvc = Nvc()
with mock.patch.object(nvc, "run", mock.Mock(return_value=full_output)):
assert nvc.get_version() == (23, 5, 0)
assert nvc.get_version() == (23, 5)


def test_nvc_get_version_with_icc_string():
Expand Down Expand Up @@ -819,7 +819,7 @@ def test_nvfortran_get_version_23_5_0():
nvfortran = Nvfortran()
with mock.patch.object(nvfortran, "run",
mock.Mock(return_value=full_output)):
assert nvfortran.get_version() == (23, 5, 0)
assert nvfortran.get_version() == (23, 5)


def test_nvfortran_get_version_with_ifort_string():
Expand Down

0 comments on commit 7b49e09

Please sign in to comment.