From d0586da7c181ef9cede1d2c12a267d9a90b5b25c Mon Sep 17 00:00:00 2001 From: fredrikr79 Date: Thu, 18 Sep 2025 10:26:40 +0200 Subject: [PATCH] parallel pi computations using threads --- main.ua | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 main.ua diff --git a/main.ua b/main.ua new file mode 100644 index 0000000..53a68a9 --- /dev/null +++ b/main.ua @@ -0,0 +1,11 @@ +f ← ˜÷1+1ⁿ2 +ι ← +⟜(\+↯⤙(˜÷⌵-)) # linspace +i! ← ÷⊃⧻/+ ^0 ι # integrate numerically (mean function value) +t! ← ⊙(&p×1e3⌵-)⊙now^0⊙now # time 1-ary function + +0 1 4 # interval [a, b] with n partitions (threads) +⊂⟜(\+↯⤙(˜÷⌵-)) # partition into n subintervals +⊃(t!(⧈₂/(i!f⊙⊙1e8)) # sequential: integrate each area +| t!(wait⧈₂/pool(i!f⊙⊙1e8)) # threading with n threads: this is faster +) +×4÷⊃⧻/+ ◌ # discard one of the benchmarked calculations, collect result