Skip to content

Commit

Permalink
Remove support for '-' in nvidia version numbers (which causes proble…
Browse files Browse the repository at this point in the history
…ms with compiler wrapper which do not support this).
  • Loading branch information
hiker committed Feb 5, 2025
1 parent 032ab26 commit ca139c1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 32 deletions.
32 changes: 2 additions & 30 deletions source/fab/tools/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,21 +467,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 @@ -499,21 +485,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 Down
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 ca139c1

Please sign in to comment.