Skip to content

Commit

Permalink
Fix GPU compilation of array values.
Browse files Browse the repository at this point in the history
  • Loading branch information
athas committed Jan 9, 2025
1 parent 17da205 commit 1dc7e3e
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

* `futhark pkg`: fixed parsing of Git timestamps in Z time zone.

* GPU backends did not handle array constants correctly in some cases.

## [0.25.25]

### Added
Expand Down
3 changes: 3 additions & 0 deletions src/Futhark/CodeGen/ImpGen/GPU/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,9 @@ compileThreadExp :: ExpCompiler GPUMem KernelEnv Imp.KernelOp
compileThreadExp (Pat [pe]) (BasicOp (Opaque _ se)) =
-- Cannot print in GPU code.
copyDWIM (patElemName pe) [] se []
-- The static arrays stuff does not work inside kernels.
compileThreadExp (Pat [dest]) (BasicOp (ArrayVal vs t)) =
compileThreadExp (Pat [dest]) (BasicOp (ArrayLit (map Constant vs) (Prim t)))
compileThreadExp (Pat [dest]) (BasicOp (ArrayLit es _)) =
forM_ (zip [0 ..] es) $ \(i, e) ->
copyDWIMFix (patElemName dest) [fromIntegral (i :: Int64)] e []
Expand Down
2 changes: 2 additions & 0 deletions src/Futhark/CodeGen/ImpGen/GPU/Block.hs
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,8 @@ compileBlockExp (Pat [pe]) (BasicOp (Opaque _ se)) =
-- Cannot print in GPU code.
copyDWIM (patElemName pe) [] se []
-- The static arrays stuff does not work inside kernels.
compileBlockExp (Pat [dest]) (BasicOp (ArrayVal vs t)) =
compileBlockExp (Pat [dest]) (BasicOp (ArrayLit (map Constant vs) (Prim t)))
compileBlockExp (Pat [dest]) (BasicOp (ArrayLit es _)) =
forM_ (zip [0 ..] es) $ \(i, e) ->
copyDWIMFix (patElemName dest) [fromIntegral (i :: Int64)] e []
Expand Down

0 comments on commit 1dc7e3e

Please sign in to comment.