fp-arena 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. fp_arena-0.1.0/LICENSE +29 -0
  2. fp_arena-0.1.0/MANIFEST.in +3 -0
  3. fp_arena-0.1.0/PKG-INFO +108 -0
  4. fp_arena-0.1.0/README.md +71 -0
  5. fp_arena-0.1.0/fp_arena/__init__.py +73 -0
  6. fp_arena-0.1.0/fp_arena/corpus/__init__.py +2 -0
  7. fp_arena-0.1.0/fp_arena/corpus/cloudsc/__init__.py +2 -0
  8. fp_arena-0.1.0/fp_arena/corpus/cloudsc/cloudsc.py +2344 -0
  9. fp_arena-0.1.0/fp_arena/corpus/cloudsc/cloudsc_noise_floor.py +128 -0
  10. fp_arena-0.1.0/fp_arena/corpus/cloudsc/cloudsc_reference_data.py +166 -0
  11. fp_arena-0.1.0/fp_arena/corpus/cloudsc/offload_cloudsc_to_gpu.py +969 -0
  12. fp_arena-0.1.0/fp_arena/corpus/hdiff.py +47 -0
  13. fp_arena-0.1.0/fp_arena/corpus/heat3d.py +33 -0
  14. fp_arena-0.1.0/fp_arena/corpus/vdav.py +99 -0
  15. fp_arena-0.1.0/fp_arena/dtypes.py +214 -0
  16. fp_arena-0.1.0/fp_arena/environments.py +109 -0
  17. fp_arena-0.1.0/fp_arena/extensions.py +242 -0
  18. fp_arena-0.1.0/fp_arena/runtime/include/fp_arena/float32sr.h +93 -0
  19. fp_arena-0.1.0/fp_arena/runtime/include/fp_arena/float64sr.h +98 -0
  20. fp_arena-0.1.0/fp_arena/runtime/include/fp_arena/mpfr.h +319 -0
  21. fp_arena-0.1.0/fp_arena/runtime/include/fp_arena/stochastic_rounding.h +224 -0
  22. fp_arena-0.1.0/fp_arena/runtime/include/fp_arena/timers.h +76 -0
  23. fp_arena-0.1.0/fp_arena/search/__init__.py +80 -0
  24. fp_arena-0.1.0/fp_arena/search/budget.py +91 -0
  25. fp_arena-0.1.0/fp_arena/search/config.py +173 -0
  26. fp_arena-0.1.0/fp_arena/search/inputs.py +241 -0
  27. fp_arena-0.1.0/fp_arena/search/instruction_mix.py +127 -0
  28. fp_arena-0.1.0/fp_arena/search/knobs.py +276 -0
  29. fp_arena-0.1.0/fp_arena/search/registry.py +47 -0
  30. fp_arena-0.1.0/fp_arena/search/results.py +306 -0
  31. fp_arena-0.1.0/fp_arena/search/retarget.py +254 -0
  32. fp_arena-0.1.0/fp_arena/search/runner.py +541 -0
  33. fp_arena-0.1.0/fp_arena/search/screening.py +168 -0
  34. fp_arena-0.1.0/fp_arena/search/search.py +1308 -0
  35. fp_arena-0.1.0/fp_arena/search/store.py +156 -0
  36. fp_arena-0.1.0/fp_arena/search/timers.py +197 -0
  37. fp_arena-0.1.0/fp_arena/transformations/__init__.py +12 -0
  38. fp_arena-0.1.0/fp_arena/transformations/change_and_propagate_fp_types.py +1442 -0
  39. fp_arena-0.1.0/fp_arena.egg-info/PKG-INFO +108 -0
  40. fp_arena-0.1.0/fp_arena.egg-info/SOURCES.txt +50 -0
  41. fp_arena-0.1.0/fp_arena.egg-info/dependency_links.txt +1 -0
  42. fp_arena-0.1.0/fp_arena.egg-info/requires.txt +20 -0
  43. fp_arena-0.1.0/fp_arena.egg-info/top_level.txt +1 -0
  44. fp_arena-0.1.0/pyproject.toml +65 -0
  45. fp_arena-0.1.0/setup.cfg +4 -0
  46. fp_arena-0.1.0/tests/test_auto_enable.py +100 -0
  47. fp_arena-0.1.0/tests/test_change_and_propagate_fp_types.py +1899 -0
  48. fp_arena-0.1.0/tests/test_dace_half_cuda.py +55 -0
  49. fp_arena-0.1.0/tests/test_experiment.py +766 -0
  50. fp_arena-0.1.0/tests/test_mpfr.py +372 -0
  51. fp_arena-0.1.0/tests/test_search.py +438 -0
  52. fp_arena-0.1.0/tests/test_stochastic_rounding.py +118 -0
fp_arena-0.1.0/LICENSE ADDED
@@ -0,0 +1,29 @@
1
+ BSD 3-Clause License
2
+
3
+ Copyright (c) 2019-2021, Scalable Parallel Computing Lab, ETH Zurich, and all contributors listed in AUTHORS
4
+ All rights reserved.
5
+
6
+ Redistribution and use in source and binary forms, with or without
7
+ modification, are permitted provided that the following conditions are met:
8
+
9
+ * Redistributions of source code must retain the above copyright notice, this
10
+ list of conditions and the following disclaimer.
11
+
12
+ * Redistributions in binary form must reproduce the above copyright notice,
13
+ this list of conditions and the following disclaimer in the documentation
14
+ and/or other materials provided with the distribution.
15
+
16
+ * Neither the name of the copyright holder nor the names of its
17
+ contributors may be used to endorse or promote products derived from
18
+ this software without specific prior written permission.
19
+
20
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
23
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
24
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
26
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
27
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
28
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -0,0 +1,3 @@
1
+ recursive-include fp_arena/runtime/include *.h
2
+ include README.md
3
+ include LICENSE
@@ -0,0 +1,108 @@
1
+ Metadata-Version: 2.4
2
+ Name: fp-arena
3
+ Version: 0.1.0
4
+ Summary: A rapid-prototyping environment for custom floating-point types in DaCe
5
+ Author: ETH Zurich and the FP-Arena authors
6
+ License-Expression: BSD-3-Clause
7
+ Project-URL: Homepage, https://github.com/spcl/FP-Arena
8
+ Project-URL: Repository, https://github.com/spcl/FP-Arena
9
+ Project-URL: Issues, https://github.com/spcl/FP-Arena/issues
10
+ Project-URL: Changelog, https://github.com/spcl/FP-Arena/blob/main/CHANGELOG.md
11
+ Keywords: dace,floating-point,stochastic-rounding,reduced-precision,prototyping
12
+ Classifier: Development Status :: 3 - Alpha
13
+ Classifier: Operating System :: OS Independent
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.12
16
+ Classifier: Topic :: Scientific/Engineering
17
+ Classifier: Topic :: Software Development :: Code Generators
18
+ Requires-Python: >=3.12
19
+ Description-Content-Type: text/markdown
20
+ License-File: LICENSE
21
+ Requires-Dist: numpy
22
+ Requires-Dist: ordered-set
23
+ Requires-Dist: scipy
24
+ Requires-Dist: tqdm
25
+ Provides-Extra: extended
26
+ Requires-Dist: dace-extended>=1.0.0; extra == "extended"
27
+ Provides-Extra: dace
28
+ Requires-Dist: dace>=2.0.0b2; extra == "dace"
29
+ Provides-Extra: testing
30
+ Requires-Dist: pytest; extra == "testing"
31
+ Requires-Dist: pytest-xdist; extra == "testing"
32
+ Provides-Extra: corpus
33
+ Requires-Dist: h5py; extra == "corpus"
34
+ Provides-Extra: dev
35
+ Requires-Dist: fp-arena[extended,testing]; extra == "dev"
36
+ Dynamic: license-file
37
+
38
+ # FP-Arena
39
+
40
+ A rapid-prototyping environment for testing custom floating-point types in
41
+ [DaCe](https://github.com/spcl/dace). FP-Arena adds new FP types (and the C++
42
+ that implements them) as a **plugin** that registers itself into DaCe at import
43
+ time — no fork, no DaCe source changes.
44
+
45
+
46
+ ## Install
47
+
48
+ Pick the DaCe FP-Arena runs on with an extra; both install the `dace` package, so take exactly one:
49
+
50
+ ```bash
51
+ pip install "fp-arena[extended]" # DaCe extended (PyPI dace-extended): all of FP-Arena
52
+ pip install "fp-arena[dace]" # spcl's dace: the types and change_and_propagate_fp_types; not fp_arena.search
53
+ ```
54
+
55
+ `fp_arena.search` uses DaCe extended's vectorization passes.
56
+
57
+ The benchmark kernels the examples and tests use (heat3d, hdiff, vadv, CLOUDSC) live in `fp_arena.corpus`; their
58
+ reference data (`.h5`, `.sdfg`) ships only with a checkout.
59
+
60
+ Already have a DaCe checkout (any `extended`-based branch) you want to use? Install without an extra, which pulls no
61
+ DaCe:
62
+
63
+ ```bash
64
+ pip install fp-arena # or, from a checkout: pip install -e .
65
+ ```
66
+
67
+ ## Quick start
68
+
69
+ Importing `fp_arena` registers the types *and* auto-enables any SDFG that uses
70
+ them, so there is nothing else to call:
71
+
72
+ ```python
73
+ import numpy as np
74
+ import dace
75
+ import fp_arena # registers types + auto-enables on compile
76
+
77
+ @dace.program
78
+ def axpy(a: fp_arena.float32sr[1024], b: fp_arena.float32sr[1024],
79
+ c: fp_arena.float32sr[1024]):
80
+ for i in dace.map[0:1024]:
81
+ c[i] = a[i] * b[i] + c[i] # arithmetic rounds stochastically
82
+
83
+ sdfg = axpy.to_sdfg()
84
+ a = np.full(1024, 1.0, np.float32)
85
+ b = np.full(1024, 1.0, np.float32)
86
+ c = np.zeros(1024, np.float32)
87
+ sdfg(a=a, b=b, c=c) # headers injected + fast-math stripped automatically
88
+ ```
89
+
90
+
91
+ ## Notes
92
+
93
+ - Auto-enable wraps `SDFG.compile` (installed on import) and only touches SDFGs
94
+ that actually use an FP-Arena type. Turn it off with
95
+ `fp_arena.disable_auto_extensions()`; enable a single SDFG explicitly with
96
+ `sdfg.enable_fp_arena_extensions()`.
97
+ - The SR types are header-only, allocation-free, and `__host__`/`__device__`
98
+ capable (GPU codegen works; the device RNG is clock-seeded).
99
+ - Stochastic rounding needs exact IEEE rounding, so enabling removes
100
+ `-ffast-math` / `/fp:fast` / `--use_fast_math` from DaCe's compiler flags
101
+ (otherwise on by default). Auto-enable scopes this to the SR compile; the
102
+ explicit `enable_fp_arena_extensions` makes it a persistent default.
103
+ - Both types capture each operation's result exactly (error-free), which is what
104
+ matters for error analysis. `float32sr` evaluates each op in `double` (exact
105
+ for +/−/×) and rounds by perturbing the dropped mantissa bits; `float64sr`
106
+ uses error-free transforms (TwoSum, FMA TwoProd) since there is no wider native
107
+ type, then rounds against the exact residual (`ulp` is a power of two, so the
108
+ probability compare is exact too).
@@ -0,0 +1,71 @@
1
+ # FP-Arena
2
+
3
+ A rapid-prototyping environment for testing custom floating-point types in
4
+ [DaCe](https://github.com/spcl/dace). FP-Arena adds new FP types (and the C++
5
+ that implements them) as a **plugin** that registers itself into DaCe at import
6
+ time — no fork, no DaCe source changes.
7
+
8
+
9
+ ## Install
10
+
11
+ Pick the DaCe FP-Arena runs on with an extra; both install the `dace` package, so take exactly one:
12
+
13
+ ```bash
14
+ pip install "fp-arena[extended]" # DaCe extended (PyPI dace-extended): all of FP-Arena
15
+ pip install "fp-arena[dace]" # spcl's dace: the types and change_and_propagate_fp_types; not fp_arena.search
16
+ ```
17
+
18
+ `fp_arena.search` uses DaCe extended's vectorization passes.
19
+
20
+ The benchmark kernels the examples and tests use (heat3d, hdiff, vadv, CLOUDSC) live in `fp_arena.corpus`; their
21
+ reference data (`.h5`, `.sdfg`) ships only with a checkout.
22
+
23
+ Already have a DaCe checkout (any `extended`-based branch) you want to use? Install without an extra, which pulls no
24
+ DaCe:
25
+
26
+ ```bash
27
+ pip install fp-arena # or, from a checkout: pip install -e .
28
+ ```
29
+
30
+ ## Quick start
31
+
32
+ Importing `fp_arena` registers the types *and* auto-enables any SDFG that uses
33
+ them, so there is nothing else to call:
34
+
35
+ ```python
36
+ import numpy as np
37
+ import dace
38
+ import fp_arena # registers types + auto-enables on compile
39
+
40
+ @dace.program
41
+ def axpy(a: fp_arena.float32sr[1024], b: fp_arena.float32sr[1024],
42
+ c: fp_arena.float32sr[1024]):
43
+ for i in dace.map[0:1024]:
44
+ c[i] = a[i] * b[i] + c[i] # arithmetic rounds stochastically
45
+
46
+ sdfg = axpy.to_sdfg()
47
+ a = np.full(1024, 1.0, np.float32)
48
+ b = np.full(1024, 1.0, np.float32)
49
+ c = np.zeros(1024, np.float32)
50
+ sdfg(a=a, b=b, c=c) # headers injected + fast-math stripped automatically
51
+ ```
52
+
53
+
54
+ ## Notes
55
+
56
+ - Auto-enable wraps `SDFG.compile` (installed on import) and only touches SDFGs
57
+ that actually use an FP-Arena type. Turn it off with
58
+ `fp_arena.disable_auto_extensions()`; enable a single SDFG explicitly with
59
+ `sdfg.enable_fp_arena_extensions()`.
60
+ - The SR types are header-only, allocation-free, and `__host__`/`__device__`
61
+ capable (GPU codegen works; the device RNG is clock-seeded).
62
+ - Stochastic rounding needs exact IEEE rounding, so enabling removes
63
+ `-ffast-math` / `/fp:fast` / `--use_fast_math` from DaCe's compiler flags
64
+ (otherwise on by default). Auto-enable scopes this to the SR compile; the
65
+ explicit `enable_fp_arena_extensions` makes it a persistent default.
66
+ - Both types capture each operation's result exactly (error-free), which is what
67
+ matters for error analysis. `float32sr` evaluates each op in `double` (exact
68
+ for +/−/×) and rounds by perturbing the dropped mantissa bits; `float64sr`
69
+ uses error-free transforms (TwoSum, FMA TwoProd) since there is no wider native
70
+ type, then rounds against the exact residual (`ulp` is a power of two, so the
71
+ probability compare is exact too).
@@ -0,0 +1,73 @@
1
+ # Copyright 2024-2026 ETH Zurich and the FP-Arena authors. All rights reserved.
2
+ """
3
+ FP-Arena: a rapid-prototyping environment for testing custom floating-point
4
+ types in DaCe.
5
+
6
+ Importing this package registers the FP-Arena types (e.g. ``float32sr``,
7
+ ``float64sr``) into DaCe without modifying DaCe itself, so they can be used like
8
+ any built-in DaCe scalar type. Call :func:`enable_fp_arena_extensions` on an
9
+ SDFG before compiling it to attach the DaCe environments that pull in the
10
+ matching C++ headers and link flags.
11
+ """
12
+
13
+ from fp_arena.dtypes import (
14
+ FP_ARENA_TYPECLASSES,
15
+ Float32sr,
16
+ Float64sr,
17
+ float32sr,
18
+ float64sr,
19
+ mpfr,
20
+ register,
21
+ )
22
+ from fp_arena.environments import INCLUDE_DIR, MPFR, FPArenaSR
23
+ from fp_arena.extensions import (
24
+ attach_environments,
25
+ disable_auto_extensions,
26
+ disable_fast_math,
27
+ enable_auto_extensions,
28
+ enable_fp_arena_extensions,
29
+ precise_math,
30
+ required_environments,
31
+ uses_fp_arena_types,
32
+ )
33
+ from fp_arena.transformations.change_and_propagate_fp_types import (
34
+ DEFAULT_PROMOTION_RULES,
35
+ change_and_propagate_fp_types,
36
+ )
37
+
38
+ # Register the types and the SDFG convenience method on import (idempotent).
39
+ register()
40
+
41
+ import dace as _dace
42
+
43
+ if not hasattr(_dace.SDFG, "enable_fp_arena_extensions"):
44
+ _dace.SDFG.enable_fp_arena_extensions = lambda self: enable_fp_arena_extensions(
45
+ self
46
+ )
47
+
48
+ # Automatically enable FP-Arena for any SDFG that uses its types, so the
49
+ # explicit call above becomes optional. Disable with disable_auto_extensions().
50
+ enable_auto_extensions()
51
+
52
+ __all__ = [
53
+ "DEFAULT_PROMOTION_RULES",
54
+ "FP_ARENA_TYPECLASSES",
55
+ "INCLUDE_DIR",
56
+ "MPFR",
57
+ "FPArenaSR",
58
+ "Float32sr",
59
+ "Float64sr",
60
+ "attach_environments",
61
+ "change_and_propagate_fp_types",
62
+ "disable_auto_extensions",
63
+ "disable_fast_math",
64
+ "enable_auto_extensions",
65
+ "enable_fp_arena_extensions",
66
+ "float32sr",
67
+ "float64sr",
68
+ "mpfr",
69
+ "precise_math",
70
+ "register",
71
+ "required_environments",
72
+ "uses_fp_arena_types",
73
+ ]
@@ -0,0 +1,2 @@
1
+ # Copyright 2019-2026 ETH Zurich and the FP-Arena authors. All rights reserved.
2
+ """A corpus of benchmark kernels written in the DaCe Python frontend."""
@@ -0,0 +1,2 @@
1
+ # Copyright 2019-2026 ETH Zurich and the FP-Arena authors. All rights reserved.
2
+ """CloudSC cloud microphysics: the kernel, its dwarf reference data and GPU offloading."""