is it possible to switch on hyperthreading in cc?

Discussion in 'C Programming' started by Carson, Aug 16, 2004.

  1. Carson

    Carson Guest

    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
     
    Carson, Aug 16, 2004
    #1
    1. Advertising

  2. Carson

    Jack Klein Guest

    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.

    --
    Jack Klein
    Home: http://JK-Technology.Com
    FAQs for
    comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
    comp.lang.c++ http://www.parashift.com/c -faq-lite/
    alt.comp.lang.learn.c-c++
    http://www.contrib.andrew.cmu.edu/~ajo/docs/FAQ-acllc.html
     
    Jack Klein, Aug 16, 2004
    #2
    1. Advertising

  3. "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.

    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.

    --
    Keith Thompson (The_Other_Keith) <http://www.ghoti.net/~kst>
    San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
    We must do something. This is something. Therefore, we must do this.
     
    Keith Thompson, Aug 16, 2004
    #3
  4. Carson

    Dan Pop Guest

    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.

    Dan
    --
    Dan Pop
    DESY Zeuthen, RZ group
    Email:
     
    Dan Pop, Aug 16, 2004
    #4
  5. Carson

    Dag Viken Guest

    "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.

    Dag
     
    Dag Viken, Aug 17, 2004
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Param - Home

    p4 hyperthreading & web gardening

    Param - Home, Aug 20, 2004, in forum: ASP .Net
    Replies:
    6
    Views:
    383
    Alvin Bruney [MVP]
    Aug 24, 2004
  2. Joe Jax
    Replies:
    1
    Views:
    502
    LOZANO-MORÁN, Gabriel
    Apr 21, 2005
  3. Replies:
    3
    Views:
    1,876
    Scott Allen
    Dec 9, 2005
  4. Brad Grier

    Hyperthreading Problem

    Brad Grier, Jan 9, 2004, in forum: Java
    Replies:
    8
    Views:
    4,537
    Danny Woods
    Jan 11, 2004
  5. Garry Hodgson
    Replies:
    5
    Views:
    762
Loading...

Share This Page