|
1 |
| -using CLArrays |
2 |
| -using GPUArrays.TestSuite, Base.Test |
3 |
| -using GPUArrays: global_size |
4 |
| -using CUDAnative, CUDAdrv |
5 |
| -TestSuite.run_tests(CLArray) |
6 |
| - |
7 |
| -using CLArrays |
8 |
| - |
9 |
| -x = CLArray(rand(Float32, 10)) |
| 1 | +if ( |
| 2 | + get(ENV, "TRAVIS", "") == "true" || |
| 3 | + get(ENV, "APPVEYOR", "") == "true" || |
| 4 | + get(ENV, "CI", "") == "true" |
| 5 | + ) |
10 | 6 |
|
11 |
| -GPUArrays.gpu_call(x, (x,)) do state, l |
12 |
| - l[1] = 1f0 ^ 1.0 |
13 |
| - return |
| 7 | + Pkg.checkout("Transpiler", "sd/struct_buffer") |
| 8 | + Pkg.checkout("Sugar", "sd/struct_buffer") |
| 9 | + Pkg.checkout("GPUArrays", "sd/abstractgpu") |
14 | 10 | end
|
15 | 11 |
|
16 |
| - |
17 |
| -using ArrayFire |
18 |
| - |
19 |
| -ArrayFire.set_backend(AF_BACKEND_OPENCL) |
20 |
| - |
21 | 12 | 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 |
| 13 | +using GPUArrays.TestSuite, Base.Test |
77 | 14 |
|
78 |
| -print_mem_info("GPU-Mem apres loop", 0) |
| 15 | +TestSuite.run_tests(CLArray) |
0 commit comments