Simpler iteration timing/prediction code
This commit is contained in:
parent
10451dcde9
commit
384257825b
26
src/main.c
26
src/main.c
|
@ -1,4 +1,5 @@
|
|||
#include <alloca.h>
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
@ -26,10 +27,13 @@ static void ReportProgress(uintmax_t current, uintmax_t total, clock_t now) {
|
|||
if (current >= _timing_last_count) {
|
||||
float inferred_rate = (float)(current - _timing_last_count) /
|
||||
((float)(now - _timing_last_time) / CLOCKS_PER_SEC);
|
||||
_timing_rate = _timing_rate * (1. - _timing_exp_backoff) +
|
||||
inferred_rate * _timing_exp_backoff;
|
||||
if (_timing_exp_backoff > 0.0001) {
|
||||
_timing_exp_backoff *= 0.99;
|
||||
if (inferred_rate < _timing_rate) {
|
||||
_timing_rate = inferred_rate;
|
||||
_timing_exp_backoff = 0.3;
|
||||
} else {
|
||||
_timing_rate = _timing_rate * (1. - _timing_exp_backoff) +
|
||||
inferred_rate * _timing_exp_backoff;
|
||||
_timing_exp_backoff = fmax(0.99 * _timing_exp_backoff, 0.001);
|
||||
}
|
||||
_timing_last_count = current;
|
||||
_timing_last_time = now;
|
||||
|
@ -256,8 +260,14 @@ int main(int argc, char *argv[]) {
|
|||
PermutationReset(b_out_perms + i);
|
||||
}
|
||||
|
||||
#pragma omp for schedule(guided)
|
||||
#pragma omp for schedule(dynamic)
|
||||
for (size_t lhs_i = 0; lhs_i < row_count - 1; lhs_i++) {
|
||||
{
|
||||
clock_t now = clock();
|
||||
uintmax_t tested_now = tested;
|
||||
ReportProgress(tested_now, total, now);
|
||||
}
|
||||
|
||||
if (seen[lhs_i]) {
|
||||
const uintmax_t remaining = (uintmax_t)row_count * perm_iterations;
|
||||
#pragma omp atomic update
|
||||
|
@ -351,12 +361,6 @@ int main(int argc, char *argv[]) {
|
|||
skip_permutations:;
|
||||
#pragma omp atomic update
|
||||
tested += perm_iterations;
|
||||
{
|
||||
clock_t now = clock();
|
||||
#pragma omp task default(none) shared(tested, total) firstprivate(now)
|
||||
ReportProgress(tested, total, now);
|
||||
}
|
||||
|
||||
} // For loop over rhs_i
|
||||
} // For loop over lhs_i
|
||||
|
||||
|
|
Loading…
Reference in New Issue