From be1a426a5edef50bdc29abbd82faa7280b399019 Mon Sep 17 00:00:00 2001 From: Joerg Henrichs Date: Mon, 11 Nov 2024 11:00:26 +1100 Subject: [PATCH] Renamed cray compiler wrapper to be CrayCcWrapper and CrayFtnWrapper, to avoid confusion with Craycc. --- source/fab/tools/__init__.py | 8 +++---- source/fab/tools/compiler_wrapper.py | 10 +++++---- source/fab/tools/tool_repository.py | 12 +++++----- .../unit_tests/tools/test_compiler_wrapper.py | 22 +++++++++---------- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/source/fab/tools/__init__.py b/source/fab/tools/__init__.py index 4ee807da..bc7430b7 100644 --- a/source/fab/tools/__init__.py +++ b/source/fab/tools/__init__.py @@ -12,8 +12,8 @@ from fab.tools.compiler import (CCompiler, Compiler, Craycc, Crayftn, FortranCompiler, Gcc, Gfortran, Icc, Icx, Ifort, Ifx, Nvc, Nvfortran) -from fab.tools.compiler_wrapper import (CompilerWrapper, CrayCc, CrayFtn, - Mpicc, Mpif90) +from fab.tools.compiler_wrapper import (CompilerWrapper, CrayCcWrapper, + CrayFtnWrapper, Mpicc, Mpif90) from fab.tools.flags import Flags from fab.tools.linker import Linker from fab.tools.psyclone import Psyclone @@ -34,9 +34,9 @@ "Cpp", "CppFortran", "Craycc", - "CrayCc", + "CrayCcWrapper", "Crayftn", - "CrayFtn", + "CrayFtnWrapper", "Fcm", "Flags", "FortranCompiler", diff --git a/source/fab/tools/compiler_wrapper.py b/source/fab/tools/compiler_wrapper.py index 1c7ea666..09ce5015 100644 --- a/source/fab/tools/compiler_wrapper.py +++ b/source/fab/tools/compiler_wrapper.py @@ -204,8 +204,9 @@ def __init__(self, compiler: Compiler): # ============================================================================ -class CrayFtn(CompilerWrapper): - '''Class for the Cray Fortran compiler wrapper. +class CrayFtnWrapper(CompilerWrapper): + '''Class for the Cray Fortran compiler wrapper. We add 'wrapper' to the + class name to make this class distinct from the Crayftn compiler class. :param compiler: the compiler that the ftn wrapper will use. ''' @@ -216,8 +217,9 @@ def __init__(self, compiler: Compiler): # ============================================================================ -class CrayCc(CompilerWrapper): - '''Class for the Cray C compiler wrapper +class CrayCcWrapper(CompilerWrapper): + '''Class for the Cray C compiler wrapper. We add 'wrapper' to the class + name to make this class distinct from the Craycc compiler class :param compiler: the compiler that the mpicc wrapper will use. ''' diff --git a/source/fab/tools/tool_repository.py b/source/fab/tools/tool_repository.py index 427f770a..d699574a 100644 --- a/source/fab/tools/tool_repository.py +++ b/source/fab/tools/tool_repository.py @@ -17,7 +17,8 @@ from fab.tools.tool import Tool from fab.tools.category import Category from fab.tools.compiler import Compiler -from fab.tools.compiler_wrapper import CrayCc, CrayFtn, Mpif90, Mpicc +from fab.tools.compiler_wrapper import (CrayCcWrapper, CrayFtnWrapper, + Mpif90, Mpicc) from fab.tools.linker import Linker from fab.tools.versioning import Fcm, Git, Subversion from fab.tools import (Ar, Cpp, CppFortran, Craycc, Crayftn, @@ -76,9 +77,10 @@ def __init__(self): for fc in all_fc: mpif90 = Mpif90(fc) self.add_tool(mpif90) - # I assume cray has (besides cray) only support for gfortran/ifort + # I assume cray has (besides cray) only support for Intel and GNU if fc.name in ["gfortran", "ifort"]: - crayftn = CrayFtn(fc) + crayftn = CrayFtnWrapper(fc) + print("NEW NAME", crayftn, crayftn.name) self.add_tool(crayftn) # Now create the potential mpicc and Cray cc wrapper @@ -86,9 +88,9 @@ def __init__(self): for cc in all_cc: mpicc = Mpicc(cc) self.add_tool(mpicc) - # I assume cray has (besides cray) only support for gfortran/ifort + # I assume cray has (besides cray) only support for Intel and GNU if cc.name in ["gcc", "icc"]: - craycc = CrayCc(cc) + craycc = CrayCcWrapper(cc) self.add_tool(craycc) def add_tool(self, tool: Tool): diff --git a/tests/unit_tests/tools/test_compiler_wrapper.py b/tests/unit_tests/tools/test_compiler_wrapper.py index 42ee31ab..07f9a08b 100644 --- a/tests/unit_tests/tools/test_compiler_wrapper.py +++ b/tests/unit_tests/tools/test_compiler_wrapper.py @@ -12,9 +12,9 @@ import pytest -from fab.tools import (Category, CompilerWrapper, CrayCc, CrayFtn, - Gcc, Gfortran, Icc, Ifort, Mpicc, Mpif90, - ToolRepository) +from fab.tools import (Category, CompilerWrapper, CrayCcWrapper, + CrayFtnWrapper, Gcc, Gfortran, Icc, Ifort, + Mpicc, Mpif90, ToolRepository) def test_compiler_wrapper_compiler_getter(): @@ -351,9 +351,9 @@ def test_compiler_wrapper_mpi_ifort(): def test_compiler_wrapper_cray_icc(): '''Tests the Cray wrapper for icc.''' - craycc = CrayCc(Icc()) + craycc = CrayCcWrapper(Icc()) assert craycc.name == "craycc-icc" - assert str(craycc) == "CrayCc(icc)" + assert str(craycc) == "CrayCcWrapper(icc)" assert isinstance(craycc, CompilerWrapper) assert craycc.category == Category.C_COMPILER assert craycc.mpi @@ -362,9 +362,9 @@ def test_compiler_wrapper_cray_icc(): def test_compiler_wrapper_cray_ifort(): '''Tests the Cray wrapper for ifort.''' - crayftn = CrayFtn(Ifort()) + crayftn = CrayFtnWrapper(Ifort()) assert crayftn.name == "crayftn-ifort" - assert str(crayftn) == "CrayFtn(ifort)" + assert str(crayftn) == "CrayFtnWrapper(ifort)" assert isinstance(crayftn, CompilerWrapper) assert crayftn.category == Category.FORTRAN_COMPILER assert crayftn.mpi @@ -373,9 +373,9 @@ def test_compiler_wrapper_cray_ifort(): def test_compiler_wrapper_cray_gcc(): '''Tests the Cray wrapper for gcc.''' - craycc = CrayCc(Gcc()) + craycc = CrayCcWrapper(Gcc()) assert craycc.name == "craycc-gcc" - assert str(craycc) == "CrayCc(gcc)" + assert str(craycc) == "CrayCcWrapper(gcc)" assert isinstance(craycc, CompilerWrapper) assert craycc.category == Category.C_COMPILER assert craycc.mpi @@ -384,9 +384,9 @@ def test_compiler_wrapper_cray_gcc(): def test_compiler_wrapper_cray_gfortran(): '''Tests the Cray wrapper for gfortran.''' - crayftn = CrayFtn(Gfortran()) + crayftn = CrayFtnWrapper(Gfortran()) assert crayftn.name == "crayftn-gfortran" - assert str(crayftn) == "CrayFtn(gfortran)" + assert str(crayftn) == "CrayFtnWrapper(gfortran)" assert isinstance(crayftn, CompilerWrapper) assert crayftn.category == Category.FORTRAN_COMPILER assert crayftn.mpi