Opened 5 years ago

Closed 4 years ago

#5438 closed bug (invalid)

Wrong result for element check

Reported by: Owned by: benl
Priority: high Milestone: 7.4.1
Component: Data Parallel Haskell Version: 7.0.4
Keywords: Cc:
Operating System: Unknown/Multiple Architecture: Unknown/Multiple
Type of failure: Incorrect result at runtime Test Case:
Blocked By: Blocking:
Related Tickets: Differential Rev(s):
Wiki Page:


On the beginners list, Luca Ciciriello reported that

{-# LANGUAGE PArr #-}
{-# OPTIONS -fdph-seq #-}

module Main where

import Control.Parallel
import GHC.PArr

parArr :: [:String:]
parArr = [: "1", "2", "3", "4" :]

isElement :: String -> Bool
isElement x = x `elemP` parArr

main :: IO ()
main = do
          putStrLn $ (show . isElement) "5"

prints True. Obviously it should print False. I've replicated the behaviour with 7.0.4 and 6.10.4 on 64-bit linux (Luca tested on Mac and Windows).

As far as I can tell, elemP no longer exists in dph, so I had to modify to test with HEAD, and

{-# LANGUAGE ParallelArrays #-}
{-# OPTIONS -fdph-seq #-}

module Main where

import GHC.PArr
import Data.Array.Parallel

parArr :: [:String:]
parArr = [: "1", "2", "3", "4" :]

isElement :: String -> Bool
isElement x = x `elemP1` parArr
    elemP1 :: Eq a => a -> [:a:] -> Bool
    elemP1 v ar = lengthP (filterP (== v) ar) /= 0

main :: IO ()
main = do
          putStrLn $ (show . isElement) "5"

also prints True with HEAD, but prints False with 6.10.4 and 7.0.4 (with the necessary modifications, ParallelArrays -> PArr, don't import Data.Array.Parallel).

Change History (4)

comment:1 Changed 5 years ago by igloo

  • Milestone set to 7.4.1
  • Owner set to benl
  • Priority changed from normal to high

Thanks for the report. Ben, looks like one for you?

comment:2 Changed 5 years ago by

According to Luca, foldP also misbehaves. I don't know yet in which way.

comment:3 Changed 5 years ago by

Apparently a mistake, it seems foldP behaves correctly.

comment:4 Changed 4 years ago by chak

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

Data Parallel Haskell code must be compiled with '-fvectorise'. If you do that for this example, the vectoriser will complain that it cannot vectorise String. As explained on only types from the mock Prelude Data.Array.Parallel.Prelude.* are being support at the moment.

(Besides, DPH isn't in a usable state in 7.0.x. You need to use 7.2.x, which has limited support for DPH.)

Note: See TracTickets for help on using tickets.