⍝ Parallel Programming With Dyalog'14
)load isolate
iss←isolate.New¨4⍴⊂⍬
data←4 1E6 (?⍴) 6  ⍝ roll 4 million dice
iss.x←↓data        ⍝ 1 million into each isolate
iss.((+⌿ ÷ ≢) x)   ⍝ compute 4 means in parallel
t←⎕AI[3] ⋄ iss.⎕DL 6 6 6 6 ⋄ ⎕AI[3]-t
)copy dfns queens
q←queens IÏ ⍳13    ⍝ f IÏ  ←→ f ∥¨
   isolate.Running 'q'
 ≢¨isolate.Values 'q'
¯1↑isolate.Values 'q'
≢¨q
⍝ Now open Task Manager
⎕FX 'r←loop n' 'r←⎕AI[3]' ':While 0<n←n-1 ⋄ {}∪10000?10000 ⋄ :End' 'r←⎕AI[3]-r'
⎕VR 'loop'
loop 1000
T←⎕AI[3] ⋄ loop  ¨ 4⍴10000 ⋄ ⎕AI[3]-T
T←⎕AI[3] ⋄ loop IÏ 4⍴10000 ⋄ ⎕AI[3]-T
isolate.Reset 0
queens_asynch←queens II  ⍝ f II  ←→ f∥  (asynchronous version)
q13←queens_asynch 13     ⍝ q13 is a "future"
'MYGUI' ⎕WC 'Form' 'Hello Eastbourne' ('Posn' 10 10)('Size' 10 40)
'MYGUI.TEXT' ⎕WC 'Label' (txt←'# of solutions to (queens 13) is ...   ')
{MYGUI.TEXT.Caption←(¯6↓txt),⍕≢q13}&0
⎕DQ 'MYGUI'
⍝ Now let's do some interesting work!
]open http://www.dyalog.com/blog
⍝ Morten: Remember to start a local server
)xload d:\demos\mandelbrot
)ed buildset_core
)ed buildset
)ed init_isolates
mandelbrot

