Skip to content

Commit e050f23

Browse files
Merge pull request #2597 from devitocodes/deviceid-envvar
api: Add DEVITO_DEVICE_DEFAULT env var
2 parents 019c837 + e8c1f1b commit e050f23

4 files changed

Lines changed: 15 additions & 4 deletions

File tree

FAQ.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,9 @@ Used to select a specific "backend compiler". The backend compiler takes as inpu
292292
#### DEVITO_PLATFORM
293293
This environment variable is mostly needed when running on GPUs, to ask Devito to generate code for a particular device (see for example this [tutorial](https://github.com/devitocodes/devito/blob/main/examples/gpu/01_diffusion_with_openmp_offloading.ipynb)). Can be also used to specify CPU architectures such as Intel's -- Haswell, Broadwell, SKL and KNL -- ARM, AMD, and Power. Often one can ignore this variable because Devito typically does a decent job at auto-detecting the underlying platform.
294294

295+
#### DEVITO_DEVICEID
296+
Specify the default device to use when running on a GPU. This is useful when multiple GPUs are available on the system. The default is `0`, which means the first device. Use `1` for the second device, and so on.
297+
295298
#### DEVITO_LANGUAGE
296299
Specify the generated code language. The default is `C`, which means sequential C. Use `openmp` to emit C+OpenMP or `openacc` for C+OpenACC.
297300

devito/arch/archinfo.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1023,7 +1023,12 @@ def supports(self, query, language=None):
10231023
return False
10241024

10251025
cc = get_nvidia_cc()
1026-
if query == 'async-loads' and cc >= 80:
1026+
if cc is None:
1027+
# Something off with `get_nvidia_cc` on this system
1028+
warning(f"Couldn't establish if `query={query}` is supported on this "
1029+
"system. Assuming it is not.")
1030+
return False
1031+
elif query == 'async-loads' and cc >= 80:
10271032
# Asynchronous pipeline loads -- introduced in Ampere
10281033
return True
10291034
elif query in ('tma', 'thread-block-cluster') and cc >= 90:

devito/parameters.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,7 @@ def _signature_items(self):
147147
'DEVITO_OPT': 'opt',
148148
'DEVITO_MPI': 'mpi',
149149
'DEVITO_TOPOLOGY': 'topology',
150+
'DEVITO_DEVICEID': 'deviceid',
150151
'DEVITO_LANGUAGE': 'language',
151152
'DEVITO_AUTOTUNING': 'autotuning',
152153
'DEVITO_LOGGING': 'log-level',

devito/types/dimension.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -916,7 +916,7 @@ def __init_finalize__(self, name, parent=None, factor=None, condition=None,
916916
super().__init_finalize__(name, parent)
917917

918918
# Process subsampling factor
919-
if factor is None or factor == 1:
919+
if factor is None:
920920
self._factor = None
921921
elif is_number(factor):
922922
self._factor = int(factor)
@@ -937,16 +937,18 @@ def uses_symbolic_factor(self):
937937
def factor_data(self):
938938
if isinstance(self.factor, Constant):
939939
return self.factor.data
940-
else:
940+
elif self.factor is not None:
941941
return self.factor
942+
else:
943+
return 1
942944

943945
@property
944946
def spacing(self):
945947
return self.factor_data * self.parent.spacing
946948

947949
@property
948950
def factor(self):
949-
return self._factor if self.uses_symbolic_factor else 1
951+
return self._factor
950952

951953
@cached_property
952954
def symbolic_factor(self):

0 commit comments

Comments
 (0)