Skip to content
Snippets Groups Projects
Commit e5c4caa3 authored by xiyehu2's avatar xiyehu2
Browse files

CPU only run

parent 9f69bc02
No related branches found
No related tags found
No related merge requests found
......@@ -25,7 +25,7 @@ def count(paths, path_table, off):
data = np.load("table/table-half_31_120722.npz", allow_pickle=True)
table = data['table'].item()
_table = data['table'].item()
twzr = data['wfm'].item()
static_sig = data['static_sig']
target = data['target']
......@@ -33,19 +33,22 @@ t_idx = np.nonzero(target)[0]
nt = twzr.omega.size
_table_cp = {}
for key in table:
_table_cp[key] = cp.array(table[key])
# _sig = np.copy(static_sig)
for key in _table:
_table_cp[key] = cp.array(_table[key])
n_repeat = 500
total_t = np.zeros((nt+1, 2))
gpu_t = np.zeros((nt+1, 2))
cpu_t = np.zeros((nt+1, 2))
times = {
'total_t': np.zeros((nt + 1, 2)),
'gpu_t': np.zeros((nt + 1, 2)),
'cpu_t': np.zeros((nt + 1, 2))
}
filling_ratio = np.zeros((nt+1, 2))
n_move = np.zeros((nt+1, 2))
for i in range(nt+1):
_sig = cp.array(static_sig)
# _sig = cp.array(static_sig)
_sig = np.copy(static_sig)
f_prob = i/nt
t_t = np.zeros(n_repeat)
g_t = np.zeros(n_repeat)
......@@ -54,11 +57,12 @@ for i in range(nt+1):
nm = np.zeros(n_repeat)
print(i, f_prob)
for j in range(n_repeat):
filled = np.random.rand(nt)
tr = filled < f_prob
fa = filled >= f_prob
filled[tr] = 1
filled[fa] = 0
# filled = np.random.rand(nt)
# tr = filled < f_prob
# fa = filled >= f_prob
# filled[tr] = 1
# filled[fa] = 0
filled = np.random.binomial(1, f_prob, nt)
f_idx = np.nonzero(filled)[0]
b = benchmark(
test,
......@@ -75,21 +79,18 @@ for i in range(nt+1):
n_move[i,0] = np.mean(nm)
n_move[i,1] = np.var(nm)
gpu_t[i,0] = np.mean(g_t)
gpu_t[i,1] = np.var(g_t)
cpu_t[i,0] = np.mean(c_t)
cpu_t[i,1] = np.var(c_t)
total_t[i,0] = np.mean(t_t)
total_t[i,1] = np.var(t_t)
times['gpu_t'][i,0] = np.mean(g_t)
times['gpu_t'][i,1] = np.var(g_t)
times['cpu_t'][i,0] = np.mean(c_t)
times['cpu_t'][i,1] = np.var(c_t)
times['total_t'][i,0] = np.mean(t_t)
times['total_t'][i,1] = np.var(t_t)
filling_ratio[i,0] = np.mean(ratio)
filling_ratio[i,1] = np.var(ratio)
times = {}
times['gpu_t'] = gpu_t
times['cpu_t'] = cpu_t
times['total_t'] = total_t
np.savez(
f"data/120722_benchmark_{nt}-half_wfm-and-transfer.npz",
f"data/120822_{nt}-half_wfm-and-transfer_CPU.npz",
wfm=twzr,
target=target,
filling_ratio=filling_ratio,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment