BigInt module (SSE2)
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: BigInt module (SSE2)
My apologies for the bump. On Linux (Mint x64) and PureBasic 5.42 x64 BigInt operations stall execution (it stops). When LoadValue is called.
*RandN is just a buffer with random memory.
The exact same code works perfectly fine on Windows x64 and x86.
Scratch that, it was caused by a stack corruption in another library. When isolated, this code runs fine.
Code: Select all
Debug "loading value...."
BigInt::LoadValue(*n, *RandN, ByteSize, #True)
Debug "loaded value..."
The exact same code works perfectly fine on Windows x64 and x86.
Scratch that, it was caused by a stack corruption in another library. When isolated, this code runs fine.
Re: BigInt module (SSE2)
That explains why I couldn't replicate the problem.Crusiatus Black wrote:Scratch that, it was caused by a stack corruption in another library. When isolated, this code runs fine.
Anyway, glad to hear it works fine after all
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: BigInt module (SSE2)
Ah sorry, I didn't mean to give you unnecessary work. Now for me a challenge, how to find the stack issue that only occurs on Linux...wilbert wrote:That explains why I couldn't replicate the problem.Crusiatus Black wrote:Scratch that, it was caused by a stack corruption in another library. When isolated, this code runs fine.
Anyway, glad to hear it works fine after all
Re: BigInt module (SSE2)
No problem and good luck with tracking down the stack issue.Crusiatus Black wrote:Ah sorry, I didn't mean to give you unnecessary work. Now for me a challenge, how to find the stack issue that only occurs on Linux...
It can be difficult sometimes to solve something which is only happening on one OS.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
- Crusiatus Black
- Enthusiast
- Posts: 389
- Joined: Mon May 12, 2008 1:25 pm
- Location: The Netherlands
- Contact:
Re: BigInt module (SSE2)
Thank you! Yes, the purifier told me about the stack issue on Linux, however on Windows the purifier is quiet.wilbert wrote:No problem and good luck with tracking down the stack issue.Crusiatus Black wrote:Ah sorry, I didn't mean to give you unnecessary work. Now for me a challenge, how to find the stack issue that only occurs on Linux...
It can be difficult sometimes to solve something which is only happening on one OS.
The programming life is a magical life.
- NicknameFJ
- User
- Posts: 90
- Joined: Tue Mar 17, 2009 6:36 pm
- Location: Germany
Re: BigInt module (SSE2)
Hello Wilbert,
first I wish you a happy new year 2018.
Thank you for sharing your BigInt-Lib.
Maybe I´am doing something wrong with it, maybe there is an error in it.
Run this short prg and it will crash with an Stack Overflow Error. I´m on Windows 10 with PB 5.61 x64.
It is always wenn the result of a^b mod(c) is zero. The same happens when using the ModMul-Funktion and the result of a * b mod(c) is zero too. I think the error is in your procedure divmod_private procedure because this proc is called in both; if I comment the call of divmod_privat out, sure the result ist wrong when doing so, but no crash at all.
Maybe I´m doing something wrong with it. In this case it would be nice when you can tell me what I´m doing wrong.
Maybe you can take a look because I don´t understand your great code so I can not fix it by myself.
Thank you
NicknameFJ
first I wish you a happy new year 2018.
Thank you for sharing your BigInt-Lib.
Maybe I´am doing something wrong with it, maybe there is an error in it.
Run this short prg and it will crash with an Stack Overflow Error. I´m on Windows 10 with PB 5.61 x64.
It is always wenn the result of a^b mod(c) is zero. The same happens when using the ModMul-Funktion and the result of a * b mod(c) is zero too. I think the error is in your procedure divmod_private procedure because this proc is called in both; if I comment the call of divmod_privat out, sure the result ist wrong when doing so, but no crash at all.
Maybe I´m doing something wrong with it. In this case it would be nice when you can tell me what I´m doing wrong.
Maybe you can take a look because I don´t understand your great code so I can not fix it by myself.
Thank you
NicknameFJ
Code: Select all
IncludeFile "O:\Includes\BigInt\BigInt.pbi"
Define.BigInt::BigInt X, A, B, C
BigInt::SetValue(A,12)
BiGInt::SetValue(B,13)
BiGInt::SetValue(C,27)
BIGInt::ModPow(X,A,B,C)
PS: Sorry for my weird english, but english is not my native language.
Re: BigInt module (SSE2)
I made a small change to the module code in the first post.NicknameFJ wrote:Maybe I´am doing something wrong with it, maybe there is an error in it.
Run this short prg and it will crash with an Stack Overflow Error. I´m on Windows 10 with PB 5.61 x64.
Can you check if it works fine now ?
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
- NicknameFJ
- User
- Posts: 90
- Joined: Tue Mar 17, 2009 6:36 pm
- Location: Germany
Re: BigInt module (SSE2)
Hello wilbert,
after a few short tests it seems to work fine.
Thank you very very much for your answer and for fixing it so fast.
When we ever met tell me that you are wilbert and I will spend you one beer, or two, or three .....
NicknameFJ
after a few short tests it seems to work fine.
Thank you very very much for your answer and for fixing it so fast.
When we ever met tell me that you are wilbert and I will spend you one beer, or two, or three .....
NicknameFJ
PS: Sorry for my weird english, but english is not my native language.
- Michael Vogel
- Addict
- Posts: 2677
- Joined: Thu Feb 09, 2006 11:27 pm
- Contact:
Re: BigInt module (SSE2)
Great stuff, thanks to wilbert and little john!
Combining the Radi and BigInt modules allow wonderful calculations, like the old calculator precision test to repeat x^2 26 times starting with the value 1.0000001
Combining the Radi and BigInt modules allow wonderful calculations, like the old calculator precision test to repeat x^2 26 times starting with the value 1.0000001
Code: Select all
z=Radi::MaxDestDigits(BigInt::#BigIntBits,2,10)
Debug "A binary number with "+Str(BigInt::#BigIntBits)+" digits has up To "+Str(z)+" decimal digits"
z=z/2
BigInt::SetValue(n1,10000001)
For i=1 To 26
BigInt::Multiply(n1, n1)
s.s=Left(Radi::Hex2Dec(BigInt::GetHex(n1)),z)
BigInt::SetHexValue(n1,Radi::Dec2Hex(s))
Next i
Debug Radi::Hex2Dec(BigInt::GetHex(n1))
Re: BigInt module (SSE2)
hello wilbert
do you have a non-asm version?
could be useful for trying out on the C back-end
btw, I came across this document about arbitrary precision arithmetic algorithms with test-code in fortran https://ia800403.us.archive.org/10/item ... 9.5911.pdf
do you have a non-asm version?
could be useful for trying out on the C back-end
btw, I came across this document about arbitrary precision arithmetic algorithms with test-code in fortran https://ia800403.us.archive.org/10/item ... 9.5911.pdf
Re: BigInt module (SSE2)
Sorry, I don't.
At the time I didn't think about the possibility of PB running on something other than x86 / x64.
Windows (x64)
Raspberry Pi OS (Arm64)
Raspberry Pi OS (Arm64)
- Kwai chang caine
- Always Here
- Posts: 5353
- Joined: Sun Nov 05, 2006 11:42 pm
- Location: Lyon - France
Re: BigInt module (SSE2)
Useful funstion
Works here
Works here
Thanks for sharing121FA000A3723A57C24A442FE55618CF
1234567890ABCDEF
The happiness is a road...
Not a destination
Not a destination