Advertisements

On Mon, 16 Aug 2004 00:08:28 GMT, "Carson" <> wrote in
comp.lang.c:
> 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.

Advertisements

"Carson" <> writes:
> 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.

In <0WSTc.3871$> "Carson" <> writes:
> 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.

"Carson" <> wrote in message
news:0WSTc.3871$...
> 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.

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!