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

Automap #60

Draft
wants to merge 33 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
b7fb406
OptionPricing and LocVolCalib.
athas Feb 29, 2024
ac9afff
pagerank
athas Feb 29, 2024
556a821
AUTOMAP mri-q.
athas Mar 11, 2024
4840ae7
AUTOMAP sgemm - crashes in monomorphisation.
athas Mar 11, 2024
8818011
Another AUTOMAP; does not monomorphise.
athas Mar 11, 2024
583380c
More AUTOMAP
athas Mar 13, 2024
7ca34a5
More.
athas Mar 13, 2024
6df8f31
Kill a few more maps.
athas Mar 14, 2024
ef93fad
More AUTOMAP.
athas Mar 14, 2024
73d98d2
More AUTOMAP.
athas Mar 14, 2024
f03e7c5
More AUTOMAP.
athas Mar 15, 2024
5513459
AUTOMAP canny.
athas Mar 15, 2024
598a0a0
More AUTOMAP.
athas Mar 15, 2024
8c4176c
Workarounds for some type checker bugs.
athas Mar 18, 2024
9d6f3cf
Another workaround.
athas Mar 18, 2024
f06b091
Remove more.
athas Mar 18, 2024
7925aad
More AUTOMAP.
athas Mar 19, 2024
d77c92d
These maps can also be left out.
athas Mar 30, 2024
310aef4
Oops, move paren.
athas Apr 1, 2024
f1199c2
More AUTOMAP.
athas Apr 1, 2024
7d76f0c
No fear.
athas Apr 3, 2024
bdd137a
Fewer maps.
athas Apr 3, 2024
7ff8e54
More AUTOMAP.
athas Apr 3, 2024
339afc8
Merge branch 'master' into automap
athas Apr 3, 2024
386a539
Less crazy name.
athas May 7, 2024
2b31c4c
Add larger dataset.
athas May 24, 2024
9db009e
This needs a tuning file to go well.
athas May 24, 2024
748f9d9
Add gitignore for random data.
athas Jun 1, 2024
986b9e1
Bump all dependencies.
athas Jun 1, 2024
abac607
Fix RNG.
athas Jul 10, 2024
6351315
Use sha256sum binary.
athas Jul 12, 2024
54f010d
Add LICENSE.
athas Jul 17, 2024
0d427b9
Merge branch 'master' into automap
athas Jul 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
Unless otherwise specifies, the programs in this repository are
covered by the license terms below.

ISC License

Copyright (c) DIKU, University of Copenhagen

Permission to use, copy, modify, and/or distribute this software for
any purpose with or without fee is hereby granted, provided that the
above copyright notice and this permission notice appear in all
copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
6 changes: 2 additions & 4 deletions accelerate/canny/canny.fut
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def edgeWeak: f32 = 0.5
def edgeStrong: f32 = 1.0

def toGreyscale [h][w] (img: [h][w]i32): [h][w]f32 =
map (\row -> map (255.0*) (map luminanceOfRGBA32 row)) img
255.0 * luminanceOfRGBA32 img

def gaussianX [h][w] (img: [h][w]f32): [h][w]f32 =
tabulate_2d h w (\x y ->
Expand Down Expand Up @@ -120,9 +120,7 @@ def nonMaximumSuppression [h][w] (low: f32) (high: f32) (magdir: [h][w](f32,i32)
else if mag >= high then 1.0 else 0.5)

def selectStrong [h][w] (img: [h][w]f32): []i32 =
let strong =
map (\x -> if x == edgeStrong then 1 else 0)
(flatten img)
let strong = i32.bool (flatten img == edgeStrong)
-- The original Accelerate implementation used an exclusive scan
-- here, so we have to play with the indices.
let targetIdxAndLen = scan (+) 0 strong
Expand Down
10 changes: 5 additions & 5 deletions accelerate/fft/fft.fut
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ import "lib/github.com/diku-dk/fft/stockham-radix-2"
module fft = mk_fft f32

def tabmap [n] 'a 'b (f: i32 -> a -> b) (xs: [n]a) =
map2 f (map i32.i64 (iota n)) xs
f (i32.i64 (iota n)) xs

def centre_2d [n][m] (arr: [n][m]c32): [n][m]c32 =
let f (i: i32) (j: i32) (x: c32) =
c32.mk_re (f32.i32 ((-1) ** (i+j))) c32.* x
in tabmap (f >-> tabmap) arr

def transform [n][m] (cutoff: i32) (arr: [n][m]u8) =
let arr_complex = map1 (map1 (f32.u8 >-> c32.mk_re)) arr
let arr_complex = c32.mk_re (f32.u8 arr)
let arr_centered = centre_2d arr_complex
let arr_freq = fft.fft2 arr_centered
let centre_i = i32.i64 n / 2
Expand All @@ -44,7 +44,7 @@ def transform [n][m] (cutoff: i32) (arr: [n][m]u8) =
then c32.mk_re 0f32 else x
let arr_filt = tabmap (zap >-> tabmap) arr_freq
let arr_inv = fft.ifft2 arr_filt
in map1 (map1 c32.mag) arr_inv
in c32.mag arr_inv

-- We have two entry points, for testing and the actual high-pass
-- filtering application. The reason is that rounding the f32 values
Expand All @@ -57,7 +57,7 @@ def unpack_rgb (x: [3]u8): (u8, u8, u8) =
(x[0], x[1], x[2])

def main [n][m] (cutoff: i32) (img: [n][m][3]u8): ([n][m]f32,[n][m]f32,[n][m]f32) =
let (r, g, b) = map1 (map1 (unpack_rgb) >-> unzip3) img |> unzip3
let (r, g, b) = unzip3 (unzip3 (unpack_rgb img))
let r' = transform cutoff r
let g' = transform cutoff g
let b' = transform cutoff b
Expand All @@ -68,4 +68,4 @@ def pack_rgb ((r,g,b): (f32, f32, f32)): [3]u8 =

entry highpass_filter [n][m] (cutoff: i32) (img: [n][m][3]u8): [n][m][3]u8 =
let (rss, gss, bss) = main cutoff img
in map3 (map3 (\r g b -> [u8.f32 r, u8.f32 g, u8.f32 b])) rss gss bss
in (\r g b -> [u8.f32 r, u8.f32 g, u8.f32 b]) rss gss bss
Binary file added accelerate/fluid/benchmarking/large.in.gz
Binary file not shown.
2 changes: 2 additions & 0 deletions accelerate/fluid/fluid.fut
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@
--
-- ==
-- compiled input @ benchmarking/medium.in
-- compiled input @ benchmarking/large.in.gz

-- medium.in attributes: n_steps=1, n_solver_steps=40, grid_res=100
-- large.in attributes: n_steps=1, n_solver_steps=40, grid_res=2000

------------------------------------------------------------
-- General helper functions.
Expand Down
14 changes: 7 additions & 7 deletions accelerate/hashcat/hashcat.fut
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type md5 = (u32, u32, u32, u32)
def us32 (x: i32) = u32.i32 x

def rs: [64]u32 =
map us32
us32
[ 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22, 7, 12, 17, 22,
5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20, 5, 9, 14, 20,
4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23, 4, 11, 16, 23,
Expand Down Expand Up @@ -77,13 +77,13 @@ def initial_chunk = (0x67452301_u32,
0x10325476_u32)

def md5s [n] (bs: [n][16]u32): [n]md5 =
map (md5_chunk initial_chunk) bs
md5_chunk initial_chunk bs


def first_true [n] (bools : [n]bool): i32 =
(reduce_comm (\p (i,x) -> if x then (i,x) else p)
(-1,false)
(zip (map i32.i64 (iota n)) bools)).0
(zip (i32.i64 (iota n)) bools)).0

-- Input preprocessing.

Expand All @@ -97,17 +97,17 @@ def mk_block (bs: []u8) ((i,k): (i64,i64)): [16]u32 =
let block[0:k] = bs[i:i+k]
let block[k:k+4] = one_bit
let block[64-8:64-4] = bytes (u32.i64(k*8))
in map unbytes (unflatten block)
in unbytes (unflatten block)

def md5_blocks [n][k] (bs: [k]u8) (offsets: [n]i64): [n][16]u32 =
let lengths = map (\(i, j) -> if i > j then k-i else j-i)
(zip offsets (rotate 1 offsets))
in map (mk_block bs) (zip offsets lengths)
in mk_block bs (zip offsets lengths)

entry mk_dict [n] (bs: []i8) (offsets: [n]i64): dict[n] =
md5_blocks (map u8.i8 bs) offsets
md5_blocks (u8.i8 bs) offsets

-- The entry point.

entry main [n] (a: u32) (b: u32) (c: u32) (d: u32) (bs: []i8) (offsets: [n]i32): i32 =
first_true (map (==(a,b,c,d)) (md5s (mk_dict bs (map i64.i32 offsets))))
first_true (md5s (mk_dict bs (i64.i32 offsets)) == (a,b,c,d))
2 changes: 1 addition & 1 deletion accelerate/julia/futhark.pkg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require {
github.com/diku-dk/complex 0.2.0 #19c5afb0931c4cfe4d8f2e9540ba01edd9460639
github.com/athas/matte 0.1.3 #ec4243a5f64cb818a4289dbc4953460ea19da12c
github.com/diku-dk/lys 0.1.23 #9248502662fba6286b975b3f29e881dc8424ed03
github.com/diku-dk/lys 0.1.25 #7bb0fc8402f95da498a119ef8d841e1d9b891963
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,4 @@ pkgs: with pkgs; [
xxd
python3
gcc
ncurses.dev
]
8 changes: 7 additions & 1 deletion accelerate/julia/lib/github.com/diku-dk/lys/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,18 @@ SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
include $(SELF_DIR)/setup_flags.mk
FRONTEND_DIR = $(SELF_DIR)/$(LYS_FRONTEND)

ifeq ($(LYS_FRONTEND), sdl)
FONT_DEPS=font_data.h
else
FONT_DEPS=
endif

ifeq ($(shell test futhark.pkg -nt lib; echo $$?),0)
$(PROGNAME):
futhark pkg sync
@make # The sync might have resulted in a new Makefile.
else
$(PROGNAME): $(PROGNAME)_wrapper.o $(PROGNAME)_printf.h font_data.h $(FRONTEND_DIR)/liblys.c $(FRONTEND_DIR)/liblys.h $(SELF_DIR)/shared.c $(SELF_DIR)/shared.h $(FRONTEND_DIR)/main.c
$(PROGNAME): $(PROGNAME)_wrapper.o $(PROGNAME)_printf.h $(FONT_DEPS) $(FRONTEND_DIR)/liblys.c $(FRONTEND_DIR)/liblys.h $(SELF_DIR)/shared.c $(SELF_DIR)/shared.h $(FRONTEND_DIR)/main.c
gcc $(FRONTEND_DIR)/liblys.c $(SELF_DIR)/shared.c $(FRONTEND_DIR)/main.c -I. -I$(SELF_DIR) -DPROGHEADER='"$(PROGNAME)_wrapper.h"' -DPRINTFHEADER='"$(PROGNAME)_printf.h"' -DLYS_TEXT $(PROGNAME)_wrapper.o -o $@ $(CFLAGS) $(LDFLAGS)
endif

Expand Down
Loading