|
@@ -3,7 +3,7 @@ using StarPU
|
|
|
using LinearAlgebra
|
|
|
|
|
|
@target STARPU_CPU+STARPU_CUDA
|
|
|
-@codelet function mandelbrot(pixels ::Matrix{Int64}, params ::Matrix{Float32} ) :: Nothing
|
|
|
+@codelet function mandelbrot(pixels ::Matrix{Int64}, centerr ::Float64, centeri ::Float64, offset ::Int64, dim ::Int64 ) :: Nothing
|
|
|
height :: Int64 = height(pixels)
|
|
|
width :: Int64 = width(pixels)
|
|
|
zoom :: Float64 = width * 0.25296875
|
|
@@ -11,10 +11,6 @@ using LinearAlgebra
|
|
|
diverge :: Float32 = 4.0
|
|
|
max_iterations :: Float32 = ((width/2) * 0.049715909 * log10(zoom));
|
|
|
imi :: Float32 = 1. / max_iterations
|
|
|
- centerr :: Float32 = params[1,1]
|
|
|
- centeri :: Float32 = params[2,1]
|
|
|
- offset :: Float32 = params[3,1]
|
|
|
- dim :: Float32 = params[4,1]
|
|
|
cr :: Float64 = 0.
|
|
|
zr :: Float64 = 0.
|
|
|
ci :: Float64 = 0.
|
|
@@ -27,7 +23,10 @@ using LinearAlgebra
|
|
|
zr = cr
|
|
|
ci = centeri + (y-1+offset - (dim / 2)) * iz
|
|
|
zi = ci
|
|
|
- for n = 0:max_iterations
|
|
|
+ max_it :: Float64 = max_iterations
|
|
|
+ n = 0
|
|
|
+ for i = 0:max_it
|
|
|
+ n = i
|
|
|
if (zr*zr + zi*zi > diverge)
|
|
|
break
|
|
|
end
|
|
@@ -50,15 +49,14 @@ end
|
|
|
@debugprint "starpu_init"
|
|
|
starpu_init()
|
|
|
|
|
|
-function mandelbrot_with_starpu(A ::Matrix{Int64}, params ::Matrix{Float32}, nslicesx ::Int64)
|
|
|
+function mandelbrot_with_starpu(A ::Matrix{Int64}, cr ::Float64, ci ::Float64, dim ::Int64, nslicesx ::Int64)
|
|
|
horiz = StarpuDataFilter(STARPU_MATRIX_FILTER_BLOCK, nslicesx)
|
|
|
@starpu_block let
|
|
|
- hA, hP = starpu_data_register(A,params)
|
|
|
+ hA = starpu_data_register(A)
|
|
|
starpu_data_partition(hA,horiz)
|
|
|
- starpu_data_partition(hP,horiz)
|
|
|
-
|
|
|
+
|
|
|
@starpu_sync_tasks for taskx in (1 : nslicesx)
|
|
|
- @starpu_async_cl mandelbrot(hA[taskx], hP[taskx]) [STARPU_W, STARPU_R]
|
|
|
+ @starpu_async_cl mandelbrot(hA[taskx]) [STARPU_W] [cr, ci, (taskx-1)*dim/nslicesx, dim]
|
|
|
end
|
|
|
end
|
|
|
end
|
|
@@ -80,16 +78,9 @@ function min_times(cr ::Float64, ci ::Float64, dim ::Int64, nslices ::Int64)
|
|
|
tmin=0;
|
|
|
|
|
|
pixels ::Matrix{Int64} = zeros(dim, dim)
|
|
|
- params :: Matrix{Float32} = zeros(4*nslices,1)
|
|
|
- for i=0:(nslices-1)
|
|
|
- params[4*i+1,1] = cr
|
|
|
- params[4*i+2,1] = ci
|
|
|
- params[4*i+3,1] = i*dim/nslices
|
|
|
- params[4*i+4,1] = dim
|
|
|
- end
|
|
|
for i = 1:10
|
|
|
t = time_ns();
|
|
|
- mandelbrot_with_starpu(pixels, params, nslices)
|
|
|
+ mandelbrot_with_starpu(pixels, cr, ci, dim, nslices)
|
|
|
t = time_ns()-t
|
|
|
if (tmin==0 || tmin>t)
|
|
|
tmin=t
|