-
Notifications
You must be signed in to change notification settings - Fork 1
/
gap_test_common.h
79 lines (65 loc) · 2.43 KB
/
gap_test_common.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
// Copyright 2021 Seth Troisi
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include <cstdint>
#include <cstdio>
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
#include <chrono>
#include "gap_common.h"
using std::cout;
using std::endl;
using std::vector;
/** See gap_test_stats.py */
class StatsCounters {
public:
StatsCounters(std::chrono::high_resolution_clock::time_point now) : s_start_t(now) {}
const std::chrono::high_resolution_clock::time_point s_start_t;
uint32_t s_tests = 0;
/* Counters for unknowns after sieve */
size_t s_total_unknown = 0;
size_t s_t_unk_prev = 0;
size_t s_t_unk_next = 0;
/* PRP counter */
size_t s_total_prp_tests = 0;
/* Number of times fallback or skips happened */
size_t s_skips_after_one_side = 0;
size_t s_gap_out_of_sieve_prev = 0;
size_t s_gap_out_of_sieve_next = 0;
/* Interval stats */
float s_best_merit_interval = 0;
size_t s_best_merit_interval_m = 0;
// This can change in const possible_print_stats
mutable float s_tests_per_second = 0;
/** Return if stats were printed */
void process_results(
const Config &config,
long m, bool is_last,
size_t unknown_l, size_t unknown_u,
int prev_p, int next_p,
int p_tests, int n_tests,
float merit);
bool possible_print_stats(
const Config &config,
long m, bool is_last,
size_t unknown_l, size_t unknown_u,
int prev_p, int next_p) const;
};
void test_interval_cpu(
const uint64_t m, const mpz_t &K, const size_t SIEVE_LENGTH,
size_t &s_total_prp_tests,
size_t &s_gap_out_of_sieve_prev, size_t &s_gap_out_of_sieve_next,
vector<int32_t> (&unknowns)[2],
int &prev_p, int &next_p);