Skip to content

Commit ecee115

Browse files
committed
misc: Typo and additions
1 parent 824827b commit ecee115

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

devito/arch/archinfo.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
"""Collection of utilities to detect properties of the underlying architecture."""
22

3+
from contextlib import suppress
34
from functools import cached_property
4-
from subprocess import PIPE, Popen, DEVNULL, run
5+
from subprocess import PIPE, Popen, DEVNULL, run, CalledProcessError
56
from pathlib import Path
67
import ctypes
78
import re
@@ -11,6 +12,7 @@
1112

1213
import cpuinfo
1314
import numpy as np
15+
from packaging.version import parse, InvalidVersion
1416
import psutil
1517

1618
from devito.logger import warning
@@ -553,6 +555,30 @@ def get_cuda_path():
553555
return None
554556

555557

558+
@memoized_func
559+
def get_cuda_version():
560+
cuda_home = get_cuda_path()
561+
if cuda_home is None:
562+
nvc_version_command = ['nvcc', '--version']
563+
else:
564+
nvc_version_command = [f'{cuda_home}/bin/nvcc', '--version']
565+
566+
cuda_version = None
567+
try:
568+
out = run(nvc_version_command, capture_output=True, text=True)
569+
except (FileNotFoundError, CalledProcessError):
570+
pass
571+
finally:
572+
if out.returncode == 0:
573+
start = out.stdout.find('release')
574+
start = out.stdout.find(',', start)
575+
stop = out.stdout.find('\n', start)
576+
with supress(InvalidVersion):
577+
cuda_version = parse(out.stdout[start:stop])
578+
579+
return cuda_version
580+
581+
556582
@memoized_func
557583
def get_advisor_path():
558584
"""

devito/arch/compiler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -661,14 +661,15 @@ def __init_finalize__(self, **kwargs):
661661
# self.cflags += ['-ta=tesla,host']
662662

663663
def __lookup_cmds__(self):
664+
# Note: Using `nvc++` instead of `nvcc` because of issue #1219
664665
self.CC = 'nvc++'
665666
self.CXX = 'nvc++'
666667
self.MPICC = 'mpic++'
667668
self.MPICXX = 'mpicxx'
668669

669670
def add_libraries(self, libs):
670671
# Urgh...
671-
# NvidiaComiler inherits from Compiler inherits from GCCToolchain in codepy
672+
# NvidiaCompiler inherits from Compiler inherits from GCCToolchain in codepy
672673
# And _GCC_ supports linking versioned shared objects with the syntax:
673674
# `gcc -L/path/to/versioned/lib -l:libfoo.so.2.0 ...`
674675
# But this syntax is not supported by the Nvidia compiler.

0 commit comments

Comments
 (0)