Aliquot Sequence Research
2.0
Compute properties of the sum-of-proper-divisors function.
|
Functions to sieve blocks of sigma function. More...
Functions | |
sieve_config_t * | moews_init_sieve (size_t bound, size_t seg_len) |
creates a sieve_config_t which is shared by a pool of workers More... | |
void | moews_destroy_sieve (sieve_config_t *cfg) |
free's memory associated with sieve_config_t More... | |
sieve_worker_t * | moews_init_worker (const sieve_config_t *cfg) |
creates a worker object which can be used to run the sieve More... | |
void | destroy_worker (sieve_worker_t *worker) |
free's memory associated with sieve_worker_t More... | |
void | moews_sieve_odd_standard (sieve_worker_t *worker, const uint64_t seg_start) |
runs sieve for odd sigma(m) More... | |
void | moews_sieve_odd_squared (sieve_worker_t *worker, const uint64_t seg_start) |
takes odd m in range and runs sieve for sigma(m * m) More... | |
uint64_t | moews_lookup_sigma_m (const sieve_worker_t *worker, uint64_t m) |
lookup sigma(m) from m in a sieved block More... | |
uint64_t | moews_lookup_sigma_m_squared (const sieve_worker_t *worker, uint64_t m) |
lookup sigma(m * m) from m in a sieved block More... | |
bool | moews_check_prime (const sieve_worker_t *worker, uint64_t m) |
checks if odd numbers in range (seg_start, seg_start + seg_len) is prime More... | |
size_t | moews_estimate_heap_usage (size_t bound, size_t seg_len, size_t num_workers) |
estimates how much heap the sieving buffers will require More... | |
Functions to sieve blocks of sigma function.
The parameter seg_len has will increase sieve runtime by upto a order-of-magnitude if set to low/high. If seg_len is set to low the sieve will execute far more instructions than needed to complete the same outcome, as it's performance is improves with larger values of seg_len. I believe^ the amount of instructions increases exponentially as seg_len shrinks, judging by the cachegrind instruction lookup counts. However if seg_len is set to high the sieve will start thrashing at the cache missing reads/writes in the intermediate sieving steps thus degrading performance. I believe^^ this effect is more pronounced at bounds lower than ~10^9 as seg_len's that result in a reasonable amount of operations also happen to require sieving buffers that fit (very approximately) into my 32mb LL cache.
test ^ and ^^
The performance of this sieve is highly variable on the value of seg_len, unfortunately not in a clearly tractable way. It is clear that if seg_len is set to low (whatever that means) the sieve will do a lot of additional operations for the same result. This selected cachegrind/time output from 2 pom_yang run is illustrative:
Note that the seg_len=12500 is running an order of magnitude more instructions and far fewer references on the data cache, these references are relatively inaccurate.
The seg_len value can also degrade performace if it is set to high:
Comparing to the seg_len=400000 run we can observe that slightly less instructions are being executed but we are still in the same order of magnitude. More interestingly we can notice this run made an order of magnitude fewer references to the data cache and.. those references were much less accurate, likely accounting for the performace degradation. The vast majority of these misses originate from interactions with the sigma and numbers buffers.
Files in the cg directory for more details.
This is a rewrite of Anton Mosunov's implementation of the [Moews and Moews] sieving algorithm, prepared to utilized in the tabulation of non-aliquots, sect. 3 of [Chum et al.]. This implementation includes undocumented optimization on the original method of [Moews and Moews] that are essential for performance, I can't make any sense of why it works however. The _meows_naive_sieve implements the algorithm as described in the paper, it is much slower.
-> [Moews and Moews] Moews, D. and Moews, P. C. (1991). A search for aliquot cycles below 10 10. Mathematics of Computation, 57(196):849.
-> [Chum et al.] Chum, K., Guy, R. K., Jacobson, J. M. J., and Mosunov, A. S. (2018). Numerical and statistical analysis of aliquot sequences. Experimental Mathematics, 29(4):414–425.
void destroy_worker | ( | sieve_worker_t * | worker | ) |
free's memory associated with sieve_worker_t
worker | to be free'd |
bool moews_check_prime | ( | const sieve_worker_t * | worker, |
uint64_t | m | ||
) |
checks if odd numbers in range (seg_start, seg_start + seg_len) is prime
worker | that has previously run moews_sieve_odd_standard |
m | check if this odd number in range (seg_start, seg_start + seg_len) is prime |
void moews_destroy_sieve | ( | sieve_config_t * | cfg | ) |
free's memory associated with sieve_config_t
cfg | to be free'd |
size_t moews_estimate_heap_usage | ( | size_t | bound, |
size_t | seg_len, | ||
size_t | num_workers | ||
) |
estimates how much heap the sieving buffers will require
bound | sieve all odd sigma upto to bound |
seg_len | size of range to sieve in a step |
num_workers | number of threads working |
sieve_config_t* moews_init_sieve | ( | size_t | bound, |
size_t | seg_len | ||
) |
creates a sieve_config_t which is shared by a pool of workers
bound | sieving all odd sigma upto to bound |
seg_len | size of range to sieve in a step |
sieve_worker_t* moews_init_worker | ( | const sieve_config_t * | cfg | ) |
creates a worker object which can be used to run the sieve
cfg | initalized sieve configuration struct |
uint64_t moews_lookup_sigma_m | ( | const sieve_worker_t * | worker, |
uint64_t | m | ||
) |
lookup sigma(m) from m in a sieved block
worker | see definition, has run moews_sieve_odd_standard last |
m | number to lookup |
uint64_t moews_lookup_sigma_m_squared | ( | const sieve_worker_t * | worker, |
uint64_t | m | ||
) |
lookup sigma(m * m) from m in a sieved block
worker | see definition, has run moews_sieve_odd_squared last |
m | number to lookup |
void moews_sieve_odd_squared | ( | sieve_worker_t * | worker, |
uint64_t | seg_start | ||
) |
takes odd m in range and runs sieve for sigma(m * m)
worker | see struct definiton |
seg_start | start of range to sieve |
void moews_sieve_odd_standard | ( | sieve_worker_t * | worker, |
uint64_t | seg_start | ||
) |
runs sieve for odd sigma(m)
worker | see struct definiton |
seg_start | start of range to sieve |