Hello, I am submitting a bug report for accelerate-llvm-native (based on what I saw issues for it were moved/resubmitted/double submitted here?). I've created a gist describing the issue and containing the relevant files and output in addition to information here.
I believe this bug may actually be with LLVM itself, and I plan to file a bug there as well, but I think there is a workaround that can be done in accelerate-llvm-native in the mean time.
Description
The following Accelerate code SIGSEGV's by trying to access an invalid address.
module Main where
import Data.Array.Accelerate as A
import Data.Array.Accelerate.LLVM.Native
g :: Scalar Double -> Scalar Double
g = (runN (A.map f :: Acc (Scalar Double) -> Acc (Scalar Double)))
where
f x = let y = recip x
b = (-y) * y
in y + tanh b
main :: IO ()
main = do
let r = g (fromList Z [1])
print (indexArray r Z)
This issue first occurred while I was writing some simple numeric functions for automatic differentiation and the bug caused my code to unpredictably crash.
Expected behaviour
The expected behaviour is the program should output 0.23840584404423515 (= 1 + tanh(-1)).
Current behaviour
Running the program currently produces “stack exec -- accelerate-llvm-b…” terminated by signal SIGSEGV (Address boundary error).
Possible solution
See the gist for a detailed description, but a workaround would be to turn off (or give the ability to turn off) FP contract option (-fp-contract for llc and opt). Compiling the generated LLVM IR without this option by hand produced an object which, when placed in Accelerates cache, produces the expected behaviour.
Steps to reproduce
- Take the files from the gist, (namely
accelerate-llvm-bug.cabal, stack.yaml, and Main.hs) and place them in the same folder (e.g. download the ZIP and unzip it).
- Run
stack build.
- Run
stack exec accelerate-llvm-bug.
Your environment
Haskell package versions are all from Stack LTS 10.2.
- Version used:
accelerate-1.1.1.0
- Backend(s) used and version:
accelerate-llvm-1.1.0.0, accelerate-llvm-native-1.1.0.1
- Operating system and version:
$ lsb_release -a
Distributor ID: Ubuntu
Description: Ubuntu 17.04
Release: 17.04
Codename: zesty
- Link to your project: the gist
- Misc. versions of other tools:
-
$ clang-5.0 --version
clang version 5.0.1-svn319952-1~exp1 (branches/release_50)
Target: x86_64-pc-linux-gnu
Thread model: posix
InstalledDir: /usr/bin
-
$ llc-5.0 --version
LLVM (http://llvm.org/):
LLVM version 5.0.1
Optimized build.
Default target: x86_64-pc-linux-gnu
Host CPU: broadwell
Registered Targets: [...]
Thank you, and don't hesitate to ask for more info!
Hello, I am submitting a bug report for
accelerate-llvm-native(based on what I saw issues for it were moved/resubmitted/double submitted here?). I've created a gist describing the issue and containing the relevant files and output in addition to information here.I believe this bug may actually be with LLVM itself, and I plan to file a bug there as well, but I think there is a workaround that can be done in
accelerate-llvm-nativein the mean time.Description
The following Accelerate code SIGSEGV's by trying to access an invalid address.
This issue first occurred while I was writing some simple numeric functions for automatic differentiation and the bug caused my code to unpredictably crash.
Expected behaviour
The expected behaviour is the program should output
0.23840584404423515(= 1 + tanh(-1)).Current behaviour
Running the program currently produces
“stack exec -- accelerate-llvm-b…” terminated by signal SIGSEGV (Address boundary error).Possible solution
See the gist for a detailed description, but a workaround would be to turn off (or give the ability to turn off) FP contract option (
-fp-contractforllcandopt). Compiling the generated LLVM IR without this option by hand produced an object which, when placed in Accelerates cache, produces the expected behaviour.Steps to reproduce
accelerate-llvm-bug.cabal,stack.yaml, andMain.hs) and place them in the same folder (e.g. download the ZIP and unzip it).stack build.stack exec accelerate-llvm-bug.Your environment
Haskell package versions are all from Stack LTS 10.2.
accelerate-1.1.1.0accelerate-llvm-1.1.0.0,accelerate-llvm-native-1.1.0.1Thank you, and don't hesitate to ask for more info!