def is_foldable(nodes): """ Return True if the iterable ``nodes`` consists of foldable Iterations, False otherwise. """ nodes = as_tuple(nodes) if len(nodes) <= 1 or any(not i.is_Iteration for i in nodes): return False if not all({PARALLEL, AFFINE}.issubset(set(i.properties)) for i in nodes): return False return (all_equal(i.dim for i in nodes) and all_equal(i.limits for i in nodes) and all_equal(i.index for i in nodes))
def config_blockshape(ctx, param, value): if value: # Block innermost loops if a full block shape is provided configuration['dle-options']['blockinner'] = True # Normalize value: # 1. integers, not strings # 2. sanity check the (hierarchical) blocking shape normalized_value = [] for i, block_shape in enumerate(value): # If hierarchical blocking is activated, say with N levels, here in # `bs` we expect to see 3*N entries bs = [int(x) for x in block_shape.split()] levels = [bs[x:x + 3] for x in range(0, len(bs), 3)] if any(len(level) != 3 for level in levels): raise ValueError( "Expected 3 entries per block shape level, but got " "one level with less than 3 entries (`%s`)" % levels) normalized_value.append(levels) if not all_equal(len(i) for i in normalized_value): raise ValueError( "Found different block shapes with incompatible " "number of levels (`%s`)" % normalized_value) configuration['dle-options']['blocklevels'] = len( normalized_value[0]) else: normalized_value = [] return tuple(normalized_value)
def config_blockshape(ctx, param, value): if value: # Block innermost loops if a full block shape is provided # Note: see https://github.com/devitocodes/devito/issues/320 for why # we use blockinner=True only if the backend compiler is Intel flag = isinstance(configuration['compiler'], IntelCompiler) configuration['opt-options']['blockinner'] = flag # Normalize value: # 1. integers, not strings # 2. sanity check the (hierarchical) blocking shape normalized_value = [] for i, block_shape in enumerate(value): # If hierarchical blocking is activated, say with N levels, here in # `bs` we expect to see 3*N entries bs = [int(x) for x in block_shape.split()] levels = [bs[x:x + 3] for x in range(0, len(bs), 3)] if any(len(level) != 3 for level in levels): raise ValueError( "Expected 3 entries per block shape level, but got " "one level with less than 3 entries (`%s`)" % levels) normalized_value.append(levels) if not all_equal(len(i) for i in normalized_value): raise ValueError( "Found different block shapes with incompatible " "number of levels (`%s`)" % normalized_value) configuration['opt-options']['blocklevels'] = len( normalized_value[0]) else: normalized_value = [] return tuple(normalized_value)
def homogenise_gpus(gpu_infos): if gpu_infos == []: warning('No graphics cards detected') return None if all_equal(gpu_infos): gpu_infos[0]['ncards'] = len(gpu_infos) return gpu_infos[0] warning('Different models of graphics cards detected') return None
def homogenise_gpus(gpu_infos): if gpu_infos == []: warning('No graphics cards detected') return {} # Check must ignore physical IDs as they may differ for gpu_info in gpu_infos: gpu_info.pop('physicalid', None) if all_equal(gpu_infos): gpu_infos[0]['ncards'] = len(gpu_infos) return gpu_infos[0] warning('Different models of graphics cards detected') return {}
def homogenise_gpus(gpu_infos): """ Run homogeneity checks on a list of GPUs, return GPU with count if homogeneous, otherwise None. """ if gpu_infos == []: warning('No graphics cards detected') return {} # Check must ignore physical IDs as they may differ for gpu_info in gpu_infos: gpu_info.pop('physicalid', None) if all_equal(gpu_infos): gpu_infos[0]['ncards'] = len(gpu_infos) return gpu_infos[0] warning('Different models of graphics cards detected') return {}