473,322 Members | 1,345 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Hyper-threading

My application uses multiple-threads and is a kind of AI simulation or
ALife. This works fine but I was wondering if and how one can make use
of hyper-threading in C#?
Thanks for any hint, Francois

____________________________
The Netron Project,
http://netron.sf.net

Nov 16 '05 #1
21 6559
Illumineo wrote:
My application uses multiple-threads and is a kind of AI simulation or
ALife. This works fine but I was wondering if and how one can make use
of hyper-threading in C#?


.NET threads are mapped on OS threads, so the OS will schedule these
threads and therefore if hyperthreading is enabled, the threads will
take advantage of that.

FB
--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Nov 16 '05 #2
Just a silly question: How do I enable hyperthreading? Is this an option in
the C# project or an option I have to set somewhere in the control panels or
is this a build in feature of the processor?

Ciao
Dante

"Frans Bouma [C# MVP]" <pe******************@xs4all.nl> schrieb im
Newsbeitrag news:Oi**************@TK2MSFTNGP09.phx.gbl...
Illumineo wrote:
My application uses multiple-threads and is a kind of AI simulation or
ALife. This works fine but I was wondering if and how one can make use
of hyper-threading in C#?


.NET threads are mapped on OS threads, so the OS will schedule these
threads and therefore if hyperthreading is enabled, the threads will
take advantage of that.

FB
--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------

Nov 16 '05 #3
Thanks for the answers.

Well, then hyperthreading is just an eye catcher: As long I have a
hyperthreading CPU and an application with threats I get the Hyperthreading
technology for free, am I right?

Hyper, hyper...
"Wayne" <Me******@community.nospam> schrieb im Newsbeitrag
news:ed*************@TK2MSFTNGP12.phx.gbl...
However, if it wasn't enabled when you installed windows I don't believe you will have the correct HAL and therefore may not be able to take full
advantage of the multi CPU's. You will need to install the correct one once you enable HT.

In Device manager you expand the Computer node, if you see multiprocessor PC (or something that indicates more than one CPU) you are fine. However, if
you see Uniprocessor PC, you'll want to go to it's properties and update
driver. Choose the driver manually to install. You will want to use the
Multiprocessor driver that matches the uniprocessor driver you have, in my
case it is an ACPI driver. Be sure you don't select the wrong one.

In the past I did some experimenting and found I could go from Multi to Uni in my machine, but was unable to go back to multi. Hopefully it was because I switched from one to the other. If you can't upgrade the driver to get the multi, you will need to reinstall windows with the HT enabled.

If all goes well you should see two CPU windows in the performance tab of
the Task Manager.

--
Thanks
Wayne Sepega
Jacksonville, Fl
"When a man sits with a pretty girl for an hour, it seems like a minute. But let him sit on a hot stove for a minute and it's longer than any hour.
That's relativity." - Albert Einstein

"Ollie Riches" <ol**********@phoneanalser.net> wrote in message
news:#I*************@TK2MSFTNGP15.phx.gbl...
hyper threading is enable by in the BIOS setting of the machine
--
HTH

Ollie Riches
http://www.phoneanalyser.net

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a programmer
helping programmers.
"Dante" <no****@thank.you> wrote in message
news:OF**************@TK2MSFTNGP10.phx.gbl...
Just a silly question: How do I enable hyperthreading? Is this an
option in
the C# project or an option I have to set somewhere in the control
panels
or
is this a build in feature of the processor?

Ciao
Dante

"Frans Bouma [C# MVP]" <pe******************@xs4all.nl> schrieb im
Newsbeitrag news:Oi**************@TK2MSFTNGP09.phx.gbl...
> Illumineo wrote:
> > My application uses multiple-threads and is a kind of AI

simulation or > > ALife. This works fine but I was wondering if and how one can make use > > of hyper-threading in C#?
>
> .NET threads are mapped on OS threads, so the OS will schedule these
> threads and therefore if hyperthreading is enabled, the threads will
> take advantage of that.
>
> FB
>
>
> --

------------------------------------------------------------------------
> Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com > My .NET blog: http://weblogs.asp.net/fbouma
> Microsoft MVP (C#)

------------------------------------------------------------------------



Nov 16 '05 #4
Dante,

Beside your application there are a lot of other applications active.

You don't need to use an application with threads to have the benefit.

Cor
Nov 16 '05 #5
Ok, granted. I think even without my threads the application is running on
some threads.

I am just saying: If I would declare our application as hyperthreaded people
get impressed - "Wow, they are using hyperthreading technology". But in fact
we are only that HT technology because the OS is supporting it without that
I have do some tricky things to the application.
"Cor Ligthert" <no************@planet.nl> schrieb im Newsbeitrag
news:%2****************@TK2MSFTNGP10.phx.gbl...
Dante,

Beside your application there are a lot of other applications active.

You don't need to use an application with threads to have the benefit.

Cor

Nov 16 '05 #6
> Ok, granted. I think even without my threads the application is running on
some threads.


No it is not.

For the rest we do agree, in a lot of cases can using threading mean more
throughput time beside that it uses forever more processor time.

Cor
Nov 16 '05 #7
Cor Ligthert <no************@planet.nl> wrote:
Ok, granted. I think even without my threads the application is running on
some threads.


No it is not.


I disagree. Try running the following program and look at the number of
threads with something like prcview:

using System;
using System.Threading;

class Test
{
static void Main()
{
Thread.Sleep(50000);
}
}

On my box at least, there are three threads in the process.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #8
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Cor Ligthert <no************@planet.nl> wrote:
> Ok, granted. I think even without my threads the application is running on
> some threads.


No it is not.


I disagree. Try running the following program and look at the number of
threads with something like prcview:

using System;
using System.Threading;

class Test
{
static void Main()
{
Thread.Sleep(50000);
}
}

On my box at least, there are three threads in the process.

I would claim that "the application" is running on only a
single thread in that case. The console has its own thread,
but that is an OS feature, beneath the application in a very
real sense, usually invisible except with tools. Likewise,
there is a thread associated with the CLR VM that does
garbage collection. The VM is also properly considered
part of the platform, not the application. (I realize this is
a fine distinction that hinges upon definitions.)

Of course, if you insist that those 3 threads are part of
the application which runs the console and VM as DLLs,
I won't quibble any further about it. <g>

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.
Nov 16 '05 #9
Larry Brasfield <do***********************@hotmail.com> wrote:
On my box at least, there are three threads in the process.


I would claim that "the application" is running on only a
single thread in that case. The console has its own thread,
but that is an OS feature, beneath the application in a very
real sense, usually invisible except with tools. Likewise,
there is a thread associated with the CLR VM that does
garbage collection. The VM is also properly considered
part of the platform, not the application. (I realize this is
a fine distinction that hinges upon definitions.)

Of course, if you insist that those 3 threads are part of
the application which runs the console and VM as DLLs,
I won't quibble any further about it. <g>


Given the context of the question, that's exactly what I'd say. In
terms of the number of threads running within the process - threads
which can take advantage of hyperthreading for sure - there are always
multiple threads in any .NET app. I doubt very much that the scheduler
cares whether the thread is running code written by the .NET developer
or code written by MS :)

(I don't know for sure whether hyperthreading works for multiple
processes - I suspect it would be a lot simpler not to support that at
the OS level, but I'm not an expect on hyperthreading.)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #10
The scheduling unit on Windows systems is the thread.
AFAIK, the Windows scheduler does not care at all which process a
thread belongs to when assigning CPU time.
Therefore, having an hyperthreaded CPU should boost the whole system
performance, not only your application's throughput.
Obviously, if your app is multi-threaded, it will gain benefit from
being executed on an HT CPU. But the same should apply when running
several single-threaded applications simultaneously.
That's the whole number of schedulable threads that counts, not only
your application's threads.

A good introduction can be found at
http://arstechnica.com/articles/paed...rthreading.ars.

Claudio Brotto

Nov 16 '05 #11
Claudio Brotto <cl************@gmail.com> wrote:
The scheduling unit on Windows systems is the thread.
AFAIK, the Windows scheduler does not care at all which process a
thread belongs to when assigning CPU time.


Excellent - that's good to hear, thanks :)

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #12
Claudio,

In short I wrote that already to Dante, I got the idea, that he understood
from my answer that he could call his application therefore a hyperthreaded
application. And on that I answered. "No it is not".

Jon disagrees that with me, however I don't want to discuss that. When Jon
thinks that because of hyperthreading every .Net application has to be
called a hyperthreaded application, I let him free in that, than we
*disagree* and he is than right in that.

http://groups-beta.google.com/group/...991215cf1ffd21

Cor
Nov 16 '05 #13
IMHO, the point here is this:

Claiming an application is "hyper-threaded" is wrong. An application is
not hyper-threaded: the underlying hardware and OS support may be HTed.
We, as programmers, can take advantage of such a technology, but all we
are enabled to do is develop a "multi-threaded" application, maybe
executing IO intensive code in a secondary thread to keep the UI thread
responsive, etc.
We do not write code such as

#ifdef MULTIPROCESSOR
// MP, or HT, stuff here
#else
// SP stuff here.
#endif

We can (most often we should) create and use threads no matter of the
number of processors our software will run on (be them real processors,
as in MP machines, or "virtual" processors as in HT machines).
That's quite obvious: how can we know what kind of hardware our
application will be deployed to ?

The OS is a piece of software which is there just to hide the
underlying hw idiosyncrasies and provide a coherent programming model
to the software developers.
Parts of the OS ARE different when run on SP/MP machines, just because
the OS is responsible for thread scheduling and all other issues which
change according to the # of processors we have.

I am not meaning that the code we write will run without bugs no matter
of the # of CPUs.
A lot of issues arise on MP machines which will never happen on SP
machines, especially when we try to avoid locking as much as possible
(on MP machines that is really a good choice !): then we'll have to
face any sort of strange bugs, and we must be very careful therefore.

And this just considers the OS.
What about the VM we program against (be it the CLR or the JVM or any
other VM) ?
I mean, between a call to System.Threading.Thread.Start(...) and the
real work done by the CPU there are a lot of levels of virtualization !
When writing .NET code, IMHO, we should take the CLR as out target,
understand as much as possible all its multi-threading issues (no, it's
not enough to know what the Monitor.Enter method does :-( ) and let the
VM do its work under the hood.
This is because
a) we don't see the CPU, we see the VM
b) we cannot fully control the VM behaviour
c) the VM behaviour might change in future releases

Ok, I'm done with my long post :-)
My basic opinion, just to summarize it: your code can leverage MP
thecnologies, but MP/HT are out of your code control !

Best Regards.

Claudio

Nov 16 '05 #14
Claudio Brotto wrote:
The scheduling unit on Windows systems is the thread.
AFAIK, the Windows scheduler does not care at all which process a
thread belongs to when assigning CPU time.
Therefore, having an hyperthreaded CPU should boost the whole system
performance, not only your application's throughput.
Obviously, if your app is multi-threaded, it will gain benefit from
being executed on an HT CPU. But the same should apply when running
several single-threaded applications simultaneously.
That's the whole number of schedulable threads that counts, not only
your application's threads.


Keep in mind that context switching between threads takes resources and
can ruin that much CPU data internally (caches) that it can actually
SLOW down your system in some occasions. HT is more or less a trick on 1
CPU to use the time the CPU otherwise has to wait for the slow memory
connection. This only works if the 2 threads don't need excessive memory
access of course :)

FB

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Nov 16 '05 #15
Cor Ligthert wrote:
Claudio,

In short I wrote that already to Dante, I got the idea, that he understood
from my answer that he could call his application therefore a hyperthreaded
application. And on that I answered. "No it is not".

Jon disagrees that with me, however I don't want to discuss that. When Jon
thinks that because of hyperthreading every .Net application has to be
called a hyperthreaded application, I let him free in that, than we
*disagree* and he is than right in that.


What's there to disagree on? Windows XP supports hyperthreading,
Windows' kernel schedules threads, not processes, and every .NET app has
at least 2 threads and often 3. This means that every .NET app benefits
from hyperthreading if they fall into the category of threads which
benefit from hyperthreading (and I think they do).

There is no such thing as 'hyperthreaded application'. That's just pure
marketing bs, as every application is per definition a hyperthreaded
application as every application has at least 1 thread.

FB

--
------------------------------------------------------------------------
Get LLBLGen Pro, productive O/R mapping for .NET: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
Nov 16 '05 #16
When somebody is interested

A very simple however clear presentation of multithreading.

http://www.intel.com/personal/do_mor...s/03b_base.swf

Cor
Nov 16 '05 #17
What do you mean with the console has his own thread?

A managed V1.X process has a minimum of three threads:
1. The applications main thread.
2. The finalizer thread.
3. The Debugger helper thread.

1. Runs the CLR code and all of the (unmanaged) runtime libraries loaded by
the CLR and your JITted code (supposed here there are no extra threads
created directly/indirectly by your code) .
2. Runs the finalizer (executes the Finaly methods on the classes that have
registered their Finalizer) this thread Is woken by the GC. Note that the GC
run's on #1 your main thread if in pre-emptive mode and on this same thread
when in concurrent mode.
3. Is only used when debugging and profiling, but is always created when the
CLR starts the managed execution environment.

Note that during execution of managed code libraries extra threads might be
created, manual threads as well as threadpool threads, that's why I said
this 3 is a minimum.

Willy.

"Larry Brasfield" <do***********************@hotmail.com> wrote in message
news:Oj**************@TK2MSFTNGP09.phx.gbl...
"Jon Skeet [C# MVP]" <sk***@pobox.com> wrote in message
news:MP************************@msnews.microsoft.c om...
Cor Ligthert <no************@planet.nl> wrote:
> Ok, granted. I think even without my threads the application is
> running on
> some threads.

No it is not.


I disagree. Try running the following program and look at the number of
threads with something like prcview:

using System;
using System.Threading;

class Test
{
static void Main()
{
Thread.Sleep(50000);
}
}

On my box at least, there are three threads in the process.

I would claim that "the application" is running on only a
single thread in that case. The console has its own thread,
but that is an OS feature, beneath the application in a very
real sense, usually invisible except with tools. Likewise,
there is a thread associated with the CLR VM that does
garbage collection. The VM is also properly considered
part of the platform, not the application. (I realize this is
a fine distinction that hinges upon definitions.)

Of course, if you insist that those 3 threads are part of
the application which runs the console and VM as DLLs,
I won't quibble any further about it. <g>

--
--Larry Brasfield
email: do***********************@hotmail.com
Above views may belong only to me.

Nov 16 '05 #18
Willy,

I don't know if we agree or disagree from your text.

However from the first more advanced computers and the more advanced OS we
have had by instance IO processors, who took over partial processing of the
processor, however where in fact doing multiprocessing.

I won't call this as a feature from the application. It is behaviour of the
OS, Hardware or whatever feature that is added and is not an special feature
from the created application, as I thought is told more in this thread.
Applications that did benefits from those features where never called
multiprocessor applications.

Only when the application has things as multithreading or remoting itself,
than it can benefit as application extra from the hyperthreading (or
multiprocessors) and can you call it in my opinion a feature of the
application.

Just my thought,

Cor
Nov 16 '05 #19
Thx Cor,

that is what I wanted to hear: MT is provided by the hardware, not by any
software. If anyone is telling me that his software is MT or supporting it I
know what he really wants to say.

Ciao
Dante
Nov 16 '05 #20
Dante,
that is what I wanted to hear: MT is provided by the hardware, not by any
software. If anyone is telling me that his software is MT or supporting it
I
know what he really wants to say.


HT not MT, MT is done by the application.

From HT (on an Operating System that support it) is benefiting every
application.

HyperThreading is as well called using more processors, what the concurents
of Intel say, that Intel did.
They have made two (ore more) processors in one chip.

See the link to the Intel presentation I have showed in this thread

http://www.intel.com/personal/do_mor...s/03b_base.swf
:-)

Cor
Nov 16 '05 #21
I ment HT....I got the picture.
"Cor Ligthert" <no************@planet.nl> schrieb im Newsbeitrag
news:Of**************@TK2MSFTNGP09.phx.gbl...
Dante,
that is what I wanted to hear: MT is provided by the hardware, not by any software. If anyone is telling me that his software is MT or supporting it I
know what he really wants to say.
HT not MT, MT is done by the application.

From HT (on an Operating System that support it) is benefiting every
application.

HyperThreading is as well called using more processors, what the

concurents of Intel say, that Intel did.
They have made two (ore more) processors in one chip.

See the link to the Intel presentation I have showed in this thread

http://www.intel.com/personal/do_mor...s/03b_base.swf

:-)

Cor

Nov 16 '05 #22

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: VIJAY KUMAR | last post by:
Hi pals, I am using 2 web forms (pages). In first page, i have Datagrid control and on second page i have a hyper link control to the first page and Add value to the data grid/Database. ...
2
by: AlanHill1965 | last post by:
Hi All, I have developing a database system for the last couple of weeks and got stuck on one part of the functionality. I have posted this question over at MSDN, but no joy, perhaps they got...
3
by: ajaspersonal | last post by:
"i want to change font_style (hyper link<a href...>text</a>) normal to italics.when load a page" this is my problem but that label included in one 'USERCONTROL' This user controls may...
5
by: McGuard | last post by:
I am trying to send an SMS using hyper terminal in windows XP pro. I am connecting my Satellite Phone (Motorola Iridium 9505A) to my notebook via serial cable (RS232) . Below are the sample...
1
by: simons | last post by:
Hi All, I'm trying to add a hyper link to one of the filed in my DataList control. I added a link button but could not bound it to an ID filed and then link it to the page that i need. I'm...
0
by: mclewell | last post by:
i created an html hyper link field and clicking on the data in the field produces a security warning pop up requiring a yes click before the link is activated, is there a way to turn off this...
1
by: =?Utf-8?B?Q29kZVNsaW5nZXI=?= | last post by:
I plan to build my own 2008 Server/Hyper-V system and will not be using one of the tested Dell or HP systems from the release notes and could use some pointers as to my assumnptions and answers to...
1
by: Kalaram | last post by:
I am makeing a CD, and in this CD i have alot of .pdf & .ppt & .pps files and i have one html page that i use as index to all the files, when i click on the hyper link of .pdf file , it opens...
8
by: jolakammu | last post by:
Guys, I am calling onclick="document.form.submit();" in a hyper clink. On click, it goes to a fuseaction where act_load_structure.cfm loads the structure with form variable. But the form...
3
Fary4u
by: Fary4u | last post by:
Hi is any body know how to create the hyper link with following code i can't do it ? <?xml version="1.0" encoding="utf-8" standalone="yes"?> <images> <pic> <image>img/1.jpg</image>...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.