From 7a345f6d3ea16569d17b43dce48d1c8a0c496862 Mon Sep 17 00:00:00 2001 From: Tom Smeding Date: Mon, 8 Feb 2021 13:39:05 +0100 Subject: Update Futhark kernel for new Futhark --- aberth/aberth_kernel.fut | 22 +++++++++++----------- aberth/futhark.pkg | 4 ++-- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/aberth/aberth_kernel.fut b/aberth/aberth_kernel.fut index 9d0c59e..f868ee5 100644 --- a/aberth/aberth_kernel.fut +++ b/aberth/aberth_kernel.fut @@ -7,29 +7,29 @@ module uniform_real = uniform_real_distribution f32 rand_engine module cplx = mk_complex f32 type complex = cplx.complex -let N = 22i32 +let N = 22i64 let PolyN = N + 1 type poly = [PolyN]f32 -- First element of pair steps fastest -let iota2 (n: i32) (m: i32): [](i32, i32) = +let iota2 (n: i64) (m: i64): [](i64, i64) = flatten (map (\y -> map (\x -> (x, y)) (iota n)) (iota m)) -let evaln_c (p: poly) (nterms: i32) (pt: complex): complex = +let evaln_c (p: poly) (nterms: i64) (pt: complex): complex = foldr (\coef accum -> cplx.mk_re coef cplx.+ pt cplx.* accum) (cplx.mk_re p[nterms-1]) (take (nterms - 1) p) let eval_c (p: poly) (pt: complex): complex = evaln_c p (length p) pt -let evaln_d (p: poly) (nterms: i32) (pt: f32): f32 = +let evaln_d (p: poly) (nterms: i64) (pt: f32): f32 = foldr (\coef accum -> coef + pt * accum) p[nterms-1] (take (nterms - 1) p) let eval_d (p: poly) (pt: f32): f32 = evaln_d p (length p) pt let derivative (p: poly): *poly = - map2 (\i v -> f32.i32 (i32.bool (i != PolyN - 1) * (i + 1)) * v) + map2 (\i v -> f32.i64 (i64.bool (i != PolyN - 1) * (i + 1)) * v) (0.. f32.abs coef * f32.i32 (4 * i + 1)) p (0.. f32.abs coef * f32.i64 (4 * i + 1)) p (0.. f32.i32 (i32.get_bit i bitfield * 2 - 1)) + in tabulate PolyN (\i -> f32.i32 (i32.get_bit (i32.i64 i) bitfield * 2 - 1)) let calc_index (value: f32) (left: f32) (right: f32) (steps: i32): i32 = @@ -158,9 +158,9 @@ entry main_job in map (point_index width height bottom_left top_right) pts) (start_index ..< start_index + num_polys)) let filtered = filter (\i -> i != -1) indices - in reduce_by_index (replicate (width * height) 0) + in reduce_by_index (replicate (i64.i32 width * i64.i32 height) 0) (+) 0 - filtered + (map i64.i32 filtered) (map (const 1) filtered) entry main_all @@ -168,6 +168,6 @@ entry main_all (left: f32) (top: f32) (right: f32) (bottom: f32) (seed: i32) : []i32 = - main_job 0 (1 << N) width height left top right bottom seed + main_job 0 (i32.i64 (1 << N)) width height left top right bottom seed -entry get_N: i32 = N +entry get_N: i32 = i32.i64 N diff --git a/aberth/futhark.pkg b/aberth/futhark.pkg index c136912..0525d23 100644 --- a/aberth/futhark.pkg +++ b/aberth/futhark.pkg @@ -1,4 +1,4 @@ require { - github.com/diku-dk/complex 0.1.2 #790bf261a6a36a9454b55f3f8109ac5cb1f4bf6e - github.com/diku-dk/cpprandom 1.2.1 #869304710af3a023683d6670316d55dafd973c71 + github.com/diku-dk/complex 0.1.3 #6de81e642afe53306e04c3b38d59b7296e2dc0c5 + github.com/diku-dk/cpprandom 1.3.0 #68b67cb55242db59b79d94b5cdf961b2d654e698 } -- cgit v1.2.3