Re: Ask for help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



not to play devil's advocate, but couldn't you just stop optimizing
the code and let it run?
if you're not concerned (as much) with speed as accurate results and
getting (apparently) inaccurate results with an optimization ....
then don't optimize?





On Tue, Mar 17, 2009 at 10:36 AM, Wei, Wanxia <v592e@xxxxxx> wrote:
> Dear All:
>
> Thank you all for your quick help.
>
> My C program is a local search algorithm for solving SAT (Satisfiability problem). The
> following is a brief description of this program.
>
> This program uses random integers to generate an initial assignment to a SAT instance.
> Then, it chooses a variable by using a heuristic and then flips this variable (flip
> means to change the value of a variable from 0 to 1 or from 1 to 0) in each search
> step. After many search steps, if the assignment satisfies the instance, this program
> stops. If the assignment still does not satisfy the instance after many search steps,
> this program stops after a predefined number of search steps. The number of search
> steps is what I call performance in my previous e-mail. In addition, this program uses
> both static and dynamic allocations.
>
> When I ran the two executables with different options on some SAT instances, they have
> different flip numbers (the parameters for these two executables are the same. For
> example, I use the same seed for them to generate initial assignments).  I ran the
> executable generated by using “gcc -m32 –O3 –lm” on a wide range of instance on
> different servers for more than 1 year but I never got any errors (such as core dump).
>
>
> If possible, please tell me what reinterpret_cast or similar operation is so that I can
> look for bugs from such operations in my program.
>
> Thank you very much for your time and help.
>
> Wanxia
>
>
>
>
>
>
> Quoting John Fine <johnsfine@xxxxxxxxxxx>:
>
>> If your meaning for the word "performance" is the usual meaning, the
>> earlier response by Andrew Haley answers the whole question.
>>
>> But the way you phrased the question makes me think you meant "behavior"
>> when you wrote "performance".
>>
>> -fno-strict-aliasing can give you correct behavior from a program that
>> incorrectly uses a reinterpret_cast or similar operation. That should be
>> considered a bug, and if there are few of those in your code, you should
>> find and correct them.
>>
>> Some old code has enough incorrect reinterpret_cast operations that
>> correcting them is impractical and you need the -fno-strict-aliasing
>>
>> I'm not sure what -DNDEBUG or -static might change in the behavior or
>> performance of your code. I'm just guessing that -fno-strict-aliasing is
>> the important difference.
>>
>> Wei, Wanxia wrote:
>> > gcc -m32 -O3 -DNDEBUG -fno-strict-aliasing -static –lm
>> >
>> > gcc -m32 –O3 –lm
>> >
>> >
>> ...
>> >  the
>> > different performance of the two executables of my C program means there are bugs
>> in
>> > this program?
>> >
>> >
>>
>
>
>
>



-- 
~ When the great Tao is forgotten, kindness and morality arise.


[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux