News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Extension of the number range

Started by Gunther, March 14, 2022, 01:00:56 AM

Previous topic - Next topic

mineiro

Hello sir Gunther, I'm testing a new version and will post after clean code.
Program now check's for overflow and remap memory, so, overflow will not occur anymore, well, only if machine don't have enough memory.
Program accepts console user input or redirection by a file.

time spend to calculate and show all iterations of number bellow: 11minutes 13 seconds
iterations: 49551 (or 49552 if given value N(0) is to be counted)
number below have 2098 digits

Your start value is: N(0) =
987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321987654321
It's an odd  number.
This leads to the following Collatz Sequence:
---------------------------------------------
N(1) = 2962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962965962962964

Instead of printing digit by digit I do conversion and printed value buffer.
time spend: 14 seconds

After optimization time spend = 8 seconds

So, I'm only cleaning and commenting the source code and will post today.
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

Gunther

Mineiro,

as I have already written: You are very diligent.

However, I have questions. Why do you calculate with BCD numbers? All values that can occur are positive. There is no fractional part, so these rounding
errors won't appear. Wouldn't it be more convenient and faster to calculate in binary? The test for even or odd would also be simplified etc.

You have to know the facts before you can distort them.

mineiro

#17
Quote from: Gunther on March 17, 2022, 12:21:06 AM
Why do you calculate with BCD numbers?
To be easy to print iterations.

Quote
Wouldn't it be more convenient and faster to calculate in binary?
Yes, will be a lot faster if it's not necessary print all iterations value I suppose.
Well, convert decimal input string into binary number; do arithmetic on binary number, after each iteration convert binary number to decimal string and print. It's necessary check timings.

Follow a new attached version. For a reason that I don't understand it's not accepting input redirected files. I'm without win64 debug here.
If theres a file name "six.txt", and inside this file exist string "6",<enter> so it works. But when I try giant values I'm receiving an error (SEH I suppose).
collatz <six.txt >result.txt

To redirect output to a file it's working fine:
collatz >result.txt
I'd rather be this ambulant metamorphosis than to have that old opinion about everything

daydreamer

Quote from: mineiro on March 17, 2022, 01:19:49 AM
Yes, will be a lot faster if it's not necessary print all iterations value I suppose.
I tried SIMT solution
one. Thread calculate and second thread converts/prints, while first thread continue calculate But fibonnaci
Bcd is just loop with SSE orps to ascii, while binary also need div loop

my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding

Gunther

Mineiro,

Quote from: mineiro on March 17, 2022, 01:19:49 AM
Follow a new attached version. For a reason that I don't understand it's not accepting input redirected files. I'm without win64 debug here.
If theres a file name "six.txt", and inside this file exist string "6",<enter> so it works. But when I try giant values I'm receiving an error (SEH I suppose).
collatz <six.txt >result.txt

To redirect output to a file it's working fine:
collatz >result.txt

I'll test your program as soon as possible.
You have to know the facts before you can distort them.

Gunther

Daydreamer,

Quote from: daydreamer on March 17, 2022, 03:22:20 AM
I tried SIMT solution
one. Thread calculate and second thread converts/prints, while first thread continue calculate But fibonnaci
Bcd is just loop with SSE orps to ascii, while binary also need div loop

is this effort really necessary? The division by 2 can be done with a binary shift. Then only the multiplication by 3 and subsequent addition of 1 remains.
That's all it really is. We probably don't need to output every approximation either, just the starting value and the number of iterations at the end.
You have to know the facts before you can distort them.

daydreamer

Quote from: Gunther on March 17, 2022, 03:42:51 AM
is this effort really necessary? The division by 2 can be done with a binary shift. Then only the multiplication by 3 and subsequent addition of 1 remains.
That's all it really is. We probably don't need to output every approximation either, just the starting value and the number of iterations at the end.
I used prints every few seconds interval,just like Cg programs shows 0-100% progress better than wait and know nothing about progress
anyway my progress is learn/practice SIMT skill or stay onethreaded which will utilize few % of modern 32 core cpu
my none asm creations
https://masm32.com/board/index.php?topic=6937.msg74303#msg74303
I am an Invoker
"An Invoker is a mage who specializes in the manipulation of raw and elemental energies."
Like SIMD coding