473,320 Members | 2,003 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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
Nov 14 '05 #1
3 1023
"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.
Nov 14 '05 #2
> 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
Nov 14 '05 #3
Carson wrote:
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>

--
Er*********@sun.com

Nov 14 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Krisztian Kepes | last post by:
Hi ! I want to start many py programs - with other parameters. Because the programs have many to-do, I don't want to wait for them. In Delphi it is like this: >>>>>>>>>>>>>>>
31
by: poisondart | last post by:
Hi, I'm not sure if this is the right group to post this. If not, then I would appreciate if somebody could point me to the correct group. This is my first time releasing software to the...
10
by: Jean-David Beyer | last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2 V6.1 (with all the FixPacks) on my old machine. I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat...
0
by: Mihaly | last post by:
Hello, i'm using a VC++ com+ object, it's reference in vs .net, this com object have a function that have to params, the interop com object recive Object Params and the original com object say...
2
by: Tobias Olbort | last post by:
Hello, i've a outer function, which takes a params-array as a parameter. I want to pass this array to inner function with a params-array (e. g. string.format). When i've passed an integer to...
3
by: Stan Huff | last post by:
Is there any way to disable the "params" on a particular invocation so that one can pass an array containing the arguments and not have receiver get an array having you argument array stuffed into...
8
by: David Duerrenmatt | last post by:
Hi there For some reasons, I've to use Python 1.5.2 and am looking for a workaround: In newer Python versions, I can call a function this way: func = some_function func(*params) Then,...
12
by: Steve Howell | last post by:
I've always thought that the best way to introduce new programmers to Python is to show them small code examples. When you go to the tutorial, though, you have to wade through quite a bit of...
2
by: FFMG | last post by:
Hi, I was looking at http://www.php.net/manual/en/function.call-user-func-array.php and I was wondering... Given, // -- function foo( &$params) {
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.