Re: [GHC] #2270: gcd is specialised only for Int

2009-07-17 Thread GHC
#2270: gcd is specialised only for Int
+---
Reporter:  dons |Owner:  
d...@galois.com 
Type:  bug  |   Status:  closed 
 
Priority:  normal   |Milestone:  6.12.1 
 
   Component:  libraries/base   |  Version:  6.8.2  
 
Severity:  normal   |   Resolution:  duplicate  
 
Keywords:  rules, performance, double, gcd  |   Difficulty:  Unknown
 
Testcase:   |   Os:  
Unknown/Multiple
Architecture:  Unknown/Multiple |  
+---
Changes (by igloo):

  * status:  new = closed
  * resolution:  = duplicate

Comment:

 Closing, as this ticket is subsumed by #3055.

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2270#comment:8
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2270: gcd is specialised only for Int

2009-04-11 Thread GHC
#2270: gcd is specialised only for Int
+---
Reporter:  dons |Owner:  
d...@galois.com 
Type:  bug  |   Status:  new
 
Priority:  normal   |Milestone:  6.12.1 
 
   Component:  libraries/base   |  Version:  6.8.2  
 
Severity:  normal   |   Resolution: 
 
Keywords:  rules, performance, double, gcd  |   Difficulty:  Unknown
 
Testcase:   |   Os:  
Unknown/Multiple
Architecture:  Unknown/Multiple |  
+---
Changes (by igloo):

  * milestone:  6.10.2 = 6.12.1

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2270#comment:7
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2270: gcd is specialised only for Int

2008-10-04 Thread GHC
#2270: gcd is specialised only for Int
-+--
 Reporter:  dons |  Owner:  [EMAIL 
PROTECTED] 
 Type:  bug  | Status:  new 
 Priority:  normal   |  Milestone:  6.10.2  
Component:  libraries/base   |Version:  6.8.2   
 Severity:  normal   | Resolution:  
 Keywords:  rules, performance, double, gcd  | Difficulty:  Unknown 
 Testcase:   |   Architecture:  Unknown/Multiple
   Os:  Unknown/Multiple |  
-+--
Changes (by igloo):

  * milestone:  6.10.1 = 6.10.2

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2270#comment:6
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2270: gcd is specialised only for Int

2008-07-31 Thread GHC
#2270: gcd is specialised only for Int
-+--
 Reporter:  dons |  Owner:  [EMAIL 
PROTECTED]
 Type:  bug  | Status:  new
 Priority:  normal   |  Milestone:  6.10.1 
Component:  libraries/base   |Version:  6.8.2  
 Severity:  normal   | Resolution: 
 Keywords:  rules, performance, double, gcd  | Difficulty:  Unknown
 Testcase:   |   Architecture:  Unknown
   Os:  Unknown  |  
-+--
Changes (by guest):

  * keywords:  = rules, performance, double, gcd
 * cc: rules, performance, double, gcd (removed)
 * cc: [EMAIL PROTECTED] (added)

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2270#comment:3
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2270: gcd is specialised only for Int

2008-07-09 Thread GHC
#2270: gcd is specialised only for Int
+---
 Reporter:  dons|  Owner:  [EMAIL PROTECTED]
 Type:  bug | Status:  new
 Priority:  normal  |  Milestone:  6.10.1 
Component:  libraries/base  |Version:  6.8.2  
 Severity:  normal  | Resolution: 
 Keywords:  | Difficulty:  Unknown
 Testcase:  |   Architecture:  Unknown
   Os:  Unknown |  
+---
Changes (by igloo):

  * component:  Compiler = libraries/base

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2270#comment:2
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


Re: [GHC] #2270: gcd is specialised only for Int

2008-06-30 Thread GHC
#2270: gcd is specialised only for Int
--+-
 Reporter:  dons  |  Owner:  [EMAIL PROTECTED]
 Type:  bug   | Status:  new
 Priority:  normal|  Milestone:  6.10.1 
Component:  Compiler  |Version:  6.8.2  
 Severity:  normal| Resolution: 
 Keywords:| Difficulty:  Unknown
 Testcase:|   Architecture:  Unknown
   Os:  Unknown   |  
--+-
Changes (by igloo):

  * difficulty:  = Unknown
  * milestone:  = 6.10.1

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2270#comment:1
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs


[GHC] #2270: gcd is specialised only for Int

2008-05-07 Thread GHC
#2270: gcd is specialised only for Int
+---
Reporter:  dons |   Owner:  [EMAIL PROTECTED]
Type:  bug  |  Status:  new
Priority:  normal   |   Component:  Compiler   
 Version:  6.8.2|Severity:  normal 
Keywords:   |Testcase: 
Architecture:  Unknown  |  Os:  Unknown
+---
 We have the general:

 {{{

 gcd :: (Integral a) = a - a - a
 gcd 0 0 =  error Prelude.gcd: gcd 0 0 is undefined
 gcd x y =  gcd' (abs x) (abs y)
where gcd' a 0  =  a
  gcd' a b  =  gcd' b (a `rem` b)
 }}}

 And a specialisation for Int only:

 {{{
 {-# RULES
 gcd/Int-Int-Int gcd = gcdInt
  #-}

 gcdInt (I# a) (I# b) = g a b
where g 0# 0# = error GHC.Base.gcdInt: gcd 0 0 is undefined
  g 0# _  = I# absB
  g _  0# = I# absA
  g _  _  = I# (gcdInt# absA absB

 }}}

 Thanks to the gcdInt# primop.

 If we use Word here, or other Int types, we get the slow version (which is
 only 10x slower, surprisingly):

 {{{
 main = print . sumU
  . mapU (gcd 2)
  $ enumFromToU 0 (1 :: Word)

 }}}

 Comes out as:

 {{{

  time ./henning
 15002
 ./henning  25.73s user 0.05s system 99% cpu 25.936 total

 }}}

 Versus:

 {{{

 $ time ./henning
 15002
 ./henning  2.33s user 0.00s system 99% cpu 2.334 tota

 }}}

 So there are two things we can do here to improve the situation:

 == Step 1: Add rules for getting from the other Int* types to gcdInt# ==

 {{{

 {-# RULES

 gcd/Int32-Int32-Int32 gcd = gcdInt32

   #-}

 gcdInt32 :: Int32 - Int32 - Int32
 gcdInt32 x y = fromIntegral ((gcd :: Int - Int - Int) (fromIntegral x)
 (fromIntegral y))

 }}}

 For example, takes the running time from 28 seconds to 2.4seconds, for:

 {{{

 main = print . sumU
  . mapU (gcd 2)
  $ enumFromToU 0 (1 :: Int32)

 }}}

 == Step 2: optionally add a gcdWord# ==

 We could then also add a gcdWord# primop,or perhaps just following
 fromIntegral, and test
 for negative first, then conditionally dispatch to gcdInt.

 What do people think?

-- 
Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/2270
GHC http://www.haskell.org/ghc/
The Glasgow Haskell Compiler___
Glasgow-haskell-bugs mailing list
Glasgow-haskell-bugs@haskell.org
http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs