Skip to content
This repository was archived by the owner on Sep 27, 2021. It is now read-only.

Commit 580efd9

Browse files
committed
get ready for testing
1 parent 5fec458 commit 580efd9

File tree

2 files changed

+64
-6
lines changed

2 files changed

+64
-6
lines changed

REQUIRE

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,6 @@ Transpiler 0.3
1515
Sugar 0.3
1616
Matcha 0.0.2
1717

18-
CUDAnative 0.4.1 # llvm codegen fix
19-
CUDAdrv 0.5.1
20-
CUDArt 0.4.0 # for cuda c compiler support
21-
CUBLAS 0.2.0 # for CUDAdrv support
22-
CUFFT
23-
2418
OpenCL 0.6.0 #proper packed conversion
2519
CLBLAS 1.1.0
2620
CLFFT 0.4.0 # 0.5.0

test/runtests.jl

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,67 @@ GPUArrays.gpu_call(x, (x,)) do state, l
1212
l[1] = 1f0 ^ 1.0
1313
return
1414
end
15+
16+
17+
using ArrayFire
18+
19+
ArrayFire.set_backend(AF_BACKEND_OPENCL)
20+
21+
using CLArrays
22+
TY=Float32
23+
N = 2^9
24+
h = TY(2*π/N)
25+
epsn = TY(h * .5)
26+
C = TY(2/epsn)
27+
tau = TY(epsn * h)
28+
Tfinal = 50.
29+
30+
S(x,y) = exp(-x^2/0.1f0)*exp(-y^2/0.1f0)
31+
32+
# real-space and reciprocal-space grids
33+
# the real-space grid is just used for plotting!
34+
X_cpu = convert.(TY,collect(linspace(-pi+h, pi, N)) .* ones(1,N))
35+
X = CLArray(X_cpu);
36+
k = collect([0:N/2; -N/2+1:-1]);
37+
 = CLArray(convert.(TY,kron(k.^2, ones(1,N)) + kron(ones(N), k'.^2)));
38+
39+
# initial condition
40+
uc = TY(2.0)*(CLArray{TY}(rand(TY, (N, N)))-TY(0.5));
41+
42+
#################################################################
43+
#################################################################
44+
function take_step!(u, t_plot)
45+
uff = fft(u)
46+
uff1 = fft(u.^3f0-u)
47+
@. tmp1 = ((1f0+C*tau*Â) .* uff .- tau/epsn *.* uff1)) ./ (1f0+(epsn*tau)*Â.^2f0+C*tau*Â)
48+
u .= real.(ifft(tmp1))
49+
nothing
50+
end
51+
function normalise_af!(u,out)
52+
out .= u-minimum(u)
53+
out .= out / maximum(out)
54+
nothing
55+
end
56+
#################################################################
57+
#################################################################
58+
59+
T_plot = 0.01; t_plot = 0.0
60+
61+
62+
up = copy(uc)
63+
@time for n = 1:ceil(Tfinal / tau)
64+
@show n
65+
take_step!(uc, t_plot)
66+
t_plot += tau
67+
# f t_plot >= T_plot
68+
# # @show n
69+
# normalise_af!(uc,up)
70+
# draw_image(window_, up, Ref(ArrayFire.af_cell(0, 0, pointer(""), ArrayFire.AF_COLORMAP_HEAT)))
71+
# set_title(window_,"N = $N, n = $n, t = $(round(n*tau,4)), max = $(maximum(uc)) - min = $(minimum(uc))")
72+
# # set_axes_limits_3d(window_,-3.2f0,3.2f0,-3.2f0,-3.2f0,-2.3f0,2.0f0,true,Ref(ArrayFire.af_cell(0, 0, pointer(""), ArrayFire.AF_COLORMAP_HEAT)))
73+
# show(window_)
74+
# t_plot = 0.0
75+
# end
76+
end
77+
78+
print_mem_info("GPU-Mem apres loop", 0)

0 commit comments

Comments
 (0)