parameters: (self, equiv_set, lhs, args, loc)
return_statement: return parfor
docstring: Convert a reduce call to a parfor.
          The call arguments should be (call_name, array, init_value).
docstring_summary: Convert a reduce call to a parfor.
          The call arguments should be (call_name, array, init_value).
docstring_tokens: Convert a reduce call to a parfor . The call arguments should be ( call_name array init_value ) .
function: def _reduce_to_parfor(self, equiv_set, lhs, args, loc):
          """
          Convert a reduce call to a parfor.
          The call arguments should be (call_name, array, init_value).
          """
          scope = lhs.scope
          call_name = args[0]
          in_arr = args[1]
          arr_def = get_definition(self.func_ir, in_arr.name)
  
          mask_var = None
          mask_indices = None
          result = guard(self._find_mask, arr_def)
          if result:
              in_arr, mask_var, mask_typ, mask_indices = result
  
          init_val = args[2]
          size_vars = equiv_set.get_shape(in_arr if mask_indices == None else mask_var)
          index_vars, loopnests = self._mk_parfor_loops(size_vars, scope, loc)
          mask_index = index_vars
          if mask_indices:
              index_vars = tuple(x if x else index_vars[0] for x in mask_indices)
          acc_var = lhs
  
          # init block has to init the reduction variable
          init_block = ir.Block(scope, loc)
          init_block.body.append(ir.Assign(init_val, acc_var, loc))
  
          # produce loop body
          body_label = next_label()
          index_var, loop_body = self._mk_reduction_body(call_name,
                                  scope, loc, index_vars, in_arr, acc_var)
          if mask_indices:
              index_var = mask_index[0]
  
          if mask_var != None:
              true_label = min(loop_body.keys())
              false_label = max(loop_body.keys())
              body_block = ir.Block(scope, loc)
              loop_body[body_label] = body_block
              mask = ir.Var(scope, mk_unique_var("$mask_val"), loc)
              self.typemap[mask.name] = mask_typ
              mask_val = ir.Expr.getitem(mask_var, index_var, loc)
              body_block.body.extend([
                 ir.Assign(mask_val, mask, loc),
                 ir.Branch(mask, true_label, false_label, loc)
              ])
  
          parfor = Parfor(loopnests, init_block, loop_body, loc, index_var,
                          equiv_set, ('{} function'.format(call_name),
                                      'reduction'), self.flags)
          return parfor
function_tokens: def _reduce_to_parfor ( self , equiv_set , lhs , args , loc ) : scope = lhs . scope call_name = args [ 0 ] in_arr = args [ 1 ] arr_def = get_definition ( self . func_ir , in_arr . name ) mask_var = None mask_indices = None result = guard ( self . _find_mask , arr_def ) if result : in_arr , mask_var , mask_typ , mask_indices = result init_val = args [ 2 ] size_vars = equiv_set . get_shape ( in_arr if mask_indices == None else mask_var ) index_vars , loopnests = self . _mk_parfor_loops ( size_vars , scope , loc ) mask_index = index_vars if mask_indices : index_vars = tuple ( x if x else index_vars [ 0 ] for x in mask_indices ) acc_var = lhs # init block has to init the reduction variable init_block = ir . Block ( scope , loc ) init_block . body . append ( ir . Assign ( init_val , acc_var , loc ) ) # produce loop body body_label = next_label ( ) index_var , loop_body = self . _mk_reduction_body ( call_name , scope , loc , index_vars , in_arr , acc_var ) if mask_indices : index_var = mask_index [ 0 ] if mask_var != None : true_label = min ( loop_body . keys ( ) ) false_label = max ( loop_body . keys ( ) ) body_block = ir . Block ( scope , loc ) loop_body [ body_label ] = body_block mask = ir . Var ( scope , mk_unique_var ( "$mask_val" ) , loc ) self . typemap [ mask . name ] = mask_typ mask_val = ir . Expr . getitem ( mask_var , index_var , loc ) body_block . body . extend ( [ ir . Assign ( mask_val , mask , loc ) , ir . Branch ( mask , true_label , false_label , loc ) ] ) parfor = Parfor ( loopnests , init_block , loop_body , loc , index_var , equiv_set , ( '{} function' . format ( call_name ) , 'reduction' ) , self . flags ) return parfor