Smolaa
Pseudokod za jacobija može biti ovakav:
kernel void jacobi_step(psi, psinew, m, n, threadcount, psi_size):
id = get_global_id(0)
repeats = (int)ceil((float)(m * n) / threadcount)
for (int iter = 0; iter < repeats; iter++)
number = id + iter * thread_count
if (number >= psi_size)
break
i = (number % m) + 1
j = ((number / m) % n) + 1
psinew[i * (m + 2) + j] = 0.25 * (psi[(i - 1) * (m + 2) + j] + psi[(i + 1) * (m + 2) + j] + psi[i * (m + 2) + j - 1] + psi[i * (m + 2) + j + 1])
return
Za buffere se može stavit CL_MEM_READ_WRITE | CL_MEM_COPY_HOST_PTR
radi jednostavnosti i veličinu (m+2) * (n+2) * sizeof(double) za varijable psi i psitmp.