@@ -3287,6 +3287,8 @@ class Kernel(Cached):
3287
3287
empty)
3288
3288
:param ldargs: A list of arguments to pass to the linker when
3289
3289
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)
3290
3292
:param cpp: Is the kernel actually C++ rather than C? If yes,
3291
3293
then compile with the C++ compiler (kernel is wrapped in
3292
3294
extern C for linkage reasons).
@@ -3309,7 +3311,7 @@ class Kernel(Cached):
3309
3311
@classmethod
3310
3312
@validate_type (('name' , str , NameTypeError ))
3311
3313
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 ):
3313
3315
# Both code and name are relevant since there might be multiple kernels
3314
3316
# extracting different functions from the same code
3315
3317
# 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=[],
3323
3325
code .update_persistent_hash (key_hash , LoopyKeyBuilder ())
3324
3326
code = key_hash .hexdigest ()
3325
3327
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 ) )
3327
3329
return md5 (hashee .encode ()).hexdigest ()
3328
3330
3329
3331
@cached_property
3330
3332
def _wrapper_cache_key_ (self ):
3331
3333
return (self ._key , )
3332
3334
3333
3335
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 ):
3335
3337
# Protect against re-initialization when retrieved from cache
3336
3338
if self ._initialized :
3337
3339
return
@@ -3346,6 +3348,7 @@ def __init__(self, code, name, opts={}, include_dirs=[], headers=[],
3346
3348
assert isinstance (code , (str , Node , loopy .Program , loopy .LoopKernel ))
3347
3349
self ._code = code
3348
3350
self ._initialized = True
3351
+ self .requires_zeroed_output_arguments = requires_zeroed_output_arguments
3349
3352
3350
3353
@property
3351
3354
def name (self ):
0 commit comments