-
-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
44 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
/// method, Revista do DETUA, vol. 4, no. 6, March 2006, | ||
/// pp. 759-768. | ||
/// | ||
/// Copyright (C) 2020 Kim Walisch, <[email protected]> | ||
/// Copyright (C) 2021 Kim Walisch, <[email protected]> | ||
/// | ||
/// This file is distributed under the BSD License. See the COPYING | ||
/// file in the top level directory. | ||
|
@@ -71,12 +71,13 @@ T S2_hard_thread(T x, | |
T sum = 0; | ||
|
||
int64_t low = thread.low; | ||
int64_t low1 = max(low, 1); | ||
int64_t segments = thread.segments; | ||
int64_t segment_size = thread.segment_size; | ||
int64_t pi_sqrty = pi[isqrt(y)]; | ||
int64_t low1 = max(low, 1); | ||
int64_t limit = min(low + segments * segment_size, z); | ||
int64_t max_b = pi[min3(isqrt(x / low1), isqrt(z), y)]; | ||
int64_t pi_sqrty = pi[isqrt(y)]; | ||
int64_t max_b = (limit <= y) ? pi_sqrty | ||
: pi[min3(isqrt(x / low1), isqrt(z), y)]; | ||
int64_t min_b = pi[min(z / limit, primes[max_b])]; | ||
min_b = max(c, min_b) + 1; | ||
|
||
|
@@ -94,6 +95,8 @@ T S2_hard_thread(T x, | |
int64_t high = min(low + segment_size, limit); | ||
low1 = max(low, 1); | ||
|
||
// For b < min_b there are no special leaves: | ||
// low <= x / (primes[b] * m) < high | ||
sieve.pre_sieve(primes, min_b - 1, low, high); | ||
int64_t b = min_b; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,7 @@ | |
/// compressed lookup table of moebius function values, | ||
/// least prime factors and max prime factors. | ||
/// | ||
/// Copyright (C) 2020 Kim Walisch, <[email protected]> | ||
/// Copyright (C) 2021 Kim Walisch, <[email protected]> | ||
/// | ||
/// This file is distributed under the BSD License. See the COPYING | ||
/// file in the top level directory. | ||
|
@@ -61,10 +61,10 @@ T D_thread(T x, | |
T sum = 0; | ||
|
||
int64_t low = thread.low; | ||
int64_t low1 = max(low, 1); | ||
int64_t segments = thread.segments; | ||
int64_t segment_size = thread.segment_size; | ||
int64_t pi_sqrtz = pi[isqrt(z)]; | ||
int64_t low1 = max(low, 1); | ||
int64_t limit = min(low + segments * segment_size, xz); | ||
int64_t max_b = pi[min3(isqrt(x / low1), isqrt(limit), x_star)]; | ||
int64_t min_b = pi[min(xz / limit, x_star)]; | ||
|
@@ -84,8 +84,8 @@ T D_thread(T x, | |
int64_t high = min(low + segment_size, limit); | ||
low1 = max(low, 1); | ||
|
||
// For i < min_b there are no special leaves: | ||
// low <= x / (primes[i] * m) < high | ||
// For b < min_b there are no special leaves: | ||
// low <= x / (primes[b] * m) < high | ||
sieve.pre_sieve(primes, min_b - 1, low, high); | ||
int64_t b = min_b; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
/// method, Revista do DETUA, vol. 4, no. 6, March 2006, | ||
/// pp. 759-768. | ||
/// | ||
/// Copyright (C) 2020 Kim Walisch, <[email protected]> | ||
/// Copyright (C) 2021 Kim Walisch, <[email protected]> | ||
/// | ||
/// This file is distributed under the BSD License. See the COPYING | ||
/// file in the top level directory. | ||
|
@@ -59,14 +59,16 @@ int64_t S2_thread(int64_t x, | |
{ | ||
int64_t sum = 0; | ||
int64_t low = thread.low; | ||
int64_t low1 = max(low, 1); | ||
int64_t segments = thread.segments; | ||
int64_t segment_size = thread.segment_size; | ||
int64_t low1 = max(low, 1); | ||
int64_t pi_sqrty = pi[isqrt(y)]; | ||
int64_t limit = min(low + segments * segment_size, z + 1); | ||
int64_t max_b = pi[min(isqrt(x / low1), y - 1)]; | ||
int64_t pi_sqrty = pi[isqrt(y)]; | ||
int64_t min_b = pi[min(z / limit, primes[max_b])]; | ||
min_b = max(c, min_b) + 1; | ||
|
||
if (c >= max_b) | ||
if (min_b > max_b) | ||
return 0; | ||
|
||
Sieve sieve(low, segment_size, max_b); | ||
|
@@ -80,8 +82,10 @@ int64_t S2_thread(int64_t x, | |
int64_t high = min(low + segment_size, limit); | ||
low1 = max(low, 1); | ||
|
||
sieve.pre_sieve(primes, c, low, high); | ||
int64_t b = c + 1; | ||
// For b < min_b there are no special leaves: | ||
// low <= x / (primes[b] * m) < high | ||
sieve.pre_sieve(primes, min_b - 1, low, high); | ||
int64_t b = min_b; | ||
|
||
// For c + 1 <= b <= pi_sqrty | ||
// Find all special leaves in the current segment that are | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,7 @@ | |
/// algorithm) that has been distributed using MPI (Message | ||
/// Passing Interface) and multi-threaded using OpenMP. | ||
/// | ||
/// Copyright (C) 2020 Kim Walisch, <[email protected]> | ||
/// Copyright (C) 2021 Kim Walisch, <[email protected]> | ||
/// | ||
/// This file is distributed under the BSD License. See the COPYING | ||
/// file in the top level directory. | ||
|
@@ -52,10 +52,10 @@ T D_thread(T x, | |
T sum = 0; | ||
|
||
int64_t low = thread.low; | ||
int64_t low1 = max(low, 1); | ||
int64_t segments = thread.segments; | ||
int64_t segment_size = thread.segment_size; | ||
int64_t pi_sqrtz = pi[isqrt(z)]; | ||
int64_t low1 = max(low, 1); | ||
int64_t limit = min(low + segments * segment_size, xz); | ||
int64_t max_b = pi[min3(isqrt(x / low1), isqrt(limit), x_star)]; | ||
int64_t min_b = pi[min(xz / limit, x_star)]; | ||
|
@@ -75,8 +75,8 @@ T D_thread(T x, | |
int64_t high = min(low + segment_size, limit); | ||
low1 = max(low, 1); | ||
|
||
// For i < min_b there are no special leaves: | ||
// low <= x / (primes[i] * m) < high | ||
// For b < min_b there are no special leaves: | ||
// low <= x / (primes[b] * m) < high | ||
sieve.pre_sieve(primes, min_b - 1, low, high); | ||
int64_t b = min_b; | ||
|
||
|