programs to pick params for cc

C

Carson

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
 
K

Keith Thompson

Carson said:
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?)

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_FAILURE);
}
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.)
 
G

Gordon Burditt

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?)

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
 
E

Eric Sosman

Carson said:
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?)

<off-topic excuse="really interesting">

http://www.coyotegulch.com/acovea/index.html

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

</off-topic>
 

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

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,201
Latest member
KourtneyBe

Latest Threads

Top