Would this be a good CPU stress test?

tank171

Member
May 27, 2007
93
0
0
I created a small program to test a CPU. It is extremely small and works well. If you open one on a single core CPU, it will use 100% of the processor. To use it on a multiple core processor, you just open one of these per core. I made it myself so I do have the source code, and I uploaded the .exe version of it onto a file hosting website. I havent ever used this site before, so I hope it works well. The file size is 570kb like on my computer. Here is a link to it.

This is the source code for c++. I just put in a random float number to test float (I think thats how it works).


#include <iostream>
using namespace std;

int main ()
{
int * i;
float * p;

while (p == p){
(*p++)+1.144564542315345;
(*i++)+1;
}
}




EDIT: I downloaded off the site and it works well.
 

cprince

Senior member
May 8, 2007
963
0
0
I don't think that this program stresses the CPU enough. You need other arithmetic operations, as well as memory operations.
 

CTho9305

Elite Member
Jul 26, 2000
9,214
1
81
Doesn't it crash almost immediately? You're doing wild pointer dereferencing.

If you compiled it without optimizations, the throughput is going to be very low; if you compiled with optimizations, the FP op and the "+1" are going to be optimized away.

K7 and K8 can do 3 integer ops and 2 FP ops (an add and a multiply) per cycle. Do more work at a time.

K7 and K8 have a 1-cycle bubble after taken branches. You need to unroll your loop to amortize this (and/or use some longer-latency instructions like integer multiplies), or you risk letting the back-end sit idle for half of the time.

I wrote a longer post with more details, but accidentally clicked reload :(.

If you're interested in a good stress test (where "good stress test" is defined as something that keeps a lot of logic active), this program comes with assembly source code.

These documents are REALLY useful if you want to understand how to keep your CPU busy:
K7: http://www.amd.com/us-en/asset...Assets/dwamd_25112.pdf
K8: http://www.amd.com/us-en/asset...nd_tech_docs/22007.pdf
Barcelona: http://www.amd.com/us-en/asset...nd_tech_docs/40546.pdf


edit: Oh, that works out to ((*p)++) + 1.144..., so you're making a mess. That compiles to:
15: (*p++)+1.144564542315345;
00401270 mov eax,dword ptr [ebp-8]
00401273 add eax,4
00401276 mov dword ptr [ebp-8],eax

Basically, you're just incrementing p, and even in debug mode the floating point add is optimized out.