def METHOD_NAME(benchmark, mode, n, p, exp):
    if mode == 'numpy':
        # numpy promotes elements to int64
        state = np.random.RandomState([SEED])
        def f():
            return state.binomial(n, p)
    elif mode == 'LLVM':
        init_fun = pnlvm.LLVMBinaryFunction.get('__pnl_builtin_mt_rand_init')
        state = init_fun.byref_arg_types[0]()
        init_fun(state, SEED)
        gen_fun = pnlvm.LLVMBinaryFunction.get('__pnl_builtin_mt_rand_binomial')
        c_n = gen_fun.byref_arg_types[1](n)
        c_p = gen_fun.byref_arg_types[2](p)
        c_out = gen_fun.byref_arg_types[-1]()
        def f():
            gen_fun(state, c_n, c_p, c_out)
            return c_out.value
    elif mode == 'PTX':
        init_fun = pnlvm.LLVMBinaryFunction.get('__pnl_builtin_mt_rand_init')
        state_size = ctypes.sizeof(init_fun.byref_arg_types[0])
        gpu_state = pnlvm.jit_engine.pycuda.driver.mem_alloc(state_size)
        init_fun.cuda_call(gpu_state, np.int32(SEED))
        gen_fun = pnlvm.LLVMBinaryFunction.get('__pnl_builtin_mt_rand_binomial')
        gpu_n = pnlvm.jit_engine.pycuda.driver.In(np.array([n], dtype=np.dtype(gen_fun.byref_arg_types[1])))
        gpu_p = pnlvm.jit_engine.pycuda.driver.In(np.array([p], dtype=np.dtype(gen_fun.byref_arg_types[2])))
        out = np.array([0.0], dtype=np.dtype(gen_fun.byref_arg_types[3]))
        gpu_out = pnlvm.jit_engine.pycuda.driver.Out(out)
        def f():
            gen_fun.cuda_call(gpu_state, gpu_n, gpu_p, gpu_out)
            return out[0]
    else:
        assert False, "Unknown mode: {}".format(mode)
    res = [f() for _ in range(32)]
    res = int(''.join(str(x) for x in res), 2)
    assert res == exp[n - 1]
    benchmark(f)