Items tagged with multithreading


I'm trying to write some simple code to help plot an approximation of a solution to the heat equation. On one set of axes I want to plot the temperature characteristic of a 1-D bar at different temperatures. I am able to do this easily enough, but the code uses a for loop and my core i7 is not being utilized properly. To rectify this I have tried to use threads, but after many hours of playing around I cannot get it to work fully. The first time I run my code I am faced with the error "Error, (in plot) cannot determine if this expression is true or false: not fHwLibraryInitialized".

Then after this I can run my code a few more times and it will produce a graph, but each time the graph will be different, meaning most of them are incorrect. After running my display command several times I am then faced with the error "kernel connection has been lost", and I need to restary. I have never played with threads before and have very little understanding of how it works.


para := proc (A, B)
return [op(A), op(B)]; 
 end proc;

HeatP := proc (f, g, n, lambda, X, N, M, T)
 local k, u, i, L, a; 
u := proc (x, t) options operator, arrow; sum((int(sin(k*lambda*x)*g, x = 0 .. 1))*exp(-k*lambda*t)*sin(k*lambda*x), k = 1 .. n) end proc;
 L := [];
 if N-X < 3 then for i from X to N do
 L := [op(L), plot(u(x, (i*T-T)/M), x = 0 .. 1)] 
end do; 
return L;
else a := floor((1/2)*(N-X))+X; 
Threads:-Task:-Continue(para, Task = [HeatP, f, g, n, lambda, X, a, M, T], Task = [HeatP, f, g, n, lambda, a+1, N, M, T])
 end if
 end proc;

g := piecewise(x <= 0, 0, 0 < x and x < 1, exp(-2/(1-(x-1/2)^2)), x >= 0, 0);

display(Threads:-Task:-Start(HeatP, 0, g, 5, Pi, 1, 8, 8, 2));

I cannot see where the problem is, but there is obviously at least one. Any help would be appreciated.

I'm running calculations like this:

    f := (i,j)-> (some complicated procedure depending on i and j);
    M:= Matrix([Threads:-Seq([Threads:-Seq( f(i,j), j=1..N)], i=1..N)]);

I have a server with 20 cores, but each core has two threads, so this code should max out all 40 threads. But what I notice is only at most 20 threads being used at a time. 

I checked kernelopts(numcpus) returns 20. 

Does anyone have any advice on how to maximize my resource usage?

Hi!I am running some grid computations and I found that I could speed up my computations if my nodes could share some partial results. It seems that Grid:-Send and Grid:-Receive is almost perfect. The problem is that Grid:-Receive blocks the computations where I cannot ensure that a message will ever be send. I've tried to run Grid:-Receive on a thread in an possible infinite loop but it still blocks.

Some pieces of code below:

  while eval(stopValue) do
    SigContainer := eval(SigContainer) union {convert(Grid:-Receive(),string)};
  end do;
end proc:

SendMessage:=proc(message::string, id::integer)
  Threads[Seq](proc(i) if i <> id then Grid:-Send(i,message) end if end proc,i=0..Grid:-NumNodes()-1);
end proc:

In the main procedure run on a node I have







stopValue := false;


Do you have any suggestions how to solve my problem?


I have a problem recently with running RootFinding:-Isolate inside a procedure which is run on threads. I have many polynomial systems to treat so I would like to balance computations between cores. Unfortunately, my code always breaks computation kernel with the error:


at com.maplesoft.mathdoc.model.WmiModelLock.acquireLock(Unknown Source)
at com.maplesoft.mathdoc.model.WmiModelLock.writeLock(Unknown Source)
at com.maplesoft.worksheet.connection.WmiOutputUpdateBuffer$ Source)
at Source)


I wrote a small example below


   local i;

   for i from 1 to n do


   catch "":
   end try:
  end do:
end proc:

Threads:-Task:-Start ( null, Task[f,10000], Task[f,10000], Task[f,10000]);


I have no much of experiences with threads in Maple so I would not be surprise if I'm trying to do something completely wrong here. Any hint or advice will be appreciate. 


When I run a maple file it uses 25% of CPU.

When I run 2 files, the half of CPU is used.

How can I change the preferences for using most of CPU

Hi. I need to calculate the elements of the large two-dimensional symmetric matrix.

for j from 1 to N do
for i from j to N do

The calculations of elements are time consuming. I want to use Threads for this purpose. Could you help me with it? Thank you.

hi, i want to write the following algorithm in maple with two threads, please help me. for m from 1 by 1 to 100 if thread1 then result1:= some equation if thread2 then result2:= some equation end if end do:

Okay, many questions here, maybe someone can answer one or two of them for me?  Can someone show a few simple multi-thread examples that work starting from version Maple 12 ?  Actually what version does multithreading actually really start working to improve calculation times? 

From what I understand the Threads package was introduced in Maple12 so it's almost experimental there.  An example I found using add() and Add() shows a slight...

Page 1 of 1