News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Multi-Core and Hyperthreading ?

Started by James Ladd, October 01, 2006, 10:45:02 PM

Previous topic - Next topic

James Ladd

I read an article recently where the person being interviewed said they would be making their next game engine multi-core enabled.
So my questions are:

1. Do you have to do something special to make use of multi-core?

2. Is it enough to make the application multi-threaded to get maximum advantage from multiple cores and
    hyper threading?

I always make my apps multi-threaded so im a little concerned there could be more that has to be done to make the
most of Multi-cores.

Rgs, James.

Tedd

As far as I understand it, it's down to the OS to schedule threads onto the different cores. So in that case there's nothing extra you need to do.
There shouldn't be anything more special about running multiple threads than running multiple processes -- the only different being that the threads run in the same process-space (and therefore have access to the same memory space, etc.)
Of course, when trying to hype-up your latest product, it's always good to sprout buzzwords like multicore programming, enhanced hyper-threading technology, ..insert favourite here.. :bdg
No snowflake in an avalanche feels responsible.

James Ladd


dsouza123

There is the issue of affinity, which allows/restricts a process to a particular core/CPU.

For example with one of the upcoming quad core systems and some
calculation intensive program that you want to run four instances of,
one on each core to hopefully get the maximum throughput,
you could just let the OS run each instance on what ever core it picks,
maybe running all four on one core, not an ideal situation, or moving
a process among the cores also not ideal.

The built in task managing program allows setting the affinity of a process
to a particular core as do other utilities, what APIs can be called to select
the core/set the affinity ?

For example the freeware command line utility, process, from beyondlogic.org
will show the number of processors/CPUs/cores on the system
and can set the affinity of a process to a particular one on systems with more than one.

======= some other issues/questions ============

In many articles the writers repeat the claim that most programs aren't multithreaded
but using any of the various programs that show a thread count for each process
shows that doesn't match reality. 

Are they confusing a multithreaded process and one that can somehow take advantage
of hyperthreading ?

=======================
A slight digression:
The issue of terms CPU, core, processor, hyperthreaded.

In the past each physical processor chip had one core and fit in a socket on the motherboard
so one chip == one processor == one CPU == one core.
A motherboard with two or four sockets had two or four processors/CPUs/cores.

Then Intel produced the hyperthreaded processors, still with one core
but it would be viewed as two logical CPUs though not equal to two
CPUs each in its own socket, more like 1 and some fraction.
So one chip == one processor == two logical CPUs == one core.

Later on both Intel and AMD have come up with dual core CPUs
where two cores are in the chip(s) that go into one socket,
so a dual core CPU is nearly the same as two single core CPUs each in it's own socket.
One chip == two processors == two CPUs == two cores.

Soon to appear are the quad core CPUs with four cores together in one socket.

================

The OS and multicore CPUs, my understanding is the number of sockets
determines what is allowable, so a motherboard with one socket with a quad core
would still count as one, but have four CPUs. 
And a two socket motherboard with a quad core in each socket would allow eight CPUs.
The OS still has to be built to support multiple CPUs.