Skip to content

Commit af89122

Browse files
committed
compiler: Change C++ standard for CUDA>12
1 parent 7b2209c commit af89122

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])
@@ -666,9 +666,22 @@ def check_cuda_runtime():
666666
cuda.cudaRuntimeGetVersion(ctypes.byref(runtime_version)) == 0:
667667
driver_version = driver_version.value
668668
runtime_version = runtime_version.value
669-
if driver_version < runtime_version:
670-
warning("The NVidia driver (v%d) on this system may not be compatible "
671-
"with the CUDA runtime (v%d)" % (driver_version, runtime_version))
669+
670+
driver_v = parse(str(driver_version/1000))
671+
runtime_v = parse(str(runtime_version/1000))
672+
# First check the "major" version, known to be incompatible
673+
if driver_v.major < runtime_v.major:
674+
raise RuntimeError(
675+
f'The NVidia driver (v{driver_version}) on this system is '
676+
f'not compatible with the CUDA runtime (v{runtime_version})'
677+
)
678+
# Next check the version including minor revisions which may still
679+
# be compatible
680+
elif driver_v < runtime_v:
681+
warning(
682+
f'The NVidia driver (v{driver_version}) on this system may '
683+
f'not be compatible with the CUDA runtime (v{runtime_version})'
684+
)
672685
else:
673686
warning("Unable to check compatibility of NVidia driver and runtime")
674687

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)