Overclock.net - Overclocking.net
     
 
Home Gallery Reviews Blogs Register Today's Posts Mark Forums Read Members List


Go Back   Overclock.net - Overclocking.net > Software, Programming and Coding > Coding and Programming

Reply
 
LinkBack Thread Tools
Old 02-26-08   #41 (permalink)
Luck : 10pts
 
Licht's Avatar
 
amd ati

Join Date: Mar 2007
Location: Fl, US
Posts: 12,855
Blog Entries: 3

Rep: 365 Licht is a proven memberLicht is a proven memberLicht is a proven memberLicht is a proven member
Unique Rep: 242
Trader Rating: 0
Default

Quote:
Originally Posted by shinya View Post
I dunno what algorithms you're using to check primality (i didn't see the code), but a lot of research has been done on such stuff.

Since your objective is stressing the system for benchmarking purposes, maybe you've no actual interest in efficiency - which eventually add complexity. But maybe you might wanna consider some cleaver stuff for future releases.

The "standard" algorithm to find prime numbers from 2 up to N is called Sieve of Eratosthenes. http://en.wikipedia.org/wiki/Sieve_of_Eratosthenes
It's easy to implement with a single core, but i have no idea how to adapt it for multiple cores! It sounds hard!

Other than that, you might be aware of the mersenne prime search http://www.mersenne.org (which found only mersenne primes, which is a prime in the form 2^p - 1, where p is a prime number), and the math behind it http://www.mersenne.org/math.htm

Hope it helps! Happy coding!
I detect a prime number in a single line of code. I divide it by a number and if it comes out without any decimals places it is not a prime number. If it does not come out even then i proceed to increase the number again and again until it either detects it as not a prime number or the divisor reaches half the value of the number in question in which case we go to the next number 2 numbers up. Well in single threaded thats how it works. In multithreading it increases the number by 2 times the number of threads so that all threads continually check different numbers and in the end add their results together. I'm quite proud of how efficient the code is.

Code:
while (Continue == true) // ///////////////////////Benching loop
            {
                if (CurrentDivisor > (CurrentNumber / 2)) // ///////Skip if larger then half
                {
                    CurrentNumber += RelInc;
                    CurrentDivisor = 2;
                    ThisPrimes += 1;
                }
                if (CurrentNumber > (TestLength - 1))
                {
                    if (ThreadCount == 1)
                    {
                        FoundPrimes += ThisPrimes;
                        Time2 = (Convert.ToDecimal(DateTime.Now.Millisecond)
                            + (Convert.ToDecimal(DateTime.Now.Second) * 1000)
                            + (Convert.ToDecimal(DateTime.Now.Minute) * 60000)
                            + (Convert.ToDecimal(DateTime.Now.Hour) * 3600000)) - Time;
                        MessageBox.Show("Time to complete : "
                            + Convert.ToString(Time2)
                            + "ms - Prime Numbers found : "
                            + Convert.ToString(FoundPrimes));
                        Rad1.Enabled = true;
                        Rad2.Enabled = true;
                        Rad3.Enabled = true;
                        Rad4.Enabled = true;
                        Rad5.Enabled = true;
                        Rad6.Enabled = true;
                        Rad7.Enabled = true;
                        Rad8.Enabled = true;
                        Rad9.Enabled = true;
                        Rad10.Enabled = true;
                        Rad11.Enabled = true;
                        Rad12.Enabled = true;
                        Rad13.Enabled = true;
                        Rad14.Enabled = true;
                        Rad15.Enabled = true;
                        Btn2.Enabled = true;
                        Btn1.Text = "Benchmark";
                        Btn1.Enabled = true;
                        FoundPrimes = 1;
                        progressBar1.Value = 0;
                        ThreadsFinished = 0;
                        Continue = false;
                        Thread.CurrentThread.Abort();
                    }
                    else
                    {
                        if (ThreadsFinished == (ThreadCount - 1))
                        {
                            FoundPrimes += ThisPrimes;
                            Time2 = (Convert.ToDecimal(DateTime.Now.Millisecond)
                                + (Convert.ToDecimal(DateTime.Now.Second) * 1000)
                                + (Convert.ToDecimal(DateTime.Now.Minute) * 60000)
                                + (Convert.ToDecimal(DateTime.Now.Hour) * 3600000)) - Time;
                            MessageBox.Show("Time to complete : " 
                                + Convert.ToString(Time2) 
                                + "ms - Prime Numbers found : " 
                                + Convert.ToString(FoundPrimes));
                            Rad1.Enabled = true;
                            Rad2.Enabled = true;
                            Rad3.Enabled = true;
                            Rad4.Enabled = true;
                            Rad5.Enabled = true;
                            Rad6.Enabled = true;
                            Rad7.Enabled = true;
                            Rad8.Enabled = true;
                            Rad9.Enabled = true;
                            Rad10.Enabled = true;
                            Rad11.Enabled = true;
                            Rad12.Enabled = true;
                            Rad13.Enabled = true;
                            Rad14.Enabled = true;
                            Rad15.Enabled = true;
                            Btn2.Enabled = true;
                            Btn1.Text = "Benchmark";
                            Btn1.Enabled = true;
                            FoundPrimes = 1;
                            progressBar1.Value = 0;
                            ThreadsFinished = 0;
                            Continue = false;
                            Thread.CurrentThread.Abort();
                        }
                        else
                        {
                            FoundPrimes += ThisPrimes;
                            ThreadsFinished += 1;
                            Continue = false;
                            Thread.CurrentThread.Abort();
                        }
                    }
                }
                if (Decimal.Round(CurrentNumber / CurrentDivisor, 0) == (CurrentNumber / CurrentDivisor)
                    | Decimal.Round(CurrentNumber / CurrentDivisor, 0) - 1 == (CurrentNumber / CurrentDivisor))
                {
                    CurrentDivisor = 2;
                    CurrentNumber += RelInc;
                    if (Convert.ToDecimal(ThreadNumber) == 1)
                    {
                        progressBar1.Value = Convert.ToInt32((CurrentNumber / TestLength) * 100); //
                    }
                }
                else
                {
                    CurrentDivisor += 1;
                }
            }
That code is actually bad anymore looking at it. The new code i am working on should be monstrously more efficient. Theres really too many checks involved there... the big issue is multi threading which adds quite a bit of code.

Quote:
What kind of help do you need? I'm in a class now that's entirely about the line between hardware and software, and I would be very interested in applying what I'm learning
If you want to get involved my messengers are.

YIM/MSN : dager332@yahoo.com
Xfire : dekustars

We can talk more there. Or over PM (not preferred) if you don't have any messengers. I do need help working on an algorithm at the moment... quite complex...

System: Uzicht #4.5
CPU
Phenom II X4 920
Motherboard
Gigabyte 790X AM2+
Memory
6GB Kingston DDR2 667MHZ
Graphics Card
HD4850 + HD3870
Hard Drive
4x WD1600AAJS RAID0
Sound Card
X-Fi Extreme Gamer Professional
Power Supply
OCZ Game-X-Stream 700w
Case
NZXT Black Steel
CPU cooling
Xigmatec Rifle
GPU cooling
Stock Saphire 3870 Cooling
OS
Windows 7 Ultimate x86-x64
Monitor
Samsung SyncMaster 19"Wide
Licht is offline Overclocked Account Licht's Gallery   Reply With Quote
Old 02-26-08   #42 (permalink)
With great difficulty
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 5,210

Rep: 614 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 370
FAQs Submitted: 6
Trader Rating: 5
Default

That really only tests the floating point divide performance, which is an extremely slow and relatively uncommon instruction. I hate to say it so bluntly, but that's a pretty bad benchmark. Is that the entire thing?
__________________
System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 02-26-08   #43 (permalink)
Luck : 10pts
 
Licht's Avatar
 
amd ati

Join Date: Mar 2007
Location: Fl, US
Posts: 12,855
Blog Entries: 3

Rep: 365 Licht is a proven memberLicht is a proven memberLicht is a proven memberLicht is a proven member
Unique Rep: 242
Trader Rating: 0
Default

Quote:
Originally Posted by rabidgnome229 View Post
That really only tests the floating point divide performance, which is an extremely slow and relatively uncommon instruction. I hate to say it so bluntly, but that's a pretty bad benchmark. Is that the entire thing?
I'm adding more tests next build. For the most part of the code that is it. You can of course change the division to multiplication. Quite easily actually. I was not aware that division was a complicated instruction for the CPU to carry out. That and the fact its a floating point instruction gives AMD a massive advantage if i remember correctly... Hm. Anyways might as well spill it i'm working on multi-threaded pi calculation among other things.

System: Uzicht #4.5
CPU
Phenom II X4 920
Motherboard
Gigabyte 790X AM2+
Memory
6GB Kingston DDR2 667MHZ
Graphics Card
HD4850 + HD3870
Hard Drive
4x WD1600AAJS RAID0
Sound Card
X-Fi Extreme Gamer Professional
Power Supply
OCZ Game-X-Stream 700w
Case
NZXT Black Steel
CPU cooling
Xigmatec Rifle
GPU cooling
Stock Saphire 3870 Cooling
OS
Windows 7 Ultimate x86-x64
Monitor
Samsung SyncMaster 19"Wide
Licht is offline Overclocked Account Licht's Gallery   Reply With Quote
Old 02-26-08   #44 (permalink)
With great difficulty
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 5,210

Rep: 614 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 370
FAQs Submitted: 6
Trader Rating: 5
Default

Quote:
Originally Posted by Licht View Post
I'm adding more tests next build. For the most part of the code that is it. You can of course change the division to multiplication. Quite easily actually. I was not aware that division was a complicated instruction for the CPU to carry out. That and the fact its a floating point instruction gives AMD a massive advantage if i remember correctly... Hm. Anyways might as well spill it i'm working on multi-threaded pi calculation among other things.
Floating point is slower than integer, and divide is as slow as it gets. As an example, a PIII can perform an integer add in 1 clock cycle, integer multiply in 4, and integer divide in 36. Floating point numbers are 3, 5, and 38.
__________________
System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 02-26-08   #45 (permalink)
Luck : 10pts
 
Licht's Avatar
 
amd ati

Join Date: Mar 2007
Location: Fl, US
Posts: 12,855
Blog Entries: 3

Rep: 365 Licht is a proven memberLicht is a proven memberLicht is a proven memberLicht is a proven member
Unique Rep: 242
Trader Rating: 0
Default

Quote:
Originally Posted by rabidgnome229 View Post
Floating point is slower than integer, and divide is as slow as it gets. As an example, a PIII can perform an integer add in 1 clock cycle, integer multiply in 4, and integer divide in 36. Floating point numbers are 3, 5, and 38.
Very interesting information. So turn division into multiplication (simple enough) and avoid numbers 3, 5, and 38 and you should notice decent-great performance gains?

System: Uzicht #4.5
CPU
Phenom II X4 920
Motherboard
Gigabyte 790X AM2+
Memory
6GB Kingston DDR2 667MHZ
Graphics Card
HD4850 + HD3870
Hard Drive
4x WD1600AAJS RAID0
Sound Card
X-Fi Extreme Gamer Professional
Power Supply
OCZ Game-X-Stream 700w
Case
NZXT Black Steel
CPU cooling
Xigmatec Rifle
GPU cooling
Stock Saphire 3870 Cooling
OS
Windows 7 Ultimate x86-x64
Monitor
Samsung SyncMaster 19"Wide
Licht is offline Overclocked Account Licht's Gallery   Reply With Quote
Old 02-26-08   #46 (permalink)
Off By 340 Undecillion
 
The Bartender Paradox's Avatar
 
amd nvidia

Join Date: Oct 2004
Location: Portland, Oregon
Posts: 2,472

Rep: 368 The Bartender Paradox is a proven memberThe Bartender Paradox is a proven memberThe Bartender Paradox is a proven memberThe Bartender Paradox is a proven member
Unique Rep: 276
Hardware Reviews: 1
Trader Rating: 3
Default

Just a few nitpicks on the algorithm, you only need to check up to the square root of the number in question, not half the number. Also, If you wanted to keep the calculations in integers you can use the remainder function to see if a number evenly divides (remainder = 0)
__________________
Congratulations! You have foundthe secret text! You get a cookie.

System: ½
CPU
AMD A64 3500+ Winchester
Motherboard
DFI nF4 SLi-DR
Memory
OCZ 4000VX
Graphics Card
EVGA 7800GT
Hard Drive
Maxtor 300Gb 16Mb Buffer
Sound Card
computers make sounds?
Power Supply
OCZ PowerStream 520W
Case
None
CPU cooling
Big
GPU cooling
Bigger
OS
XP Pro
Monitor
SOYO LCD
The Bartender Paradox is online now Overclocked Account The Bartender Paradox's Gallery   Reply With Quote
Old 02-26-08   #47 (permalink)
Luck : 10pts
 
Licht's Avatar
 
amd ati

Join Date: Mar 2007
Location: Fl, US
Posts: 12,855
Blog Entries: 3

Rep: 365 Licht is a proven memberLicht is a proven memberLicht is a proven memberLicht is a proven member
Unique Rep: 242
Trader Rating: 0
Default

Quote:
Originally Posted by The Bartender Paradox View Post
Just a few nitpicks on the algorithm, you only need to check up to the square root of the number in question, not half the number. Also, If you wanted to keep the calculations in integers you can use the remainder function to see if a number evenly divides (remainder = 0)
Ah, very handy. Decimals are slower then Integers aren't they? (Meaning i think so but i am not sure.)

System: Uzicht #4.5
CPU
Phenom II X4 920
Motherboard
Gigabyte 790X AM2+
Memory
6GB Kingston DDR2 667MHZ
Graphics Card
HD4850 + HD3870
Hard Drive
4x WD1600AAJS RAID0
Sound Card
X-Fi Extreme Gamer Professional
Power Supply
OCZ Game-X-Stream 700w
Case
NZXT Black Steel
CPU cooling
Xigmatec Rifle
GPU cooling
Stock Saphire 3870 Cooling
OS
Windows 7 Ultimate x86-x64
Monitor
Samsung SyncMaster 19"Wide
Licht is offline Overclocked Account Licht's Gallery   Reply With Quote
Old 02-26-08   #48 (permalink)
With great difficulty
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 5,210

Rep: 614 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 370
FAQs Submitted: 6
Trader Rating: 5
Default

Quote:
Originally Posted by Licht View Post
Very interesting information. So turn division into multiplication (simple enough) and avoid numbers 3, 5, and 38 and you should notice decent-great performance gains?
The numbers 3 5 and 38 are the clock cycles per floating point add, multiply and divide respectively.

The focus isn't be getting it to run as fast as possible. A good benchmark should try to test common instructions, weighted by how common they are. The instructions you test would depend on what kind of benchmark you want. Real-world apps tend to use different instructions than multimedia apps or scientific apps, for example

Quote:
Originally Posted by Licht View Post
Ah, very handy. Decimals are slower then Integers aren't they? (Meaning i think so but i am not sure.)
Anything with a decimal is stored as a floating point number. Floating point instructions are generally a good bit slower than integer
__________________
System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Old 02-26-08   #49 (permalink)
Luck : 10pts
 
Licht's Avatar
 
amd ati

Join Date: Mar 2007
Location: Fl, US
Posts: 12,855
Blog Entries: 3

Rep: 365 Licht is a proven memberLicht is a proven memberLicht is a proven memberLicht is a proven member
Unique Rep: 242
Trader Rating: 0
Default

Quote:
The numbers 3 5 and 38 are the clock cycles per floating point add, multiply and divide respectively.

The focus isn't be getting it to run as fast as possible. A good benchmark should try to test common instructions, weighted by how common they are. The instructions you test would depend on what kind of benchmark you want. Real-world apps tend to use different instructions than multimedia apps or scientific apps, for example
Ok ok i see what you are talking about.

Quote:
Anything with a decimal is stored as a floating point number. Floating point instructions are generally a good bit slower than integer
Ok so ditch everything decimal and move to integers and multiplication in every possible situation. Ok will be simple enough to work with the new engine. (I haven't started on pi, i am working on Prime Numerization now and it won't take long, should be done with that much today. Then i will start researching on pi and probably conquer some other things while im at it.)

System: Uzicht #4.5
CPU
Phenom II X4 920
Motherboard
Gigabyte 790X AM2+
Memory
6GB Kingston DDR2 667MHZ
Graphics Card
HD4850 + HD3870
Hard Drive
4x WD1600AAJS RAID0
Sound Card
X-Fi Extreme Gamer Professional
Power Supply
OCZ Game-X-Stream 700w
Case
NZXT Black Steel
CPU cooling
Xigmatec Rifle
GPU cooling
Stock Saphire 3870 Cooling
OS
Windows 7 Ultimate x86-x64
Monitor
Samsung SyncMaster 19"Wide
Licht is offline Overclocked Account Licht's Gallery   Reply With Quote
Old 02-26-08   #50 (permalink)
With great difficulty
 
rabidgnome229's Avatar
 
intel nvidia

Join Date: Feb 2006
Location: Pittsburgh
Posts: 5,210

Rep: 614 rabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famousrabidgnome229 is becoming famous
Unique Rep: 370
FAQs Submitted: 6
Trader Rating: 5
Default

Quote:
Originally Posted by Licht View Post
Ok ok i see what you are talking about.



Ok so ditch everything decimal and move to integers and multiplication in every possible situation. Ok will be simple enough to work with the new engine. (I haven't started on pi, i am working on Prime Numerization now and it won't take long, should be done with that much today. Then i will start researching on pi and probably conquer some other things while im at it.)
You should still test floating point and still test division, because both are important. You just shouldn't only test fp division
__________________
System: It goes to eleven
CPU
E6300
Motherboard
DS3
Memory
2GB XMS2 DDR2-800
Graphics Card
EVGA 8600GTS
Hard Drive
1.294 TB
Sound Card
Audigy 2 ZS
Power Supply
Corsair 520HX
Case
Lian-Li v1000B Plus
CPU cooling
TTBT
GPU cooling
Thermalright V2
OS
Arch Linux/XP
Monitor
Samsung 226bw
rabidgnome229 is offline Overclocked Account   Reply With Quote
Reply

Tags
benchmark, doublemark, doublemark topic, multi-thread, stress test


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools



All times are GMT -5. The time now is 12:24 PM.


Overclock.net is a Carbon Neutral Site Creative Commons License

Terms of Service / Forum Rules | Privacy Policy | DMCA Info | Advertising | Become an Official Vendor
Copyright © 2009 Shogun Interactive Development. Most rights reserved.
Page generated in 0.19242 seconds with 9 queries