views:

471

answers:

3

I recently got my home PC upgraded to a quad-core CPU and 64-bit OS. I have some former experience with C/C++ and I'm really "itching" to try exercising some 64-bit CPU capabilities. What's a good "Hello World" type program that demonstrates 64-bit multi-core capabilities by doing some simple things that don't work well at all in 32-bit single-core code?

I'm just trying to get a "feel" for how these new CPUs can impact the performance of C/C++ code in extreme cases.

+1  A: 

You probably want to do something tyst performs computationally expensive operations om big numbers or large areas og memory in an independent fashion, such as raytracing or protein folding.

The important thing to keep in mind is that 64 bit or multicore processors can't really do anything that single-core processors CANNOT do, essentially they just do it faster and to bigger numbers.

Williham Totland
+3  A: 

OpenMP would be an easy way to play around with multicore programming in C++. The wikipedia example doesn't really do anything processor intensive, but you could replace the 'cout' with some independent, long-running function.

OpenMP

As far as 64-bit, a lot of your performance increase is going to come from a few places.

Increased throughput, because all data elements are wider the processor can process more data in any given clock cycle. Take a look at some of the Microsoft benchmarks for Exchange Server, they have now moved to support 64-bit only because the throughput increases are incredible.

More registers, since the 64-bit architecture has a large number of registers most function parameters and the return value can be passed using registers.

In the x86 ABI with some calling conventions one or maybe two parameter could be passed via registers and the rest have to be pushed onto the stack. With a common calling convention like cdecl not a single parameter or return value is placed in a register. Since the stack is located in main memory this can be a big performance hit.

joshperry
+1  A: 

Considering how many different parallelism models there are and how they are each adapted to different tasks, there is no satisfactory answer to your question. It all depends what you really want to do eventually. You should pick the model that's adapted to what you want to do (if it doesn't contradict the previous constraint, try message-passing, it's refreshingly easy compared to others).

I would have to say that Jherico's tongue-in-cheek answer in the comments is right. For such a simple task as "hello world", the best model is no parallelism at all.

Pascal Cuoq