Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > C Programming > A tool that suggests optimized logic for a piece ofcode/module/function

Reply
Thread Tools

A tool that suggests optimized logic for a piece ofcode/module/function

 
 
karthikbalaguru
Guest
Posts: n/a
 
      01-11-2010
Hi,
There are certain editors that highlight
the syntax/color for datatypes/variables
or comments etc.

Similarly,
Is there a tool for C language that
could suggest an optimized/alternate
programming logic for the function that
is written ?

The optimized/alternate logic can be
suggested as soon as we finish coding
for one function or it can be suggested
as soon as the code is compiled/parsed
by that tool.

It will be even more helpful if that tool
also provides the cycle counts, cache
usage, cache misses and lines of code
also.

It would be better if that tool has an
option to enable / disable this feature
either through compile time or some
other configurations.

Any ideas ?

Thx in advans,
Karthik Balaguru
 
Reply With Quote
 
 
 
 
acd
Guest
Posts: n/a
 
      01-12-2010
On 11 Jan., 21:07, karthikbalaguru <(E-Mail Removed)>
wrote:
> Hi,
> There are certain editors that highlight
> the syntax/color for datatypes/variables
> or comments etc.
>
> Similarly,
> Is there a tool for C language that
> could suggest an optimized/alternate
> programming logic for the function that
> is written ?
>
> The optimized/alternate logic can be
> suggested as soon as we finish coding
> for one function or it can be suggested
> as soon as the code is compiled/parsed
> by that tool.
>
> It will be even more helpful if that tool
> also provides the cycle counts, cache
> usage, cache misses and lines of code
> also.
>
> It would be better if that tool has an
> option to enable / disable this feature
> either through compile time or some
> other configurations.
>
> Any ideas ?
>
> Thx in advans,
> Karthik Balaguru


Brain?

Seriously, I think this is impossible.
What I can recommend to you are some good books, including
(More) Programming Perls
and
Hacker's delight.

Andreas
 
Reply With Quote
 
 
 
 
scattered
Guest
Posts: n/a
 
      01-12-2010
On Jan 12, 11:04*am, acd <(E-Mail Removed)> wrote:
> On 11 Jan., 21:07, karthikbalaguru <(E-Mail Removed)>
> wrote:
>
>
>
>
>
> > Hi,
> > There are certain editors that highlight
> > the syntax/color for datatypes/variables
> > or comments etc.

>
> > Similarly,
> > Is there a tool for C language that
> > could suggest an optimized/alternate
> > programming logic for the function that
> > is written ?

>
> > The optimized/alternate logic can be
> > suggested as soon as we finish coding
> > for one function or it can be suggested
> > as soon as the code is compiled/parsed
> > by that tool.

>
> > It will be even more helpful if that tool
> > also provides the cycle counts, cache
> > usage, cache misses and lines of code
> > also.

>
> > It would be better if that tool has an
> > option to enable / disable this feature
> > either through compile time or some
> > other configurations.

>
> > Any ideas ?

>
> > Thx in advans,
> > Karthik Balaguru

>
> Brain?
>
> Seriously, I think this is impossible.
> What I can recommend to you are some good books, including
> (More) Programming Perls
> and
> Hacker's delight.
>
> Andreas- Hide quoted text -
>
> - Show quoted text -


I don't see why it would be impossible. Optimizing compilers exist and
by using similar techniques it should be possible to write a compiler
that uses C as both the source and target language. How useful this
would be is another question. The resulting code would need to be
humanly readable if the tool would be of any use and the would
probably place severe restrictions on the sorts of optimizations that
can be done. I would be surprised if no work along these lines has
been done.

-scattered
 
Reply With Quote
 
Andrew Poelstra
Guest
Posts: n/a
 
      01-12-2010
On 2010-01-12, scattered <(E-Mail Removed)> wrote:
> On Jan 12, 11:04*am, acd <(E-Mail Removed)> wrote:
>> On 11 Jan., 21:07, karthikbalaguru <(E-Mail Removed)>
>> wrote:
>> > Hi,
>> > There are certain editors that highlight
>> > the syntax/color for datatypes/variables
>> > or comments etc.

>>
>> > Similarly,
>> > Is there a tool for C language that
>> > could suggest an optimized/alternate
>> > programming logic for the function that
>> > is written ?

>>
>> > The optimized/alternate logic can be
>> > suggested as soon as we finish coding
>> > for one function or it can be suggested
>> > as soon as the code is compiled/parsed
>> > by that tool.

>>
>> > It will be even more helpful if that tool
>> > also provides the cycle counts, cache
>> > usage, cache misses and lines of code
>> > also.

>>
>> > It would be better if that tool has an
>> > option to enable / disable this feature
>> > either through compile time or some
>> > other configurations.

>>
>> > Any ideas ?

>>
>> > Thx in advans,
>> > Karthik Balaguru

>>
>> Brain?
>>
>> Seriously, I think this is impossible.
>> What I can recommend to you are some good books, including
>> (More) Programming Perls
>> and
>> Hacker's delight.
>>
>> Andreas- Hide quoted text -
>>
>> - Show quoted text -

>
> I don't see why it would be impossible. Optimizing compilers exist and
> by using similar techniques it should be possible to write a compiler
> that uses C as both the source and target language. How useful this
> would be is another question. The resulting code would need to be
> humanly readable if the tool would be of any use and the would
> probably place severe restrictions on the sorts of optimizations that
> can be done. I would be surprised if no work along these lines has
> been done.
>


Indeed, some of what he suggested (loop counting, etc) would be not
only very useful, but would be an excellent parsing/analysis learning
experience if the OP were to try and implement it himself.

And C would be an excellent language for this, because it has so few
keywords and such straightforward branch control contructs (function
pointers aside).


 
Reply With Quote
 
Walter Banks
Guest
Posts: n/a
 
      01-12-2010


scattered wrote:

> On Jan 12, 11:04 am, acd <(E-Mail Removed)> wrote:
>
> > (More) Programming Perls
> > and
> > Hacker's delight.


---------------------------------------

>


> I don't see why it would be impossible. Optimizing compilers exist and
> by using similar techniques it should be possible to write a compiler
> that uses C as both the source and target language. How useful this
> would be is another question. The resulting code would need to be
> humanly readable if the tool would be of any use and the would
> probably place severe restrictions on the sorts of optimizations that
> can be done. I would be surprised if no work along these lines has
> been done.


Programming Pearls and Hacker's delight are both must haves
even if you are only remotely interested programming algorithms.

There has been quite a bit of work done in compilers at the
expression level to optimize algorithms and statements
implementing functionally equivalent statements in the
generated code.

The problem in the bigger scale suggested by the op is the
ability to recognize the larger overview of the programming
objective at the scale of turning a bubble sort into a quick
sort.

At the statement level recognizing functionality is generally
a simple task. At the function level this a significantly larger
problem.

The solution may be mostly hard work and processing
cycles. A start may be to catalog common functions
and implementations and create a significant tool
to recognize these functions from source code extracting
out key function parameters and then using these to select
alternative implementations.

As well as the data base of common functions a significant
piece of expert system software would need to be written
to extract knowledge out of the source.

Do-able probably.

Regards,

--
Walter Banks
Byte Craft Limited
http://www.bytecraft.com







 
Reply With Quote
 
Walter Banks
Guest
Posts: n/a
 
      01-12-2010


karthikbalaguru wrote:

> Is there a tool for C language that
> could suggest an optimized/alternate
> programming logic for the function that
> is written ?
>
> The optimized/alternate logic can be
> suggested as soon as we finish coding
> for one function or it can be suggested
> as soon as the code is compiled/parsed
> by that tool.
>
> It will be even more helpful if that tool
> also provides the cycle counts, cache
> usage, cache misses and lines of code
> also.
>
> It would be better if that tool has an
> option to enable / disable this feature
> either through compile time or some
> other configurations.


Metrics are available in many (especially embedded system)
compilers as part of the listing and report files. Better
compilers do a good job of instruction scheduling and
cache management in their code generation.

The issue is the larger one of function rewriting where
the problem is larger and less work has been done
looking for solutions.


Regards,

--
Walter Banks
Byte Craft Limited
http://www.bytecraft.com


 
Reply With Quote
 
Andy
Guest
Posts: n/a
 
      01-12-2010
On Jan 12, 11:12*am, scattered <(E-Mail Removed)> wrote:
> I don't see why it would be impossible. Optimizing compilers exist and
> by using similar techniques it should be possible to write a compiler
> that uses C as both the source and target language. How useful this
> would be is another question. The resulting code would need to be
> humanly readable if the tool would be of any use and the would
> probably place severe restrictions on the sorts of optimizations that
> can be done. I would be surprised if no work along these lines has
> been done.


The optimizations would have to be limited to that subset that can be
implemented at the C level. That might be difficult to do, since the
optimization is not usually concerned with whether or not the
optimized version can be portrayed in C.

The generated C code would have to look similar (same variable names,
etc.) to the original to be useful.

And if the compiler can show you those optimizations in the form of
modified code, why not have it skip showing you the code and just
optimize it behind the scenes like it always does?

Andy
 
Reply With Quote
 
karthikbalaguru
Guest
Posts: n/a
 
      01-12-2010
On Jan 12, 11:03*pm, Walter Banks <(E-Mail Removed)> wrote:
> karthikbalaguru wrote:
> > Is there a tool for C language that
> > could suggest an optimized/alternate
> > programming logic for the function that
> > is written ?

>
> > The optimized/alternate logic can be
> > suggested as soon as we finish coding
> > for one function or it can be suggested
> > as soon as the code is compiled/parsed
> > by that tool.

>
> > It will be even more helpful if that tool
> > also provides the cycle counts, cache
> > usage, cache misses and lines of code
> > also.

>
> > It would be better if that tool has an
> > option to enable / disable this feature
> > either through compile time or some
> > other configurations.

>
> Metrics are available in many (especially embedded system)
> compilers as part of the listing and report files. Better
> compilers do a good job of instruction scheduling and
> cache management in their code generation.
>


Yes, many embedded system based
compilers support the report generation
of cache misses, cache usage and
instruction cycles. I would like to
convey that it would be better if the
same tool provides those various
optimization reports for both the
logics apart from the optimized/
alternate logic suggested by it.

> The issue is the larger one of function rewriting where
> the problem is larger and less work has been done
> looking for solutions.
>


It is strange that no much research or
work is done in this area ? Strange !!

I think, this is one of the most required
tool for efficient software development
in any kind of platform.

Thx in advans,
Karthik Balaguru
 
Reply With Quote
 
karthikbalaguru
Guest
Posts: n/a
 
      01-12-2010
On Jan 12, 10:56*pm, Walter Banks <(E-Mail Removed)> wrote:
> scattered wrote:
> > On Jan 12, 11:04 am, acd <(E-Mail Removed)> wrote:

>
> > > (More) Programming Perls
> > > and
> > > Hacker's delight.

>
> ---------------------------------------
>
>
>
> > I don't see why it would be impossible. Optimizing compilers exist and
> > by using similar techniques it should be possible to write a compiler
> > that uses C as both the source and target language. How useful this
> > would be is another question. The resulting code would need to be
> > humanly readable if the tool would be of any use and the would
> > probably place severe restrictions on the sorts of optimizations that
> > can be done. I would be surprised if no work along these lines has
> > been done.

>
> Programming Pearls and Hacker's delight are both must haves
> even if you are only remotely interested programming algorithms.
>
> There has been quite a bit of work done in compilers at the
> expression level to optimize algorithms and statements
> implementing functionally equivalent statements in the
> generated code.
>


True !

> The problem in the bigger scale suggested by the op is the
> ability to recognize the larger overview of the programming
> objective at the scale of turning a bubble sort into a quick
> sort.
>


Exactly, this is the actual problem that
has to be addressed.

> At the statement level recognizing functionality is generally
> a simple task. At the function level this a significantly larger
> problem.
>
> The solution may be mostly hard work and processing
> cycles. A start may be to catalog common functions
> and implementations and create a significant tool
> to recognize these functions from source code extracting
> out key function parameters and then using these to select
> alternative implementations.
>
> As well as the data base of common functions a significant
> piece of expert system software would need to be written
> to extract knowledge out of the source.
>
> Do-able probably.
>


Thx in advans,
Karthik Balaguru

 
Reply With Quote
 
karthikbalaguru
Guest
Posts: n/a
 
      01-12-2010
On Jan 13, 12:05*am, Andy <(E-Mail Removed)> wrote:
> On Jan 12, 11:12*am, scattered <(E-Mail Removed)> wrote:
>
> > I don't see why it would be impossible. Optimizing compilers exist and
> > by using similar techniques it should be possible to write a compiler
> > that uses C as both the source and target language. How useful this
> > would be is another question. The resulting code would need to be
> > humanly readable if the tool would be of any use and the would
> > probably place severe restrictions on the sorts of optimizations that
> > can be done. I would be surprised if no work along these lines has
> > been done.

>
> The optimizations would have to be limited to that subset that can be
> implemented at the C level.


True !

> That might be difficult to do, since the
> optimization is not usually concerned with whether or not the
> optimized version can be portrayed in C.
>


True, but i am looking only at the
C level optimization.

> The generated C code would have to look similar (same variable names,
> etc.) to the original to be useful.
>


I think, in such scenarios, the tool should
be having tremendous knowledge about
the software/program and take care
end to end. Maybe, the tool can generate
report on the changes and the reason for
the changes so the developer can use
it for further developments or any other
maintenance activities on that code.

> And if the compiler can show you those optimizations in the form of
> modified code, why not have it skip showing you the code and just
> optimize it behind the scenes like it always does?
>


Maybe, it would be better if it
can do it before user rather than
behind the scenes so that the user
is aware of the kind of optimzations
that are being done and could be
taken care. It is also needed so that
the developer will be able to take care
of further developments on the same
program/software and also for the
maintenance activities on that
program/software.

Thx in advans,
Karthik Balaguru
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
problem in running a basic code in python 3.3.0 that includes HTML file Satabdi Mukherjee Python 1 04-04-2013 07:48 PM
Download a file piece by piece Patrick Plattes Ruby 2 11-30-2006 07:48 PM
Toshiba suggests end of DVD war is near. Allan DVD Video 1 06-02-2005 01:31 PM
"Google Suggests" and the AJAX .NET Wrapper? Phin ASP .Net 2 06-02-2005 07:43 AM



Advertisments