@@ -403,8 +403,11 @@ def generate_buffers(clusters, key, sregistry, options, **kwargs):
403403 # Finally create the actual buffer
404404 cls = callback or Array
405405 name = sregistry .make_name (prefix = '%sb' % f .name )
406+ # We specify the padding to match the input Function's one, so that
407+ # the array can be used in place of the Function with valid strides
406408 mapper [f ] = cls (name = name , dimensions = dimensions , dtype = f .dtype ,
407- grid = f .grid , halo = f .halo , space = 'mapped' , mapped = f , f = f )
409+ padding = f .padding , grid = f .grid , halo = f .halo ,
410+ space = 'mapped' , mapped = f , f = f )
408411
409412 return mapper
410413
@@ -440,7 +443,19 @@ def __init__(self, f, b, clusters):
440443 # NOTE: The `key` is to avoid Clusters including `f` but not directly
441444 # using it in an expression, such as HaloTouch Clusters
442445 key = lambda c : any (i in c .ispace .dimensions for i in self .bdims )
443- ispaces = {c .ispace for c in clusters if key (c )}
446+ ispaces = set ()
447+ for c in clusters :
448+ if not key (c ):
449+ continue
450+
451+ # Iterations space and buffering dims
452+ ispace = c .ispace
453+ edims = [d for d in self .bdims if d not in ispace .dimensions ]
454+ if not edims :
455+ ispaces .add (ispace )
456+ else :
457+ # Add all missing buffering dimensions
458+ ispaces .add (ispace .insert (self .dim , edims ))
444459
445460 if len (ispaces ) > 1 :
446461 # Best effort to make buffering work in the presence of multiple
0 commit comments