18 #include "../common/helper/helper.hpp" 39 std::cerr <<
"Usage: check_gentle [options] (OpenCL version)" << std::endl
41 <<
"Options:" << std::endl
42 <<
" --first n first odd number to check (3 by default)" << std::endl
43 <<
" --infos-first-gpu print infos about the first GPU found and exit" << std::endl
44 <<
" --infos-opencl print infos about OpenCL and exit" << std::endl
45 <<
" --last n last odd number to check <= 7927*7927 (1000001 by default)" << std::endl
46 <<
" --nb n number of odd numbers to check" << std::endl
47 <<
" --nb-opencl n number of OpenCL units (65536 default, must be changed with --par-factor)" << std::endl
48 <<
" --no-print do not print bad numbers" << std::endl
49 <<
" --par-factor parallelize the factorization instead numbers" << std::endl;
60 main(
int argc,
const char*
const argv[]) {
71 unsigned int nb_opencl = 65536;
72 bool par_factor =
false;
73 bool print_bad =
true;
77 for (
unsigned int i = 1; i < static_cast<unsigned int>(argc); ++i) {
78 const std::string param(argv[i]);
80 if (param ==
"--first") {
86 else if (param ==
"--infos-first-gpu") {
89 std::cout <<
"OpenCL first GPU device found:" << std::endl;
94 else if (param ==
"--infos-opencl") {
95 std::cout <<
"OpenCL platforms and devices:" << std::endl;
100 else if (param ==
"--last") {
106 else if (param ==
"--nb") {
109 else if (param ==
"--nb-opencl") {
112 else if (param ==
"--no-print") {
115 else if (param ==
"--par-factor") {
128 std::cout <<
"opencl/check_gentle" 129 <<
"\tFirst: " << first
130 <<
"\tLast: " << last
131 <<
"\tNb: " << (first <= last
132 ? (last - first)/2 + 1
134 <<
"\tNb OpenCL: " << nb_opencl
138 std::cout << std::endl
144 const std::chrono::steady_clock::time_point clock_start = std::chrono::steady_clock::now();
157 std::chrono::duration<double> duration = std::chrono::steady_clock::now() - clock_start;
cl::Device get_first_device_gpu()
Return the first GPU device found. If not found then print an error message and exit.
std::set< nat_type > opencl_check_gentle_varsigma_odd(nat_type first_n, nat_type last_n, unsigned int opencl_nb_number, bool print_bad, bool print_time)
Check in the order all odd gentle numbers between first_n and last_n, and if print_bad then print all...
uint64_t nat_type
Type for natural number used in all code, on 64 bits.
const std::string prime_filename
Default filename for the binary file "big_data/prime28.bin".
nat_type divide_until_odd(nat_type n)
Return n divided by 2 until the result is odd.
unsigned int get_uint(int argc, const char *const argv[], unsigned int i, void(*help_and_exit_function)())
Return argv[i] converted in integer.
constexpr bool is_even(nat_type n)
Return true iff n is even.
std::string duration_to_string(std::chrono::duration< double > duration_second)
Return a string with the duration expressed in milliseconds, seconds, minutes and hours...
bool read_primes_table()
Read the binary file prime_filename to fill the table with all primes < 2^28. This table must be read...
int main(int argc, const char *const argv[])
void print_device(const cl::Device &device)
Print information on this device.
void print_intern_config_compiler()
Print to stdcout the intern configuration of the compiler.
void print_platforms()
Print information on all platforms.
std::set< nat_type > opencl_check_gentle_varsigma_odd__parallelize_factorization(nat_type first_n, nat_type last_n, unsigned int opencl_nb, bool print_bad, bool print_time)
Like opencl_check_gentle_varsigma_odd() but instead parallelize on group of opencl_nb numbers...
unsigned long get_ulong(int argc, const char *const argv[], unsigned int i, void(*help_and_exit_function)())
Return argv[i] converted in integer.
Implementation of the OpenCL parallel algorithms presented in the report.