mersenneforum.org Program for searching all odd-16-digit Aliquot cycles
 Register FAQ Search Today's Posts Mark Forums Read

2015-06-22, 15:40   #12
henryzz
Just call me Henry

"David"
Sep 2007
Cambridge (GMT)

2×5×569 Posts

Quote:
 Originally Posted by Drdmitry The most of platform-specific code appeared in the program because of the need to implement the mulmod function. x64 processors can multiply two 64 bit numbers modulo another 64 bit number just in two basic assembler operations, which is much faster than the standard long arithmetic routine. If one can provide a fast cross-platform implementation of this function that would be great. In my implementation of mulmod, unfortunately, I did not manage to write it straight in assembler (perhaps because of my poor knowledge of how to add assembler code to a C++ program). I used VC++ intrinsic _mul128 for multiplication and some dirty hack found somewhere on the internet for taking the remainder. Nevertheless this combination worked about ten times faster than if NTL library is used. I did not try GMP but I expect that my mulmod will work significantly faster. I also used GetTickCount() function from windows.h to measure the time spent by certain procedures. I am sure that this part can easily be made platform independent.
Code:
long long int mulmod(long long int a, long long int b, long long int n) {
long long int d, dummy; /* d will get a*b mod c */
asm ("imulq %3\n\t" /* mul a*b -> rdx:rax */
"idivq %4\n\t" /* (a*b)/c -> quot in rax remainder in rdx */
:"=a"(dummy), "=&d"(d) /* output */
:"a"(a), "rm"(b), "rm"(n) /* input */
:"cc" /* imulq and idivq can set conditions */
);
return d;
}
This is what I use in c for gcc on windows. Will this work in c++? Will this work on linux?

2015-06-22, 17:15   #13
Antonio

"Antonio Key"
Sep 2011
UK

21316 Posts

Quote:
 Originally Posted by Antonio reserving 31730000-31739999 Approx. 10hrs work.

Reserving 31720000-31729999.

Question: is Ctrl-C the only method of exiting the program when it has finished?

2015-06-22, 17:21   #14
Drdmitry

Nov 2011

2×32×13 Posts

Quote:
 Originally Posted by henryzz Code: long long int mulmod(long long int a, long long int b, long long int n) { long long int d, dummy; /* d will get a*b mod c */ asm ("imulq %3\n\t" /* mul a*b -> rdx:rax */ "idivq %4\n\t" /* (a*b)/c -> quot in rax remainder in rdx */ :"=a"(dummy), "=&d"(d) /* output */ :"a"(a), "rm"(b), "rm"(n) /* input */ :"cc" /* imulq and idivq can set conditions */ ); return d; } This is what I use in c for gcc on windows. Will this work in c++? Will this work on linux?
It does not work in Visual Studio. (I just remember that VC++ does not support x64 inline assembler). I will try to compile it on Linux machine in the nearest few days.

2015-06-22, 17:29   #15
Drdmitry

Nov 2011

2·32·13 Posts

Quote:
 Originally Posted by Antonio Range complete, no results. Reserving 31720000-31729999. Question: is Ctrl-C the only method of exiting the program when it has finished?
Great, thanks. It is interesting to see that cycles are so rare for high numbers.
At the end you can enter any number (or even symbol) to exit. I put that in the code to be sure that the window with the program does not suddenly disappear. That is good for testing the program but probably not for the distributed computing. I will remove that feature and reupload the program again.

 2015-06-22, 18:13 #16 ChristianB   Apr 2013 Germany 2·32·17 Posts If you really want to allow some distributed computing with this app you should consider those points too:input and output filenames should be fixed (BOINC renames input and output files for better management) it should be easy to substitute all file open operations through an external library (because the external library will resolve the path) calculate the IOPS/FLOPS that are needed for a certain range (to estimate the runtime on a host where only the benchmark is known) provide some kind of suspend/resume (checkpointing) mechanism (BOINC may switch between applications every X minutes, set by the owner of the host) This way it can be compiled as a BOINC application and added to an existing BOINC project very easily.
2015-06-23, 00:53   #17
Happy5214

"Alexander"
Nov 2008
The Alamo City

22·3·29 Posts

Quote:
 Originally Posted by Drdmitry It does not work in Visual Studio. (I just remember that VC++ does not support x64 inline assembler). I will try to compile it on Linux machine in the nearest few days.
I wrote a quick test using henryzz's gcc code that worked successfully using g++ on an x64 Linux box.

2015-06-23, 04:07   #18
Antonio

"Antonio Key"
Sep 2011
UK

21316 Posts

Quote:
 Originally Posted by Antonio Reserving 31720000-31729999.
Only 1 cycle found.
Reserving 31710000-31719999.
Attached Files
 output_odd_10e16_31720000-31729999.txt (56 Bytes, 71 views)

2015-06-23, 10:29   #19
henryzz
Just call me Henry

"David"
Sep 2007
Cambridge (GMT)

2×5×569 Posts

Quote:
 Originally Posted by henryzz Sounds like a good idea. reserving 31740000-31746032 I am assuming the chance of success is proportional to the time spent rather than the range of n.

reserving 31700000-31709999

2015-06-23, 11:17   #20
Antonio

"Antonio Key"
Sep 2011
UK

32·59 Posts

Quote:
 Originally Posted by Antonio Reserving 31710000-31719999.
Reserving 31690000-31699999

2015-06-23, 15:16   #21
Drdmitry

Nov 2011

23410 Posts

Quote:
 Originally Posted by Antonio Only 1 cycle found. Reserving 31710000-31719999.
Great, The first pair is found! It is not in the Pat's list, so I'll send it to him with the discoverer name Antonio&Bodyagin. Please let me know if you want to be named otherwise.

Thanks to henryzz, It seems that I have managed to compile the program on Linux. I added the Linux source file to the main archive and also attached it here. The next step will be to translate all the comments there :)

Also I am reserving 1 - 1.
Attached Files
 main_linux.zip (7.6 KB, 67 views)

 2015-06-23, 15:58 #22 RichD     Sep 2008 Kansas 31×97 Posts I got a Linux build. I'll take two ranges. 31670000-31679999 31680000-31689999

 Similar Threads Thread Thread Starter Forum Replies Last Post Drdmitry Aliquot Sequences 124 2017-07-02 02:48 Drdmitry Aliquot Sequences 25 2016-12-16 15:26 schickel Aliquot Sequences 7 2013-02-08 01:33 schickel Aliquot Sequences 23 2011-05-16 23:13 R. Gerbicz Math 0 2010-07-01 12:30

All times are UTC. The time now is 21:06.

Mon Aug 3 21:06:43 UTC 2020 up 17 days, 16:53, 0 users, load averages: 1.16, 1.26, 1.35