Skip to content

Commit 7b0fc5b

Browse files
wence-sv2518
authored andcommitted
base: Kernel can specify if it requires output arguments zero
Necessary to handle tsfc-generated kernels that have a par_loop access descriptor for their outputs that is not INC.
1 parent 32c565b commit 7b0fc5b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

pyop2/base.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3287,6 +3287,8 @@ class Kernel(Cached):
32873287
empty)
32883288
:param ldargs: A list of arguments to pass to the linker when
32893289
compiling this Kernel.
3290+
:param requires_zeroed_output_arguments: Does this kernel require the
3291+
output arguments to be zeroed on entry when called? (default no)
32903292
:param cpp: Is the kernel actually C++ rather than C? If yes,
32913293
then compile with the C++ compiler (kernel is wrapped in
32923294
extern C for linkage reasons).
@@ -3309,7 +3311,7 @@ class Kernel(Cached):
33093311
@classmethod
33103312
@validate_type(('name', str, NameTypeError))
33113313
def _cache_key(cls, code, name, opts={}, include_dirs=[], headers=[],
3312-
user_code="", ldargs=None, cpp=False):
3314+
user_code="", ldargs=None, cpp=False, requires_zeroed_output_arguments=False):
33133315
# Both code and name are relevant since there might be multiple kernels
33143316
# extracting different functions from the same code
33153317
# Also include the PyOP2 version, since the Kernel class might change
@@ -3323,15 +3325,15 @@ def _cache_key(cls, code, name, opts={}, include_dirs=[], headers=[],
33233325
code.update_persistent_hash(key_hash, LoopyKeyBuilder())
33243326
code = key_hash.hexdigest()
33253327
hashee = (str(code) + name + str(sorted(opts.items())) + str(include_dirs)
3326-
+ str(headers) + version + str(ldargs) + str(cpp))
3328+
+ str(headers) + version + str(ldargs) + str(cpp) + str(requires_zeroed_output_arguments))
33273329
return md5(hashee.encode()).hexdigest()
33283330

33293331
@cached_property
33303332
def _wrapper_cache_key_(self):
33313333
return (self._key, )
33323334

33333335
def __init__(self, code, name, opts={}, include_dirs=[], headers=[],
3334-
user_code="", ldargs=None, cpp=False):
3336+
user_code="", ldargs=None, cpp=False, requires_zeroed_output_arguments=False):
33353337
# Protect against re-initialization when retrieved from cache
33363338
if self._initialized:
33373339
return
@@ -3346,6 +3348,7 @@ def __init__(self, code, name, opts={}, include_dirs=[], headers=[],
33463348
assert isinstance(code, (str, Node, loopy.Program, loopy.LoopKernel))
33473349
self._code = code
33483350
self._initialized = True
3351+
self.requires_zeroed_output_arguments = requires_zeroed_output_arguments
33493352

33503353
@property
33513354
def name(self):

0 commit comments

Comments
 (0)