is it possible to switch on hyperthreading in cc?

C

Carson

Hi,

I am now writing a c-code, which is extremely computational extensive.

My computer is 2.8GHz Pentium (supports hyperthreading), using cygwin cc
(latest version) to compile with the followings:

cc -c -O3 -mcpu=i686 $(FLIST)

when i run my program, (a.out), it takes a quite a bit of time to finish,
(around 2 hours each run, I need to run through many test cases.)

And i notice that my cpu load is only ~50% when my program is running.

is it possible to do some tricks on cc so that my code will use HT during
runtime?

Thanks.

Carson
 
J

Jack Klein

Hi,

I am now writing a c-code, which is extremely computational extensive.

My computer is 2.8GHz Pentium (supports hyperthreading), using cygwin cc
(latest version) to compile with the followings:

cc -c -O3 -mcpu=i686 $(FLIST)

when i run my program, (a.out), it takes a quite a bit of time to finish,
(around 2 hours each run, I need to run through many test cases.)

And i notice that my cpu load is only ~50% when my program is running.

is it possible to do some tricks on cc so that my code will use HT during
runtime?

Thanks.

Carson

There is no such thing as hyperthreading in C. There may or may not
be extensions available from your compiler or operating system, but
they have nothing to do with the standard C language. You need to ask
in a group that supports your compiler/OS combination.
 
K

Keith Thompson

Carson said:
I am now writing a c-code, which is extremely computational extensive.

My computer is 2.8GHz Pentium (supports hyperthreading), using cygwin cc
(latest version) to compile with the followings:

cc -c -O3 -mcpu=i686 $(FLIST)

when i run my program, (a.out), it takes a quite a bit of time to finish,
(around 2 hours each run, I need to run through many test cases.)

And i notice that my cpu load is only ~50% when my program is running.

is it possible to do some tricks on cc so that my code will use HT during
runtime?

That's really not a C language question; it's a question about your
compiler, so we can't help you here.

Cygwin's cc is really gcc. A Google search for "gcc hyperthreading"
might give you something useful. Failing that, try a gcc-specific
mailing list or newsgroup.
 
D

Dan Pop

In said:
I am now writing a c-code, which is extremely computational extensive.

My computer is 2.8GHz Pentium (supports hyperthreading), using cygwin cc
(latest version) to compile with the followings:

cc -c -O3 -mcpu=i686 $(FLIST)

when i run my program, (a.out), it takes a quite a bit of time to finish,
(around 2 hours each run, I need to run through many test cases.)

And i notice that my cpu load is only ~50% when my program is running.

is it possible to do some tricks on cc so that my code will use HT during
runtime?

If your CPU load is ~50% when your program is running, chances are that
hyperthreading is already activated and you may want to switch it off.

It is highly unlikely that this can be done with user mode code and
without rebooting your system. Your best chance is to do it with your
BIOS setup program, before booting the system.

Dan
 
D

Dag Viken

Carson said:
Hi,

I am now writing a c-code, which is extremely computational extensive.

My computer is 2.8GHz Pentium (supports hyperthreading), using cygwin cc
(latest version) to compile with the followings:

cc -c -O3 -mcpu=i686 $(FLIST)

when i run my program, (a.out), it takes a quite a bit of time to finish,
(around 2 hours each run, I need to run through many test cases.)

And i notice that my cpu load is only ~50% when my program is running.

is it possible to do some tricks on cc so that my code will use HT during
runtime?

Thanks.

Carson

Hyperthreading means that the processor can execute two threads
simultaneously, so one thread only uses 50% of the total CPU capacity while
the other execution unit is idle. Therefore, a single-threaded program can
never use more than 50% CPU. You need to make your application
multi-threaded (two or more threads) in order take full advantage of your
CPU. If you split the computations into two equal parts, you can set off two
threads doing half the work each and the runtime should be close to half the
time.

I have never used cygwin cc so I do not know what kind of multi-threading
support it has. Alternatively, you could run two separate processes doing
half the work each. If it is relatively easy to split the computational
tasks, this solution will be easier to implement than multi-threading.

Dag
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,535
Members
45,007
Latest member
obedient dusk

Latest Threads

Top