@@ -4024,7 +4024,7 @@ def __init__(self, kernel, iterset, *args, **kwargs):
4024
4024
if arg ._is_dat and arg .access not in [INC , READ , WRITE ]:
4025
4025
raise RuntimeError ("Iteration over a LocalSet does not make sense for RW args" )
4026
4026
4027
- self ._it_space = self . build_itspace (iterset )
4027
+ self ._it_space = build_itspace (self . args , iterset )
4028
4028
4029
4029
# Attach semantic information to the kernel's AST
4030
4030
# Only need to do this once, since the kernel "defines" the
@@ -4183,52 +4183,6 @@ def update_arg_data_state(self):
4183
4183
if arg ._is_mat :
4184
4184
arg .data ._needs_assembly = True
4185
4185
4186
- def build_itspace (self , iterset ):
4187
- """Checks that the iteration set of the :class:`ParLoop` matches the
4188
- iteration set of all its arguments. A :class:`MapValueError` is raised
4189
- if this condition is not met.
4190
-
4191
- Also determines the size of the local iteration space and checks all
4192
- arguments using an :class:`IterationIndex` for consistency.
4193
-
4194
- :return: class:`IterationSpace` for this :class:`ParLoop`"""
4195
-
4196
- if isinstance (iterset , (LocalSet , Subset )):
4197
- _iterset = iterset .superset
4198
- else :
4199
- _iterset = iterset
4200
- block_shape = None
4201
- if configuration ["type_check" ]:
4202
- if isinstance (_iterset , MixedSet ):
4203
- raise SetTypeError ("Cannot iterate over MixedSets" )
4204
- for i , arg in enumerate (self .args ):
4205
- if arg ._is_global :
4206
- continue
4207
- if arg ._is_direct :
4208
- if arg .data .dataset .set != _iterset :
4209
- raise MapValueError (
4210
- "Iterset of direct arg %s doesn't match ParLoop iterset." % i )
4211
- continue
4212
- for j , m in enumerate (arg ._map ):
4213
- if isinstance (_iterset , ExtrudedSet ):
4214
- if m .iterset != _iterset and m .iterset not in _iterset :
4215
- raise MapValueError (
4216
- "Iterset of arg %s map %s doesn't match ParLoop iterset." % (i , j ))
4217
- elif m .iterset != _iterset and m .iterset not in _iterset :
4218
- raise MapValueError (
4219
- "Iterset of arg %s map %s doesn't match ParLoop iterset." % (i , j ))
4220
- if arg ._uses_itspace :
4221
- _block_shape = arg ._block_shape
4222
- if block_shape and block_shape != _block_shape :
4223
- raise IndexValueError ("Mismatching iteration space size for argument %d" % i )
4224
- block_shape = _block_shape
4225
- else :
4226
- for arg in self .args :
4227
- if arg ._uses_itspace :
4228
- block_shape = arg ._block_shape
4229
- break
4230
- return IterationSpace (iterset , block_shape )
4231
-
4232
4186
@cached_property
4233
4187
def dat_args (self ):
4234
4188
return [arg for arg in self .args if arg ._is_dat ]
@@ -4296,6 +4250,57 @@ def iteration_region(self):
4296
4250
interior facets."""
4297
4251
return self ._iteration_region
4298
4252
4253
+
4254
+ def build_itspace (args , iterset ):
4255
+ """Creates an class:`IterationSpace` for the :class:`ParLoop` from the
4256
+ given iteration set.
4257
+
4258
+ Also checks that the iteration set of the :class:`ParLoop` matches the
4259
+ iteration set of all its arguments. A :class:`MapValueError` is raised
4260
+ if this condition is not met.
4261
+
4262
+ Also determines the size of the local iteration space and checks all
4263
+ arguments using an :class:`IterationIndex` for consistency.
4264
+
4265
+ :return: class:`IterationSpace` for this :class:`ParLoop`"""
4266
+
4267
+ if isinstance (iterset , (LocalSet , Subset )):
4268
+ _iterset = iterset .superset
4269
+ else :
4270
+ _iterset = iterset
4271
+ block_shape = None
4272
+ if configuration ["type_check" ]:
4273
+ if isinstance (_iterset , MixedSet ):
4274
+ raise SetTypeError ("Cannot iterate over MixedSets" )
4275
+ for i , arg in enumerate (args ):
4276
+ if arg ._is_global :
4277
+ continue
4278
+ if arg ._is_direct :
4279
+ if arg .data .dataset .set != _iterset :
4280
+ raise MapValueError (
4281
+ "Iterset of direct arg %s doesn't match ParLoop iterset." % i )
4282
+ continue
4283
+ for j , m in enumerate (arg ._map ):
4284
+ if isinstance (_iterset , ExtrudedSet ):
4285
+ if m .iterset != _iterset and m .iterset not in _iterset :
4286
+ raise MapValueError (
4287
+ "Iterset of arg %s map %s doesn't match ParLoop iterset." % (i , j ))
4288
+ elif m .iterset != _iterset and m .iterset not in _iterset :
4289
+ raise MapValueError (
4290
+ "Iterset of arg %s map %s doesn't match ParLoop iterset." % (i , j ))
4291
+ if arg ._uses_itspace :
4292
+ _block_shape = arg ._block_shape
4293
+ if block_shape and block_shape != _block_shape :
4294
+ raise IndexValueError ("Mismatching iteration space size for argument %d" % i )
4295
+ block_shape = _block_shape
4296
+ else :
4297
+ for arg in args :
4298
+ if arg ._uses_itspace :
4299
+ block_shape = arg ._block_shape
4300
+ break
4301
+ return IterationSpace (iterset , block_shape )
4302
+
4303
+
4299
4304
DEFAULT_SOLVER_PARAMETERS = {'ksp_type' : 'cg' ,
4300
4305
'pc_type' : 'jacobi' ,
4301
4306
'ksp_rtol' : 1.0e-7 ,
0 commit comments