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 #2159

Open
wants to merge 304 commits into
base: master
Choose a base branch
from
Open

AUTOMAP #2159

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
304 commits
Select commit Hold shift + click to select a range
6a958f0
Add options to set all ranks to zero for debugging.
zfnmxt Feb 12, 2024
989e1e3
Use PuLP instead of setting ranks to zero.
zfnmxt Feb 12, 2024
3c2e319
Add PuLP stuff.
zfnmxt Feb 12, 2024
5ef513d
Improve Solution.
athas Feb 12, 2024
678633b
Preserve types better.
athas Feb 12, 2024
c73e681
WIP on type checker integration.
athas Feb 14, 2024
fb42c32
Now we get quite far in type checking!
athas Feb 15, 2024
333ca8d
Instantiate sizes properly.
athas Feb 15, 2024
b4983c6
Don't normalize/forget variables.
zfnmxt Feb 15, 2024
b122b27
Preserve uniqueness.
athas Feb 15, 2024
fc083ad
Jank frame fix.
zfnmxt Feb 15, 2024
1ed744b
SPEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEED
zfnmxt Feb 15, 2024
6eb745e
Add `GLPK.hs`.
zfnmxt Feb 15, 2024
1d77281
Basic things work now.
athas Feb 16, 2024
cb21531
Fix typo.
athas Feb 16, 2024
4d673d3
Working AUTOMAP (not really).
athas Feb 16, 2024
8fd5e18
Support AUTOMAP on `BinOp`s.
zfnmxt Feb 16, 2024
32c9a73
Some work on overloaded type variables.
athas Feb 17, 2024
5f45f19
Tear out some organs we probably do not need anymore.
athas Feb 17, 2024
ae1f529
Remove more guts.
athas Feb 17, 2024
0f6156a
Must also unify here.
athas Feb 17, 2024
9bf72c8
AUTOMAP does not work yet.
athas Feb 17, 2024
7d3bcc7
Defunctionalization and internalization AUTOMAP progress.
zfnmxt Feb 18, 2024
3e091b7
Oops.
zfnmxt Feb 18, 2024
8993923
Basic map-only AUTOMAP seems to work now.
zfnmxt Feb 18, 2024
4c8a124
Please shut up.
athas Feb 18, 2024
6407ff3
Handle automapped operand.
athas Feb 18, 2024
9f10932
Put these adjacent.
athas Feb 18, 2024
2ea1c6a
Add frame to binop result.
athas Feb 18, 2024
b644e3f
AUTOMAP `OpSection` support.
zfnmxt Feb 18, 2024
c44a2cf
Merge branch 'master' into constraints
athas Feb 19, 2024
14c5544
Flail at the constraint solver.
athas Feb 19, 2024
52beb8c
Print this too.
athas Feb 19, 2024
8f4cb68
Add ambiguity checking.
zfnmxt Feb 19, 2024
7e9e907
Merge branch 'master' into constraints
athas Feb 19, 2024
6d91328
Forgot the source.
zfnmxt Feb 19, 2024
2c19d78
Add rep shapes here.
athas Feb 19, 2024
8dd13d4
Make the design of `Rank.hs` less dumb.
zfnmxt Feb 20, 2024
af0b0bb
Pass a list of possible solutions around.
zfnmxt Feb 20, 2024
012680d
Cap the number of solutions.
zfnmxt Feb 20, 2024
9ab28c0
Make big `M` actually big(ish).
zfnmxt Feb 20, 2024
7616bcc
AUTOMAP for short-circuiting operators.
zfnmxt Feb 20, 2024
870f97f
Use `Int`s instead of `Double`s and print out rank maps.
zfnmxt Feb 20, 2024
87da34a
Apparently powers of 2 are better. 10^6 also somehow gives incorrect …
zfnmxt Feb 20, 2024
043ff22
Support auto replicates in internalization.
zfnmxt Feb 20, 2024
674bf01
Fiddle with Ident type checking.
athas Feb 21, 2024
a10bd3d
Fix type checking of LetWith.
athas Feb 21, 2024
2bb4085
OptionPricing now type checks.
athas Feb 21, 2024
4af653a
- Introduce rank representation for `AutoMap` annotations to carry ra…
zfnmxt Feb 22, 2024
c336b16
Do not rewrite automapped short-circuiting ops.
athas Feb 22, 2024
ff353e5
We do not need this.
athas Feb 22, 2024
986856d
Try to handle logical operators.
athas Feb 22, 2024
263ec73
Remove `autoMapRank`.
zfnmxt Feb 22, 2024
285604e
Another hash.
athas Feb 22, 2024
2334dfd
Make uniqueness explicit.
athas Feb 22, 2024
3212b97
Hack to detect no integer solutions from `glpk`.
zfnmxt Feb 22, 2024
eb49178
Add some notes to clarify how this will actually work.
zfnmxt Feb 23, 2024
94af090
Bit more.
zfnmxt Feb 23, 2024
a7c8dd9
Unnecessary warnings.
athas Feb 23, 2024
86acaed
Slices better be i64.
athas Feb 23, 2024
073d69e
Merge branch 'master' into constraints
athas Feb 23, 2024
92be29d
Implement occurs check.
athas Feb 23, 2024
aec83f3
This is too much.
athas Feb 23, 2024
df35808
Add Futhark.Util.debugTraceM.
athas Feb 23, 2024
02c71b7
Prettyprint AUTOMAP annotations.
zfnmxt Feb 23, 2024
2a64af3
Also prettyprint binops.
zfnmxt Feb 23, 2024
d201507
Fix checkOneExp.
athas Feb 23, 2024
2119f29
Fix frame duplication.
zfnmxt Feb 23, 2024
81d53e5
Remove `checkApply_`.
zfnmxt Feb 23, 2024
6b17195
Forgot to remove this too.
zfnmxt Feb 23, 2024
e09ad67
Rank fixes.
zfnmxt Feb 24, 2024
e2505f5
Don't peel frames and distribute instead.
zfnmxt Feb 24, 2024
f25bd9e
Change objective from `M_i + R_i` to `M_i + max(0, |R_i| - |F_i|).`
zfnmxt Feb 24, 2024
93fa76e
Add some tests.
zfnmxt Feb 24, 2024
b3d3c42
Renaming hack to not count these when looking for new solutions.
zfnmxt Feb 24, 2024
3cdce28
Add leetcode test.
zfnmxt Feb 24, 2024
6616a07
Easier to read with some linebreaks.
athas Feb 24, 2024
2de3f1e
Remove map intrinsic.
athas Feb 25, 2024
d24831d
Fix AUTOMAP shapes for the replicate case.
zfnmxt Feb 25, 2024
60db26b
Remove confusing/wrong name.
zfnmxt Feb 25, 2024
54882ab
Better frame computation + clarifying notes.
zfnmxt Feb 25, 2024
c04ade2
Bump Nix and cabal.
athas Feb 25, 2024
6c91e26
Work on supporting AUTOMAP in interpreter.
athas Feb 25, 2024
9919fec
We must also touch automaps here.
athas Feb 26, 2024
f4d2b8d
Merge branch 'master' into constraints
athas Feb 26, 2024
afa09d3
Add another test program.
athas Feb 26, 2024
58c8ff3
Distribute frames recursively.
zfnmxt Feb 26, 2024
99fb122
The vindication of Robert.
athas Feb 26, 2024
e404169
Basic internalization working.
zfnmxt Feb 27, 2024
27588dc
Remove some complexity.
zfnmxt Feb 27, 2024
8af019e
Fixes.
zfnmxt Feb 27, 2024
321b524
Looks like we actually do need some reshaping.
zfnmxt Feb 27, 2024
bb03727
Oops. Fix reshaping.
zfnmxt Feb 27, 2024
10cfde8
Better to do the reshaping here, I think.
zfnmxt Feb 27, 2024
5adef90
Begin handling overloaded type variables.
athas Feb 26, 2024
1d9d25d
These should be frames.
zfnmxt Feb 27, 2024
266368a
Revert "Better to do the reshaping here, I think."
zfnmxt Feb 27, 2024
d190923
Strip off automapped shapes from arg static values. Fixes `optionpric…
zfnmxt Feb 27, 2024
56c18c0
Prevent loops.
zfnmxt Feb 27, 2024
8e1acff
Don't need this.
zfnmxt Feb 28, 2024
9e5d59a
Undo AUTOMAP-handling in the later phases of internalization.
zfnmxt Feb 28, 2024
8d88c95
Undo AUTOMAP-handling in `FullNormalise.hs`.
zfnmxt Feb 28, 2024
dd807f7
Merge branch 'master' into constraints
athas Feb 29, 2024
de5cf38
Use proper type here.
athas Feb 29, 2024
dcfdf1e
Also update type here.
athas Feb 29, 2024
9c869ab
Fix handling of overloaded type variables.
athas Feb 29, 2024
837f3cd
Add checkSizeExp to Terms2.
athas Feb 29, 2024
12d21a4
Fixes to updating of types.
athas Feb 29, 2024
c6aaf9c
Fix unification of abstract types.
athas Mar 1, 2024
b6d2e1b
Also do the AUTOMAP on size expressions.
athas Mar 1, 2024
45a5c44
Fix instantiation of parametric abstract types.
athas Mar 1, 2024
a3a5094
Must match.
athas Mar 1, 2024
989c757
Fix `mri-q.fut`.
zfnmxt Mar 2, 2024
101285a
`debugTraceM` now takes a level.
zfnmxt Mar 2, 2024
178a7a0
Expand AUTOMAP annotations in normalization.
zfnmxt Mar 1, 2024
e971922
Apostrophes are important, man.
zfnmxt Mar 3, 2024
d62614f
Fixes/clean-up.
zfnmxt Mar 4, 2024
51c5393
Tuples must have more than one field.
athas Mar 4, 2024
8260a4d
Start handling overloaded tyvars.
athas Mar 4, 2024
5bab301
This order is better.
athas Mar 4, 2024
2d9515b
Merge branch 'master' into constraints
athas Mar 5, 2024
9e2c1ee
Refactor to return one list with everything.
athas Mar 5, 2024
a6676ef
Let-generalise in Terms2.
athas Mar 5, 2024
d85bd68
Fix return types of partially applied functions in AM nests.
zfnmxt Mar 5, 2024
43c9479
Only return a single solution when doing rank analysis.
zfnmxt Mar 5, 2024
155f2bb
Strangle some warnings.
athas Mar 6, 2024
9fd510b
Merge branch 'master' into constraints
athas Mar 6, 2024
bc06303
Fix typo.
athas Mar 6, 2024
07b507d
Remove unneeded things.
athas Mar 6, 2024
a495374
Off-by-truth.
athas Mar 6, 2024
c11e72e
Add bindingParam.
athas Mar 6, 2024
47d24de
Allow touching TypeExps here.
athas Mar 6, 2024
b34f3ab
Also perform AM on expressions in params.
athas Mar 6, 2024
6305172
Remove lingering `PuLP` stuff.
zfnmxt Mar 6, 2024
c8a4348
Start adding location info.
athas Mar 7, 2024
56c99a8
More location info.
zfnmxt Mar 7, 2024
05fe9a0
Also put locations in constraints.
athas Mar 7, 2024
ef20fbe
Easy fix.
zfnmxt Mar 7, 2024
37cc601
More FIXME extermination.
zfnmxt Mar 7, 2024
75e5be4
Proper AUTOMAP for single expressions.
athas Mar 7, 2024
941dec2
Has to be written like this.
athas Mar 7, 2024
82c8458
Reduce duplication.
athas Mar 7, 2024
9cb6d4e
Merge branch 'master' into constraints
athas Mar 11, 2024
f93e2cf
Merge branch 'master' into constraints
athas Mar 11, 2024
f0bef22
Work on sum types.
athas Mar 11, 2024
cefc91b
Fix for-in loops.
athas Mar 11, 2024
80c6d80
Detect duplicate fields.
athas Mar 11, 2024
c1fb806
Handle type arguments here.
athas Mar 11, 2024
c4e11a9
let should not be generalised.
athas Mar 11, 2024
8cb7c7d
Stop erroneously changing the type of automapped functions.
zfnmxt Mar 11, 2024
c6fa39e
Some sum fixes.
athas Mar 11, 2024
4de7ecf
Detect more ambiguities.
athas Mar 11, 2024
c4610ba
Add notion of equality type.
athas Mar 11, 2024
521846f
Remove duplicate comment.
athas Mar 11, 2024
300cce6
Fix check.
athas Mar 12, 2024
6a69052
Avoid artificial type variables in constraints.
athas Mar 12, 2024
2fbe6c2
Better to do this in same pass.
athas Mar 12, 2024
f16ee6a
More cleanup.
athas Mar 12, 2024
74be173
Consistency.
athas Mar 12, 2024
64f6a86
Fix crashing when LP objective is a constant. This fix is jank(ish).
zfnmxt Mar 13, 2024
1cff1d8
Merge branch 'constraints' into no-artificial
zfnmxt Mar 13, 2024
5666c2b
Fix tuples/records in rank analysis.
zfnmxt Mar 13, 2024
7039dcc
Delete this.
zfnmxt Mar 13, 2024
e5b4f10
Add sum type support.
zfnmxt Mar 13, 2024
228ee57
Merge branch 'master' into constraints
athas Mar 13, 2024
a258fe0
Merge branch 'master' into constraints
athas Mar 13, 2024
f611db0
Merge branch 'master' into constraints
athas Mar 14, 2024
62ddb1d
Respect return type annotations.
athas Mar 14, 2024
fc5f05d
Lovely code.
athas Mar 14, 2024
6f3e32d
Update type annotation here.
athas Mar 15, 2024
bf64e47
Handle equality case too.
athas Mar 15, 2024
5941f88
Do not impose inferred type on polymorphic functions.
athas Mar 15, 2024
630e39b
Merge branch 'master' into constraints
athas Mar 18, 2024
64637d0
Fix implicit record fields.
athas Mar 18, 2024
616a612
Fix type checking of project sections.
athas Mar 18, 2024
f3619fa
Merge branch 'master' into constraints
athas Mar 21, 2024
30d0a9f
Merge branch 'master' into constraints
athas Mar 23, 2024
ac04728
Rework type constraint solving.
athas Mar 27, 2024
4931170
Merge branch 'master' into constraints
athas Mar 30, 2024
2bdca0e
Substitute dependent sizes when expanding automaps.
athas Mar 30, 2024
06d7232
Workaround for wrong return type handling.
athas Mar 30, 2024
a1628f3
Handle special case.
athas Mar 30, 2024
6ce8ed3
Must expand here.
athas Apr 2, 2024
ef05260
Merge branch 'master' into constraints
athas Apr 2, 2024
c8dc1f5
Merge branch 'master' into constraints
athas Apr 11, 2024
f0497af
Merge branch 'master' into constraints
athas Apr 26, 2024
9372788
Merge branch 'master' into constraints
athas Apr 27, 2024
ac6a514
Merge branch 'master' into constraints
athas May 1, 2024
05311de
Strangle warnings.
athas May 1, 2024
4cbdb8d
Warning-free tests.
athas May 1, 2024
a4946a1
Link against static glpk.
athas May 1, 2024
9cf8ab8
This is cleaner.
athas May 1, 2024
ab0d1b0
Merge branch 'master' into constraints
athas May 8, 2024
591c14e
Merge branch 'master' into constraints
athas Jun 6, 2024
323922f
Fix typo.
athas Jun 6, 2024
8a808e0
let should not be generalised.
athas Jun 8, 2024
e71f281
Minor refactoring.
athas Jun 8, 2024
e24e5c0
Merge branch 'master' into constraints
athas Jun 28, 2024
d0b0ede
Merge branch 'master' into constraints
athas Jul 3, 2024
0d7e661
Crudely strangle warnings.
athas Jul 3, 2024
ab28bb1
Merge branch 'master' into automap
athas Jul 4, 2024
f126abe
Track explicit type parameters in constraint solver.
athas Jul 5, 2024
63fca3f
Merge branch 'master' into automap
athas Jul 7, 2024
e10ad58
Merge branch 'master' into automap
athas Jul 9, 2024
2b576bb
Merge branch 'master' into automap
athas Jul 11, 2024
1ace2df
A bit more work.
athas Jul 11, 2024
5522eb8
Check for equality.
athas Jul 11, 2024
43744e5
Detect ambiguous equality type.
athas Jul 11, 2024
7329e8b
Abstraction.
athas Jul 11, 2024
8a99272
Refine.
athas Jul 11, 2024
f7892a1
More fixes.
athas Jul 11, 2024
fbafb6d
Define before use.
athas Jul 11, 2024
4b2a9e2
Break long line.
athas Jul 11, 2024
d393544
Add missing cases.
athas Jul 11, 2024
d86eec2
This is OK now.
athas Jul 11, 2024
43c85b3
Correct handling of type annotation.
athas Jul 11, 2024
44c5405
Simplify.
athas Jul 12, 2024
f16024b
Merge branch 'master' into automap
athas Jul 14, 2024
2333b7e
Also AUTOMAP in return type annotations.
athas Jul 14, 2024
5f94900
Propagate liftedness properly.
athas Jul 14, 2024
041e9e0
Simplify.
athas Jul 14, 2024
9834d68
Simplify the level stuff.
athas Jul 14, 2024
e5088b5
Improve handling of branches.
athas Jul 15, 2024
1046414
Supposed to be ambiguous.
athas Jul 15, 2024
d0bea36
Now inferred differently.
athas Jul 15, 2024
0a07d32
Must be more explicit now.
athas Jul 15, 2024
80cfae5
This is OK now.
athas Jul 16, 2024
66be58e
Fix Constr.
athas Jul 16, 2024
7068b88
Fiddle with liftedness checking.
athas Jul 16, 2024
2aecc9a
Merge branch 'master' into automap
athas Aug 23, 2024
303a535
Merge branch 'master' into automap
athas Sep 4, 2024
2807acc
Work on error message.
athas Sep 4, 2024
24f6294
Merge branch 'master' into automap
athas Sep 25, 2024
d8dbec2
Fix some mistaken tests.
athas Sep 25, 2024
90d3678
Linebreak.
athas Sep 25, 2024
bc804c1
Fix another test.
athas Sep 25, 2024
2a0cc26
Fix more error messages.
athas Sep 25, 2024
b77f1c2
Less weird.
athas Sep 25, 2024
dee1188
Introduce breadcrumbs in constraint solver.
athas Sep 25, 2024
e098b6d
A bit more work.
athas Sep 25, 2024
7210e8f
Better error for tuple mismatches.
athas Oct 5, 2024
67cdaf9
Better reasons.
athas Oct 5, 2024
59ddb21
Constructor match.
athas Oct 6, 2024
946ae65
More reasons.
athas Oct 6, 2024
897b52e
Merge branch 'master' into automap
athas Oct 13, 2024
fba5782
Function application reason.
athas Oct 13, 2024
29293af
Branch reasons.
athas Oct 13, 2024
5818c5f
Merge branch 'master' into automap
athas Oct 16, 2024
279de4a
Merge branch 'master' into automap
athas Nov 4, 2024
8a23982
Merge branch 'master' into automap
athas Nov 23, 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
5 changes: 5 additions & 0 deletions cabal.project
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,8 @@ package futhark
ghc-options: -j -fwrite-ide-info -hiedir=.hie

allow-newer: base, template-haskell

source-repository-package
type: git
location: https://github.com/jyp/glpk-hs.git
tag: 1f276aa19861203ea8367dc27a6ad4c8a31c9062
7 changes: 7 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ let
zlib =
haskellPackagesNew.callPackage ./nix/zlib.nix {zlib=pkgs.zlib;};

gasp =
haskellPackagesNew.callPackage ./nix/gasp.nix {};

glpk-hs =
haskellPackagesNew.callPackage ./nix/glpk-hs.nix {};

futhark =
# callCabal2Nix does not do a great job at determining
# which files must be included as source, which causes
Expand Down Expand Up @@ -75,6 +81,7 @@ let
"--extra-lib-dirs=${pkgs.glibc.static}/lib"
"--extra-lib-dirs=${pkgs.gmp6.override { withStatic = true; }}/lib"
"--extra-lib-dirs=${pkgs.libffi.overrideAttrs (old: { dontDisableStatic = true; })}/lib"
"--extra-lib-dirs=${pkgs.glpk.overrideAttrs (old: { dontDisableStatic = true; })}/lib"
# The ones below are due to GHC's runtime system
# depending on libdw (DWARF info), which depends on
# a bunch of compression algorithms.
Expand Down
8 changes: 5 additions & 3 deletions docs/language-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1002,9 +1002,11 @@ Syntactic sugar for ``let a = a with [i] = v in a``.
...............................

Bind ``f`` to a function with the given parameters and definition
(``e``) and evaluate ``body``. The function will be treated as
aliasing any free variables in ``e``. The function is not in scope of
itself, and hence cannot be recursive.
(``e``) and evaluate ``body``. The function will be treated as
aliasing any free variables in ``e``. The function is not in scope of
itself, and hence cannot be recursive. While the function can be made
polymorphic by putting in explicit size parameters, it is not
automatically generalised the way top level functions are.

``loop pat = initial for x in a do loopbody``
.............................................
Expand Down
15 changes: 15 additions & 0 deletions futhark.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,11 @@ library
Futhark.Pkg.Types
Futhark.Profile
Futhark.Script
Futhark.Solve.GLPK
Futhark.Solve.LP
Futhark.Solve.Matrix
Futhark.Solve.Simplex
Futhark.Solve.BranchAndBound
Futhark.Test
Futhark.Test.Spec
Futhark.Test.Values
Expand Down Expand Up @@ -419,11 +424,15 @@ library
Language.Futhark.Tuple
Language.Futhark.TypeChecker
Language.Futhark.TypeChecker.Consumption
Language.Futhark.TypeChecker.Constraints
Language.Futhark.TypeChecker.Error
Language.Futhark.TypeChecker.Names
Language.Futhark.TypeChecker.Match
Language.Futhark.TypeChecker.Modules
Language.Futhark.TypeChecker.Monad
Language.Futhark.TypeChecker.Rank
Language.Futhark.TypeChecker.Terms
Language.Futhark.TypeChecker.Terms2
Language.Futhark.TypeChecker.Terms.Loop
Language.Futhark.TypeChecker.Terms.Monad
Language.Futhark.TypeChecker.Terms.Pat
Expand Down Expand Up @@ -496,6 +505,9 @@ library
, mwc-random
, prettyprinter >= 1.7
, prettyprinter-ansi-terminal >= 1.1
-- remove me later
, glpk-hs
, silently

executable futhark
import: common
Expand Down Expand Up @@ -531,6 +543,8 @@ test-suite unit
Futhark.Optimise.ArrayLayoutTests
Futhark.Pkg.SolveTests
Futhark.ProfileTests
Futhark.Solve.BranchAndBoundTests
Futhark.Solve.SimplexTests
Language.Futhark.CoreTests
Language.Futhark.PrimitiveTests
Language.Futhark.SemanticTests
Expand All @@ -549,3 +563,4 @@ test-suite unit
, tasty-hunit
, tasty-quickcheck
, text
, vector >=0.12
14 changes: 14 additions & 0 deletions nix/gasp.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{ mkDerivation, adjunctions, base, binary, constraints, containers
, distributive, lib, mtl, QuickCheck
}:
mkDerivation {
pname = "gasp";
version = "1.4.0.0";
sha256 = "9a73a6ea7eb844493deb76c85c50249915e5ca29a6734a0b133a0e136c232f9f";
libraryHaskellDepends = [
adjunctions base binary constraints containers distributive mtl
QuickCheck
];
description = "A framework of algebraic classes";
license = lib.licenses.bsd3;
}
23 changes: 23 additions & 0 deletions nix/glpk-hs.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{ mkDerivation, array, base, containers, deepseq, fetchgit, gasp
, glpk, lib, mtl
}:
mkDerivation {
pname = "glpk-hs";
version = "0.8";
src = fetchgit {
url = "https://github.com/ludat/glpk-hs.git";
sha256 = "0nly5nifdb93f739vr3jzgi16fccqw5l0aabf5lglsdkdad713q1";
rev = "efcb8354daa1205de2b862898353da2e4beb76b2";
fetchSubmodules = true;
};
isLibrary = true;
isExecutable = true;
libraryHaskellDepends = [ array base containers deepseq gasp mtl ];
librarySystemDepends = [ glpk ];
executableHaskellDepends = [
array base containers deepseq gasp mtl
];
description = "Comprehensive GLPK linear programming bindings";
license = lib.licenses.bsd3;
mainProgram = "glpk-hs-example";
}
2 changes: 1 addition & 1 deletion prelude/soacs.fut
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ import "zip"
--
-- **Span:** *O(S(f))*
def map 'a [n] 'x (f: a -> x) (as: [n]a) : *[n]x =
intrinsics.map f as
f as

-- | Apply the given function to each element of a single array.
--
Expand Down
17 changes: 6 additions & 11 deletions prelude/zip.fut
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,6 @@

-- The main reason this module exists is that we need it to define
-- SOACs like `map2`.
-- We need a map to define some of the zip variants, but this file is
-- depended upon by soacs.fut. So we just define a quick-and-dirty
-- internal one here that uses the intrinsic version.
local def internal_map 'a [n] 'x (f: a -> x) (as: [n]a) : *[n]x =
intrinsics.map f as

-- | Construct an array of pairs from two arrays.
def zip [n] 'a 'b (as: [n]a) (bs: [n]b) : *[n](a, b) =
Expand All @@ -22,15 +17,15 @@ def zip2 [n] 'a 'b (as: [n]a) (bs: [n]b) : *[n](a, b) =

-- | As `zip2`@term, but with one more array.
def zip3 [n] 'a 'b 'c (as: [n]a) (bs: [n]b) (cs: [n]c) : *[n](a, b, c) =
internal_map (\(a, (b, c)) -> (a, b, c)) (zip as (zip2 bs cs))
(\(a, (b, c)) -> (a, b, c)) (zip as (zip2 bs cs))

-- | As `zip3`@term, but with one more array.
def zip4 [n] 'a 'b 'c 'd (as: [n]a) (bs: [n]b) (cs: [n]c) (ds: [n]d) : *[n](a, b, c, d) =
internal_map (\(a, (b, c, d)) -> (a, b, c, d)) (zip as (zip3 bs cs ds))
(\(a, (b, c, d)) -> (a, b, c, d)) (zip as (zip3 bs cs ds))

-- | As `zip4`@term, but with one more array.
def zip5 [n] 'a 'b 'c 'd 'e (as: [n]a) (bs: [n]b) (cs: [n]c) (ds: [n]d) (es: [n]e) : *[n](a, b, c, d, e) =
internal_map (\(a, (b, c, d, e)) -> (a, b, c, d, e)) (zip as (zip4 bs cs ds es))
(\(a, (b, c, d, e)) -> (a, b, c, d, e)) (zip as (zip4 bs cs ds es))

-- | Turn an array of pairs into two arrays.
def unzip [n] 'a 'b (xs: [n](a, b)) : ([n]a, [n]b) =
Expand All @@ -42,18 +37,18 @@ def unzip2 [n] 'a 'b (xs: [n](a, b)) : ([n]a, [n]b) =

-- | As `unzip2`@term, but with one more array.
def unzip3 [n] 'a 'b 'c (xs: [n](a, b, c)) : ([n]a, [n]b, [n]c) =
let (as, bcs) = unzip (internal_map (\(a, b, c) -> (a, (b, c))) xs)
let (as, bcs) = unzip ((\(a, b, c) -> (a, (b, c))) xs)
let (bs, cs) = unzip bcs
in (as, bs, cs)

-- | As `unzip3`@term, but with one more array.
def unzip4 [n] 'a 'b 'c 'd (xs: [n](a, b, c, d)) : ([n]a, [n]b, [n]c, [n]d) =
let (as, bs, cds) = unzip3 (internal_map (\(a, b, c, d) -> (a, b, (c, d))) xs)
let (as, bs, cds) = unzip3 ((\(a, b, c, d) -> (a, b, (c, d))) xs)
let (cs, ds) = unzip cds
in (as, bs, cs, ds)

-- | As `unzip4`@term, but with one more array.
def unzip5 [n] 'a 'b 'c 'd 'e (xs: [n](a, b, c, d, e)) : ([n]a, [n]b, [n]c, [n]d, [n]e) =
let (as, bs, cs, des) = unzip4 (internal_map (\(a, b, c, d, e) -> (a, b, c, (d, e))) xs)
let (as, bs, cs, des) = unzip4 ((\(a, b, c, d, e) -> (a, b, c, (d, e))) xs)
let (ds, es) = unzip des
in (as, bs, cs, ds, es)
35 changes: 24 additions & 11 deletions shell.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,28 @@
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs {};
python = pkgs.python311Packages;
python = pkgs.python311.withPackages (ps: with ps; [
(
buildPythonPackage rec {
pname = "PuLP";
version = "2.7.0";
src = fetchPypi {
inherit pname version;
sha256 = "sha256-5z7msy1jnJuM9LSt7TNLoVi+X4MTVE4Fb3lqzgoQrmM=";
};
doCheck = false;
}
)
ps.mypy
black
cycler
numpy
pyopencl
matplotlib
jsonschema
sphinx
sphinxcontrib-bibtex
]);
haskell = pkgs.haskell.packages.ghc96;
in
pkgs.stdenv.mkDerivation {
Expand All @@ -22,6 +43,7 @@ pkgs.stdenv.mkDerivation {
haskell.haskell-language-server
haskellPackages.graphmod
haskellPackages.apply-refact
python
xdot
hlint
pkg-config
Expand All @@ -31,17 +53,8 @@ pkgs.stdenv.mkDerivation {
ghcid
niv
ispc
python.python
python.mypy
python.black
python.cycler
python.numpy
python.pyopencl
python.matplotlib
python.jsonschema
python.sphinx
python.sphinxcontrib-bibtex
imagemagick # needed for literate tests
glpk
]
++ lib.optionals (stdenv.isLinux)
[ opencl-headers
Expand Down
20 changes: 10 additions & 10 deletions src/Futhark/Internalise/Defunctionalise.hs
Original file line number Diff line number Diff line change
Expand Up @@ -750,7 +750,7 @@ etaExpand e_t e = do
M.fromList . zip (retDims ret) $
map (ExpSubst . flip sizeFromName mempty . qualName) ext'
ret' = applySubst (`M.lookup` extsubst) ret
e' = mkApply e (map (Nothing,) vars) $ AppRes (toStruct $ retType ret') ext'
e' = mkApply e (map (\v -> (Nothing, mempty, v)) vars) $ AppRes (toStruct $ retType ret') ext'
pure (params, e', ret)
where
getType (RetType _ (Scalar (Arrow _ p d t1 t2))) =
Expand Down Expand Up @@ -856,7 +856,7 @@ unRetType (RetType ext t) = do

defuncApplyFunction :: Exp -> Int -> DefM (Exp, StaticVal)
defuncApplyFunction e@(Var qn (Info t) loc) num_args = do
let (argtypes, rettype) = unfoldFunType t
let (argtypes, rettype) = first (map snd) $ unfoldFunType t
sv <- lookupVar (toStruct t) (qualLeaf qn)

case sv of
Expand Down Expand Up @@ -908,9 +908,9 @@ liftedName _ _ = "defunc"
defuncApplyArg ::
String ->
(Exp, StaticVal) ->
((Maybe VName, Exp), [ParamType]) ->
(((Maybe VName, AutoMap), Exp), [ParamType]) ->
DefM (Exp, StaticVal)
defuncApplyArg fname_s (f', LambdaSV pat lam_e_t lam_e closure_env) ((argext, arg), _) = do
defuncApplyArg fname_s (f', LambdaSV pat lam_e_t lam_e closure_env) (((argext, _), arg), _) = do
(arg', arg_sv) <- defuncExp arg
let env' = alwaysMatchPatSV pat arg_sv
dims = mempty
Expand Down Expand Up @@ -961,18 +961,18 @@ defuncApplyArg fname_s (f', LambdaSV pat lam_e_t lam_e closure_env) ((argext, ar
callret <- unRetType lifted_rettype

pure
( mkApply fname' [(Nothing, f'), (argext, arg')] callret,
( mkApply fname' [(Nothing, mempty, f'), (argext, mempty, arg')] callret,
sv
)
-- If 'f' is a dynamic function, we just leave the application in
-- place, but we update the types since it may be partially
-- applied or return a higher-order value.
defuncApplyArg _ (f', DynamicFun _ sv) ((argext, arg), argtypes) = do
defuncApplyArg _ (f', DynamicFun _ sv) (((argext, _), arg), argtypes) = do
(arg', _) <- defuncExp arg
let (argtypes', rettype) = dynamicFunType sv argtypes
restype = foldFunType argtypes' (RetType [] rettype)
callret = AppRes restype []
apply_e = mkApply f' [(argext, arg')] callret
apply_e = mkApply f' [(argext, mempty, arg')] callret
pure (apply_e, sv)
--
defuncApplyArg fname_s (_, sv) ((_, arg), _) =
Expand All @@ -989,7 +989,7 @@ updateReturn (AppRes ret1 ext1) (AppExp apply (Info (AppRes ret2 ext2))) =
AppExp apply $ Info $ AppRes (combineTypeShapes ret1 ret2) (ext1 <> ext2)
updateReturn _ e = e

defuncApply :: Exp -> NE.NonEmpty (Maybe VName, Exp) -> AppRes -> SrcLoc -> DefM (Exp, StaticVal)
defuncApply :: Exp -> NE.NonEmpty ((Maybe VName, AutoMap), Exp) -> AppRes -> SrcLoc -> DefM (Exp, StaticVal)
defuncApply f args appres loc = do
(f', f_sv) <- defuncApplyFunction f (length args)
case f_sv of
Expand All @@ -1006,8 +1006,8 @@ defuncApply f args appres loc = do
(argtypes, _) = unfoldFunType $ typeOf f
fmap (first $ updateReturn appres) $
foldM (defuncApplyArg fname) (f', f_sv) $
NE.zip args $
NE.tails argtypes
NE.zip args . NE.tails . map snd $
argtypes
where
intrinsicOrHole e' = do
-- If the intrinsic is fully applied, then we are done.
Expand Down
Loading
Loading