Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions easybuild/toolchains/compiler/nvhpc.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
##
# Copyright 2026 Ghent University
#
# This file is part of EasyBuild,
# originally created by the HPC team of Ghent University (http://ugent.be/hpc/en),
# with support of Ghent University (http://ugent.be/hpc),
# the Flemish Supercomputer Centre (VSC) (https://www.vscentrum.be),
# Flemish Research Foundation (FWO) (http://www.fwo.be/en)
# and the Department of Economy, Science and Innovation (EWI) (http://www.ewi-vlaanderen.be/en).
#
# https://github.com/easybuilders/easybuild
#
# EasyBuild is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation v2.
#
# EasyBuild is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with EasyBuild. If not, see <http://www.gnu.org/licenses/>.
##
"""Compatibility module such that compiler.nvhpc.NVHPC and compiler.compiler.nvidia_compilers.NvidiaCompilers
can be used interchangeably
"""

from easybuild.base import fancylogger
from easybuild.toolchains.compiler.nvidia_compilers import NVHPC # noqa # pylint:disable=unused-import
Comment thread
lexming marked this conversation as resolved.
Outdated

_log = fancylogger.getLogger('compiler.nvhpc', fname=False)
_log.deprecated("easybuild.toolchains.compiler.nvhpc was replaced by "
"easybuild.toolchains.compiler.nvidia_compilers in EasyBuild 5.2.0", '6.0')

# TODO EasyBuild 6.0: Remove NVHPC name from NvidiaCompilers.COMPILER_MODULE_NAME
22 changes: 18 additions & 4 deletions easybuild/toolchains/compiler/nvidia_compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* Andreas Herten (Forschungszentrum Juelich GmbH)
"""

import abc
import easybuild.tools.systemtools as systemtools
from easybuild.tools.toolchain.compiler import Compiler

Expand All @@ -45,7 +46,8 @@
class NvidiaCompilers(Compiler):
"NVHPC compiler class"

COMPILER_MODULE_NAME = ['nvidia-compilers']
# TODO EasyBuild 6.0: Remove NVHPC name
COMPILER_MODULE_NAME = ['nvidia-compilers', 'NVHPC']

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Flamefire Hmmm, is this necessary?

Doesn't this mean that the NVHPC module must be available in order to use nvidia-compilers as compiler component in a toolchain?

cc @lexming

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I understand the code correctly it is an "either". Not fully sure though.

@lexming lexming Jan 19, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, this seems more of a convenience attribute in the Compiler class, with no defined purpose. Only real use in framework is to determine the compiler in optarch, which is compatible with this being a list of possible compilers and not all of them:

current_compiler_names = (getattr(self, 'COMPILER_MODULE_NAME', []) +


COMPILER_FAMILY = TC_CONSTANT_NVHPC

Expand Down Expand Up @@ -101,6 +103,18 @@ def _set_compiler_flags(self):
self.variables.nextend('OPTFLAGS', ['tp=x64'])
super()._set_compiler_flags()

def _set_compiler_vars(self):
"""Set the compiler variables"""
super()._set_compiler_vars()

# Former name used in EasyBuild until 5.2.0, now a DEPRECATED alias
class NVHPC(metaclass=abc.ABCMeta): # pylint: disable=too-few-public-methods
"""DEPRECATED alias for NvidiaCompilers."""
def __new__(cls, *args, **kwargs):
if cls is NVHPC:
inst = NvidiaCompilers(*args, **kwargs)
inst.log.deprecated(
"easybuild.toolchains.compiler.nvhpc was replaced by "
"easybuild.toolchains.compiler.nvidia_compilers in EasyBuild 5.2.0", '6.0')
return inst
return super().__new__(cls)


NVHPC.register(NvidiaCompilers)
2 changes: 2 additions & 0 deletions easybuild/toolchains/nvhpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@
from easybuild.toolchains.linalg.nvscalapack import NVScaLAPACK
from easybuild.toolchains.mpi.nvhpcx import NVHPCX
from easybuild.toolchains.nvidia_compilers import NvidiaCompilersToolchain
# Backwards compatibility
from easybuild.toolchains.nvidia_compilers import NVHPCToolchain # noqa # pylint:disable=unused-import
from easybuild.tools.toolchain.toolchain import SYSTEM_TOOLCHAIN_NAME


Expand Down
14 changes: 14 additions & 0 deletions easybuild/toolchains/nvidia_compilers.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
* Andreas Herten (Forschungszentrum Juelich)
"""

import abc
from easybuild.toolchains.compiler.nvidia_compilers import NvidiaCompilers
from easybuild.toolchains.gcccore import GCCcore
from easybuild.tools.toolchain.toolchain import SYSTEM_TOOLCHAIN_NAME
Expand All @@ -48,3 +49,16 @@ class NvidiaCompilersToolchain(NvidiaCompilers):
# nvidia-compilers is only an optional subtoolchain because of legacy reasons;
# recent NVHPC toolchains (versions >= 25.0) always have nvidia-compilers are subtoolchain
OPTIONAL = True


class NVHPCToolchain(metaclass=abc.ABCMeta): # pylint: disable=too-few-public-methods
"""DEPRECATED alias for NvidiaCompilersToolchain."""
def __new__(cls, *args, **kwargs):
if cls is NVHPCToolchain:
inst = NvidiaCompilersToolchain(*args, **kwargs)
inst.log.deprecated("NVHPCToolchain was replaced by NvidiaCompilersToolchain in EasyBuild 5.2.0", '6.0')
return inst
return super().__new__(cls)


NVHPCToolchain.register(NvidiaCompilersToolchain)
35 changes: 32 additions & 3 deletions test/framework/toolchain.py
Original file line number Diff line number Diff line change
Expand Up @@ -528,7 +528,7 @@ def test_validate_pass_by_value(self):

pass_by_value = True
ids = []
for k, v in tc.variables.items():
for _, v in tc.variables.items():
for x in v:
idx = id(x)
if idx not in ids:
Expand Down Expand Up @@ -908,8 +908,6 @@ def test_misc_flags_unique_fortran(self):
flag = tc.COMPILER_UNIQUE_OPTION_MAP[opt]
if isinstance(flag, list):
flag = ' '.join(flag)
else:
flag = flag
for var in flag_vars:
flags = tc.get_variable(var)
if enable:
Expand Down Expand Up @@ -3389,6 +3387,37 @@ def test_get_flag(self):
tc.options.options_map['openmp'] = flags
self.assertEqual(tc.get_flag('openmp'), flagstring)

def test_nvhpc_compatibility(self):
"""Test that software using EasyBuild before 5.2.0 continues working
the compiler.nvhpc toolchain being renamed to NvidiaCompilers"""
with self.temporarily_allow_deprecated_behaviour(), self.mocked_stdout_stderr():
from easybuild.toolchains.compiler.nvhpc import NVHPC
self.assertIn("nvhpc was replaced by easybuild.toolchains.compiler.nvidia_compilers", self.get_stderr())
from easybuild.toolchains.nvompi import Nvompi
from easybuild.toolchains.compiler.nvidia_compilers import NvidiaCompilers
from easybuild.toolchains.nvhpc import NvidiaCompilersToolchain, NVHPCToolchain

tc = NvidiaCompilers(name='NvidiaCompilers', version='2024a') # Common usage
# Might be checked by pre-5.2.0 users
self.assertIsInstance(tc, NVHPC)

with self.temporarily_allow_deprecated_behaviour(), self.mocked_stdout_stderr():
tc = NVHPC(name='NVHPC', version='2024a') # Might be used by pre-5.2.0 users
self.assertIn("nvhpc was replaced by easybuild.toolchains.compiler.nvidia_compilers", self.get_stderr())
self.assertIsInstance(tc, NvidiaCompilers)

tc = Nvompi(version='2024a') # Common usage
self.assertIsInstance(tc, NvidiaCompilers)
self.assertIsInstance(tc, NvidiaCompilersToolchain)
# Might be checked by pre-5.2.0 users
self.assertIsInstance(tc, NVHPC)
self.assertIsInstance(tc, NVHPCToolchain)

with self.temporarily_allow_deprecated_behaviour(), self.mocked_stdout_stderr():
tc = NVHPCToolchain(name='NVHPC', version='2024a') # Might be used by pre-5.2.0 users
self.assertIn("NVHPCToolchain was replaced by NvidiaCompilersToolchain", self.get_stderr())
self.assertIsInstance(tc, NvidiaCompilersToolchain)
Comment thread
Flamefire marked this conversation as resolved.
Outdated


def suite(loader=None):
""" return all the tests"""
Expand Down