Multiprocessor improvement in gcc?


Results 1 to 6 of 6

Thread: Multiprocessor improvement in gcc?

  1. #1
    Join Date
    May 2003
    Posts
    145

    Multiprocessor improvement in gcc?

    Would I experience a significant performance increase when running gcc on a multi-processor system? Or is gcc single-threaded and would I just be wasting money? Would I need to do something w/ distcc to get a performance increase?

    Any help would be greatly appreciated,
    cfaun5

  2. #2
    Join Date
    Apr 2001
    Location
    SF Bay Area, CA
    Posts
    14,936
    gcc is single-threaded, yes. In general, compilation is a single threaded problem -- you can't very easily compile independent chunks of a program at the same time.

    However, you can run more than one instance of gcc at a time (on different source files), to take advantage of multiple processors. That's what make's -j flag is for -- it tells make to spawn off a bunch of processes at a time, instead of waiting for each one to finish before running the next.

    So for instance, if the program's Makefile says that to build the executable, it needs 100 different object files, make -j will know that it can (probably) build each of those object files independently of each other. So it'll issue some number of gcc commands in parallel, to compile some of the object files, and when each one finishes, it'll start another, until it runs into a dependency that forces it to go single-process again. (For example, the final link requires all the object files, so make will have to go back to one process for the final link.)

  3. #3
    Join Date
    May 2003
    Posts
    145
    Thank you; this helps greatly.

  4. #4
    Join Date
    May 2003
    Posts
    145

    Unhappy

    Sorry for my ignorance, but I tried the -j flag in gcc, and it said it was an unrecognized option (version 3.3.5-20050130). I looked at the manuals for newer versions and there was not any -j's there either. I couldn't find what you described.

    Did I misinterpret something?

    Thanks once again,
    cfaun5

  5. #5
    Join Date
    May 2005
    Posts
    16
    The '-j' flag is for make, not gcc.

  6. #6
    Join Date
    May 2003
    Posts
    145
    Whoops. Sorry about that. Thank you!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •