Loading [MathJax]/extensions/tex2jax.js
Parallel numerical verification of the σ_odd problem  October 6, 2018
All Classes Namespaces Files Functions Variables Typedefs Macros
threads.hpp
Go to the documentation of this file.
1 /* -*- coding: latin-1 -*- */
2 /** \file threads/threads/threads.hpp (January 6, 2018)
3  * \brief
4  * Implementation of the threads parallel algorithms presented in the report.
5  *
6  * GPLv3 --- Copyright (C) 2017, 2018 Olivier Pirson
7  * http://www.opimedia.be/
8  */
9 
10 #ifndef PROGS_SRC_THREADS_THREADS_THREADS_HPP_
11 #define PROGS_SRC_THREADS_THREADS_THREADS_HPP_
12 
13 // \cond
14 #include <set>
15 #include <thread>
16 #include <vector>
17 // \endcond
18 
19 #include "../../common/sigmaodd/helper.hpp"
20 #include "../../common/sigmaodd/primes.hpp"
21 
22 
23 namespace threads {
24 
27 
28 
29 
30  /* ************
31  * Prototypes *
32  **************/
33 
34  /**
35  * Check in the order all odd gentle numbers between first_n and last_n,
36  * and if print_bad
37  * then print all bad numbers between first_n and last_n (included).
38  * The consequence of the result is that:
39  * if (all numbers < first_n respect the conjecture)
40  * and (all perfect squares < last_n respect the conjecture)
41  * and (all bad numbers < last_n respect the conjecture)
42  * then all numbers < last_n respect the conjecture.
43  *
44  * One master thread dispatch one range of numbers for each of the (nb_thread - 1) slaves threads
45  * and compute itself one range.
46  * Then wait that they all finish, and so forth with next numbers.
47  *
48  * Printing is do in increasing order.
49  *
50  * sigmaodd::primes.cpp must be compiled without the macro PRIME16.
51  *
52  * @param nb_thread >= 1
53  * @param first_n 3 <= odd <= last_n
54  * @param last_n <= MAX_POSSIBLE_N
55  * @param previous_bad_table if not empty then must be contains all bad numbers < first_n
56  * @param print_bad
57  * @param range_size even
58  *
59  * @return the set of all bad numbers between first_n and last_n (included)
60  */
61  std::set<nat_type>
63  (unsigned int nb_thread,
64  nat_type first_n, nat_type last_n,
65  const std::set<nat_type> &previous_bad_table = std::set<nat_type>(),
66  bool print_bad = true,
67  unsigned int range_size = 2000);
68 
69 
70  /** \brief
71  * Check in the order all odd gentle numbers between first_n and last_n,
72  * and if print_bad
73  * then print all bad numbers between first_n and last_n (included).
74  * The consequence of the result is that:
75  * if (all numbers < first_n respect the conjecture)
76  * and (all perfect squares < last_n respect the conjecture)
77  * and (all bad numbers < last_n respect the conjecture)
78  * then all numbers < last_n respect the conjecture.
79  *
80  * One master thread dispatch one range of numbers for each of the (nb_thread - 1) slaves threads
81  * and compute itself one range.
82  * There is no barrier, the master thread dispatch new range for free slave threads
83  * and compute itself one new range.
84  * And so forth with next numbers.
85  *
86  * Printing is do in increasing order.
87  *
88  * sigmaodd::primes.cpp must be compiled without the macro PRIME16.
89  *
90  * @param nb_thread >= 1
91  * @param first_n 3 <= odd <= last_n
92  * @param last_n <= MAX_POSSIBLE_N
93  * @param previous_bad_table if not empty then must be contains all bad numbers < first_n
94  * @param print_bad
95  * @param range_size even
96  * @param master_range_size even
97  *
98  * @return the set of all bad numbers between first_n and last_n (included)
99  */
100  std::set<nat_type>
102  (unsigned int nb_thread,
103  nat_type first_n, nat_type last_n,
104  const std::set<nat_type> &previous_bad_table = std::set<nat_type>(),
105  bool print_bad = true,
106  unsigned int range_size = 20000,
107  unsigned int master_range_size = 200);
108 
109 
110  /**
111  * Check in the order all odd gentle numbers between first_n and last_n,
112  * and if print_bad
113  * then print all bad numbers between first_n and last_n (included).
114  * The consequence of the result is that:
115  * if (all numbers < first_n respect the conjecture)
116  * and (all perfect squares < last_n respect the conjecture)
117  * and (all bad numbers < last_n respect the conjecture)
118  * then all numbers < last_n respect the conjecture.
119  *
120  * One master thread dispatch one number for each of the (nb_thread - 1) slaves threads
121  * and compute itself one number.
122  * Then wait that they all finish, and so forth with next numbers.
123  *
124  * Printing is do in not deterministic order.
125  *
126  * sigmaodd::primes.cpp must be compiled without the macro PRIME16.
127  *
128  * @param nb_thread >= 1
129  * @param first_n 3 <= odd <= last_n
130  * @param last_n <= MAX_POSSIBLE_N
131  * @param previous_bad_table if not empty then must be contains all bad numbers < first_n
132  * @param print_bad
133  *
134  * @return the set of all bad numbers between first_n and last_n (included)
135  */
136  std::set<nat_type>
138  (unsigned int nb_thread,
139  nat_type first_n, nat_type last_n,
140  const std::set<nat_type> &previous_bad_table = std::set<nat_type>(),
141  bool print_bad = true);
142 
143 } // namespace threads
144 
145 #endif // PROGS_SRC_THREADS_THREADS_THREADS_HPP_
uint64_t nat_type
Type for natural number used in all code, on 64 bits.
Definition: helper.hpp:33
sigmaodd::prime_type prime_type
Definition: threads.hpp:26
std::set< nat_type > threads_check_gentle_varsigma_odd__dynamic(unsigned int nb_thread, nat_type first_n, nat_type last_n, const std::set< nat_type > &previous_bad_table, bool print_bad, unsigned int range_size, unsigned int master_range_size)
Check in the order all odd gentle numbers between first_n and last_n, and if print_bad then print all...
Definition: threads.cpp:107
uint32_t prime_type
Type for prime number, particularly for the table of primes.
Definition: primes.hpp:49
std::set< nat_type > threads_check_gentle_varsigma_odd__by_range(unsigned int nb_thread, nat_type first_n, nat_type last_n, const std::set< nat_type > &previous_bad_table, bool print_bad, unsigned int range_size)
Definition: threads.cpp:27
sigmaodd::nat_type nat_type
Definition: threads.hpp:25
std::set< nat_type > threads_check_gentle_varsigma_odd__one_by_one(unsigned int nb_thread, nat_type first_n, nat_type last_n, const std::set< nat_type > &previous_bad_table, bool print_bad)
Definition: threads.cpp:227