code: def test_struct_reduce(ctx_factory):
      pytest.importorskip("mako")
  
      context = ctx_factory()
      queue = cl.CommandQueue(context)
  
      (dev,) = context.devices
      if (
          dev.vendor == "NVIDIA"
          and dev.platform.vendor == "Apple"
          and dev.driver_version == "8.12.47 310.40.00.05f01"
      ):
          pytest.skip("causes a compiler hang on Apple/Nv GPU")
  
      mmc_dtype, mmc_c_decl = make_mmc_dtype(context.devices[0])
  
      preamble = (
          mmc_c_decl
          + r"""//CL//
  
      minmax_collector mmc_neutral()
      {
          // FIXME: needs infinity literal in real use, ok here
          minmax_collector result;
          result.cur_min = 1<<30;
          result.cur_max = -(1<<30);
          return result;
      }
  
      minmax_collector mmc_from_scalar(float x)
      {
          minmax_collector result;
          result.cur_min = x;
          result.cur_max = x;
          return result;
      }
  
      minmax_collector agg_mmc(minmax_collector a, minmax_collector b)
      {
          minmax_collector result = a;
          if (b.cur_min < result.cur_min)
              result.cur_min = b.cur_min;
          if (b.cur_max > result.cur_max)
              result.cur_max = b.cur_max;
          return result;
      }
  
      """
      )
  
      from pyopencl.clrandom import rand as clrand
  
      a_gpu = clrand(queue, (20000,), dtype=np.int32, a=0, b=10**6)
      a = a_gpu.get()
  
      from pyopencl.reduction import ReductionKernel
  
      red = ReductionKernel(
          context,
          mmc_dtype,
          neutral="mmc_neutral()",
          reduce_expr="agg_mmc(a, b)",
          map_expr="mmc_from_scalar(x[i])",
          arguments="__global int *x",
          preamble=preamble,
      )
  
      minmax = red(a_gpu).get()
      # print minmax["cur_min"], minmax["cur_max"]
      # print np.min(a), np.max(a)
  
      assert abs(minmax["cur_min"] - np.min(a)) < 1e-5
      assert abs(minmax["cur_max"] - np.max(a)) < 1e-5
  
imports: import numpy
  import numpy.linalg
  import sys
  from pytools import memoize
  from test_array import general_clrand
  import pytest
  import pyopencl
  import pyopencl.array
  from pyopencl.tools import pytest_generate_tests_for_pyopencl
  from pyopencl.characterize import has_double_support, has_struct_arg_count_bug
  from pyopencl.scan import InclusiveScanKernel, ExclusiveScanKernel, GenericScanKernel, GenericDebugScanKernel
  from pyopencl.characterize import get_pocl_version
label_desc: Use image node_id 17 for calling a global function with example usage: test_struct_reduce(ctx_factory) without return types