"Carson" <ca****@ieee.org> writes:
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.)
--
Keith Thompson (The_Other_Keith)
ks***@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.