def visit_IndexReduce(self, expr):
    bounds = self.tuple_to_var_list(expr.shape)
    n_vars = len(bounds)
    acc = self.fresh_var(expr.type, "acc", self.visit_expr(expr.init))
    # try to get a simple primitive to use as the OpenMP combiner
    # if this isn't possible then run the loops sequentially
    #
    # TODO: instead of falling back on sequential execution 
    # use complex combiners by generating one 
    # accumulator value per thread and then combining those
    combine_prim = self.get_binop_prim(expr.combine)
    if combine_prim is prims.add:
      omp_reduce_op = "+"
    elif combine_prim is prims.multiply:
      omp_reduce_op = "*"
    elif combine_prim is prims.logical_and:
      omp_reduce_op = "&&"
    elif combine_prim is prims.logical_or:
      omp_reduce_op = "||"
    else:
      omp_reduce_op = None 
 
    loop_vars = self.loop_vars(n_vars)
    assert expr.init is not None, "Accumulator required but not given"
    elt = self.fresh_var(return_type(expr.fn), "elt")
    if omp_reduce_op: self.enter_parfor()
    body, private_vars = self.build_loop_body(expr.fn, loop_vars, target_name = elt)
    if omp_reduce_op:
      body += "\n%s = %s %s %s;" % (acc, acc, omp_reduce_op, elt)
    else:
      combine_name, combine_closure_args, _ = self.get_fn_info(expr.combine)
      combine_arg_str = ", ".join(tuple(combine_closure_args) + (acc, elt))
      body += "\n%s = %s(%s);\n" % (acc, combine_name, combine_arg_str)
    loops = self.build_loops(loop_vars, bounds, body)
    if omp_reduce_op: 
      self.exit_parfor()

    if omp_reduce_op and self.depth == 0:
      release_gil = "\nPy_BEGIN_ALLOW_THREADS\n"
      acquire_gil = "\nPy_END_ALLOW_THREADS\n" 
      omp = self.omp_pragma(len(loop_vars), private_vars, 
                            reduce_op = omp_reduce_op, 
                            reduce_vars = [acc])
      loops = release_gil + omp + loops + acquire_gil    
    self.append(loops)
    return acc
Report that the given test succeeded.
dataset/ETHPy150Open iskandr/parakeet/parakeet/openmp_backend/multicore_compiler.py/MulticoreCompiler.visit_IndexReduce--crossover with--dataset/ETHPy150Open twisted/twisted/twisted/trial/reporter.py/TestResult.addSuccess