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

Add WebGPU backend #2140

Draft
wants to merge 178 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 120 commits
Commits
Show all changes
178 commits
Select commit Hold shift + click to select a range
433f253
Add dummy WebGPU modules.
athas Feb 4, 2024
573c0b4
Small start on generating some WGSL kernel code
spaarmann Feb 6, 2024
52f4182
Create basic WGSL AST module
spaarmann Feb 7, 2024
06693b8
Add WGSL functions and attributes
spaarmann Feb 11, 2024
5e8a1e1
Support some WGSL built-ins corresponding to `KernelOp`s
spaarmann Feb 11, 2024
2525f46
(Half-)support some more expressions for WGSL generation
spaarmann Feb 13, 2024
34d06a2
Only use Seq over [Stmt] in WGSL AST
spaarmann Feb 14, 2024
7053cc4
Generate WGSL struct for scalar kernel uses
spaarmann Feb 14, 2024
73bf56a
Use scalars struct to copy used scalars into WGSL kernel body
spaarmann Feb 15, 2024
8ecf3aa
Generate WGSL storage buffer bindings for `MemoryUse`s
spaarmann Feb 15, 2024
39376e9
Generate WGSL override expressions for `ConstUse`s and some built-ins
spaarmann Feb 15, 2024
03f417a
Generate WGSL binding attributes for memory uses and scalar uniform b…
spaarmann Feb 15, 2024
00293b5
Add markers and simple script to extract only shader code from --comp…
spaarmann Feb 15, 2024
fa78beb
Fix missing semicolons in WGSL.Stmt Pretty instance
spaarmann Feb 15, 2024
a94dcbe
Generate WGSL assignments for Read and Write instructions
spaarmann Feb 15, 2024
fd54b11
Initial support for some 64-bit integer operations
spaarmann Feb 26, 2024
e24ba89
Merge branch 'master' into webgpu
spaarmann Feb 26, 2024
008018b
Inline scalarUses as list comprehension
spaarmann Feb 27, 2024
25434fd
Semi-tested implementation of 64-bit integer multiplication
spaarmann Feb 27, 2024
d82d28d
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann Feb 27, 2024
5a9b5e9
Make unimplemented statements/operations a bit more obvious
spaarmann Feb 27, 2024
9f42ddf
For and While loops WGSL generation
spaarmann Feb 28, 2024
85bd86b
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann Feb 28, 2024
d055de3
GetLocalSize returns 32-bit integer
spaarmann Feb 28, 2024
6d27ed7
Remaining int and bool CmpOps in WGSL
spaarmann Feb 28, 2024
a98203e
Factor out common call2 function
spaarmann Feb 28, 2024
5b347ba
More BinOps for WGSL
spaarmann Feb 28, 2024
4375a73
Start supporting shift binops
spaarmann Mar 3, 2024
388ead1
Finish shift binops
spaarmann Mar 5, 2024
1b0f7fc
Some initial plumbing bits for ad-hoc WGSL testing
spaarmann Mar 5, 2024
2f96584
Support UnOpExps and fix i64 equality binop
spaarmann Mar 7, 2024
fed1ece
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann Mar 7, 2024
c6f9a01
Declare ConstUse variables as i64 but only pass lower 32 bits for now
spaarmann Mar 7, 2024
6eef379
Define KernelM and mkGlobalIdent
spaarmann Mar 7, 2024
abef517
Start using KernelM
spaarmann Mar 8, 2024
1a77525
Make module-scope names unique (generates invalid copies for buffers …
spaarmann Mar 9, 2024
2ad3d97
Add renaming mechanism, rename memory buffers to be unique
spaarmann Mar 9, 2024
4fd4942
Continue on testing setup
spaarmann Mar 10, 2024
7d12e8a
Format numbers as valid JS numbers in webgpu tests
spaarmann Mar 12, 2024
73a2dfc
Give each kernel its own bind group
spaarmann Mar 12, 2024
0e1c2f8
Include kernel interface information in WebGPU test data output
spaarmann Mar 12, 2024
f30bb92
Generate override decls with default values
spaarmann Mar 14, 2024
e884398
Basic working JS WGSL primitive test runner
spaarmann Mar 14, 2024
b6578bc
Implement more i32 binops
spaarmann Mar 14, 2024
110a4d7
Improved test runner output
spaarmann Mar 14, 2024
7d14ac6
Fix shift operators
spaarmann Mar 14, 2024
d729360
Generate all bindings into a single bind group
spaarmann Mar 14, 2024
4a8e115
Add pow i64 support
spaarmann Mar 17, 2024
d92c032
Start on supporting i64 in WGSL tests
spaarmann Mar 17, 2024
7511798
Support i64 arrays in WGSL tests
spaarmann Mar 18, 2024
c176eab
Fix bug in negate_i64 (and thus sub_i64)
spaarmann Mar 18, 2024
84e22a4
Fix generation of 64-bit integer literals
spaarmann Mar 18, 2024
66f8187
Ability to run multiple test files, show results on page
spaarmann Mar 19, 2024
76cb98a
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann Mar 19, 2024
ddca383
Fix tab indentation in futhark.cabal
spaarmann Mar 19, 2024
b3f3d5a
Add testing support for u32, u64
spaarmann Mar 19, 2024
d2ecb34
Fix comparison with expected values for 64-bit ints
spaarmann Mar 19, 2024
7e0a928
Add f32 testing support
spaarmann Mar 19, 2024
dbe2df4
Enumerate unimplemented statements for better overview
spaarmann Mar 19, 2024
f669178
Fix some testing error handling
spaarmann Mar 19, 2024
86b0644
Add some float built-in functions
spaarmann Mar 19, 2024
a355d12
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann Mar 19, 2024
7df0010
Nicer test result layout
spaarmann Mar 21, 2024
217a2bd
Rename arith.wgsl to scalr.wgsl
spaarmann Mar 21, 2024
210f020
Start on i8 support
spaarmann Mar 25, 2024
0595c86
More i8 progress
spaarmann Mar 25, 2024
03f6849
Finish basic i8 support
spaarmann Mar 26, 2024
66ebdfe
Basic support for booleans in storage buffers
spaarmann Mar 26, 2024
9f505f7
bool output support in tests; improve robustness of finding right kernel
spaarmann Mar 26, 2024
b2489f4
Print expected output according to its type rather than input type
spaarmann Mar 26, 2024
f717367
Initial i16 support
spaarmann Mar 28, 2024
3300a1a
bool <-> integer conversions
spaarmann Mar 28, 2024
1a08b97
Some tolerance for float comparisons for primitive tests
spaarmann Mar 29, 2024
595c69c
Start implementing GPU abstraction layer for WebGPU
spaarmann Apr 1, 2024
5e2c2ed
Rest of the abstraction layer other than kernel creation and launching
spaarmann Apr 1, 2024
31ea0f4
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann Apr 1, 2024
03c0177
Some WebGPU initialization code
spaarmann Apr 2, 2024
07c8b32
Re-use scalar readback buffer, some more initialization + teardown
spaarmann Apr 3, 2024
96bf5fa
Initial gpu_create_kernel and gpu_launch_kernel draft
spaarmann Apr 3, 2024
20b75ae
Add uncaptured error callback
spaarmann Apr 3, 2024
268d569
Start on Haskell side of WebGPU C code generation
spaarmann Apr 4, 2024
9563870
Factor out common host code definitions into new module so that WebGPU
spaarmann Apr 4, 2024
c79d552
Refactor KernelInterface stuff a bit, compute proper scalars struct l…
spaarmann Apr 6, 2024
951bddb
Generate static wgpu_kernel_info array
spaarmann Apr 7, 2024
b119e6d
Add webgpu CLI command, fix a bunch of errors in webgpu.h
spaarmann Apr 7, 2024
7619232
More RTS and code gen fixes, enough to compile a whole program to WASM
spaarmann Apr 9, 2024
d90ddb2
Generate MacroDefs for ConstUses and builtin overrides
spaarmann Apr 9, 2024
6852d68
Fix some more errors, actually get a compiling program
spaarmann Apr 9, 2024
6cb660a
Actually pass arguments in LaunchKernel
spaarmann Apr 10, 2024
4829dc8
Some temporary debug logging
spaarmann Apr 10, 2024
128c279
Fix kernel info for launches not being found, remove debug logs
spaarmann Apr 10, 2024
3d56b86
Experimental support for compiling against Dawn
spaarmann Apr 14, 2024
e217988
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann Apr 14, 2024
5f5a183
Mark entry points to be exported
spaarmann Apr 15, 2024
b796eba
Export a very basic JS interface
spaarmann Apr 16, 2024
4677681
Start on `futhark test` server wrapper
spaarmann Apr 16, 2024
29495a4
Start on generating a proper JS interface
spaarmann Apr 18, 2024
013185f
Small fixes
spaarmann Apr 18, 2024
8bcaa4c
More JS wrapper stuff
spaarmann Apr 22, 2024
413c285
Fix JS interface, add some debugging infrastructure stuff
spaarmann Apr 23, 2024
aa71988
Small bits on test server
spaarmann Apr 23, 2024
d394682
Don't generate semicolons at the end of WGSL struct decls
spaarmann Apr 24, 2024
f77a5dd
Basic WS server proxying structure
spaarmann Apr 24, 2024
b2360a6
First server protocol command
spaarmann Apr 24, 2024
14a33fc
inputs and outputs commands, start on restore
spaarmann Apr 25, 2024
50402be
Enough commands and fixes for `futhark test tests/soacs/map2.fut` to …
spaarmann Apr 27, 2024
48b96ce
More reasonable CLI arg parsing in Python runner
spaarmann Apr 28, 2024
7a5b6a3
Very basic naive way of spawning a headless chrome process to run Web…
spaarmann Apr 28, 2024
7026205
Properly use Selenium for driving browser
spaarmann Apr 29, 2024
3aa419b
Remove __pycache__ files
spaarmann Apr 30, 2024
b061b91
Remove some debug and old stuff
spaarmann May 2, 2024
31b9c9e
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann May 2, 2024
12fea55
Work around Chrome/Dawn bug by only passing override consts used by t…
spaarmann May 4, 2024
68efe20
Support for futhark bench
spaarmann May 5, 2024
0d9e28e
Improve benchmarking timer accuracy
spaarmann May 5, 2024
4fca89a
Default chrome to start headless
spaarmann May 5, 2024
d509c8f
Ignore generates .js files in tests dir
spaarmann May 5, 2024
1103075
Ignore python cache in rts/python
spaarmann May 5, 2024
43e2139
Couple of fixes + more options for browser_test runner
spaarmann May 5, 2024
6f05062
Support more types for WASM<->JS interactions, enable WASM_BIGINT
spaarmann May 5, 2024
f094382
Factor WGSL definition into separate package.
athas May 8, 2024
064cfdf
Merge pull request #2145 from diku-dk/webgpu-package
spaarmann May 8, 2024
a4826b4
Address some feedback
spaarmann May 8, 2024
477a499
Add more browser crud.
athas May 8, 2024
5335aab
Don't set Linux-specific options when using remote chrome driver
spaarmann May 11, 2024
f432f0d
Revamp JS interface to rely less on codegen and be more usable; do bi…
spaarmann May 11, 2024
04bbfbe
Move browser_test.py to tools/
spaarmann May 11, 2024
d08227c
Move i32/u32 specific WGSL functions into scalar32.wgsl
spaarmann May 11, 2024
0cd6b65
Round up host2gpu memcpy to multiple of 4
spaarmann May 11, 2024
13b45b2
Same rounding for gpu_memcpy
spaarmann May 11, 2024
9997bdd
Implement division ops for {i,u}{8,16}
spaarmann May 11, 2024
3b06550
Support passing full 64-bit ConstUses
spaarmann May 12, 2024
63f63bb
Add (not very well tested yet) support for dynamic and >1d block dims
spaarmann May 12, 2024
edd8bfd
Handle kernels without any ScalarUses
spaarmann May 12, 2024
cda16ff
Some ormolu formatting
spaarmann May 12, 2024
278eb49
More ormolu formatting
spaarmann May 12, 2024
3a72791
Python formatting
spaarmann May 12, 2024
5880101
Make tools/browser_test.py type-check
spaarmann May 14, 2024
3e6c248
Rework monad structure in ImpGen.WebGPU a bit to make adding module-d…
spaarmann May 16, 2024
a4f3de0
Add support for some shared memory
spaarmann May 17, 2024
01b3350
Limited i64 division ops, reduce duplication in `wgslBinOp`
spaarmann May 18, 2024
f52330d
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann May 18, 2024
16203c1
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann May 20, 2024
034d9cc
Handle booolean scalars properly
spaarmann May 20, 2024
c7c1fdd
signed int to f32 conversions
spaarmann May 20, 2024
1bd5676
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann May 20, 2024
3aaadf0
Fix literal 1 with 64-bit loop counters
spaarmann May 21, 2024
a39f51c
Fix findMemoryTypes not traversing through code nested in comments
spaarmann May 21, 2024
430b5e1
Always enable f16 extension
spaarmann May 21, 2024
31e1b7b
int->float conversions
spaarmann May 21, 2024
a11bfe3
Start on supporting atomics
spaarmann May 22, 2024
cf9d902
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann May 23, 2024
adb8c1a
wip reading small integer shared memory
spaarmann May 24, 2024
fee3435
Work around chrome bug when lockstep width is not accessed
spaarmann May 25, 2024
e02fe70
Use normal types for shared memory instead of atomic<i32> for small t…
spaarmann May 25, 2024
5c733b0
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann May 25, 2024
e82825a
Prototype of UniformRead KernelOp
spaarmann May 25, 2024
9cf0b04
Implement UniformRead as a normal read on other GPU backends
spaarmann May 26, 2024
e4aa784
Some float to int conversions
spaarmann May 26, 2024
620b24e
Remaining atomic ops
spaarmann May 26, 2024
1b48b69
Fix WGSL bool literal pretty printing
spaarmann May 26, 2024
93d9672
rts: define max_thread_block_size
spaarmann May 26, 2024
8bec2dd
rts: Check if copy padding could corrupt data
spaarmann May 26, 2024
8f56dbb
Also generate barriers for ErrorSyncs
spaarmann May 27, 2024
6bc25bc
Add some more sizes
spaarmann May 28, 2024
45fac4a
atomicStore/Load for Write/Reads from atomically-typed buffers
spaarmann May 28, 2024
e6d77d8
JS interface: `entry` object instead of `entry_` prefix
spaarmann May 30, 2024
ab6f828
Loosen bound.
athas Jun 10, 2024
9aa2e64
Compile with optimizations instead of debug info
spaarmann Jun 11, 2024
9e49866
Merge remote-tracking branch 'origin/master' into webgpu
spaarmann Jun 11, 2024
846c60c
Handle `AtomicWrite`s
spaarmann Jun 11, 2024
4b6639d
More robust base64 encoding in JS
spaarmann Jun 11, 2024
e5c8fab
f{16,32} to signed 8,16,32 bit integers
spaarmann Jun 13, 2024
8fd6c0a
Merge branch 'master' into webgpu
athas Jul 17, 2024
3bfed49
Apparently renamed.
athas Jul 17, 2024
826e3b9
Whitespace cleanup.
athas Jul 17, 2024
faa389b
Constness fix.
athas Jul 17, 2024
1bde361
Merge branch 'master' into webgpu
athas Sep 4, 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
15 changes: 15 additions & 0 deletions futhark.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ extra-source-files:
rts/c/backends/hip.h
rts/c/backends/multicore.h
rts/c/backends/opencl.h
rts/c/backends/webgpu.h
rts/c/lock.h
rts/c/copy.h
rts/c/timing.h
Expand Down Expand Up @@ -78,6 +79,11 @@ extra-source-files:
rts/python/values.py
rts/python/opencl.py
rts/python/scalar.py
rts/webgpu/server_ws.js
rts/wgsl/scalar.wgsl
rts/wgsl/scalar8.wgsl
rts/wgsl/scalar16.wgsl
rts/wgsl/scalar64.wgsl
prelude/functional.fut
prelude/math.fut
prelude/soacs.fut
Expand Down Expand Up @@ -175,8 +181,10 @@ library
Futhark.CLI.Script
Futhark.CLI.Test
Futhark.CLI.WASM
Futhark.CLI.WebGPU
Futhark.CodeGen.Backends.CCUDA
Futhark.CodeGen.Backends.COpenCL
Futhark.CodeGen.Backends.CWebGPU
Futhark.CodeGen.Backends.HIP
Futhark.CodeGen.Backends.GenericC
Futhark.CodeGen.Backends.GenericC.CLI
Expand Down Expand Up @@ -209,11 +217,15 @@ library
Futhark.CodeGen.RTS.OpenCL
Futhark.CodeGen.RTS.Python
Futhark.CodeGen.RTS.JavaScript
Futhark.CodeGen.RTS.WebGPU
Futhark.CodeGen.RTS.WGSL
Futhark.CodeGen.ImpCode
Futhark.CodeGen.ImpCode.GPU
Futhark.CodeGen.ImpCode.Kernels
Futhark.CodeGen.ImpCode.Multicore
Futhark.CodeGen.ImpCode.OpenCL
Futhark.CodeGen.ImpCode.Sequential
Futhark.CodeGen.ImpCode.WebGPU
Futhark.CodeGen.ImpGen
Futhark.CodeGen.ImpGen.CUDA
Futhark.CodeGen.ImpGen.GPU
Expand All @@ -235,6 +247,8 @@ library
Futhark.CodeGen.ImpGen.Multicore.SegScan
Futhark.CodeGen.ImpGen.OpenCL
Futhark.CodeGen.ImpGen.Sequential
Futhark.CodeGen.ImpGen.WGSL
Futhark.CodeGen.ImpGen.WebGPU
Futhark.CodeGen.OpenCL.Heuristics
Futhark.Compiler
Futhark.Compiler.CLI
Expand Down Expand Up @@ -377,6 +391,7 @@ library
Futhark.Script
Futhark.Test
Futhark.Test.Spec
Futhark.Test.WebGPUTest
Futhark.Test.Values
Futhark.Tools
Futhark.Transform.CopyPropagate
Expand Down
Loading
Loading