mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Hardware > GPU Computing

Reply
 
Thread Tools
Old 2017-08-08, 05:56   #34
error
 
Sep 2014

1716 Posts
Default

Quote:
Originally Posted by preda View Post
No, I simply don't know how to do it -- I'm lacking the math background. If you could describe how to do it, that'd help me understand.
Ah, OK. See https://en.wikipedia.org/wiki/Jacobi_symbol

Basically you check the numbers mod 4 or 8, swap them around, take the remainder, and repeat until you end up with 1 or 2.
error is offline   Reply With Quote
Old 2017-08-08, 07:26   #35
preda
 
preda's Avatar
 
"Mihai Preda"
Apr 2015

101101011002 Posts
Default

Quote:
Originally Posted by error View Post
Ah, OK. See https://en.wikipedia.org/wiki/Jacobi_symbol

Basically you check the numbers mod 4 or 8, swap them around, take the remainder, and repeat until you end up with 1 or 2.
OK, reading the wikipedia article I see there's a fast way to compute the Jacobi symbol.

I have two more questions:

- why, if R is a valid LL residue, (R-2/Mp) must be -1.
- why, if (x-2/Mp) is 1, it follows that iterating LL from x produces (R-2/Mp)==1 at each iteration.

(if I understood correctly what you said).
preda is offline   Reply With Quote
Old 2017-08-08, 08:23   #36
error
 
Sep 2014

23 Posts
Default

Quote:
Originally Posted by preda View Post
OK, reading the wikipedia article I see there's a fast way to compute the Jacobi symbol.

I have two more questions:

- why, if R is a valid LL residue, (R-2/Mp) must be -1.
- why, if (x-2/Mp) is 1, it follows that iterating LL from x produces (R-2/Mp)==1 at each iteration.

(if I understood correctly what you said).
At the beginning R0 = 4

This is always (R0+2/Mp) = -1 and (R0-2/Mp) = 1

The next residue is R1 = R0^2-2

This computes as (R1+2/Mp) = (R0^2/Mp) = 1 and (R1-2/Mp) = (R0^2-4/Mp) = ((R0-2)(R0+2)/Mp) = (R0-2/Mp)(R0+2/Mp) = 1*(-1) = -1

For any subsequent iteration the same happens: (Ri+2/Mp) = 1 and (Ri-2/Mp) = -1

If you take a random number Rx instead, it has equal probabilities of having any of the four combinations of (Rx+-2/Mp) as ++, +-, -+, --(1)

Then computing ((Rx^2-2)+-2/Mp) would result in ++, +-, +-, ++, which is wrong to be a proper residue 50% of the cases (it should be +-).

If you could check this at every iteration, i.e. also when you happen to run into Rx, you'd catch the case -+ as well, so 75% of the cases, and only +- would let you continue.
error is offline   Reply With Quote
Old 2017-08-08, 08:55   #37
preda
 
preda's Avatar
 
"Mihai Preda"
Apr 2015

22·3·112 Posts
Default

Quote:
Originally Posted by error View Post
At the beginning R0 = 4

This is always (R0+2/Mp) = -1 and (R0-2/Mp) = 1

The next residue is R1 = R0^2-2

This computes as (R1+2/Mp) = (R0^2/Mp) = 1 and (R1-2/Mp) = (R0^2-4/Mp) = ((R0-2)(R0+2)/Mp) = (R0-2/Mp)(R0+2/Mp) = 1*(-1) = -1

For any subsequent iteration the same happens: (Ri+2/Mp) = 1 and (Ri-2/Mp) = -1

If you take a random number Rx instead, it has equal probabilities of having any of the four combinations of (Rx+-2/Mp) as ++, +-, -+, --(1)

Then computing ((Rx^2-2)+-2/Mp) would result in ++, +-, +-, ++, which is wrong to be a proper residue 50% of the cases (it should be +-).

If you could check this at every iteration, i.e. also when you happen to run into Rx, you'd catch the case -+ as well, so 75% of the cases, and only +- would let you continue.
Indeed -- thanks! This sounds like a useful inexpensive characteristic to check. Probably not practical to check on each iteration, but even done per "block" (e.g. 10K iterations) should catch 50% of 1-errors, and get better for multi-errors. Cool!
preda is offline   Reply With Quote
Old 2017-08-08, 09:09   #38
retina
Undefined
 
retina's Avatar
 
"The unspeakable one"
Jun 2006
My evil lair

6,793 Posts
Default

How does this differ from the sum_of_inputs = sum_of_outputs test? Is it more robust? It is cheaper to compute? Should it be used as an additional test or a replacement? If there are two (or more) errors that occur between doing the tests does it go back to the +- result?
retina is offline   Reply With Quote
Old 2017-08-08, 10:33   #39
error
 
Sep 2014

23 Posts
Default

Quote:
Originally Posted by retina View Post
How does this differ from the sum_of_inputs = sum_of_outputs test? Is it more robust? It is cheaper to compute? Should it be used as an additional test or a replacement? If there are two (or more) errors that occur between doing the tests does it go back to the +- result?
If I understand that right, sumin = sumout check can only find errors in one individual iteration, where it is made.

"Jacobi-flip" sustains in subsequent iterations as well.

If more than one random errors occur in between, you gain no more, as these have an equal chance of curing the improper value as keeping it such. The overall chance remains at 50%.
error is offline   Reply With Quote
Old 2017-08-08, 10:48   #40
preda
 
preda's Avatar
 
"Mihai Preda"
Apr 2015

22·3·112 Posts
Default

Quote:
Originally Posted by retina View Post
How does this differ from the sum_of_inputs = sum_of_outputs test? Is it more robust? It is cheaper to compute? Should it be used as an additional test or a replacement? If there are two (or more) errors that occur between doing the tests does it go back to the +- result?
I have limited knowledge about sum_inp^2 != sum_out, but this is about what I remember:
- the sumout is huge, so care ("tricks") must be taken when doing the summation otherwise the errors overcome the signal.
- the sums are not over integers, but over the reals produced by the weighting of the DWT (or the output of the IFFT, before the reverse weighting)
- there is an heuristic element in deciding how much difference is "too much" (i.e. the test is approximate)

In practice, on GPU at least, the "max error" seems to me an easier and more useful indication of a plausible result.

About the "sticky" behavior of the Jacobian test, my intuition is this: when checking after each batch (e.g. 10K iterations), if inside the batch there is one *or more* errors, there is 50% probability of detection at the batch level.

So if over the whole LL there are E errors, if E is much smaller than the number of batches, we have overall "undetected error" of 0.5^E. The worst case would still be a single error (over the whole LL) with overall detection of only 1/2.
preda is offline   Reply With Quote
Old 2017-08-08, 14:11   #41
preda
 
preda's Avatar
 
"Mihai Preda"
Apr 2015

22×3×112 Posts
Default

Computing the Jacobi symbol is not so fast after all -- the slow operation is the repeated modulo of big integers. I did some experiments with GMP (GNU MP) which conveniently offers mpz_jacobi(), and the time for exponent 77002949 is around 55s on one core of my CPU.

Everything works as expected otherwise, producing -1 on all iterations.
preda is offline   Reply With Quote
Old 2017-08-08, 17:01   #42
Prime95
P90 years forever!
 
Prime95's Avatar
 
Aug 2002
Yeehaw, FL

17·487 Posts
Default

Quote:
Originally Posted by preda View Post
Computing the Jacobi symbol is not so fast after all -- the slow operation is the repeated modulo of big integers. I did some experiments with GMP (GNU MP) which conveniently offers mpz_jacobi(), and the time for exponent 77002949 is around 55s on one core of my CPU.

Everything works as expected otherwise, producing -1 on all iterations.
55 seconds every ten or hundred thousand iterations for a 50% chance of discovering an error seems like pretty cheap insurance to me.

Is there free Jacobi code available ( GMP has poisonous GNU license restrictions )? P.S. I'd google for free code but my Internet availability is severely restricted at the moment. P.P.S. I think using libgmp would avoid license issues assuming one can freely ship libgmp for all platforms that prime95 supports. But then again IANAL.
Prime95 is offline   Reply With Quote
Old 2017-08-08, 17:14   #43
GP2
 
GP2's Avatar
 
Sep 2003

2×5×7×37 Posts
Default

Quote:
Originally Posted by Prime95 View Post
P.P.S. I think using libgmp would avoid license issues assuming one can freely ship libgmp for all platforms that prime95 supports. But then again IANAL.
For Windows there's a compatible library called MPIR which is licensed LGPL v3+. Is that an acceptable license?
GP2 is offline   Reply With Quote
Old 2017-08-08, 18:20   #44
chalsall
If I May
 
chalsall's Avatar
 
"Chris Halsall"
Sep 2002
Barbados

2×112×47 Posts
Default

Quote:
Originally Posted by GP2 View Post
...which is licensed LGPL v3+. Is that an acceptable license?
It should be. The GNU Lesser General Public License allows inclusion of the code into proprietary software.
chalsall is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Stockfish / Lutefisk game, move 14 poll. Hungry for fish and black pieces. MooMoo2 Other Chess Games 0 2016-11-26 06:52
Redoing factoring work done by unreliable machines tha Lone Mersenne Hunters 23 2016-11-02 08:51
Unreliable AMD Phenom 9850 xilman Hardware 4 2014-08-02 18:08
[new fish check in] heloo mwxdbcr Lounge 0 2009-01-14 04:55
The Happy Fish thread xilman Hobbies 24 2006-08-22 11:44

All times are UTC. The time now is 15:26.


Fri Jul 7 15:26:29 UTC 2023 up 323 days, 12:55, 0 users, load averages: 1.22, 1.15, 1.11

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2023, 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.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔