Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Function hashes have incorrect length causing internal errors #514

Closed
Jasonoro opened this issue Mar 10, 2022 · 2 comments
Closed

Comments

@Jasonoro
Copy link

Description

After commit 5b7bab3, the length of generated hashes for functions have a dynamic length, instead of being 64 characters and an underscore. For example, the following program:

{-# LANGUAGE OverloadedLists #-}
{-# LANGUAGE FlexibleContexts #-}
module Main where

import qualified Data.Array.Accelerate as A
import Data.Array.Accelerate.LLVM.PTX (run)

main :: IO ()
main = do
  let mat = A.fromList (A.Z A.:. 5 A.:. 10) [0..] :: A.Matrix Int 
  let res = run $ A.scanl1 (+) (A.use mat)
  putStrLn $ show res

will result in the following LLVM code:

[...]
define void @scan_661e445b438bd447cf2795717e96b987161e314472469fc6e3bf825c3e7f4a4(i64* noalias nocapture %out.ad0, i64 %out.sh1, i64 %out.sh0, i64* noalias nocapture readonly %in.ad0, i64 %in.sh1, i64 %in.sh0) local_unnamed_addr #0 {
[...]

which is a hash of 63 characters, not 64. This causes the program execution to fail:

*** Internal error in package accelerate ***
*** Please submit a bug report at https://github.com/AccelerateHS/accelerate/issues

function not found: scan
CallStack (from HasCallStack):
  internalError: Data.Array.Accelerate.LLVM.PTX.Execute:798:16
  !#: Data.Array.Accelerate.LLVM.PTX.Execute:482:30
  scanDimOp: Data.Array.Accelerate.LLVM.PTX.Execute:421:5
  scanCore: Data.Array.Accelerate.LLVM.PTX.Execute:404:10
  scan1Op: Data.Array.Accelerate.LLVM.PTX.Execute:106:19

as Accelerate expects hashes of 64 characters.

Steps to reproduce

Steps to reproduce the behaviour:

  1. Clone the main accelerate package and the LLVM package, latest commits
  2. Create the example program above
  3. Run the program

Expected behaviour

The program runs the scanl1 function and returns the new array

Your environment

  • Accelerate: fc42aa1
  • Accelerate backend(s): PTX (accelerate-llvm@4fd0d9a91977da7382468857d08d8fafae3a341b)
  • GHC: nightly-2022-02-16
  • OS: Ubuntu 20.04.2 LTS (Jizo)

Additional context

-

@tmcdonell
Copy link
Member

Here it is not including the leading zero for values < 16. Fix incoming...

@tmcdonell
Copy link
Member

Tested on the CPU backend (on my laptop = no GPU) but seems to work now. Well spotted!

[...]
define void @scanS_661e445b438bd447cf2795717e96b987161e314472469fc6e30bf825c3e7f4a4(i64 %ix.start0, i64 %ix.end0, i64* noalias nocapture %out.ad0, i64 %out.sh1, i64 %out.sh0, i64* noalias nocapture readonly %in.ad0, i64 %in.sh1, i64 %in.sh0) local_unnamed_addr #0 {
[...]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants