Ejemplo n.º 1
0
def run_timings(k, mean=0, sd=1, a=-2, b=2, seed=101):
    n = 10**k
    mean = np.ones(n) * mean
    sd = np.ones(n) * sd
    a = np.ones(n) * a
    b = np.ones(n) * b

    start = cuda.Event()
    end = cuda.Event()

    gpu_curand_init(seed)
    start.record()
    gpu_trunc_norm(n, mean, sd, a, b)
    end.record()
    end.synchronize()
    gpu_time = start.time_till(end) * 1e-3
    gpu_curand_deinit()

    set_seed(seed)
    start.record()
    cpu_trunc_norm(n, mean, sd, a, b)
    end.record()
    end.synchronize()
    cpu_time = start.time_till(end) * 1e-3

    return (gpu_time, cpu_time)
Ejemplo n.º 2
0
def run_timings(k, mean = 0, sd = 1, a = -2, b = 2, seed = 101):
    n = 10 ** k
    mean = np.ones(n) * mean
    sd = np.ones(n) * sd
    a = np.ones(n) * a
    b = np.ones(n) * b

    start = cuda.Event()
    end = cuda.Event()

    gpu_curand_init(seed)
    start.record()
    gpu_trunc_norm(n, mean, sd, a, b)
    end.record()
    end.synchronize()
    gpu_time = start.time_till(end) * 1e-3
    gpu_curand_deinit()

    set_seed(seed)
    start.record()
    cpu_trunc_norm(n, mean, sd, a, b)
    end.record()
    end.synchronize()
    cpu_time = start.time_till(end) * 1e-3

    return (gpu_time, cpu_time)
Ejemplo n.º 3
0
def run_diagnostics(n, mean=0, sd=1, a=-2, b=2, seed=101):
    true_mean = trunc_norm_mean(mean, sd, a, b)

    mean = np.ones(n) * mean
    sd = np.ones(n) * sd
    a = np.ones(n) * a
    b = np.ones(n) * b

    gpu_curand_init(seed)
    gpu_mean = np.mean(gpu_trunc_norm(n, mean, sd, a, b))
    gpu_curand_deinit()

    set_seed(seed)
    cpu_mean = np.mean(cpu_trunc_norm(n, mean, sd, a, b))

    return (gpu_mean, cpu_mean, true_mean)
Ejemplo n.º 4
0
def run_diagnostics(n, mean = 0, sd = 1, a = -2, b = 2, seed = 101):
    true_mean = trunc_norm_mean(mean, sd, a, b)

    mean = np.ones(n) * mean
    sd = np.ones(n) * sd
    a = np.ones(n) * a
    b = np.ones(n) * b

    gpu_curand_init(seed)
    gpu_mean = np.mean(gpu_trunc_norm(n, mean, sd, a, b))
    gpu_curand_deinit()

    set_seed(seed)
    cpu_mean = np.mean(cpu_trunc_norm(n, mean, sd, a, b))

    return (gpu_mean, cpu_mean, true_mean)