def _convolve_buf(data_g, h_g, res_g=None):
    """
    buffer variant
    """
    assert_bufs_type(np.float32, data_g, h_g)

    prog = OCLProgram(abspath("kernels/convolve.cl"))

    if res_g is None:
        res_g = OCLArray.empty(data_g.shape, dtype=np.float32)

    Nhs = [np.int32(n) for n in h_g.shape]

    kernel_name = "convolve%sd_buf" % (len(data_g.shape))


    try:
        prog.run_kernel(kernel_name, data_g.shape[::-1], None,
                        data_g.data, h_g.data, res_g.data,
                        *Nhs)

    except cl.cffi_cl.LogicError as e:
        # this catches the logic error if the kernel is to big for constant memory
        if e.code == -52:
            kernel_name = "convolve%sd_buf_global" % (len(data_g.shape))
            prog.run_kernel(kernel_name, data_g.shape[::-1], None,
                            data_g.data, h_g.data, res_g.data,
                            *Nhs)

        else:
            raise e
    except cl.cffi_cl.RuntimeError as e:
        # this catches the runtime error if the kernel is to big for constant memory
        if e.code == -5:
            kernel_name = "convolve%sd_buf_global" % (len(data_g.shape))
            prog.run_kernel(kernel_name, data_g.shape[::-1], None,
                            data_g.data, h_g.data, res_g.data,
                            *Nhs)

        else:
            raise e




    return res_g
buffer variant