Skip to content

Commit 43da5a2

Browse files
committed
misc: f-string formatting
1 parent c1a31a9 commit 43da5a2

File tree

16 files changed

+125
-133
lines changed

16 files changed

+125
-133
lines changed

devito/arch/archinfo.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,7 @@ def cbk(deviceid=0):
330330
except OSError:
331331
pass
332332

333-
# *** Third try: `sycl-ls`
333+
# *** Third try: `sycl-ls`, clearly only works with Intel cards
334334
try:
335335
gpu_infos = {}
336336

@@ -453,7 +453,6 @@ def parse_product_arch():
453453
for line in lines:
454454
# Graphics cards are listed as VGA or 3D controllers in lspci
455455
if 'VGA' in line or '3D' in line or 'Display' in line:
456-
print(line)
457456
gpu_info = {}
458457
# Lines produced by lspci command are of the form:
459458
# xxxx:xx:xx.x Device Type: Name

devito/arch/compiler.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ def __init__(self):
180180
"""
181181

182182
fields = {'cc', 'ld'}
183-
default_cpp = False
183+
_default_cpp = False
184184
_cxxstd = 'c++14'
185185
_cstd = 'c99'
186186

@@ -193,7 +193,7 @@ def __init__(self, **kwargs):
193193
super().__init__(**kwargs)
194194

195195
self.__lookup_cmds__()
196-
self._cpp = kwargs.get('cpp', self.default_cpp)
196+
self._cpp = kwargs.get('cpp', self._default_cpp)
197197

198198
self.suffix = kwargs.get('suffix')
199199
if not kwargs.get('mpi'):
@@ -602,7 +602,7 @@ def __lookup_cmds__(self):
602602

603603
class PGICompiler(Compiler):
604604

605-
default_cpp = True
605+
_default_cpp = True
606606

607607
def __init_finalize__(self, **kwargs):
608608

@@ -655,7 +655,7 @@ def __lookup_cmds__(self):
655655

656656
class CudaCompiler(Compiler):
657657

658-
default_cpp = True
658+
_default_cpp = True
659659

660660
def __init_finalize__(self, **kwargs):
661661

@@ -729,7 +729,7 @@ def __lookup_cmds__(self):
729729

730730
class HipCompiler(Compiler):
731731

732-
default_cpp = True
732+
_default_cpp = True
733733

734734
def __init_finalize__(self, **kwargs):
735735

@@ -890,7 +890,7 @@ def __lookup_cmds__(self):
890890

891891
class SyclCompiler(OneapiCompiler):
892892

893-
default_cpp = True
893+
_default_cpp = True
894894

895895
def __init_finalize__(self, **kwargs):
896896
IntelCompiler.__init_finalize__(self, **kwargs)
@@ -957,7 +957,6 @@ def __new__(cls, *args, **kwargs):
957957
obj = super().__new__(cls)
958958
# Keep base to initialize accordingly
959959
obj._base = kwargs.pop('base', _base)
960-
obj.default_cpp = obj._base.default_cpp
961960

962961
return obj
963962

@@ -988,6 +987,10 @@ def __lookup_cmds__(self):
988987
def __new_with__(self, **kwargs):
989988
return super().__new_with__(base=self._base, **kwargs)
990989

990+
@property
991+
def _default_cpp(self):
992+
return self._base._default_cpp
993+
991994

992995
class CompilerRegistry(dict):
993996
"""

devito/core/operator.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,11 @@ class BasicOperator(Operator):
138138
(default) or `int64`.
139139
"""
140140

141+
LINEARIZE = False
142+
"""
143+
Linearize n-dimensional Indexeds.
144+
"""
145+
141146
ERRCTL = None
142147
"""
143148
Runtime error checking. If this option is enabled, the generated code will
@@ -150,11 +155,6 @@ class BasicOperator(Operator):
150155
The target language constructor, to be specified by subclasses.
151156
"""
152157

153-
LINEARIZE = False
154-
"""
155-
Linearize n-dimensional Indexeds.
156-
"""
157-
158158
@classmethod
159159
def _normalize_kwargs(cls, **kwargs):
160160
# Will be populated with dummy values; this method is actually overriden

devito/ir/cgen/printer.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def compiler(self):
6565
def doprint(self, expr, assign_to=None):
6666
"""
6767
The sympy code printer does a lot of extra we do not need as we handle all of
68-
it in the compiler so we directly defaults to `_print`
68+
it in the compiler so we directly defaults to `_print`.
6969
"""
7070
return self._print(expr)
7171

@@ -75,8 +75,7 @@ def _prec(self, expr):
7575
except TypeError:
7676
return self.dtype
7777
if dtype is None or np.issubdtype(dtype, np.integer):
78-
real = any(isinstance(i, Float) for i in expr.atoms())
79-
if real:
78+
if any(isinstance(i, Float) for i in expr.atoms()):
8079
try:
8180
return np.promote_types(self.dtype, np.float32).type
8281
except np.exceptions.DTypePromotionError:

devito/ir/iet/visitors.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,6 @@ def visit_Operator(self, o, mode='all'):
736736
# Plain string
737737
headers.append(c.Line(h))
738738
headers = headers + [blankline]
739-
# headers = [c.Define(*i) for i in o._headers] + [blankline]
740739

741740
# Header files
742741
includes = self._operator_includes(o) + [blankline]
@@ -1406,8 +1405,7 @@ def __init__(self, name, arguments, is_expr=False, is_indirect=False,
14061405

14071406
def generate(self):
14081407
if self.templates:
1409-
ctemplates = ", ".join(str(i) for i in self.templates)
1410-
tip = f"{self.name}<{ctemplates}>"
1408+
tip = f"{self.name}<{', '.join(str(i) for i in self.templates)}>"
14111409
else:
14121410
tip = self.name
14131411
if not self.is_indirect:

devito/mpi/routines.py

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
Transformer, ElementalCall, CommCallable)
1616
from devito.mpi import MPI
1717
from devito.symbolics import (Byref, CondNe, FieldFromPointer, FieldFromComposite,
18-
IndexedPointer, Macro, cast_mapper, subs_op_args)
18+
IndexedPointer, Macro, cast, subs_op_args)
1919
from devito.tools import (as_mapper, dtype_to_mpitype, dtype_len, infer_datasize,
2020
flatten, generator, is_integer, split)
2121
from devito.types import (Array, Bag, Dimension, Eq, Symbol, LocalObject,
@@ -306,7 +306,7 @@ def _make_bundles(self, hs):
306306
except ValueError:
307307
for i in candidates:
308308
name = "bag_%s" % i.name
309-
bag = Bag(name=name, components=(i,))
309+
bag = Bag(name=name, components=i)
310310
halo_scheme = halo_scheme.add(bag, hse)
311311

312312
hs = hs._rebuild(halo_scheme=halo_scheme)
@@ -605,7 +605,7 @@ def _make_msg(self, f, hse, key):
605605
return MPIMsg('msg%d' % key, f, halos)
606606

607607
def _make_sendrecv(self, f, hse, key, msg=None):
608-
cast = cast_mapper((f.c0.dtype, '*'))
608+
fcast = cast(f.c0.dtype, '*')
609609
comm = f.grid.distributor._obj_comm
610610

611611
bufg = FieldFromPointer(msg._C_field_bufg, msg)
@@ -619,7 +619,7 @@ def _make_sendrecv(self, f, hse, key, msg=None):
619619
sizes = [FieldFromPointer('%s[%d]' % (msg._C_field_sizes, i), msg)
620620
for i in range(len(f._dist_dimensions))]
621621

622-
arguments = [cast(bufg)] + sizes + list(f.handles) + ofsg
622+
arguments = [fcast(bufg)] + sizes + list(f.handles) + ofsg
623623
gather = Gather('gather%s' % key, arguments)
624624
# The `gather` is unnecessary if sending to MPI.PROC_NULL
625625
gather = Conditional(CondNe(torank, Macro('MPI_PROC_NULL')), gather)
@@ -671,7 +671,7 @@ def _call_compute(self, hs, compute, *args):
671671
return compute.make_call(dynamic_args_mapper=hs.omapper.core)
672672

673673
def _make_wait(self, f, hse, key, msg=None):
674-
cast = cast_mapper((f.c0.dtype, '*'))
674+
fcast = cast(f.c0.dtype, '*')
675675

676676
bufs = FieldFromPointer(msg._C_field_bufs, msg)
677677

@@ -681,7 +681,7 @@ def _make_wait(self, f, hse, key, msg=None):
681681

682682
sizes = [FieldFromPointer('%s[%d]' % (msg._C_field_sizes, i), msg)
683683
for i in range(len(f._dist_dimensions))]
684-
arguments = [cast(bufs)] + sizes + list(f.handles) + ofss
684+
arguments = [fcast(bufs)] + sizes + list(f.handles) + ofss
685685
scatter = Scatter('scatter%s' % key, arguments)
686686

687687
# The `scatter` must be guarded as we must not alter the halo values along
@@ -772,7 +772,7 @@ def _call_sendrecv(self, *args):
772772
return
773773

774774
def _make_haloupdate(self, f, hse, key, *args, msg=None):
775-
cast = cast_mapper((f.c0.dtype, '*'))
775+
fcast = cast(f.c0.dtype, '*')
776776
comm = f.grid.distributor._obj_comm
777777

778778
fixed = {d: Symbol(name="o%s" % d.root) for d in hse.loc_indices}
@@ -794,7 +794,7 @@ def _make_haloupdate(self, f, hse, key, *args, msg=None):
794794
ofsg = [fixed.get(d) or ofsg.pop(0) for d in f.dimensions]
795795

796796
# The `gather` is unnecessary if sending to MPI.PROC_NULL
797-
arguments = [cast(bufg)] + sizes + list(f.handles) + ofsg
797+
arguments = [fcast(bufg)] + sizes + list(f.handles) + ofsg
798798
gather = Gather('gather%s' % key, arguments)
799799
gather = Conditional(CondNe(torank, Macro('MPI_PROC_NULL')), gather)
800800

@@ -819,7 +819,7 @@ def _call_haloupdate(self, name, f, hse, msg):
819819
return HaloUpdateCall(name, args)
820820

821821
def _make_halowait(self, f, hse, key, *args, msg=None):
822-
cast = cast_mapper((f.c0.dtype, '*'))
822+
fcast = cast(f.c0.dtype, '*')
823823

824824
fixed = {d: Symbol(name="o%s" % d.root) for d in hse.loc_indices}
825825

@@ -839,7 +839,7 @@ def _make_halowait(self, f, hse, key, *args, msg=None):
839839

840840
# The `scatter` must be guarded as we must not alter the halo values along
841841
# the domain boundary, where the sender is actually MPI.PROC_NULL
842-
arguments = [cast(bufs)] + sizes + list(f.handles) + ofss
842+
arguments = [fcast(bufs)] + sizes + list(f.handles) + ofss
843843
scatter = Scatter('scatter%s' % key, arguments)
844844
scatter = Conditional(CondNe(fromrank, Macro('MPI_PROC_NULL')), scatter)
845845

0 commit comments

Comments
 (0)