Items tagged with multithreaded multithreaded Tagged Items Feed

Hi

I am using the Map function from the Threads package on a quad core processor, it only seems to use one thread however. The Array I am processing holds over 2 million entries and takes over 10 hours to calculate (single threaded).

Is this behavoir normal? I already tried to define a tasksize but that didn't work.

Kind regards

Jasper

Hello, everyone. I have some problem with multithreaded calculation. I just need calculate eigenvalues of matrix m at various parameters (and then export to a file) using advantages of the parallelizing. The following code works but in serial way

 

restart: with(LinearAlgebra):

m:=ImportMatrix(cat(currentdir(),"m.txt")): # here is matrix m.txt

step:=1:

 

prc:=proc(k1,k2)

local u,i,j,nmc:

u:=Matrix(ceil(1+(k2-k1)/step),5):

u[1,1]:=k1:

for i from 2 to op([1,1],u) do

u[i,1]:=u[i-1,1]+step:

end do:

for i from 1 to op([1,1],u) do

nmc:=sort(Eigenvalues(m*u[i,1], output='list')):

for j from 2 to op([1,2],u) do

u[i,j]:=nmc[j-1]:

end do:

writedata[APPEND](cat(currentdir(),"u_",convert(k2,string),".txt"), [convert(Re(u[i]),list)]):

print(u[i,1]);

end do:

return finished:

end proc:

 

with(Threads[Task]):

Start(ArrayTools[Concatenate], 2, Task=[prc,1,20], Task=[prc,20+step,40]);

quit:

 

The Start(ArrayTools[Concatenate], 2, Task=[prc,1,20], Task=[prc,20+step,40]) function makes two tasks of calculation at the parameter ranges of 1-20 and 21-40. But in this case Start spends twice more time than simply prc(20+step,40). How to realize a multithreaded calculation?

By the way I don't need to use a Concatenate function in Start but without any procedure Start doesn't work.

This piece of code returns a vector 'Sinrdensity' with identity entries. what's wrong with it?

restart;
sinrvalue := [seq(10^((1/10)*i), i = -15 .. 25, .5)];

Sinrdensity := Matrix(1, nops(sinrvalue), 0);

task := proc (sinrdensity, initialpoint, endpoint)

local bft, Theta, bound, value;

for value from initialpoint to endpoint do

bft := unapply(1/(1+I*t), t);

for Theta from 0 to 10^10 while is(0.1e-1 <= evalf(abs(bft(2^Theta...

Lyapunov fractals...

February 03 2013 acer 10166 Maple 16

The following (downsized) images of Lyapunov fractals were each generated in a few seconds, in Maple 16.

 

I may make an interface for this with embedded components, or submit it in some form on the Application Center. But I thought that I'd share this version here first.

I'm just re-using the techniques in the code behind an earlier Post on Mandelbrot and Julia fractals. But I've only used one simple coloring scheme here, so far. I'll probably try the so-called burning ship escape-time fractal next.

 

 

 

 

Here below is the contents of the worksheet attached at the end of this Post.

 

 

The procedures are defined in the Startup code region of this worksheet.

 

It should run in Maple 15 and 16, but may not work in earlier versions since it relies on a properly functioning Threads:-Task.

 

The procedure `Lyapunov` can be called as

 

          Lyapunov(W, xa, xb, ya, yb, xresolution)

          Lyapunov(W, xa, xb, ya, yb, xresolution, numterms=N)

 

where those parameters are,

 

 - W, a Vector or list whose entries should be only 0 or 1

 - xa, the leftmost x-point (a float, usually greater than 2.0)

 - xb, the rightmost x-point (a float, usually less than or equal to 4.0)

 - ya, the lowest y-point (a float, usually greater than 2.0)

 - yb, the highest y-point (a float, usually less than or equal to 4.0)

 - xresolution, the width in pixels of the returned image (Array)

 - numterms=N, (optional) where positive integer N is the number of terms added for the approx. Lyapunov exponent

 

 

The speed of calculation depends on whether the Compiler  is functional and how many cores are detected. On a 4-core Intel i7 under Windows 7 the first example below had approximately the following performce in 64bit Maple 16.

 

 

Compiled

evalhf

serial (1 core)

20 seconds

240 seconds

parallel (4 cores)

5 seconds

60 seconds

 

 

 

with(ImageTools):


W:=[0,0,1,0,1]:
res1:=CodeTools:-Usage( Lyapunov(W, 2.01, 4.0, 2.01, 4.0, 500) ):

memory used=46.36MiB, alloc change=65.73MiB, cpu time=33.87s, real time=5.17s


View(res1);


W:=[1,1,1,1,1,1,0,0,0,0,0,0]:
res2:=CodeTools:-Usage( Lyapunov(W, 2.5, 3.4, 3.4, 4.0, 500) ):

memory used=30.94MiB, alloc change=0 bytes, cpu time=21.32s, real time=3.54s


View(res2);


W:=[1,0,1,0,1,1,0,1]:
res3:=CodeTools:-Usage( Lyapunov(W, 2.1, 3.7, 3.1, 4.0, 500) ):

memory used=26.18MiB, alloc change=15.09MiB, cpu time=18.44s, real time=2.95s


View(res3);


W:=[0,1]:
res4:=CodeTools:-Usage( Lyapunov(W, 2.01, 4.0, 2.01, 4.0, 500) ):

memory used=46.25MiB, alloc change=15.09MiB, cpu time=33.52s, real time=5.18s


View(res4);

 

 

Download lyapfractpost.mw

Page 1 of 1