What is a good 64-bit Hello World multi-core program?

I recently got my home computer updated to a quad-core processor and 64-bit OS. I have some experience with C / C ++, and I really "itch" to try to implement some 64-bit processor capabilities. What a nice program like "Hello World" that demonstrates 64-bit multi-core capabilities, doing some simple things that don't work at all in 32-bit single-core code?

I'm just trying to β€œfeel” how these new processors can affect the performance of C / C ++ code in extreme cases.

+6
performance c algorithm 64bit multicore
source share
3 answers

OpenMP is an easy way to play with multi-core C ++ programming. The wikipedia example doesn't actually make the processor more intensive, but you can replace 'cout' with some independent, long-lasting function.

Openmp

As for 64-bit, most of your productivity growth will come from several places.

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

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

In x86 ABI, with some calling conventions, one or two parameters can be passed through registers, and the rest must be pushed onto the stack. When using a generic calling convention such as cdecl, no parameter or return value is placed in the register. Since the stack is in main memory, this can be a great success.

+2
source share

You probably want to do something that the thist performs computationally expensive operations with large numbers or large areas of memory independently, such as ray tracing or protein dumping.

It is important to remember that 64-bit or multi-core processors cannot really do what single-core processors CANNOT do, in fact, they just do it faster and more.

+1
source share

Given how many different parallelism models there are and how they are adapted to various tasks, there is no satisfactory answer to your question. It all depends on what you really want to do in the end. You should choose a model adapted to what you want to do (if it does not contradict the previous restriction, try messaging , it is refreshingly easy compared to others). A.

I would have to say that Jericho's answer to the words in the comments is right. For such a simple task as β€œhello world”, the best model is not parallelism at all.

+1
source share

All Articles