def __init__(self, parent=None, topology_name="", loop_type=""): Loop.__init__(self, parent=parent, valid_loop_types=["inner", "outer"]) self.loop_type = loop_type if self._loop_type == "inner": self._variable_name = "i" elif self._loop_type == "outer": self._variable_name = "j"
def __init__(self, parent=None, loop_type=""): Loop.__init__(self, parent=parent, valid_loop_types=["", "colours", "colour"]) self.loop_type = loop_type # Work out the variable name from the loop type if self._loop_type == "colours": self._variable_name = "colour" elif self._loop_type == "colour": self._variable_name = "cell" else: self._variable_name = "cell"
def __init__(self, parent=None, topology_name="", loop_type=""): Loop.__init__(self, parent=parent, valid_loop_types=["inner", "outer"]) self.loop_type = loop_type if self._loop_type == "inner": self._variable_name = "i" elif self._loop_type == "outer": self._variable_name = "j" # Pre-initialise the Loop children # TODO: See issue #440 self.addchild(Literal("NOT_INITIALISED", parent=self)) # start self.addchild(Literal("NOT_INITIALISED", parent=self)) # stop self.addchild(Literal("1", parent=self)) # step self.addchild(Schedule(parent=self)) # loop body
def __init__(self, ast, parent=None): from fparser.two.Fortran2003 import Loop_Control Loop.__init__(self, parent=parent, valid_loop_types=VALID_LOOP_TYPES) NemoFparser2ASTProcessor.__init__(self) # Keep a ptr to the corresponding node in the AST self._ast = ast # Get the loop variable ctrl = walk_ast(ast.content, [Loop_Control]) # Second element of items member of Loop Control is itself a tuple # containing: # Loop variable, [start value expression, end value expression, step # expression] # Loop variable will be an instance of Fortran2003.Name loop_var = str(ctrl[0].items[1][0]) self._variable_name = str(loop_var) # Identify the type of loop if self._variable_name in NEMO_LOOP_TYPE_MAPPING: self.loop_type = NEMO_LOOP_TYPE_MAPPING[self._variable_name] else: self.loop_type = "unknown" # Get the loop limits. These are given in a list which is the second # element of a tuple which is itself the second element of the items # tuple: # (None, (Name('jk'), [Int_Literal_Constant('1', None), Name('jpk'), # Int_Literal_Constant('1', None)]), None) limits_list = ctrl[0].items[1][1] self._start = str(limits_list[0]) self._stop = str(limits_list[1]) if len(limits_list) == 3: self._step = str(limits_list[2]) else: # Default loop increment is 1 self._step = "1" # Is this loop body a kernel? if NemoKern.match(self._ast): self.addchild(NemoKern(self._ast, parent=self)) return # It's not - walk on down the AST... self.process_nodes(self, self._ast.content, self._ast)
def __init__(self, parent=None, loop_type=""): Loop.__init__(self, parent=parent, valid_loop_types=["", "colours", "colour"]) self.loop_type = loop_type # Work out the variable name from the loop type if self._loop_type == "colours": self._variable_name = "colour" elif self._loop_type == "colour": self._variable_name = "cell" else: self._variable_name = "cell" # Pre-initialise the Loop children # TODO: See issue #440 self.addchild(Literal("NOT_INITIALISED", parent=self)) # start self.addchild(Literal("NOT_INITIALISED", parent=self)) # stop self.addchild(Literal("1", parent=self)) # step self.addchild(Schedule(parent=self)) # loop body
def __init__(self, parent=None, topology_name="", loop_type=""): Loop.__init__(self, parent=parent, valid_loop_types=VALID_LOOP_TYPES) self.loop_type = loop_type # We set the loop variable name in the constructor so that it is # available when we're determining which vars should be OpenMP # PRIVATE (which is done *before* code generation is performed) if self.loop_type == "inner": self._variable_name = "i" elif self.loop_type == "outer": self._variable_name = "j" else: raise GenerationError( "Invalid loop type of '{0}'. Expected one of {1}".format( self._loop_type, VALID_LOOP_TYPES)) # Create a dictionary to simplify the business of looking-up # loop bounds self._bounds_lookup = {} for grid_offset in SUPPORTED_OFFSETS: self._bounds_lookup[grid_offset] = {} for gridpt_type in VALID_FIELD_GRID_TYPES: self._bounds_lookup[grid_offset][gridpt_type] = {} for itspace in VALID_ITERATES_OVER: self._bounds_lookup[grid_offset][gridpt_type][itspace] = {} # Loop bounds for a mesh with NE offset self._bounds_lookup['offset_ne']['ct']['all_pts'] = \ {'inner': {'start': "1", 'stop': "+1"}, 'outer': {'start': "1", 'stop': "+1"}} self._bounds_lookup['offset_ne']['ct']['internal_pts'] = \ {'inner': {'start': "2", 'stop': ""}, 'outer': {'start': "2", 'stop': ""}} self._bounds_lookup['offset_ne']['cu']['all_pts'] = \ {'inner': {'start': "1", 'stop': ""}, 'outer': {'start': "1", 'stop': "+1"}} self._bounds_lookup['offset_ne']['cu']['internal_pts'] = \ {'inner': {'start': "2", 'stop': "-1"}, 'outer': {'start': "2", 'stop': ""}} self._bounds_lookup['offset_ne']['cv']['all_pts'] = \ {'inner': {'start': "1", 'stop': "+1"}, 'outer': {'start': "1", 'stop': ""}} self._bounds_lookup['offset_ne']['cv']['internal_pts'] = \ {'inner': {'start': "2", 'stop': ""}, 'outer': {'start': "2", 'stop': "-1"}} self._bounds_lookup['offset_ne']['cf']['all_pts'] = \ {'inner': {'start': "1", 'stop': ""}, 'outer': {'start': "1", 'stop': ""}} self._bounds_lookup['offset_ne']['cf']['internal_pts'] = \ {'inner': {'start': "1", 'stop': "-1"}, 'outer': {'start': "1", 'stop': "-1"}} # Loop bounds for a mesh with SE offset self._bounds_lookup['offset_sw']['ct']['all_pts'] = \ {'inner': {'start': "1", 'stop': "+1"}, 'outer': {'start': "1", 'stop': "+1"}} self._bounds_lookup['offset_sw']['ct']['internal_pts'] = \ {'inner': {'start': "2", 'stop': ""}, 'outer': {'start': "2", 'stop': ""}} self._bounds_lookup['offset_sw']['cu']['all_pts'] = \ {'inner': {'start': "1", 'stop': "+1"}, 'outer': {'start': "1", 'stop': "+1"}} self._bounds_lookup['offset_sw']['cu']['internal_pts'] = \ {'inner': {'start': "2", 'stop': "+1"}, 'outer': {'start': "2", 'stop': ""}} self._bounds_lookup['offset_sw']['cv']['all_pts'] = \ {'inner': {'start': "1", 'stop': "+1"}, 'outer': {'start': "1", 'stop': "+1"}} self._bounds_lookup['offset_sw']['cv']['internal_pts'] = \ {'inner': {'start': "2", 'stop': ""}, 'outer': {'start': "2", 'stop': "+1"}} self._bounds_lookup['offset_sw']['cf']['all_pts'] = \ {'inner': {'start': "1", 'stop': "+1"}, 'outer': {'start': "1", 'stop': "+1"}} self._bounds_lookup['offset_sw']['cf']['internal_pts'] = \ {'inner': {'start': "2", 'stop': "+1"}, 'outer': {'start': "2", 'stop': "+1"}} # For offset 'any' for gridpt_type in VALID_FIELD_GRID_TYPES: for itspace in VALID_ITERATES_OVER: self._bounds_lookup['offset_any'][gridpt_type][itspace] = \ {'inner': {'start': "1", 'stop': ""}, 'outer': {'start': "1", 'stop': ""}} # For 'every' grid-point type for offset in SUPPORTED_OFFSETS: for itspace in VALID_ITERATES_OVER: self._bounds_lookup[offset]['every'][itspace] = \ {'inner': {'start': "1", 'stop': "+1"}, 'outer': {'start': "1", 'stop': "+1"}}
def __init__(self, ast, parent=None): Loop.__init__(self, parent=parent, valid_loop_types=VALID_LOOP_TYPES) # Keep a ptr to the corresponding node in the AST self._ast = ast
def __init__(self, ast, parent=None): # pylint: disable=super-init-not-called, non-parent-init-called valid_loop_types = Config.get().api_conf("nemo").get_valid_loop_types() Loop.__init__(self, parent=parent, valid_loop_types=valid_loop_types) # Keep a ptr to the corresponding node in the AST self._ast = ast
def __init__(self, parent=None, variable_name=''): valid_loop_types = Config.get().api_conf("nemo").get_valid_loop_types() Loop.__init__(self, parent=parent, variable_name=variable_name, valid_loop_types=valid_loop_types)