Opened 8 years ago

Closed 8 years ago

Last modified 7 years ago

#991 closed bug (fixed)

-O option doesn't deal with par well

Reported by: shelarcy@… Owned by:
Priority: normal Milestone:
Component: Compiler Version: 6.6
Keywords: Parallel Haskell Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Test Case:
Blocked By: Blocking:
Related Tickets: Differential Revisions:

Description

I tried to parallelize below code.

circleReg1 :: Frac -> Region
circleReg1 r (Pt x y) = x*x + y*y < r*r

I use -threaded option with dual-CPU machine. So I saw these code upgrade performance very much.

[circleReg2] r (Pt x y) =
  let x' = (x*x)
      y' = y*y
      r' = r*r
  in
    x' `par` y' `par` r' `seq`  x' + y' < r'

circleReg3 r (Pt x y) =
  let x' = (x*x)
      y' = y*y
      r' = r*r
      strategy = rnf x' `par` rnf y' `par` rnf r'
  in
    x' + y' < r' `demanding` strategy

But ... If I want to optimise my code by ghc using -O option,
ghc notice error message like this;

circleReg2:

C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ghc1572_0\ghc1572_0.hc: In function `scmg_entry':
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ghc1572_0\ghc1572_0.hc:1102: warning: implicit declaration of function `newSpark'

circleReg3:

C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ghc980_0\ghc980_0.hc: In function `Main_lvl_entry':
C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\ghc980_0\ghc980_0.hc:1097: warning: implicit declaration of function `newSpark'

and -O option makes slower above code.
It seems that performance goes back to before parallelize, or more slowly.

I saw this error on Windows. Power PC Mac with GHC 6.4.1 doesn't cause this problem ... but I don't test GHC 6.6 on Mac, so I don't know this bug cause only Windows or not.

Change History (3)

comment:1 Changed 8 years ago by simonmar

  • Resolution set to fixed
  • Status changed from new to closed

The warnings are harmless; I've fixed it now anyway.

As for making the program slower, any number of things might be causing this. Firstly you should be aware that the fixity of par in 6.6 is wrong (see my recent msg to glasgow-haskell-users about this). Secondly, make sure that the granularity of the computations you intend to parallelise is large enough: there's no point trying to spark a single multiplication in parallel, for example. The mailing list is a better place to continue discussing this, until we establish whether there's a real bug.

comment:2 Changed 7 years ago by simonmar

  • Architecture changed from Unknown to Unknown/Multiple

comment:3 Changed 7 years ago by simonmar

  • Operating System changed from Unknown to Unknown/Multiple
Note: See TracTickets for help on using tickets.