Items tagged with multithreaded

I have a nested for loop that iterates through a range of values for x and y coordinates to create a 3d surface for illustration of my research. after the x loop there is a y loop, and inside of that y loop is a series of commands to find some eigenvalues of a matrix (which become the z coordinates) and sort them into already open files. This isn't bad when the precision i require is more than .02, but some of my matrices require up to 0.005 or less. The latter precision costs hours of computation time on just one processor. However my laptop has an i7, so I want to see if i can get the for loop to send its next iteration to the next processor in line while it has the previous ones still calculating. Have any tips?


a researcher at our department starts multiple Maple programs in parallel on our Linux servers.

Sometimes a high percentage of the resulting mserver processes hang. ps shows their state as

SNl (sleeping, multithreaded). strace to the processes shows that every one is waiting on a

futex without timeout. The problem occurs in versions 16 and 18. This is annoying.


Is there a fix for this?


Matthias Bauer


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


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




local u,i,j,nmc:



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


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


end do:

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


end do:

return finished:

end proc:



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



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?

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...

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.





serial (1 core)

20 seconds

240 seconds

parallel (4 cores)

5 seconds

60 seconds





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


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


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


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





Page 1 of 1