what is a thread in a cpu???

charldon

Honorable
Mar 28, 2013
30
0
10,530
hey people I know what a core is and all that stuff but what is a thread??? and what makesd thread important in gaming??? and what is hyper threading in i7??? please help !
 

chugot9218

Honorable
I've always found these topics interesting, especially parallel computing, because the way I understand it, technically there is no such thing as parallel processing, it all has to be performed in some sequence, whether it is written to be divided up or not. Perhaps someone can enlighten my view!
 

onichikun

Distinguished
Nov 13, 2009
304
1
18,860
Hmm lets see if I can describe this as simple as possible.

1) Imagine a "process" e.g. your game being a house.

2) The house contains a family, where everyone has to do chores. Assume each chore is mutually exclusive (does not depend on other chores) in this case. Assume also each chore takes N minutes.

3) If one person in the family did ALL of the chores, assuming there are M chores, it would take M*N total minutes. (For example, 4 Chores, each chore takes 10 minutes, 40 minutes for 1 person to do them all! This is known as sequential execution.)

4)If there are 4 family members, each family member can do a chore at the same time, so it take them all only 10 minutes total to do all of the chores!

Now you can look at each family member being analogous to a thread. A thread in a process is a set of instructions. In ideal cases, a thread can be executed at the same time as other threads to reduce the total time to do all available work.

For a more technical example, in a game, you may have one thread handling resources (such as swapping in required textures from a disk as your player moves through the world) while another thread is handling different events occurring in the world. If one thread had to take care of all this, it would increase the latency. If the latency of something presented to a human is too long, they will start to notice poor performance (drop in frame rates).

Ideally every task in a process could be parallelized, but unfortunately this is not the case. Their are data dependencies between tasks in may cases, which limits parallelism. Hardware limitations also limits the benefits of parallelism. Even if you had 10000 cores, and a process had 10000 threads, if the threads had dependencies between them then you would not get a linear improvement in execution time. In many cases, there is a limited amount of paralellism that can be exploited in games. So more cores does not necessarily mean more performance.

Also since programmers are required to do parallelism at the coding level (no good performing parallelizing compiler, yet) the performance improvements from having more cores may be negligible for some games, especially older ones.

*EDIT* there is a lot more to it than that. but hopefully you get the idea.

Oops missed the second part of your question!

Lets see if I can continue my analogy.

Lets say the house is broken up into 4 rooms. Each room contains a hammer, a garbage can (weird house, I know.)

Lets say the family consists of 5 people this time. And lets say the chores to be done are:
Chore # | Requires
---------------------------
1 | Hammer
2 | Garbage Can
3 | Hammer
4 | Garbage Can
5 | Hammer

In the case without hyperthreading, we can say that each room can only be occupied by 1 person at a time. This means that one person can only be doing one chore in each room. Which limits the total number of simultaneous chores to 4 chores, even though 5 needs to be done. Note that each room contains both a hammer and garbage can, so even though chore 5 requires a hammer, and there are some rooms with hammers not being used, we can't use those hammers!

With hyperthreading, we essentially let more than one person into the rooms. If there is a chore that can use a free resource (a unused hammer) we can then do that chore as well. So with hyperthreading we can share resources not being used to do more work at the same time.

In a CPU, this breaks down into mathematical operations etc. So we can share resources between instructions from multiple threads at the same time in one core. So you can ideally look at 1 physical core, being multiple "virtual" cores. Thats why people say 4 physical cores with hyperthreading is 8 (4*2) virtual cores.
 

8350rocks

Distinguished
http://www.tomshardware.com/forum/356983-28-8350-good-gaming/page-2

Scroll to the bottom of the page in that thread, I broke down how HSA and hyperthreading works...if you're interested in parallel processing you'll want to read the bit of conversation there...

This is an excerpt from the conversation:

What he is talking about, are protocols...

A software setup with data fed in a mostly serial manner favors intel, because intel's instruction execution protocol for their CPUs are 90% serial data...which means intel chips break down a serial stream of data faster (single threaded performance). AMD's instruction execution protocol for their CPUs are setup to run parallel streams of data (heavily threaded performance), which most software out right now is not designed to feed data to the CPU in this manner. So, data being fed serially to a CPU designed to run parallel streams of executions is inefficient, and favors one designed for that type of data streaming.

For example...

Picture you're at Wal-Mart (or where ever), and there are 8 checkout lanes open...the first lane has a line a mile long, and they will only allow 4 of the other 7 lanes to have a line 1 person long. It doesn't make any sense right? For starters, they're not even using all of the lanes available, and the ones they are, aren't being utilized efficiently.

That's what's happening inside an AMD architecture FX8350 with current software...

With Intel chips right now...it's more like the line at best buy...where you have 1 line a mile long, but the front person has 4 different cashiers to go to when they arrive at the front of the line.

So, having 1 line a mile long doesn't slow them down, they're designed that way...

However, once information is fed in a parallel manner to the CPU...AMD will have all 8 lanes at Wal-Mart open for business and the lines will be distributed equally with people (instructions for the CPU), but Intel will still have the Best buy type line with 4 people running a cash register...except that now there will be 4 or even 8 lines forming into that one line, which makes things slow down because they are not designed to execute like that.

I hope the analogy makes this very complicated architecture discussion make sense.

That's a great question man...

Think of it like this, when you're multitasking, RAM has an effect on the amount of multitasking you can do, though windows negates this to some degree by putting "page file" on your HDD that is dynamic in size. What that means is that windows opens a file similar to RAM and loads files from it when you don't have enough RAM to load everything into RAM at once. RAM is faster, but your performance loss is only noticeable if you're running something extremely CPU/GPU heavy...like a game in 1440p or hardcore video encoding/rendering.

When you're multitasking, AMD protocols allow your background programs to form a serial line in front of an unused core...so that you're not tapping the resources your foreground program is using.

Now, say you were running 5 fairly intensive things at once...(let's say, streaming web videos, downloading multiple music files, and playing a web game...) Your i5-3570k would be able to execute 2-3 of those (depending on their resource needs) well...the others would be passed off to a virtual core in the background and would run at a considerably slower rate.

Doing the same thing on an AMD 8 core chip, since only 1 of those requires any FP calculations, you could literally tap 5 cores to do all the work simultaneously.

That's what hyperthreading is, it is essentially passing off background or foreground applications to a "virtual core" which the processor is basically taking a fraction of clock time each cycle to run the threads dedicated to the virtual core. Now, for the sake of hardware, the i5 doesn't have any "virtual cores" in intel speak...however, the 4 cores you have can divide clocktime by % to execute functions you're currently running(the definition of CPU multitasking effectively). This will tap resources you're using elsewhere, though it won't be a largely noticeable difference in your foreground application performance unless you're doing several CPU intensive things at once. So for example...your foreground application may be using 80% of 4 cores, and your background applications may be using 20% of the clocktime per cycle to run their functions, but it's at a highly reduced rate compared to what it would be if that was the primary program running.

Clear as mud yet? :)
 

onichikun

Distinguished
Nov 13, 2009
304
1
18,860

This is actually discussing a lower-level parallelism known as instruction level parallelism (ILP) and is usually addressed separately from thread-level parallelism (TLP). We ran out of game-changing ILP improvements awhile ago.
 

8350rocks

Distinguished


It addresses TLP too...
 

TRENDING THREADS