Skip to content

Commit 46a205c

Browse files
Gray node limit
1 parent 5ab7814 commit 46a205c

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

pyqrackising/kernels.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ __kernel void gray(
925925
int i = get_global_id(0);
926926
const int max_i = get_global_size(0);
927927

928-
ulong theta_local[1024];
928+
ulong theta_local[2048];
929929
for (int b = 0; b < blocks; ++b) {
930930
theta_local[b] = theta[b];
931931
}

pyqrackising/maxcut_tfim_util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
class OpenCLContext:
1010
def __init__(self, a, b, g, d, e, f, c, q, i, j, k, l, m, n, o, p, x, y, z, w, s, t):
11+
self.GRAY_NODE_LIMIT = 131072
1112
self.MAX_GPU_PROC_ELEM = a
1213
self.IS_OPENCL_AVAILABLE = b
1314
self.work_group_size = g

pyqrackising/spin_glass_solver.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
dtype = opencl_context.dtype
1717
wgs = opencl_context.work_group_size
18+
gnl = opencl_context.GRAY_NODE_LIMIT
1819

1920

2021
@njit(parallel=True)
@@ -396,9 +397,7 @@ def spin_glass_solver(
396397

397398
local_work_group_size = min(wgs, n_qubits)
398399
global_work_group_size = n_qubits
399-
gray_work_group_size = opencl_context.MAX_GPU_PROC_ELEM
400400
opencl_args = setup_opencl(local_work_group_size, global_work_group_size, np.array([n_qubits, is_spin_glass, segment_size]))
401-
gray_args = setup_opencl(1, gray_work_group_size, np.array([n_qubits, is_spin_glass, (gray_iterations + gray_work_group_size - 1) // gray_work_group_size, segment_size]), True)
402401

403402
if is_segmented:
404403
single_bit_flips_kernel = opencl_context.single_bit_flips_segmented_kernel
@@ -409,6 +408,11 @@ def spin_glass_solver(
409408
double_bit_flips_kernel = opencl_context.double_bit_flips_kernel
410409
gray_kernel = opencl_context.gray_kernel
411410

411+
if n_qubits <= gnl:
412+
gray_work_group_size = opencl_context.MAX_GPU_PROC_ELEM
413+
gray_args = setup_opencl(1, gray_work_group_size, np.array([n_qubits, is_spin_glass, (gray_iterations + gray_work_group_size - 1) // gray_work_group_size, segment_size]), True)
414+
gray_kernel = opencl_context.gray_segmented_kernel if is_segmented else opencl_context.gray_kernel
415+
412416
thread_count = os.cpu_count() ** 2
413417
improved = True
414418
while improved:
@@ -438,7 +442,7 @@ def spin_glass_solver(
438442
improved = True
439443
continue
440444

441-
if is_opencl:
445+
if is_opencl and (n_qubits <= gnl):
442446
theta_buf_64 = make_best_theta_buf_64(best_theta)
443447
energy, state = run_gray_search_opencl(n_qubits, gray_kernel, max_energy, best_theta, theta_buf_64, G_m_buf, is_segmented, *gray_args)
444448
else:

0 commit comments

Comments
 (0)