Commit 7c8ba864 authored by helluy's avatar helluy

this case works on nvidia but not with a larger mesh

parent 2c9cf8f6
......@@ -25,8 +25,8 @@ _n = 4 * _m
_ivplot = 0
# grid size
_nx = 256
_ny = 256
_nx = 1024
_ny = 1024
_Lx = 1
_Ly = 1
......@@ -43,7 +43,7 @@ _Tmax = 2.
def solve_ocl(m = _m, n = _n, nx = _nx, ny = _ny,
Tmax = _Tmax,
Lx = _Lx, Ly = _Ly,
animate = False,
animate = True,
interactive=True,
precision="single"):
......@@ -94,8 +94,7 @@ def solve_ocl(m = _m, n = _n, nx = _nx, ny = _ny,
mf = cl.mem_flags
# compile OpenCL C program
prg = cl.Program(ctx, source).build(options = "-cl-strict-aliasing \
-cl-fast-relaxed-math")
prg = cl.Program(ctx, source).build(options = "")
# create OpenCL buffers
fn_gpu = cl.Buffer(ctx, mf.READ_WRITE,
......@@ -111,6 +110,9 @@ def solve_ocl(m = _m, n = _n, nx = _nx, ny = _ny,
event = prg.init_sol(queue, (nx * ny, ), (32, ), fn_gpu)
event.wait()
event = prg.init_sol(queue, (nx * ny, ), (32, ), fnp1_gpu)
event.wait()
# number of animation frames
nbplots = 100
itermax = int(np.floor(Tmax / dt))
......@@ -130,7 +132,6 @@ def solve_ocl(m = _m, n = _n, nx = _nx, ny = _ny,
print("start OpenCL computations...")
while t < Tmax:
t = t + dt
iter = iter + 1
#event = prg.time_step(queue, (nx * ny, ), (32, ), wn_gpu, wnp1_gpu)
event = prg.time_step(queue, (nx * ny, ), (64, ), fn_gpu, fnp1_gpu)
#event = prg.time_step(queue, (nx * ny, ), (32, ), wn_gpu, wnp1_gpu, wait_for = [event])
......@@ -153,6 +154,8 @@ def solve_ocl(m = _m, n = _n, nx = _nx, ny = _ny,
else:
print(title, end='\r')
iter = iter + 1
# copy OpenCL data to CPU and return the results
cl.enqueue_copy(queue, fn_cpu, fn_gpu).wait()
......@@ -162,7 +165,7 @@ def solve_ocl(m = _m, n = _n, nx = _nx, ny = _ny,
if __name__ == '__main__':
# gpu solve
wplot_gpu = solve_ocl(animate=False)
wplot_gpu = solve_ocl()
#print(np.sum(wplot_gpu[:, _ivplot, :, :],axis=0))
plt.clf()
#plt.imshow(np.sum(wplot_gpu[:, _ivplot, :, :],axis=0), vmin=0, vmax=1)
......
#pragma OPENCL EXTENSION cl_khr_fp64 : enable
//#pragma OPENCL EXTENSION cl_khr_fp64 : enable
#define real _real_
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment