class_docstr: .. warning::
  
      This class is deprecated, to be removed in PyOpenCL 2018.x.
  
  .. versionadded:: 2011.2
  
  .. attribute:: state
  
      A :class:`pyopencl.array.Array` containing the state of the generator.
  
  .. attribute:: nskip
  
      nskip is an integer which can (optionally) be defined in the kernel
      code as RANLUXCL_NSKIP. If this is done the generator will be faster
      for luxury setting 0 and 1, or when the p-value is manually set to a
      multiple of 24.
class_docstr_tok: ["..","warning",":",":","This","class","is","deprecated",",","to","be","removed","in","PyOpenCL","2018.x",".","..","versionadded",":",":","2011.2","..","attribute",":",":","state","A",":","class",":","`","pyopencl.array.Array","`","containing","the","state","of","the","generator",".","..","attribute",":",":","nskip","nskip","is","an","integer","which","can","(","optionally",")","be","defined","in","the","kernel","code","as","RANLUXCL_NSKIP",".","If","this","is","done","the","generator","will","be","faster","for","luxury","setting","0","and","1",",","or","when","the","p-value","is","manually","set","to","a","multiple","of","24","."]
code: def get_gen_kernel(self, dtype, distribution="uniform"):
      size_multiplier = 1
      arg_dtype = dtype
  
      if dtype == np.float64:
          bits = 64
          c_type = "double"
          rng_expr = "(shift + scale * gen)"
      elif dtype == np.float32:
          bits = 32
          c_type = "float"
          rng_expr = "(shift + scale * gen)"
      elif dtype == cltypes.float2:
          bits = 32
          c_type = "float"
          rng_expr = "(shift + scale * gen)"
          size_multiplier = 2
          arg_dtype = np.float32
      elif dtype in [cltypes.float3, cltypes.float4]:
          bits = 32
          c_type = "float"
          rng_expr = "(shift + scale * gen)"
          size_multiplier = 4
          arg_dtype = np.float32
      elif dtype == np.int32:
          assert distribution == "uniform"
          bits = 32
          c_type = "int"
          rng_expr = (
              "(shift "
              "+ convert_int4((float) scale * gen) "
              "+ convert_int4(((float) scale / (1<<24)) * gen))"
          )
  
      elif dtype == np.int64:
          assert distribution == "uniform"
          if self.support_double:
              bits = 64
          else:
              bits = 32
          c_type = "long"
          rng_expr = (
              "(shift "
              "+ convert_long4((float) scale * gen) "
              "+ convert_long4(((float) scale / (1l<<24)) * gen)"
              "+ convert_long4(((float) scale / (1l<<48)) * gen)"
              ")"
          )
  
      else:
          raise TypeError("unsupported RNG data type '%s'" % dtype)
  
      rl_flavor = "%d%s" % (
          bits,
          {"uniform": "", "normal": "norm"}[distribution],
      )
  
      src = """//CL//
              %(defines)s
  
              #include <pyopencl-ranluxcl.cl>
  
              typedef %(output_t)s output_t;
              typedef %(output_t)s4 output_vec_t;
              #define NUM_WORKITEMS %(num_work_items)d
              #define RANLUX_FUNC ranluxcl%(rlflavor)s
              #define GET_RANDOM_NUM(gen) %(rng_expr)s
  
              kernel void generate(
                  global ranluxcl_state_t *ranluxcltab,
                  global output_t *output,
                  unsigned long out_size,
                  output_t scale,
                  output_t shift)
              {
  
                ranluxcl_state_t ranluxclstate;
                ranluxcl_download_seed(&ranluxclstate, ranluxcltab);
  
                // output bulk
                unsigned long idx = get_global_id(0)*4;
                while (idx + 4 < out_size)
                {
                    output_vec_t ran = GET_RANDOM_NUM(RANLUX_FUNC(&ranluxclstate));
                    vstore4(ran, 0, &output[idx]);
                    idx += 4*NUM_WORKITEMS;
                }
  
                // output tail
                output_vec_t tail_ran = GET_RANDOM_NUM(RANLUX_FUNC(&ranluxclstate));
                if (idx < out_size)
                  output[idx] = tail_ran.x;
                if (idx+1 < out_size)
                  output[idx+1] = tail_ran.y;
                if (idx+2 < out_size)
                  output[idx+2] = tail_ran.z;
                if (idx+3 < out_size)
                  output[idx+3] = tail_ran.w;
  
                ranluxcl_upload_seed(&ranluxclstate, ranluxcltab);
              }
              """ % {
          "defines": self.generate_settings_defines(),
          "rlflavor": rl_flavor,
          "output_t": c_type,
          "num_work_items": self.num_work_items,
          "rng_expr": rng_expr,
      }
  
      prg = cl.Program(self.context, src).build()
      knl = prg.generate
      knl.set_scalar_arg_dtypes(
          [None, None, np.uint64, arg_dtype, arg_dtype]
      )
  
      return knl, size_multiplier
  
imports: import pyopencl
  import pyopencl.array
  import pyopencl.cltypes
  from pyopencl.tools import first_arg_dependent_memoize
  from pytools import memoize_method
  import numpy
label_desc: Use image node_id 3 for calling the RanluxGenerator obj's underlying member method code with example usage: obj.get_gen_kernel(dtype, distribution) and returns: knl,  size_multiplier