pake

15 Reputation

One Badge

8 years, 48 days

MaplePrimes Activity


These are questions asked by pake

I'm optimizing some code and I have noticed that running a procedure within the Threads:-Task module seems to slow the procedure down. I want to use Threads:-Task to run many procedures in parallel and so finish a task faster.
I'm attaching an example of a simple "add" procedure run outside the Task module and within the Task module. As far as I know, the procedure is thread-safe, and this is shown by the similar time it takes to run 1 or 10 simultaneously.
What is going wrong?

``

restart

addproc := proc () local i, A; A := 0; A := add(i, i = 1 .. 1000); return A end proc

ts := time[real](); for t to 1000 do addproc() end do; TA := time[real]()-ts

ts := time[real](); for t to 1000 do Threads:-Task:-Start(null, Task = addproc) end do; TS := time[real]()-ts

ts := time[real](); for t to 1000 do Threads:-Task:-Start(null, Tasks = [addproc, addproc, addproc, addproc, addproc, addproc, addproc, addproc, addproc, addproc]) end do; TM := time[real]()-ts

TA; TS; TM

0.33e-1

 

2.049

 

2.006

(1)

TM/TA

60.78787879

(2)

``


 

Download TaskExample.mw

Hi everyone,

I've not been able to figure this one out. Say I have an expression dependant on two random variables, like this:

C:=A+B

where A and B are randomvariables, each following a specific distribution.

If I ask for a Sample of C

Sample(C,1)

Maple will sample A, sample B and compute C. But say that A and B are correlated (with a cc of 0.8). How do I define this?

Thanks in advance

 

Page 1 of 1