programs to pick params for cc

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carson

    #1

    programs to pick params for cc

    Hi,

    Is there any software which takes in my source code, and pick the best
    parameters for the cc command such that it gives the best runtime
    performance? (say, shortest amount of runtime?)

    Thank you.

    Carson


  • Keith Thompson

    #2
    Re: programs to pick params for cc

    "Carson" <carson@ieee.or g> writes:[color=blue]
    > Is there any software which takes in my source code, and pick the best
    > parameters for the cc command such that it gives the best runtime
    > performance? (say, shortest amount of runtime?)[/color]

    Here's a good first approximation:

    #include <stdio.h>
    #include <stdlib.h>

    int main(int argc, char **argv)
    {
    if (argc == 2) {
    printf("cc -O3 %s\n", argv[1]);
    }
    else {
    fprintf(stderr, "Usage: %s filename.c\n", argv[0]);
    exit(EXIT_FAILU RE);
    }
    return 0;
    }

    Adjust as needed based on the documentation for your compiler.

    Which is an annoyingly long-winded way of saying that optimization
    options typically tell the compiler to do the best job it can do given
    your source code. I'm not familiar with any cases choosing particular
    command-line options based on the source code being compiled. Some
    compilers may have options that influence speed vs. space, for
    example.

    If there is a way to do what you're looking for, it's system-specific;
    you'd need to ask in a newsgroup relevant to whatever compiler you're
    using. ("cc" is a common name for C compilers; whatever "cc" you're
    using may be unrelated to the "cc" on another system.)

    --
    Keith Thompson (The_Other_Keit h) kst-u@mib.org <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.

    Comment

    • Gordon Burditt

      #3
      Re: programs to pick params for cc

      > Is there any software which takes in my source code, and pick the best[color=blue]
      >parameters for the cc command such that it gives the best runtime
      >performance? (say, shortest amount of runtime?)[/color]

      There are no "the best parameters" unless you specify what input you
      intend giving your program. Optimizing for sorting 10 records vs.
      sorting for 10 billion records (with the same code) may be very
      different.

      As stated (and even limiting the problem to a particular compiler
      serial number and platform), I think the given problem is in the
      same class as the halting problem. The program could, of course,
      try all possible combinations of optimization settings, then run
      the program for each one, and see which one ran the fastest. The
      performance of the program to determine optimal settings, would,
      of course, suck to the Nth power.

      Gordon L. Burditt

      Comment

      • Eric Sosman

        #4
        Re: programs to pick params for cc

        Carson wrote:[color=blue]
        > Hi,
        >
        > Is there any software which takes in my source code, and pick the best
        > parameters for the cc command such that it gives the best runtime
        > performance? (say, shortest amount of runtime?)[/color]

        <off-topic excuse="really interesting">



        .... describes a project that used genetic algorithms to find
        "best" (or at least "good") options for one compiler.

        </off-topic>

        --
        Eric.Sosman@sun .com

        Comment

        Working...