File: blocking1_array.fut

package info (click to toggle)
haskell-futhark 0.25.32-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,236 kB
  • sloc: haskell: 100,484; ansic: 12,100; python: 3,440; yacc: 785; sh: 561; javascript: 558; lisp: 399; makefile: 272
file content (23 lines) | stat: -rw-r--r-- 644 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
-- Arrays with non-primitive rows block the migration of whole statements.
-- This is to avoid turning a parallel device copy into a sequential operation.
-- ==
-- structure gpu {
--   /If/True/ArrayLit 1
--   /Loop/ArrayLit 2
-- }

entry case_if (A: [5]i64) (x: i64) : i64 =
  if A[0] == 0
     then let B = [A, opaque A]
           in #[unsafe] (opaque B)[x%2, 2]
     else A[1]

entry case_while (A: [5]i64) : i64 =
  loop x = A[0] while x < 1000 do
    let B = [A, opaque A]
     in #[unsafe] (opaque B)[x%2, 2]

entry case_for (A: [5]i64) : i64 =
  loop x = 0 for i < A[0] do
    let B = [A, opaque A]
     in #[unsafe] (opaque B)[x%2, 2]