[gecode-users] question about mult propagator (compiler flags)

Alejandro Arbelaez a_le_jo55 at yahoo.com
Fri Sep 15 18:29:53 CEST 2006


Hi All,
 
 I think the problem  I am facing  with multiplication isn't in the propagator, it is related with gcc optimization flags and function inlining. I have  tried the code in  Pentium 4 and Xeon pcs (with  ubuntu 6.0.3:  g++ 4.0.3, gecode-1.2.2),  and the program fails. I also tried it in a power pc (g++ 4.0.3, gecode-1.2.2 and ubuntu 6.0.3)  and it worked. I realized that some compiler flags have a strong inpact:  -ffast-math and -O3. When building gecode with -ffast-math and without -O3 or with -O3 and without -ffast-math the program works very well. Both compiler flags seems to be not compatible in this case (processor + gcc version). Even further, when debug option is turned on from configure all works (i think debug option disables compiler optimization and function inlining).
 
 In my particular case the problem is with c_d function at line 45 of gecode/int/arithmetic/mult.icc, because the function has forceinline, I think that the compiler produces some wrong optimized code. Telling gcc to not inline this function also solves the problem in both pcs.
 
 

 Cheers
 Alejandro
 
 
 

Christian Schulte <schulte at imit.kth.se> wrote: Please, let me reiterate the issues raised in the two previous replies:

 Never, never ever, report a problem without telling
  - Gecode version number
  - platform used (operating system plus C++ compiler)

In this case, early versions of Gecode had actually a bug in multiplication
(but actually not incorrectness just a  quirk). So did you double check that
the program you wrote is the program you executed?

Cheers
Christian

--
Christian Schulte, http://www.imit.kth.se/~schulte/ 

-----Original Message-----
From: users-bounces at gecode.org [mailto:users-bounces at gecode.org] On Behalf
Of Mikael Zayenz Lagerkvist
Sent: Wednesday, September 13, 2006 8:22 AM
To: Alejandro Arbelaez
Cc: users at gecode.org
Subject: Re: [gecode-users] question about mult propagator


Hello Alejandro,

When I tried your program with Gecode 1.2.2 it worked as it should, i.e., it
printed OK
A: 316 B: 120 tmp: 37920

What version of Gecode are you using? What platform are you using it on?

Cheers,
Mikael

On 9/13/06, Alejandro Arbelaez  wrote:
> Hi all,
>
> I don't understand why the following program fails,
>
> I only want to create a propagator for
> a*b=:tmp, where a=:316 and b=:120
> so after the propagation (status) tmp is going to be equal to 37920, 
> and that is the value that tmp shows in the last line of the program, 
> but the status of  A is failed ????
>
> #include "gecode/int.hh"
> #include "gecode/kernel.hh"
> #include 
>
> using namespace Gecode;
>
> class Alejo : public Space {
> public:
>   Alejo(void) {}
>   virtual Space* copy(bool share) {
>     return new Alejo(*this);
>   }
> };
>
> int main() {
>   Alejo A;
>   IntVar a(&A,0,100000);
>   IntVar b(&A,0,100000);
>   IntVar tmp(&A,Gecode::Limits::Int::int_min,
> Gecode::Limits::Int::int_max);
>   mult(&A,a,b,tmp);
>   eq(&A,a,316);
>   eq(&A,b,120);
>
>   unsigned long pp;
>   SpaceStatus estado = A.status(pp);
>
>   if(estado==SS_FAILED) std::cout<<"FAILED"<
>   if(estado==SS_SOLVED) std::cout<<"OK"<
>   std::cout<<"A: "<<<" B: "<<<" tmp: "<<
>   return 0;
> }
>
>
> Cheers
> Alejandro
> _______________________________________________
> Gecode users mailing list
> users at gecode.org https://www.gecode.org/mailman/listinfo/gecode-users
>
>
>


-- 
Mikael Zayenz Lagerkvist, http://www.ict.kth.se/~zayenz/

_______________________________________________
Gecode users mailing list
users at gecode.org
https://www.gecode.org/mailman/listinfo/gecode-users



 		
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates starting at 1&cent;/min.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.ps.uni-sb.de/pipermail/users/attachments/20060915/105ae77e/attachment.htm>


More information about the gecode-users mailing list