Skip to content

Commit ae0a9f6

Browse files
committed
compiler: Change C++ standard for CUDA>12
1 parent 2441675 commit ae0a9f6

2 files changed

Lines changed: 28 additions & 7 deletions

File tree

devito/arch/archinfo.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -573,7 +573,7 @@ def get_cuda_version():
573573
finally:
574574
if out.returncode == 0:
575575
start = out.stdout.find('release')
576-
start = out.stdout.find(',', start)
576+
start = out.stdout.find(',', start) + 1
577577
stop = out.stdout.find('\n', start)
578578
with suppress(InvalidVersion):
579579
cuda_version = parse(out.stdout[start:stop])
@@ -660,9 +660,22 @@ def check_cuda_runtime():
660660
cuda.cudaRuntimeGetVersion(ctypes.byref(runtime_version)) == 0:
661661
driver_version = driver_version.value
662662
runtime_version = runtime_version.value
663-
if driver_version < runtime_version:
664-
warning("The NVidia driver (v%d) on this system may not be compatible "
665-
"with the CUDA runtime (v%d)" % (driver_version, runtime_version))
663+
664+
driver_v = parse(str(driver_version/1000))
665+
runtime_v = parse(str(runtime_version/1000))
666+
# First check the "major" version, known to be incompatible
667+
if driver_v.major < runtime_v.major:
668+
raise RuntimeError(
669+
f'The NVidia driver (v{driver_version}) on this system is '
670+
f'not compatible with the CUDA runtime (v{runtime_version})'
671+
)
672+
# Next check the version including minor revisions which may still
673+
# be compatible
674+
elif driver_v < runtime_v:
675+
warning(
676+
f'The NVidia driver (v{driver_version}) on this system may '
677+
f'not be compatible with the CUDA runtime (v{runtime_version})'
678+
)
666679
else:
667680
warning("Unable to check compatibility of NVidia driver and runtime")
668681

devito/arch/compiler.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,11 @@
1414
from codepy.toolchain import (GCCToolchain,
1515
call_capture_output as _call_capture_output)
1616

17-
from devito.arch import (AMDGPUX, Cpu64, AppleArm, NvidiaDevice, POWER8, POWER9,
18-
Graviton, Cortex, IntelDevice, get_nvidia_cc, NvidiaArm,
19-
check_cuda_runtime, get_m1_llvm_path)
17+
from devito.arch import (
18+
AMDGPUX, Cpu64, AppleArm, NvidiaDevice, POWER8, POWER9, Graviton,
19+
Cortex, IntelDevice, get_nvidia_cc, NvidiaArm, check_cuda_runtime,
20+
get_cuda_version, get_m1_llvm_path
21+
)
2022
from devito.exceptions import CompilationError
2123
from devito.logger import debug, warning
2224
from devito.parameters import configuration
@@ -765,6 +767,12 @@ def __init_finalize__(self, **kwargs):
765767
# garbage, since the CUDA kernel behaviour would be undefined
766768
check_cuda_runtime()
767769

770+
@property
771+
def std(self):
772+
# Since CUDA 13, code needs compiling with C++17 standard
773+
_cxxstd = 'c++17' if get_cuda_version().major >= 13 else 'c++14'
774+
return _cxxstd if self._cpp else self._cstd
775+
768776
def __lookup_cmds__(self):
769777
self.CC = 'nvcc'
770778
self.CXX = 'nvcc'

0 commit comments

Comments
 (0)