Re: I apologise perhaps for a simple question



It won't do you any harm to set these changes as part of a template, but you
should only do this for release builds. otherwise you might have the side
effect that some code gets optimized away. in that case, stepping through
the code could skip lines or things like that.

when using optimization, you also have to be careful when working with data
that is used globally. the compiler might decide that some piece of code is
doing nothing that has a visible effect,and throw it away, even though you
really use it. you have to use the 'volatile' keyword so that the compiler
knows that global data values really do change. this can be an important
factor if you share global data between threads or processes, or when
developing device drivers.

not using the volatile keyword could make the compiler decide to not really
read a pointer value, but use the value that it has in the cpu registers for
that memory address. it can do this because it could assume that the value
doesn't change where the compiler can see it.

sorry for the long winded explanation. but not using volatile correctly can
lead to problems at high optimization levels, though i have to say VC2003
and vs2005 have been much better than vc6.

kind regards,
Bruno.


"Vicky" <Vicky@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8797124E-FD5B-45FE-8197-3482F0F98A36@xxxxxxxxxxxxxxxx
> Bruno,
>
> I followed your optimisation settings exactly, and I have a file of 4k
> Thankyou ever so much, I am only recently getting to grips with C++ and VS
> .NET and as such I was somewhat confused as to the lack of optimsation :o)
>
> Would it do much harm to set these 3 options as a default global template
> for each project or is it best to assign them on a per-project basis?
>
> regards
>
> vicky
>
> "Bruno van Dooren" wrote:
>
>> The release executable for this empty console application is 3 K.
>>
>> i set the optimization to /O1 (minimal size) and set /Os to favor size.
>>
>> I also set the runtime library to /MD to use the multithreaded dll. that
>> way
>> the runtime is linked dynamically instead of statically. this brought the
>> size from 21 k to 3 k.
>>
>> for your tests, did you use the same project on different machines, or
>> not?
>> the same confugration should have the same results on different machines.
>>
>>
>> kind regards,
>> Bruno.
>>
>>
>>
>> "Vicky" <Vicky@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:5C6D76E3-8BAB-4A27-8808-DC22EF1962F5@xxxxxxxxxxxxxxxx
>> > Hi,
>> >
>> > my friends and i have been confused by this problem.
>> > On a veriety of systems we have tested compiling a simple hello word
>> > applicaation to check optimisation of C++ in 2003 VS.NET.
>> > However on one of the machines, the best we can get is 61k under a
>> > blank
>> > win32 console app.
>> >
>> > We were trying to wrk out what we should tweak as we have tried
>> > excluding
>> > Libraries, and a few other tweaks as suggested in forums.
>> >
>> > Your help is much appreciated
>> >
>> > Thankyou
>> >
>> > Vicky
>>
>>
>>


.



Relevant Pages

  • Re: No Macros, No for loops, Pure C++
    ... >> As always with optimization, ... >> whether the compilerīs built in optimization is better or the template ... This means that pArray is not invariant anymore and the compiler cannot ... and a generic tensor of order n is expressed by 3^n elements. ...
    (comp.lang.cpp)
  • Re: Brian Kernighan, maybe Im not worthy, maybe Im scum
    ... what experienced programmers do, ... optimization, ... Thugs" ad nauseum fits that a lot more closely than discussing compiler ... be modified outside a loop, and guessing ...
    (comp.programming)
  • long(!) Re: need help on CFLAGS in /etc/make.conf please
    ... For example, MPlayer sets this high on purpose, so GCC will actually ... and the K&R compiler would've known exactly the kind of optimization we wanted. ... >> A msg from Richard Coleman, taken together with the GCC 3.x Known Bugs ...
    (freebsd-questions)
  • Re: SETF and variable issues in Self Similar program.
    ... The way to get a compiler to optimize a tail-call ... call optimization turned on. ... It changes the semantics of the language in a big way. ... In Common Lisp it has to interact with condition handling, ...
    (comp.lang.lisp)
  • Re: Programming languages
    ... >> execution time, ... That's not a good candidate for optimization. ... if there is comething the compiler ... António> programmers and those can't cope with anything else than ...
    (sci.lang)

Quantcast