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

OpenCL backend miscompilation #1054

Closed
athas opened this issue Jul 13, 2020 · 3 comments
Closed

OpenCL backend miscompilation #1054

athas opened this issue Jul 13, 2020 · 3 comments

Comments

@athas
Copy link
Member

athas commented Jul 13, 2020

-- ==
-- input { [0x2b28ab09u32, 0x7eaef7cfu32, 0x15d2154fu32, 0x16a6883cu32] }
-- auto output

let blk_transpose (block: [4]u32) : [4]u32 = #[sequential] map (\i ->
    let offset = u32.i32 (3-i)<<3
    in    (((block[0] >> offset) & 0xFF) << 24)
        | (((block[1] >> offset) & 0xFF) << 16)
        | (((block[2] >> offset) & 0xFF) << 8)
        | ((block[3] >> offset) & 0xFF)) (iota 4)

let main (key: [4]u32) : [11][4]u32 =
  map blk_transpose (loop w = [key] for _i < 10i32 do (w ++ [key])) :> [11][4]u32
@athas
Copy link
Member Author

athas commented Jul 13, 2020

Looks like it's the size ascription (and the Reshape it gives rise to) that produces a bad index function for the result.

@michael-elkh
Copy link
Collaborator

michael-elkh commented Jul 13, 2020

The issue seems to be linked to the sequential attribute. The issue goes away when I remove it.

@athas
Copy link
Member Author

athas commented Jul 13, 2020

It's actually linked to any kind of size coercion of a column-major array (and Futhark stores the result of the map in column-major when the innermost map is sequential, to optimise the memory access pattern). This is the simplest case that reproduces the problem, in all backends:

let main [n] [m] (xss: [n][m]i32) =
  transpose xss :> [2][3]i32

I think I have a fix for it, but I'll need to run some thorough tests, as I am super paranoid about all change we make to the array representation level.

athas added a commit that referenced this issue Jul 13, 2020
@athas athas closed this as completed in d7d02a9 Jul 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants