mersenneforum.org  

Go Back   mersenneforum.org > Fun Stuff > Lounge

Reply
 
Thread Tools
Old 2009-07-14, 04:45   #23
starrynte
 
starrynte's Avatar
 
Oct 2008
California

22×59 Posts
Default

Here is a version not yet implementing the "fast modulus", but it now uses text output which seems to be faster, plus a few minor optimizations.
Attached Files
File Type: zip LLMidlet.zip (6.1 KB, 112 views)

Last fiddled with by starrynte on 2009-07-14 at 04:47
starrynte is offline   Reply With Quote
Old 2009-07-14, 16:41   #24
henryzz
Just call me Henry
 
henryzz's Avatar
 
"David"
Sep 2007
Cambridge (GMT/BST)

23·3·5·72 Posts
Default

Quote:
Originally Posted by starrynte View Post
Here is a version not yet implementing the "fast modulus", but it now uses text output which seems to be faster, plus a few minor optimizations.
i will test on my slowcoach phone
hopefully now it is text based i will be able to run overnight tests without it stopping(you cant measure cpu time can you?)
henryzz is offline   Reply With Quote
Old 2009-07-14, 17:00   #25
henryzz
Just call me Henry
 
henryzz's Avatar
 
"David"
Sep 2007
Cambridge (GMT/BST)

133708 Posts
Default

Quote:
Originally Posted by henryzz View Post
i will test on my slowcoach phone
hopefully now it is text based i will be able to run overnight tests without it stopping(you cant measure cpu time can you?)
i left my phone at school but on my mums(a W580i which was almost twice as fast as mine) it still stops after a while
henryzz is offline   Reply With Quote
Old 2009-07-14, 17:30   #26
Damian
 
Damian's Avatar
 
May 2005
Argentina

2×3×31 Posts
Default

I tested starrynte's new version (I think you should number your versions) and compared it to the previous version.

On my f305 it seems the new version is slower than the previous one, in fact, the older version was somewhat 1.014 times faster than the new.

Code:
#    Mersenne  old midlet        new midlet         ratio
m13 | M521   | 0.38 sec        | 0.39 sec         | 1.026
m14 | M607   | 0.54 sec        | 0.56 sec         | 1.037
m15 | M1279  | 4.29 sec        | 4.4 sec          | 1.026 
m16 | M2203  | 20.58 sec       | 20.9 sec         | 1.015
m17 | M2281  | 23.11 sec       | 23.46 sec        | 1.015
m18 | M3217  | 1 min 2.57 sec  | 1 min 3.43 sec   | 1.014
Does it run faster on other phones?
Damian is offline   Reply With Quote
Old 2009-07-14, 19:00   #27
starrynte
 
starrynte's Avatar
 
Oct 2008
California

22·59 Posts
Default

Interesting. It was (much) slower on my phone too, but faster on the emulator...
From what I read from a quick glance over Google, you can't detect CPU usage on mobile applications.
I'll try a precomputed table for the percentages (which won't count as part of the time needed for the test)
Also, I'll try "starting" the midlet when pauseApp() is called, assuming that when it "stops" it's only "paused"

Last fiddled with by starrynte on 2009-07-14 at 19:02
starrynte is offline   Reply With Quote
Old 2009-09-02, 08:15   #28
henryzz
Just call me Henry
 
henryzz's Avatar
 
"David"
Sep 2007
Cambridge (GMT/BST)

133708 Posts
Default

Quote:
Originally Posted by starrynte View Post
Also reposting questions:
1) Do all LLR tests perform <exponent - 2> iterations?
2) Can you do (mod k * 2^n - 1) after each iteration for
i) only where k=1?
ii) all LLR tests?
iii) something else?
read this http://isthe.com/chongo/src/calc/lucas-calc
here are my answers based on it
1) yes
2) ii

it also explains selecting all starting values(his program wont select absolutely all as he relies on tables for the variables D, a, and b)
also look at llr's source code for that
henryzz is offline   Reply With Quote
Old 2011-08-09, 09:59   #29
henryzz
Just call me Henry
 
henryzz's Avatar
 
"David"
Sep 2007
Cambridge (GMT/BST)

23×3×5×72 Posts
Default

1802 seconds/30 minutes to test 2^23209-1(M26) on one core of a Samsung Galaxy S II. Anyone ever tested higher?
henryzz is offline   Reply With Quote
Old 2011-08-10, 03:49   #30
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

100101100010112 Posts
Default

Quote:
Originally Posted by henryzz View Post
Samsung Galaxy S II
My daughter is owning one since 2 weeks (I am still Motorola C116 guy, hehe). Willing to try what the 2-cores MPU can do. Any link for the code/application you used?
LaurV is offline   Reply With Quote
Old 2011-08-10, 12:31   #31
henryzz
Just call me Henry
 
henryzz's Avatar
 
"David"
Sep 2007
Cambridge (GMT/BST)

23×3×5×72 Posts
Default

Quote:
Originally Posted by LaurV View Post
My daughter is owning one since 2 weeks (I am still Motorola C116 guy, hehe). Willing to try what the 2-cores MPU can do. Any link for the code/application you used?
I used the latest .jar above converted to apk with http://www.netmite.com/android/
henryzz is offline   Reply With Quote
Old 2011-08-11, 03:43   #32
LaurV
Romulan Interpreter
 
LaurV's Avatar
 
Jun 2011
Thailand

7·1,373 Posts
Default

Sorry, did not see the thread has 2 pages , just now found the jar file. I will give it a try.


Quote:
Originally Posted by starrynte View Post
ok
expect a much smaller and faster version some time this week

(I found a faster way to do modulus,
a % 2^n - 1 = (a + 2^n - 1 * (a % 2^n)) / 2^n
and of course a % 2^n = a & (2^n - 1), and dividing by 2^n = shift right n bits
)
This still sounds complicate for me. To do x modulo m (m=2^n-1) you just have to add the higher n bits of x with the lower n bits of x (x<m^2 if it comes from squaring) and if the result is m, then make it 0, else you got the right result. If you do LL, you will never get a 0 "on the way", just the last one can be 0, so you don't really need the test.

This works because if y=x mod m, then y=m*k+x, so y=k*(2^n-1)+x that you can write like x=(y+k)-k*(2^n).

So your "mod 2^n-1" operation is just a mask on n bits, a shift on n bits, and an addition on n bits (maximum).
For example, 13*13 (mod 31) = (binarry) 1101*1101=101 01001 (note the space) and you have to add 101+01001=01110=14(decimal) that is 169 mod 31.

Last fiddled with by LaurV on 2011-08-11 at 03:48
LaurV is offline   Reply With Quote
Old 2011-08-11, 16:25   #33
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

26×131 Posts
Default

Quote:
Originally Posted by LaurV View Post
Sorry, did not see the thread has 2 pages , just now found the jar file. I will give it a try.




This still sounds complicate for me. To do x modulo m (m=2^n-1) you just have to add the higher n bits of x with the lower n bits of x (x<m^2 if it comes from squaring) and if the result is m, then make it 0, else you got the right result. If you do LL, you will never get a 0 "on the way", just the last one can be 0, so you don't really need the test.

This works because if y=x mod m, then y=m*k+x, so y=k*(2^n-1)+x that you can write like x=(y+k)-k*(2^n).

So your "mod 2^n-1" operation is just a mask on n bits, a shift on n bits, and an addition on n bits (maximum).
For example, 13*13 (mod 31) = (binarry) 1101*1101=101 01001 (note the space) and you have to add 101+01001=01110=14(decimal) that is 169 mod 31.
flaw:

Code:
(13:13)>binary(128)
%15 = [1, 0, 0, 0, 0, 0, 0, 0]
(13:18)>[1,0,0]+[0,0,0]
%16 = [1, 0, 0]
(13:18)>128%7
%17 = 2
(13:19)>2^3-1
%18 = 7
also I don't see how you get the last equation. according to you to do 128 mod (7=2^3-1) I take 100 + 000 = 100 and solve it as 4 but 128 = (2*49) + (4*7) +2 so the correct result is 2.
science_man_88 is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Cell Phone AstroPhotography Spherical Cow Astronomy 59 2019-01-21 22:47
IRS Phone Scam wblipp Lounge 0 2014-09-09 18:42
Masking a PIN over a phone call. Flatlander Puzzles 35 2013-10-31 10:34
Cell+ tha Hardware 1 2006-09-07 16:24
Prime95 on a cell phone JuanTutors Lounge 5 2004-08-18 08:53

All times are UTC. The time now is 22:48.


Fri Jul 16 22:48:15 UTC 2021 up 49 days, 20:35, 1 user, load averages: 2.17, 3.14, 3.03

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.