You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// Recursively calculate P(a, m), Q(a, m) and T(a, m)
91
+
bsReturn am = bs(a, m);
92
+
// Recursively calculate P(m, b), Q(m, b) and T(m, b)
93
+
bsReturn mb = bs(m, b);
94
+
// Now combine
95
+
Pab = am.P * mb.P;
96
+
Qab = am.Q * mb.Q;
97
+
Tab = (mb.Q * am.T) + (am.P * mb.T);
98
+
}
91
99
92
100
bsReturn ChudnovskyPiBS::bs_multithreaded(mpz_class a, mpz_class b, int threadCount) //clearly thread safe because nothing from outside the function is written to.
93
101
{
@@ -98,24 +106,7 @@ bsReturn ChudnovskyPiBS::bs_multithreaded(mpz_class a, mpz_class b, int threadCo
98
106
mpz_class m;
99
107
if (b - a == 1)
100
108
{
101
-
//Directly compute P(a,a+1), Q(a,a+1) and T(a,a+1)
@@ -168,7 +159,6 @@ bsReturn ChudnovskyPiBS::bs_multithreaded(mpz_class a, mpz_class b, int threadCo
168
159
return result;
169
160
}
170
161
171
-
172
162
bsReturn ChudnovskyPiBS::bs_multithreaded_barrier(mpz_class a, mpz_class b, int threadCount, int depth) //clearly thread safe because nothing from outside the function is written to.
173
163
{
174
164
if (threadCount == 0)
@@ -184,24 +174,7 @@ bsReturn ChudnovskyPiBS::bs_multithreaded_barrier(mpz_class a, mpz_class b, int
184
174
mpz_class m;
185
175
if (b - a == 1)
186
176
{
187
-
//Directly compute P(a,a+1), Q(a,a+1) and T(a,a+1)
Copy file name to clipboardExpand all lines: ChudnovskyPiBS.h
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -44,6 +44,8 @@ class ChudnovskyPiBS //Calculates Pi using Chudnovsky algorithm with Binary Spli
44
44
/// <param name="b"></param>
45
45
/// <returns></returns>
46
46
bsReturn bs(mpz_class a, mpz_class b);
47
+
voidrecursivelyComputePabQabTab_SingleThreaded(mpz_class& a, mpz_class& b, mpz_class& m, mpz_class& Pab, mpz_class& Qab, mpz_class& Tab);
48
+
voiddirectlyCompute__P_Q_T__from_A_to_AplusOne(mpz_class& a, mpz_class& Pab, mpz_class& Qab, mpz_class& Tab);
47
49
bsReturn bs_multithreaded(mpz_class a, mpz_class b, int threadCount);
48
50
bsReturn bs_multithreaded_barrier(mpz_class a, mpz_class b, int threadCount, int depth); //uses a barrier to wait for all main worker threads to spawn.
0 commit comments