counted-float 1.1.2__tar.gz → 1.1.3__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 (96) hide show
  1. {counted_float-1.1.2 → counted_float-1.1.3}/PKG-INFO +21 -6
  2. {counted_float-1.1.2 → counted_float-1.1.3}/pyproject.toml +37 -3
  3. counted_float-1.1.2/README.md +0 -701
  4. {counted_float-1.1.2 → counted_float-1.1.3}/.gitignore +0 -0
  5. {counted_float-1.1.2 → counted_float-1.1.3}/LICENSE +0 -0
  6. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/__init__.py +0 -0
  7. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/__init__.py +0 -0
  8. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/_cli.py +0 -0
  9. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/benchmarking/__init__.py +0 -0
  10. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/benchmarking/counted_float/__init__.py +0 -0
  11. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/benchmarking/counted_float/_counted_float_benchmark.py +0 -0
  12. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/benchmarking/flops/__init__.py +0 -0
  13. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/benchmarking/flops/_array_generator.py +0 -0
  14. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/benchmarking/flops/_flops_benchmark_suite.py +0 -0
  15. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/benchmarking/flops/_flops_micro_benchmark.py +0 -0
  16. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/benchmarking/micro/__init__.py +0 -0
  17. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/benchmarking/micro/_micro_benchmark.py +0 -0
  18. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/compatibility/__init__.py +0 -0
  19. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/compatibility/_numba.py +0 -0
  20. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/counting/__init__.py +0 -0
  21. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/counting/_builtin_data.py +0 -0
  22. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/counting/_context_managers.py +0 -0
  23. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/counting/_counted_float.py +0 -0
  24. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/counting/_global_counter.py +0 -0
  25. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/counting/_math_patching.py +0 -0
  26. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/counting/config/__init__.py +0 -0
  27. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/counting/config/_config.py +0 -0
  28. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/counting/config/_defaults.py +0 -0
  29. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/models/__init__.py +0 -0
  30. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/models/_base.py +0 -0
  31. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/models/_flop_counts.py +0 -0
  32. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/models/_flop_type.py +0 -0
  33. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/models/_flop_weights.py +0 -0
  34. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/models/_flops_benchmark_meta_data.py +0 -0
  35. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/models/_flops_benchmark_result.py +0 -0
  36. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/models/_flops_benchmark_type.py +0 -0
  37. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/models/_instruction_latencies.py +0 -0
  38. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/models/_micro_benchmark_result.py +0 -0
  39. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/utils/__init__.py +0 -0
  40. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/utils/_cpu_freq.py +0 -0
  41. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/utils/_formatting.py +0 -0
  42. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/utils/_geo_mean.py +0 -0
  43. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/utils/_latency.py +0 -0
  44. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/utils/_missing_data.py +0 -0
  45. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/utils/_rounding.py +0 -0
  46. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/_core/utils/_timer.py +0 -0
  47. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/benchmarking/__init__.py +0 -0
  48. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/config/__init__.py +0 -0
  49. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v8_x/benchmarks/apple_m1_github_actions.json +0 -0
  50. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v8_x/benchmarks/apple_m3_max_mbp16.json +0 -0
  51. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v8_x/benchmarks/apple_m3_mba15.json +0 -0
  52. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v8_x/benchmarks/aws_graviton_2_neoverse_n1_ec2_m6g_xlarge.json +0 -0
  53. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v8_x/benchmarks/aws_graviton_3_neoverse_v1_ec2_m7g_xlarge.json +0 -0
  54. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v8_x/specs/arm_cortex_a76.json +0 -0
  55. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v8_x/specs/arm_cortex_x1.json +0 -0
  56. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v8_x/specs/arm_neoverse_n1.json +0 -0
  57. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v8_x/specs/arm_neoverse_v1.json +0 -0
  58. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v9_0/benchmarks/aws_graviton_4_neoverse_v2_ec2_m8g_xlarge.json +0 -0
  59. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v9_0/benchmarks/azure_cobalt_100_neoverse_n2_github_actions.json +0 -0
  60. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v9_0/specs/arm_cortex_x2.json +0 -0
  61. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v9_0/specs/arm_cortex_x3.json +0 -0
  62. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v9_0/specs/arm_neoverse_n2.json +0 -0
  63. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v9_0/specs/arm_neoverse_v2.json +0 -0
  64. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v9_2/benchmarks/apple_m4_pro_mbp16.json +0 -0
  65. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v9_2/specs/arm_cortex_x4.json +0 -0
  66. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v9_2/specs/arm_cortex_x925.json +0 -0
  67. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/arm/v9_2/specs/arm_neoverse_v3.json +0 -0
  68. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/amd/2017_zen1/benchmarks/amd_ryzen_1700x.json +0 -0
  69. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/amd/2017_zen1/other/analysis_uops_info_zen1+.json +0 -0
  70. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/amd/2020_zen3/benchmark/amd_epyc_7763_linux_github.json +0 -0
  71. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/amd/2020_zen3/benchmark/amd_epyc_7763_windows_github.json +0 -0
  72. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/amd/2020_zen3/other/analysis_agner_fog_r7_5800x.json +0 -0
  73. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/amd/2020_zen3/other/analysis_uops_info_zen3.json +0 -0
  74. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/amd/2022_zen4/benchmark/amd_epyc_9r14_ec2_m7a_xlarge.json +0 -0
  75. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/amd/2022_zen4/other/analysis_agner_fog_r9_7900x.json +0 -0
  76. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/amd/2022_zen4/other/analysis_uops_info_zen4.json +0 -0
  77. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/amd/2022_zen4/other/specs_amd.json +0 -0
  78. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/amd/2024_zen5/benchmark/amd_epyc_9r45_ec2_m8a_xlarge.json +0 -0
  79. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/amd/2024_zen5/other/analysis_agner_fog_r7_9800x3d.json +0 -0
  80. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/amd/2024_zen5/other/specs_amd.json +0 -0
  81. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2017_coffee_lake_gen_8/benchmarks/intel_i7_8550U_windows.json +0 -0
  82. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2017_coffee_lake_gen_8/benchmarks/intel_i7_8700B_macos_github_actions.json +0 -0
  83. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2017_coffee_lake_gen_8/other/analysis_agner_fog_coffee_lake.json +0 -0
  84. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2017_coffee_lake_gen_8/other/analysis_uops_info_coffee_lake.json +0 -0
  85. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/benchmarks/intel_xeon_8375c_ice_lake_ec2_m6i_xlarge.json +0 -0
  86. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/other/analysis_agner_fog_ice_lake.json +0 -0
  87. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/other/analysis_uops_info_ice_lake.json +0 -0
  88. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/other/analysis_uops_info_tiger_lake.json +0 -0
  89. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2021_golden_cove_gen_12/benchmarks/intel_xeon_8488c_sapphire_rapids_ec2_m7i_xlarge.json +0 -0
  90. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2021_golden_cove_gen_12/other/analysis_uops_info_alder_lake_p.json +0 -0
  91. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2021_golden_cove_gen_12/other/specs_intel.json +0 -0
  92. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2022_raptor_cove_gen_13_14/benchmarks/intel_xeon_8559c_emerald_rapids_ec2_i7i_xlarge.json +0 -0
  93. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2022_raptor_cove_gen_13_14/other/specs_intel.json +0 -0
  94. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2023_redwood_cove_ultra_1/benchmarks/intel_xeon_6975p_granite_rapids_ec2_m8i_xlarge.json +0 -0
  95. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/data/x86/intel/2023_redwood_cove_ultra_1/other/specs_intel.json +0 -0
  96. {counted_float-1.1.2 → counted_float-1.1.3}/counted_float/py.typed +0 -0
@@ -1,12 +1,22 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: counted-float
3
- Version: 1.1.2
3
+ Version: 1.1.3
4
4
  Summary: Count floating-point operations in Python code & benchmark relative flop costs.
5
5
  Project-URL: Source, https://github.com/bertpl/counted-float
6
6
  Project-URL: ChangeLog, https://github.com/bertpl/counted-float/blob/main/CHANGELOG.md
7
7
  Project-URL: Issues, https://github.com/bertpl/counted-float/issues
8
8
  Project-URL: Roadmap, https://github.com/bertpl/counted-float/milestones
9
9
  License-File: LICENSE
10
+ Classifier: Development Status :: 5 - Production/Stable
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Intended Audience :: Science/Research
13
+ Classifier: License :: OSI Approved :: Apache Software License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Programming Language :: Python :: 3.14
19
+ Classifier: Topic :: Scientific/Engineering
10
20
  Requires-Python: >=3.11
11
21
  Requires-Dist: numpy>=1.23.2; python_version < '3.12'
12
22
  Requires-Dist: numpy>=1.26.0; python_version == '3.12'
@@ -28,10 +38,15 @@ Requires-Dist: numba>=0.61; (python_version == '3.13') and extra == 'numba'
28
38
  Requires-Dist: numba>=0.63; (python_version >= '3.14') and extra == 'numba'
29
39
  Description-Content-Type: text/markdown
30
40
 
31
- ![shields.io-python-versions](https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13-blue)
32
- ![genbadge-test-count](https://bertpl.github.io/counted-float/version_artifacts/release/v1.1.2/badge-test-count.svg)
33
- ![genbadge-test-coverage](https://bertpl.github.io/counted-float/version_artifacts/release/v1.1.2/badge-coverage.svg)
34
- ![counted_float logo](https://bertpl.github.io/counted-float/version_artifacts/release/v1.1.2/splash.webp)
41
+ [![CI](https://img.shields.io/github/actions/workflow/status/bertpl/counted-float/push_to_main.yml?branch=main&label=CI)](https://github.com/bertpl/counted-float/actions/workflows/push_to_main.yml)
42
+ [![Coverage](https://img.shields.io/badge/coverage-99.30%25-brightgreen)](https://github.com/bertpl/counted-float/actions/workflows/push_to_main.yml)
43
+ [![Tests](https://img.shields.io/badge/tests-708-blue)](https://github.com/bertpl/counted-float/actions/workflows/push_to_main.yml)
44
+ [![PyPI](https://img.shields.io/pypi/v/counted-float.svg)](https://pypi.org/project/counted-float/)
45
+ [![Python](https://img.shields.io/pypi/pyversions/counted-float.svg)](https://pypi.org/project/counted-float/)
46
+ [![License](https://img.shields.io/badge/license-Apache%202.0-blue)](https://github.com/bertpl/counted-float/blob/main/LICENSE)
47
+ [![code style: ruff](https://img.shields.io/badge/code%20style-ruff-261230)](https://github.com/astral-sh/ruff)
48
+
49
+ ![counted_float logo](https://raw.githubusercontent.com/bertpl/counted-float/v1.1.3/images/splash/splash.webp)
35
50
 
36
51
  # counted-float
37
52
 
@@ -201,7 +216,7 @@ counts.total_count() # 2
201
216
  The `counted_float` package contains a set of default, built-in FLOP weights, based on both empirical measurements
202
217
  and theoretical estimates of the relative cost of different floating point operations.
203
218
 
204
- See [fpu_data_sources.md](https://github.com/bertpl/counted-float/tree/develop/docs/analysis_methodology.md) for
219
+ See [analysis_methodology.md](https://github.com/bertpl/counted-float/blob/v1.1.3/docs/analysis_methodology.md) for
205
220
  rationale behind choice of data sources and methodology.
206
221
 
207
222
  ```
@@ -1,8 +1,10 @@
1
1
  [project]
2
2
  name = "counted-float"
3
- version = "1.1.2"
3
+ version = "1.1.3"
4
4
  description = "Count floating-point operations in Python code & benchmark relative flop costs."
5
- readme = "README.md"
5
+ # readme is dynamic: hatch-fancy-pypi-readme builds the PyPI long-description from
6
+ # README.md, rewriting relative links to tag-pinned absolute URLs (config below).
7
+ dynamic = ["readme"]
6
8
  requires-python = ">=3.11"
7
9
  dependencies = [
8
10
  # Per-Python floors: each compiled dep's floor is the earliest version shipping a
@@ -21,6 +23,19 @@ dependencies = [
21
23
  "rich>=13.0.0",
22
24
  "py-cpuinfo>=9.0.0",
23
25
  ]
26
+ classifiers = [
27
+ "Development Status :: 5 - Production/Stable",
28
+ "Intended Audience :: Developers",
29
+ "Intended Audience :: Science/Research",
30
+ "License :: OSI Approved :: Apache Software License",
31
+ "Operating System :: OS Independent",
32
+ # Python versions kept in sync with .python-versions (release.py enforces this)
33
+ "Programming Language :: Python :: 3.11",
34
+ "Programming Language :: Python :: 3.12",
35
+ "Programming Language :: Python :: 3.13",
36
+ "Programming Language :: Python :: 3.14",
37
+ "Topic :: Scientific/Engineering",
38
+ ]
24
39
 
25
40
  [project.scripts]
26
41
  counted_float = "counted_float._core._cli:cli"
@@ -58,9 +73,25 @@ dev = [
58
73
  ]
59
74
 
60
75
  [build-system]
61
- requires = ["hatchling"]
76
+ requires = ["hatchling", "hatch-fancy-pypi-readme"]
62
77
  build-backend = "hatchling.build"
63
78
 
79
+ [tool.hatch.metadata.hooks.fancy-pypi-readme]
80
+ content-type = "text/markdown"
81
+
82
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.fragments]]
83
+ path = "README.md"
84
+
85
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
86
+ # image embeds (splash, ...): relative -> tag-pinned raw URL for PyPI
87
+ pattern = '\]\((images/[^)]+)\)'
88
+ replacement = '](https://raw.githubusercontent.com/bertpl/counted-float/v$HFPR_VERSION/\1)'
89
+
90
+ [[tool.hatch.metadata.hooks.fancy-pypi-readme.substitutions]]
91
+ # docs/*.md references: relative -> tag-pinned blob URL for PyPI
92
+ pattern = '\]\((docs/[^)]+)\)'
93
+ replacement = '](https://github.com/bertpl/counted-float/blob/v$HFPR_VERSION/\1)'
94
+
64
95
  [tool.hatch.build.targets.sdist]
65
96
  # configs below also make sure the .whl file contains the data files, because wheels are built from the sdist
66
97
  packages = ["counted_float"]
@@ -122,6 +153,9 @@ runtime-evaluated-base-classes = ["pydantic.BaseModel", "counted_float._core.mod
122
153
  "__init__.py" = ["F401"] # re-export modules: naked imports, no `as` alias
123
154
  # module-level mutable patching state (original-function snapshots + context refcount) is the design
124
155
  "counted_float/_core/counting/_math_patching.py" = ["PLW0603"]
156
+ # maintainer tooling, not the shipped library: not a package (INP001), subprocess is fine (S)
157
+ "scripts/**" = ["INP001", "S"]
158
+ ".github/scripts/**" = ["INP001", "S"]
125
159
 
126
160
  [tool.ty.src]
127
161
  include = ["counted_float"]
@@ -1,701 +0,0 @@
1
- ![shields.io-python-versions](https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13-blue)
2
- ![genbadge-test-count](https://bertpl.github.io/counted-float/version_artifacts/release/v1.1.2/badge-test-count.svg)
3
- ![genbadge-test-coverage](https://bertpl.github.io/counted-float/version_artifacts/release/v1.1.2/badge-coverage.svg)
4
- ![counted_float logo](https://bertpl.github.io/counted-float/version_artifacts/release/v1.1.2/splash.webp)
5
-
6
- # counted-float
7
-
8
- This Python package provides functionality for...
9
- - **counting floating point operations** (FLOPs) of numerical algorithms implemented in plain Python, optionally weighted by their relative cost of execution
10
- - **running benchmarks** to estimate the relative cost of executing various floating-point operations (requires `numba` optional dependency for achieving accurate results)
11
-
12
- The target application area is evaluation of research prototypes of numerical algorithms where (weighted) flop counting can be
13
- useful for estimating total computational cost, in cases where benchmarking a compiled version (C, Rust, ...) is not
14
- feasible or desirable.
15
-
16
- Flop weights are computed using a highly curated dataset spanning a wide range of modern CPUs:
17
- - 19 benchmarks, 16 spec sheets, 12 third party measurements (Agner Fog, uops.info)
18
- - covering x86 (Intel, AMD) and ARM (Apple, AWS, Azure) architectures
19
-
20
- # 1. Installation
21
-
22
- Use you favorite package manager such as `uv` or `pip`:
23
-
24
- ```
25
- pip install counted-float # install without numba optional dependency
26
- pip install counted-float[numba] # install with numba optional dependency
27
- ```
28
- Numba is optional due to its relatively large size (40-50MB, including llvmlite), but without it, benchmarks will
29
- not be reliable (but will still run, but not in jit-compiled form).
30
-
31
- NOTE: the `cli` optional dependency is only useful when installing the code as a tool using e.g. `uv` or `pipx` (see below)
32
-
33
- # 2. Counting Flops
34
-
35
- ## 2.1. CountedFloat class
36
-
37
- In order to instrument all floating point operations with counting functionality,
38
- the `CountedFloat` class was implemented, which is a drop-in replacement for the built-in `float` type.
39
- The `CountedFloat` class is a subclass of `float` and is "contagious", meaning that it will automatically
40
- ensure results of math operations where at least one operand is a `CountedFloat` will also be a `CountedFloat`.
41
- This way we ensure flop counting is a 'closed system'.
42
-
43
- On top of this, `math` module functions that require counting (`sqrt`, `log2`, `pow`, ...) are
44
- also instrumented: while a `FlopCountingContext` is active (see below), they are temporarily
45
- replaced by counting equivalents. Outside such a context — including at plain `import` time —
46
- the `math` module is left completely untouched.
47
-
48
- **Example**:
49
-
50
- ```python
51
- from counted_float import CountedFloat
52
-
53
- cf = CountedFloat(1.3)
54
- f = 2.8
55
-
56
- result = cf + f # result = CountedFloat(4.1)
57
-
58
- is_float_1 = isinstance(cf, float) # True
59
- is_float_2 = isinstance(result, float) # True
60
- ```
61
-
62
- ### The counting model: what gets counted and why
63
-
64
- The counting model is a contract with two sides:
65
-
66
- - **Your side:** wrap every *runtime input* of the algorithm you want to measure in `CountedFloat`
67
- at its boundary. Contagion does the rest — everything derived from those inputs stays counted
68
- automatically.
69
- - **The library's side:** count every FLOP that a compiled (C/Rust/...) port of your algorithm
70
- would execute *on data derived from those inputs*.
71
-
72
- From this contract follows a clean rule for everything else: **constants are free.** Any plain
73
- float encountered mid-computation is, by the contract, not an input — so it must be a constant of
74
- the algorithm (a literal, a coefficient, a tolerance), and operations purely among constants are
75
- work a compiled port would fold at compile time or precompute. This is why e.g. `math.sqrt(3)`
76
- counts nothing: the port ships `sqrt(3)` as a precomputed constant.
77
-
78
- The library detects constants through two mechanisms, applying the same rule:
79
-
80
- - **Unwrapped values** (plain floats): constants by the wrapping contract, as above.
81
- - **`int` operands**: evidence of a *hardcoded* constant — ints don't fall out of floating-point
82
- computations, so an int operand almost certainly appears literally in your source. This enables
83
- counting the strength reductions a compiled port would apply: `x**2` counts MUL (i.e. `x*x`),
84
- `2**x` counts EXP2, `math.log(x, 10)` counts LOG10 — while `x**2.0`, with a float that *could*
85
- be a runtime value, conservatively counts a generic POW.
86
-
87
- The flip side: an unwrapped runtime input is invisible to the counter — that is a wrapping error
88
- at your algorithm's boundary, not something the library can detect. When in doubt, wrap.
89
-
90
- One more consequence of the context-scoped `math` patching: `math.*` calls participate in
91
- counting (and in contagion) only while a `FlopCountingContext` is active. Operator-based
92
- contagion (`+`, `*`, `**`, ...) works everywhere, but counts are meant to be read through a
93
- context — so the practical rule is simply: run your measured algorithm inside one.
94
-
95
- ## 2.2. FLOP counting context managers
96
-
97
- Once we use the `CountedFloat` class, we can use the available context managers to count the number of
98
- flops performed by `CountedFloat` objects.
99
-
100
- **Example 1**: _basic usage_
101
- ```python
102
- from counted_float import CountedFloat, FlopCountingContext
103
-
104
- cf1 = CountedFloat(1.73)
105
- cf2 = CountedFloat(2.94)
106
-
107
- with FlopCountingContext() as ctx:
108
- _ = cf1 * cf2
109
- _ = cf1 + cf2
110
-
111
- counts = ctx.flop_counts() # {FlopType.MUL: 1, FlopType.ADD: 1}
112
- counts.total_count() # 2
113
- ```
114
-
115
- **Example 2**: _math module functions_
116
-
117
- ```python
118
- import math
119
- from counted_float import CountedFloat, FlopCountingContext
120
-
121
- cf1 = CountedFloat(0.81)
122
-
123
- with FlopCountingContext() as ctx:
124
- s = math.sqrt(cf1) # s = CountedFloat(0.9)
125
-
126
- counts = ctx.flop_counts() # {FlopType.SQRT: 1}
127
- ```
128
-
129
- Note that `math.*` functions are only instrumented *inside* the context: outside it,
130
- `math.sqrt(cf1)` returns a plain `float` and counts nothing.
131
-
132
- **Example 3**: _pause counting 1_
133
-
134
- ```python
135
- from counted_float import CountedFloat, FlopCountingContext
136
-
137
- cf1 = CountedFloat(1.73)
138
- cf2 = CountedFloat(2.94)
139
-
140
- with FlopCountingContext() as ctx:
141
- _ = cf1 * cf2
142
- ctx.pause()
143
- _ = cf1 + cf2 # will be executed but not counted
144
- ctx.resume()
145
- _ = cf1 - cf2
146
-
147
- counts = ctx.flop_counts() # {FlopType.MUL: 1, FlopType.SUB: 1}
148
- counts.total_count() # 2
149
- ```
150
-
151
- **Example 4**: _pause counting 2_
152
-
153
- ```python
154
- from counted_float import CountedFloat, FlopCountingContext, PauseFlopCounting
155
-
156
- cf1 = CountedFloat(1.73)
157
- cf2 = CountedFloat(2.94)
158
-
159
- with FlopCountingContext() as ctx:
160
- _ = cf1 * cf2
161
- with PauseFlopCounting():
162
- _ = cf1 + cf2 # will be executed but not counted
163
- _ = cf1 - cf2
164
-
165
- counts = ctx.flop_counts() # {FlopType.MUL: 1, FlopType.SUB: 1}
166
- counts.total_count() # 2
167
- ```
168
-
169
- ## 2.3. Weighted FLOP counting
170
-
171
- The `counted_float` package contains a set of default, built-in FLOP weights, based on both empirical measurements
172
- and theoretical estimates of the relative cost of different floating point operations.
173
-
174
- See [fpu_data_sources.md](https://github.com/bertpl/counted-float/tree/develop/docs/analysis_methodology.md) for
175
- rationale behind choice of data sources and methodology.
176
-
177
- ```
178
- >>> from counted_float.config import get_active_flop_weights
179
- >>> get_active_flop_weights().show()
180
-
181
- {
182
- FlopType.MINUS [-x] : 0.45000
183
- FlopType.ABS [abs(x)] : 0.70000
184
- FlopType.ADD [x+y] : 1.00000
185
- FlopType.COMP [x<=y] : 1.00000
186
- FlopType.SUB [x-y] : 1.00000
187
- FlopType.MUL [x*y] : 1.40000
188
- FlopType.RND [round] : 1.80000
189
- FlopType.F2I [float->int] : 2.00000
190
- FlopType.I2F [int->float] : 2.00000
191
- FlopType.DIV [x/y] : 5.50000
192
- FlopType.SQRT [sqrt(x)] : 7.50000
193
- FlopType.EXP2 [2^x] : 16.00000
194
- FlopType.EXP [e^x] : 18.00000
195
- FlopType.LOG [log(x)] : 18.00000
196
- FlopType.EXP10 [10^x] : 22.00000
197
- FlopType.LOG2 [log2(x)] : 22.00000
198
- FlopType.LOG10 [log10(x)] : 24.00000
199
- FlopType.COS [cos(x)] : 30.00000
200
- FlopType.SIN [sin(x)] : 30.00000
201
- FlopType.POW [x^y] : 40.00000
202
- FlopType.TAN [tan(x)] : 40.00000
203
- FlopType.CBRT [cbrt(x)] : 45.00000
204
- }
205
- ```
206
- Note that these weights are rounded up to the ~10% closest semi-round number, reflecting a balance between accuracy and readability,
207
- while conveying the message that these weights should be used as approximations only. See further down for the different rounding modes.
208
-
209
- These weights will be used by default when extracting total weighted flop costs:
210
-
211
- ```python
212
- import math
213
- from counted_float import CountedFloat, FlopCountingContext
214
-
215
-
216
- cf1 = CountedFloat(1.73)
217
- cf2 = CountedFloat(2.94)
218
-
219
- with FlopCountingContext() as ctx:
220
- _ = cf1 + cf2
221
- _ = cf1 ** cf2
222
- _ = math.log2(cf2)
223
-
224
- flop_counts = ctx.flop_counts()
225
- total_cost = flop_counts.total_weighted_cost() # 1 + 40 + 22 = 63
226
- ```
227
- Note that the `total_weighted_cost` method will use the default flop weights as returned by `get_flop_weights()`. This can be
228
- overridden by either configuring different flop weights (see next section) or by setting the `weights` argument of the `total_weighted_cost()` method.
229
-
230
-
231
- ## 2.4. Configuring FLOP weights
232
-
233
- We showed earlier that the `get_flop_weights()` function returns the default FLOP weights. We can change this by
234
- using the `set_flop_weights()` function, which takes a `FlopWeights` object as an argument. This way we can configure
235
- flop weights that might be obtained using benchmarks run on the target hardware (see later sections).
236
-
237
- ```python
238
- from counted_float.config import set_active_flop_weights
239
- from counted_float import FlopWeights
240
-
241
- set_active_flop_weights(weights=FlopWeights(...)) # insert own weights here
242
- ```
243
- ## 2.5. Inspecting built-in data
244
-
245
- ### 2.5.1. Default, pre-aggregated flop weights
246
-
247
- Built-in flop weights can be inspected using the following functions:
248
-
249
- ```python
250
- from counted_float.config import get_default_consensus_flop_weights
251
-
252
- >>> get_default_consensus_flop_weights(rounding_mode=None).show()
253
-
254
- {
255
- FlopType.MINUS [-x] : 0.43688
256
- FlopType.ABS [abs(x)] : 0.71585
257
- FlopType.COMP [x<=y] : 0.97866
258
- FlopType.SUB [x-y] : 0.99565
259
- FlopType.ADD [x+y] : 1.00000
260
- FlopType.MUL [x*y] : 1.39506
261
- FlopType.RND [round] : 1.78130
262
- FlopType.F2I [float->int] : 1.91125
263
- FlopType.I2F [int->float] : 1.91839
264
- FlopType.DIV [x/y] : 5.53385
265
- FlopType.SQRT [sqrt(x)] : 7.37309
266
- FlopType.EXP2 [2^x] : 15.79616
267
- FlopType.EXP [e^x] : 17.45201
268
- FlopType.LOG [log(x)] : 18.93143
269
- FlopType.LOG2 [log2(x)] : 22.29433
270
- FlopType.EXP10 [10^x] : 22.93876
271
- FlopType.LOG10 [log10(x)] : 24.56277
272
- FlopType.SIN [sin(x)] : 30.28970
273
- FlopType.COS [cos(x)] : 31.27413
274
- FlopType.POW [x^y] : 41.65022
275
- FlopType.TAN [tan(x)] : 41.99495
276
- FlopType.CBRT [cbrt(x)] : 44.15405
277
- }
278
- ```
279
- There are 3 rounding modes:
280
- - `None` -> no rounding
281
- - `"nearest_int"` -> round up/down to nearest integer, with a minimum of 1
282
- - `"10%"` -> round to nearest semi-round number within ~10% (default)
283
-
284
-
285
- The default weights that are configured out-of-the-box in the package are the integer-rounded `consensus` weights.
286
-
287
- ### 2.5.2. Custom-aggregated flop weights
288
-
289
- We can retrieve built-in flop weights in a more fine-grained manner, by custom filtering and the aggregating them with
290
- the geometric mean.
291
-
292
- ```python
293
- from counted_float.config import get_builtin_flop_weights
294
-
295
- >>> get_builtin_flop_weights(key_filter="arm").show()
296
-
297
- {
298
- FlopType.COMP [x<=y] : 0.65000
299
- FlopType.MINUS [-x] : 0.90000
300
- FlopType.ADD [x+y] : 1.00000
301
- FlopType.SUB [x-y] : 1.00000
302
- FlopType.ABS [abs(x)] : 1.10000
303
- FlopType.F2I [float->int] : 1.50000
304
- FlopType.MUL [x*y] : 1.50000
305
- FlopType.I2F [int->float] : 1.60000
306
- FlopType.RND [round] : 1.60000
307
- FlopType.DIV [x/y] : 6.00000
308
- FlopType.SQRT [sqrt(x)] : 7.50000
309
- FlopType.EXP2 [2^x] : 16.00000
310
- FlopType.EXP [e^x] : 18.00000
311
- FlopType.LOG [log(x)] : 20.00000
312
- FlopType.LOG2 [log2(x)] : 20.00000
313
- FlopType.EXP10 [10^x] : 24.00000
314
- FlopType.LOG10 [log10(x)] : 24.00000
315
- FlopType.COS [cos(x)] : 33.00000
316
- FlopType.SIN [sin(x)] : 33.00000
317
- FlopType.POW [x^y] : 40.00000
318
- FlopType.CBRT [cbrt(x)] : 45.00000
319
- FlopType.TAN [tan(x)] : 45.00000
320
- }
321
- ```
322
-
323
- # 3. Benchmarking
324
-
325
- If the package is installed with the optional `numba` dependency, it provides the ability to micro-benchmark
326
- floating point operations as follows:
327
-
328
- ```
329
- >>> from counted_float.benchmarking import run_flops_benchmark
330
- >>> results = run_flops_benchmark()
331
-
332
- Running FLOPS benchmarks using counted-float 0.9.5 ...
333
- (Expected duration: ~87.8 seconds)
334
-
335
- baseline : wwwwwwwwwwwwwww......................... [ 74.43 ns ± 2.6% | 302 cpu cycles ± 2.6% ] / 1000 iterations
336
- add : wwwwwwwwwwwwwww......................... [ 662.35 ns ± 0.2% | 2.69K cpu cycles ± 0.2% ] / 1000 iterations
337
- add_minus : wwwwwwwwwwwwwww......................... [ 1.23 µs ± 0.2% | 4.98K cpu cycles ± 0.2% ] / 1000 iterations
338
- add_abs : wwwwwwwwwwwwwww......................... [ 1.23 µs ± 0.4% | 4.99K cpu cycles ± 0.4% ] / 1000 iterations
339
- add_add : wwwwwwwwwwwwwww......................... [ 1.29 µs ± 0.2% | 5.23K cpu cycles ± 0.2% ] / 1000 iterations
340
- add_sub : wwwwwwwwwwwwwww......................... [ 1.29 µs ± 0.2% | 5.23K cpu cycles ± 0.2% ] / 1000 iterations
341
- add_round : wwwwwwwwwwwwwww......................... [ 1.44 µs ± 0.1% | 5.84K cpu cycles ± 0.1% ] / 1000 iterations
342
- add_sqrt : wwwwwwwwwwwwwww......................... [ 3.96 µs ± 0.2% | 16.1K cpu cycles ± 0.2% ] / 1000 iterations
343
- add_cbrt : wwwwwwwwwwwwwww......................... [ 25.42 µs ± 0.2% | 103K cpu cycles ± 0.2% ] / 1000 iterations
344
- add_log : wwwwwwwwwwwwwww......................... [ 11.69 µs ± 0.3% | 47.4K cpu cycles ± 0.3% ] / 1000 iterations
345
- add_log_exp : wwwwwwwwwwwwwww......................... [ 22.57 µs ± 0.1% | 91.5K cpu cycles ± 0.1% ] / 1000 iterations
346
- add_log2 : wwwwwwwwwwwwwww......................... [ 12.00 µs ± 0.2% | 48.7K cpu cycles ± 0.2% ] / 1000 iterations
347
- add_log2_exp2 : wwwwwwwwwwwwwww......................... [ 22.48 µs ± 0.2% | 91.2K cpu cycles ± 0.2% ] / 1000 iterations
348
- add_log10 : wwwwwwwwwwwwwww......................... [ 11.50 µs ± 0.2% | 46.6K cpu cycles ± 0.2% ] / 1000 iterations
349
- add_log10_exp10 : wwwwwwwwwwwwwww......................... [ 24.68 µs ± 0.2% | 100K cpu cycles ± 0.2% ] / 1000 iterations
350
- add_sin : wwwwwwwwwwwwwww......................... [ 18.64 µs ± 0.3% | 75.6K cpu cycles ± 0.3% ] / 1000 iterations
351
- add_cos : wwwwwwwwwwwwwww......................... [ 18.92 µs ± 0.3% | 76.7K cpu cycles ± 0.3% ] / 1000 iterations
352
- add_tan : wwwwwwwwwwwwwww......................... [ 20.91 µs ± 0.2% | 84.8K cpu cycles ± 0.2% ] / 1000 iterations
353
- pow : wwwwwwwwwwwwwww......................... [ 24.12 µs ± 0.3% | 97.8K cpu cycles ± 0.3% ] / 1000 iterations
354
- pow_pow : wwwwwwwwwwwwwww......................... [ 48.15 µs ± 0.2% | 195K cpu cycles ± 0.2% ] / 1000 iterations
355
- sub : wwwwwwwwwwwwwww......................... [ 661.55 ns ± 0.2% | 2.68K cpu cycles ± 0.2% ] / 1000 iterations
356
- sub_sub : wwwwwwwwwwwwwww......................... [ 1.29 µs ± 0.2% | 5.24K cpu cycles ± 0.2% ] / 1000 iterations
357
- mul : wwwwwwwwwwwwwww......................... [ 961.78 ns ± 0.2% | 3.90K cpu cycles ± 0.2% ] / 1000 iterations
358
- mul_mul : wwwwwwwwwwwwwww......................... [ 1.92 µs ± 0.2% | 7.78K cpu cycles ± 0.2% ] / 1000 iterations
359
- div : wwwwwwwwwwwwwww......................... [ 2.45 µs ± 0.2% | 9.92K cpu cycles ± 0.2% ] / 1000 iterations
360
- div_div : wwwwwwwwwwwwwww......................... [ 5.00 µs ± 0.2% | 20.3K cpu cycles ± 0.2% ] / 1000 iterations
361
- lte_addsub : wwwwwwwwwwwwwww......................... [ 1.71 µs ± 0.2% | 6.94K cpu cycles ± 0.2% ] / 1000 iterations
362
-
363
- >>> results.flop_weights().show()
364
-
365
- {
366
- FlopType.ABS [abs(x)] : 0.89904
367
- FlopType.MINUS [-x] : 0.90935
368
- FlopType.SUB [x-y] : 0.99676
369
- FlopType.ADD [x+y] : 1.00000
370
- FlopType.RND [round] : 1.24397
371
- FlopType.MUL [x*y] : 1.55516
372
- FlopType.COMP [x<=y] : 1.69018
373
- FlopType.DIV [x/y] : 4.12333
374
- FlopType.SQRT [sqrt(x)] : 5.42419
375
- FlopType.EXP2 [2^x] : 16.95266
376
- FlopType.LOG10 [log10(x)] : 17.60079
377
- FlopType.EXP [e^x] : 17.76250
378
- FlopType.LOG [log(x)] : 17.86149
379
- FlopType.LOG2 [log2(x)] : 18.42380
380
- FlopType.EXP10 [10^x] : 21.50729
381
- FlopType.SIN [sin(x)] : 29.31571
382
- FlopType.COS [cos(x)] : 29.56218
383
- FlopType.TAN [tan(x)] : 32.88570
384
- FlopType.POW [x^y] : 39.35018
385
- FlopType.CBRT [cbrt(x)] : 40.16857
386
- FlopType.F2I [float->int] : nan
387
- FlopType.I2F [int->float] : nan
388
- }
389
- ```
390
-
391
- ## 4. Installing the package as a command-line tool
392
-
393
- An alternative way of using (parts) of the functionality is installing the package as a stand-alone command-line tool
394
- using `uv` or `pipx`:
395
-
396
- ```
397
- uv tool install git+https://github.com/bertpl/counted-float@main[numba,cli] # latest official release
398
- uv tool install git+https://github.com/bertpl/counted-float@develop[numba,cli] # or latest develop version
399
- ```
400
- This installs the `counted_float` command-line tool, which can be used to e.g. run flops benchmarks.
401
-
402
- ## 4.1. Running benchmarks
403
-
404
- ```
405
- counted_float benchmark
406
- ```
407
- after which the results will be shown as .json.
408
-
409
- ## 4.2. Show built-in data
410
-
411
- ```
412
- [~] counted_float show-data
413
- MINUS ABS COMP SUB ADD MUL RND F2I I2F DIV SQRT EXP2 EXP LOG LOG2 EXP10 LOG10 SIN COS POW TAN CBRT
414
- ALL 0.44 0.72 0.98 1.00 1.00 1.40 1.78 1.91 1.92 5.53 7.37 15.80 17.45 18.93 22.29 22.94 24.56 30.29 31.27 41.65 41.99 44.15
415
- ├─arm 0.89 1.05 0.64 1.01 1.00 1.50 1.61 1.49 1.59 6.15 7.60 15.98 18.57 19.60 20.86 23.30 24.26 32.32 34.08 42.28 42.85 44.97
416
- │ ├─v8_x 0.83 1.00 0.67 1.01 1.00 1.48 1.50 1.56 1.91 5.90 7.42 15.45 17.86 19.06 20.80 22.92 22.90 32.43 33.47 41.19 42.99 44.71
417
- │ │ ├─benchmarks 0.70 1.01 0.45 1.01 1.00 1.46 1.50 / / 4.65 6.68 13.93 16.10 17.18 18.75 20.66 20.65 29.23 30.17 37.13 38.76 40.30
418
- │ │ │ ├─apple_m1_github_actions 0.86 0.86 1.73 1.06 1.00 1.48 1.22 / / 4.07 5.70 15.50 16.98 17.33 20.52 19.61 17.95 29.86 31.59 38.67 38.97 41.44
419
- │ │ │ ├─apple_m3_max_mbp16 0.90 0.90 1.64 1.00 1.00 1.40 1.25 / / 4.00 5.28 16.69 17.42 17.59 18.15 21.06 17.31 28.77 29.17 37.93 39.04 39.48
420
- │ │ │ ├─apple_m3_mba15 0.90 0.90 1.68 1.00 1.00 1.53 1.24 / / 4.06 5.27 16.68 17.43 17.56 18.09 21.07 17.29 28.63 29.06 38.46 32.32 39.43
421
- │ │ │ ├─aws_graviton_2_neoverse_n1_ec2_m6g_xlarge 0.46 1.47 0.38 1.00 1.00 1.38 2.01 / / 5.42 8.76 10.21 14.17 15.98 17.91 22.65 25.25 28.68 29.63 33.95 41.90 40.25
422
- │ │ │ └─aws_graviton_3_neoverse_v1_ec2_m7g_xlarge 0.51 1.00 0.01 1.00 1.00 1.50 1.99 / / 6.03 9.58 11.89 14.81 17.49 19.20 19.09 27.67 30.26 31.49 36.85 42.45 40.96
423
- │ │ └─specs 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.73 2.12 7.50 8.25 / / / / / / / / / / /
424
- │ │ ├─arm_cortex_a76 1.00 1.00 1.00 1.00 1.00 1.50 1.50 2.00 3.00 7.50 8.50 / / / / / / / / / / /
425
- │ │ ├─arm_cortex_x1 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 7.50 8.00 / / / / / / / / / / /
426
- │ │ ├─arm_neoverse_n1 1.00 1.00 1.00 1.00 1.00 1.50 1.50 2.00 3.00 7.50 8.50 / / / / / / / / / / /
427
- │ │ └─arm_neoverse_v1 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 7.50 8.00 / / / / / / / / / / /
428
- │ ├─v9_0 0.74 1.00 0.25 1.00 1.00 1.51 1.80 1.27 1.27 6.78 8.83 14.32 17.90 20.66 22.09 24.04 32.41 35.53 37.31 44.86 52.70 48.30
429
- │ │ ├─benchmarks 0.54 1.00 0.06 1.00 1.00 1.52 2.16 / / 6.14 9.75 12.12 15.15 17.49 18.70 20.35 27.44 30.08 31.59 37.98 44.62 40.89
430
- │ │ │ ├─aws_graviton_4_neoverse_v2_ec2_m8g_xlarge 0.52 1.00 0.01 1.00 1.00 1.50 2.05 / / 6.04 9.49 12.66 14.40 17.66 18.54 19.86 27.12 28.76 30.11 36.90 42.70 38.65
431
- │ │ │ └─azure_cobalt_100_neoverse_n2_github_actions 0.57 1.00 0.33 1.00 1.00 1.53 2.28 / / 6.23 10.02 11.61 15.94 17.33 18.87 20.85 27.76 31.46 33.15 39.09 46.62 43.26
432
- │ │ └─specs 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 7.50 8.00 / / / / / / / / / / /
433
- │ │ ├─arm_cortex_x2 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 7.50 8.00 / / / / / / / / / / /
434
- │ │ ├─arm_cortex_x3 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 7.50 8.00 / / / / / / / / / / /
435
- │ │ ├─arm_neoverse_n2 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 7.50 8.00 / / / / / / / / / / /
436
- │ │ └─arm_neoverse_v2 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 7.50 8.00 / / / / / / / / / / /
437
- │ └─v9_2 1.16 1.16 1.55 1.02 1.00 1.51 1.55 1.66 1.66 5.80 6.70 18.44 20.04 19.11 19.75 22.96 19.23 29.29 31.69 40.89 34.73 42.11
438
- │ ├─benchmarks 1.35 1.35 2.40 1.03 1.00 1.51 1.84 / / 5.32 7.10 20.38 22.15 21.13 21.83 25.38 21.25 32.38 35.03 45.20 38.39 46.55
439
- │ │ └─apple_m4_pro_mbp16 1.35 1.35 2.40 1.03 1.00 1.51 1.84 / / 5.32 7.10 20.38 22.15 21.13 21.83 25.38 21.25 32.38 35.03 45.20 38.39 46.55
440
- │ └─specs 1.00 1.00 1.00 1.00 1.00 1.50 1.31 1.50 1.50 6.33 6.33 / / / / / / / / / / /
441
- │ ├─arm_cortex_x4 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 6.50 6.50 / / / / / / / / / / /
442
- │ ├─arm_cortex_x925 1.00 1.00 1.00 1.00 1.00 1.50 1.00 1.50 1.50 6.00 6.00 / / / / / / / / / / /
443
- │ └─arm_neoverse_v3 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 6.50 6.50 / / / / / / / / / / /
444
- └─x86 0.21 0.49 1.50 0.98 1.00 1.30 1.97 2.46 2.31 4.98 7.15 15.62 16.40 18.29 23.83 22.58 24.87 28.39 28.70 41.03 41.15 43.35
445
- ├─amd 0.25 0.45 1.52 0.99 1.00 1.17 1.22 2.39 2.51 4.74 7.38 18.22 16.50 17.98 24.59 23.73 24.13 28.04 28.30 42.41 40.31 45.11
446
- │ ├─2017_zen1 0.34 0.34 1.16 1.00 1.00 1.29 1.34 3.07 3.07 4.18 6.44 63.95 19.71 17.05 32.24 43.83 18.79 30.58 30.27 57.99 39.24 66.55
447
- │ │ ├─benchmarks 0.35 0.35 0.58 1.01 1.00 1.24 1.34 / / 4.03 6.23 58.90 18.16 15.70 29.69 40.37 17.30 28.16 27.88 53.41 36.14 61.29
448
- │ │ │ └─amd_ryzen_1700x 0.35 0.35 0.58 1.01 1.00 1.24 1.34 / / 4.03 6.23 58.90 18.16 15.70 29.69 40.37 17.30 28.16 27.88 53.41 36.14 61.29
449
- │ │ └─other 0.33 0.33 2.33 1.00 1.00 1.33 1.33 3.33 3.33 4.33 6.67 / / / / / / / / / / /
450
- │ │ └─analysis_uops_info_zen1+ 0.33 0.33 2.33 1.00 1.00 1.33 1.33 3.33 3.33 4.33 6.67 / / / / / / / / / / /
451
- │ ├─2020_zen3 0.18 0.34 1.16 1.00 1.00 0.98 1.00 2.17 2.34 4.36 6.76 11.69 15.85 16.99 22.46 19.32 21.13 24.05 24.07 38.13 38.04 39.06
452
- │ │ ├─benchmark 0.10 0.34 0.68 1.00 1.00 1.00 1.00 / / 4.30 6.86 10.33 14.01 15.02 19.86 17.08 18.69 21.26 21.28 33.72 33.63 34.54
453
- │ │ │ ├─amd_epyc_7763_linux_github 0.10 0.34 0.68 1.00 1.00 1.00 1.00 / / 4.31 6.86 10.35 11.79 15.35 14.36 14.53 22.21 22.45 22.86 30.57 33.34 31.25
454
- │ │ │ └─amd_epyc_7763_windows_github 0.10 0.34 0.68 1.00 1.00 1.00 1.00 / / 4.28 6.86 10.32 16.65 14.70 27.48 20.08 15.72 20.14 19.82 37.19 33.92 38.17
455
- │ │ └─other 0.33 0.33 1.97 1.00 1.00 0.95 1.00 2.45 2.65 4.42 6.67 / / / / / / / / / / /
456
- │ │ ├─analysis_agner_fog_r7_5800x 0.33 0.33 1.67 1.00 1.00 / 1.00 2.00 2.33 4.50 6.67 / / / / / / / / / / /
457
- │ │ └─analysis_uops_info_zen3 0.33 0.33 2.33 1.00 1.00 1.00 1.00 3.00 3.00 4.33 6.67 / / / / / / / / / / /
458
- │ ├─2022_zen4 0.15 0.33 1.41 0.99 1.00 0.99 1.00 1.85 1.78 4.41 6.92 10.77 12.47 17.12 20.49 15.83 25.03 24.11 24.56 32.21 35.99 33.32
459
- │ │ ├─benchmark 0.07 0.33 1.57 0.97 1.00 0.98 0.99 / / 4.49 6.95 9.97 11.55 15.86 18.98 14.66 23.19 22.34 22.75 29.84 33.34 30.87
460
- │ │ │ └─amd_epyc_9r14_ec2_m7a_xlarge 0.07 0.33 1.57 0.97 1.00 0.98 0.99 / / 4.49 6.95 9.97 11.55 15.86 18.98 14.66 23.19 22.34 22.75 29.84 33.34 30.87
461
- │ │ └─other 0.33 0.33 1.28 1.00 1.00 1.01 1.00 2.00 1.92 4.33 6.89 / / / / / / / / / / /
462
- │ │ ├─analysis_agner_fog_r9_7900x 0.33 0.33 1.33 1.00 1.00 / 1.00 2.00 2.00 4.33 7.00 / / / / / / / / / / /
463
- │ │ ├─analysis_uops_info_zen4 0.33 0.33 2.33 1.00 1.00 1.00 1.00 3.00 2.67 4.33 7.00 / / / / / / / / / / /
464
- │ │ └─specs_amd 0.33 0.33 0.67 1.00 1.00 1.00 1.00 1.33 1.33 4.33 6.67 / / / / / / / / / / /
465
- │ └─2024_zen5 0.39 1.04 2.83 0.95 1.00 1.50 1.68 2.64 3.08 6.31 9.84 13.71 19.04 21.09 24.62 23.64 34.12 34.84 35.83 45.40 49.16 47.78
466
- │ ├─benchmark 0.21 1.53 2.95 0.91 1.00 1.36 1.87 / / 6.12 9.69 13.33 18.50 20.50 23.94 22.98 33.17 33.87 34.83 44.14 47.79 46.45
467
- │ │ └─amd_epyc_9r45_ec2_m8a_xlarge 0.21 1.53 2.95 0.91 1.00 1.36 1.87 / / 6.12 9.69 13.33 18.50 20.50 23.94 22.98 33.17 33.87 34.83 44.14 47.79 46.45
468
- │ └─other 0.71 0.71 2.72 1.00 1.00 1.66 1.50 2.72 3.17 6.50 10.00 / / / / / / / / / / /
469
- │ ├─analysis_agner_fog_r7_9800x3d 1.00 1.00 3.00 1.00 1.00 / 1.50 3.00 3.50 6.50 10.00 / / / / / / / / / / /
470
- │ └─specs_amd 0.50 0.50 / 1.00 1.00 1.50 1.50 / / 6.50 10.00 / / / / / / / / / / /
471
- └─intel 0.18 0.53 1.47 0.98 1.00 1.45 3.17 2.53 2.14 5.23 6.93 13.38 16.30 18.60 23.09 21.50 25.64 28.75 29.11 39.70 42.01 41.67
472
- ├─2017_coffee_lake_gen_8 0.14 0.40 1.12 0.98 1.00 1.03 1.99 1.69 1.69 3.54 4.56 10.27 16.31 12.42 19.10 21.50 12.84 20.48 20.47 32.65 28.21 35.74
473
- │ ├─benchmarks 0.08 0.63 1.73 0.96 1.00 1.05 1.99 / / 3.45 4.78 10.69 16.98 12.92 19.88 22.38 13.37 21.31 21.31 33.99 29.36 37.20
474
- │ │ ├─intel_i7_8550U_windows 0.08 0.44 1.69 1.01 1.00 1.01 2.00 / / 3.15 4.79 7.02 15.44 11.99 30.07 21.33 13.00 17.80 17.21 32.36 28.09 35.06
475
- │ │ └─intel_i7_8700B_macos_github_actions 0.08 0.91 1.77 0.92 1.00 1.10 1.97 / / 3.78 4.77 16.30 18.68 13.93 13.15 23.47 13.74 25.51 26.38 35.70 30.68 39.48
476
- │ └─other 0.25 0.25 0.73 1.00 1.00 1.00 2.00 1.62 1.62 3.62 4.36 / / / / / / / / / / /
477
- │ ├─analysis_agner_fog_coffee_lake 0.25 0.25 / 1.00 1.00 1.00 2.00 1.50 1.50 3.50 4.00 / / / / / / / / / / /
478
- │ └─analysis_uops_info_coffee_lake 0.25 0.25 0.75 1.00 1.00 1.00 2.00 1.75 1.75 3.75 4.75 / / / / / / / / / / /
479
- ├─2019_sunny_cove_gen_10 0.10 0.33 0.92 0.95 1.00 0.98 1.94 1.60 1.60 3.58 4.54 12.27 9.43 14.01 17.18 13.39 20.23 19.23 19.83 28.71 29.72 28.95
480
- │ ├─benchmarks 0.04 0.44 1.30 0.91 1.00 1.00 1.89 / / 3.50 4.60 11.82 9.08 13.49 16.55 12.90 19.48 18.52 19.09 27.65 28.63 27.88
481
- │ │ └─intel_xeon_8375c_ice_lake_ec2_m6i_xlarge 0.04 0.44 1.30 0.91 1.00 1.00 1.89 / / 3.50 4.60 11.82 9.08 13.49 16.55 12.90 19.48 18.52 19.09 27.65 28.63 27.88
482
- │ └─other 0.25 0.25 0.66 1.00 1.00 0.97 2.00 1.66 1.66 3.66 4.49 / / / / / / / / / / /
483
- │ ├─analysis_agner_fog_ice_lake 0.25 0.25 0.50 1.00 1.00 / 2.00 1.50 1.50 3.50 4.00 / / / / / / / / / / /
484
- │ ├─analysis_uops_info_ice_lake 0.25 0.25 0.75 1.00 1.00 1.00 2.00 1.75 1.75 3.75 4.75 / / / / / / / / / / /
485
- │ └─analysis_uops_info_tiger_lake 0.25 0.25 0.75 1.00 1.00 1.00 2.00 1.75 1.75 3.75 4.75 / / / / / / / / / / /
486
- ├─2021_golden_cove_gen_12 0.23 0.64 1.76 0.99 1.00 1.80 4.05 3.11 2.63 6.34 8.58 14.98 18.37 21.93 25.63 24.02 32.77 34.73 35.06 44.04 50.72 46.59
487
- │ ├─benchmarks 0.13 0.99 2.52 0.98 1.00 1.99 5.03 / / 6.80 9.74 16.28 19.97 23.84 27.86 26.11 35.63 37.76 38.12 47.88 55.14 50.65
488
- │ │ └─intel_xeon_8488c_sapphire_rapids_ec2_m7i_xlarge 0.13 0.99 2.52 0.98 1.00 1.99 5.03 / / 6.80 9.74 16.28 19.97 23.84 27.86 26.11 35.63 37.76 38.12 47.88 55.14 50.65
489
- │ └─other 0.41 0.41 1.22 1.00 1.00 1.63 3.27 2.86 2.42 5.92 7.55 / / / / / / / / / / /
490
- │ ├─analysis_uops_info_alder_lake_p 0.33 0.33 1.00 1.00 1.00 1.33 2.67 2.33 2.33 5.00 6.33 / / / / / / / / / / /
491
- │ └─specs_intel 0.50 0.50 1.50 1.00 1.00 2.00 4.00 3.50 2.50 7.00 9.00 / / / / / / / / / / /
492
- ├─2022_raptor_cove_gen_13_14 0.26 0.71 1.96 1.00 1.00 2.00 4.51 3.55 2.53 7.00 9.49 15.73 19.93 24.00 28.64 26.02 35.73 37.86 38.33 49.02 55.79 51.16
493
- │ ├─benchmarks 0.13 1.00 2.55 1.00 1.00 2.00 5.08 / / 7.00 10.00 15.95 20.20 24.33 29.03 26.37 36.21 38.37 38.85 49.69 56.55 51.86
494
- │ │ └─intel_xeon_8559c_emerald_rapids_ec2_i7i_xlarge 0.13 1.00 2.55 1.00 1.00 2.00 5.08 / / 7.00 10.00 15.95 20.20 24.33 29.03 26.37 36.21 38.37 38.85 49.69 56.55 51.86
495
- │ └─other 0.50 0.50 1.50 1.00 1.00 2.00 4.00 3.50 2.50 7.00 9.00 / / / / / / / / / / /
496
- │ └─specs_intel 0.50 0.50 1.50 1.00 1.00 2.00 4.00 3.50 2.50 7.00 9.00 / / / / / / / / / / /
497
- └─2023_redwood_cove_ultra_1 0.24 0.71 1.95 0.99 1.00 1.73 4.51 3.46 2.47 6.97 9.47 14.44 20.41 24.32 27.29 25.53 36.40 37.92 38.32 48.75 55.19 50.95
498
- ├─benchmarks 0.12 1.01 2.53 0.98 1.00 1.50 5.09 / / 6.94 9.96 14.28 20.19 24.06 26.99 25.26 36.01 37.51 37.91 48.22 54.60 50.40
499
- │ └─intel_xeon_6975p_granite_rapids_ec2_m8i_xlarge 0.12 1.01 2.53 0.98 1.00 1.50 5.09 / / 6.94 9.96 14.28 20.19 24.06 26.99 25.26 36.01 37.51 37.91 48.22 54.60 50.40
500
- └─other 0.50 0.50 1.50 1.00 1.00 2.00 4.00 3.50 2.50 7.00 9.00 / / / / / / / / / / /
501
- └─specs_intel 0.50 0.50 1.50 1.00 1.00 2.00 4.00 3.50 2.50 7.00 9.00 / / / / / / / / / / /
502
-
503
-
504
- ```
505
-
506
- ## 4.2. Test performance of `CountedFloat` vs `float`
507
-
508
- ```
509
- [~] counted_float benchmark-counted-float
510
- ```
511
- See next section for results.
512
-
513
- # 5. Performance impact
514
-
515
- Obviously, using `CountedFloat` instead of regular `float` will have a performance impact due to the overhead of counting operations.
516
- It is not advised to use `CountedFloat` for production code, but just for research code for which you want to estimate the floating-point operation count.
517
-
518
- Micro-benchmarking of a bisection algorithm using `counted_float benchmark-counted-float` teaches us this:
519
- ```
520
- ------------------------------------------------------------------------------------------------------------------------
521
- Running CountedFloat benchmark...
522
-
523
- float : wwwwwwwwwwwwwww................................... [ 12.34 µs ± 1.2% | 50.1K cpu cycles ± 1.2% ] / execution
524
- CountedFloat : wwwwwwwwwwwwwww................................... [ 459.95 µs ± 0.2% | 1.87M cpu cycles ± 0.2% ] / execution
525
- ------------------------------------------------------------------------------------------------------------------------
526
-
527
- CountedFloat Benchmark Results:
528
- Bisection using float : 12.34 µs / execution
529
- Bisection using CountedFloat : 459.95 µs / execution
530
-
531
- CountedFloat is 37.3x slower than float
532
- ```
533
-
534
- # 6. Known limitations
535
-
536
- - currently any non-Python-built-in math operations are not counted (e.g. `numpy`)
537
- - not all Python built-in math operations are counted (e.g. hyperbolic functions)
538
- - flop weights should be taken with a grain of salt and should only provide relative ballpark estimates w.r.t computational complexity. Production implementations in a compiled language could have vastly differing performance depending on cpu cache sizes, branch prediction misses, compiler optimizations using vector operations (AVX etc...), etc...
539
-
540
- # Appendix A - Flop counting / analysis details
541
-
542
- This appendix provides detailed information about how each floating-point operation (FLOP) type is counted and analyzed in the `counted-float` package. All `math.*` entries below assume an active `FlopCountingContext` (outside one, the `math` module is not instrumented). For each flop type, you will find:
543
- - Relevant scalar instructions for ARM (v8+) and x86 (SSE2+)
544
- - Python operations that are counted for this flop type
545
- - Python operations that are *not* counted for this flop type
546
-
547
- ## Flop Types
548
-
549
- ### FlopType.ABS (`abs(x)`)
550
- - Relevant CPU instructions
551
- - **ARM:** `FABS`
552
- - **x86:** `ANDPD`
553
- - **Counted Python operations:** `abs(x)` where `x` is a `CountedFloat`
554
- - **Not counted:** `numpy.abs`, complex abs, abs on non-CountedFloat
555
-
556
- ### FlopType.MINUS (`-x`)
557
- - Relevant CPU instructions
558
- - **ARM:** `FNEG`
559
- - **x86:** `XORPD`
560
- - **Counted Python operations:** Unary minus (`-x`) for `CountedFloat`
561
- - **Not counted:** Negation on non-CountedFloat, numpy negation
562
-
563
- ### FlopType.COMP (`x<=y`, `x>y`, `x==y`, `x==0.0`, ...)
564
- - Relevant CPU instructions
565
- - **ARM:** `FCMP`
566
- - **x86:** `(U)COMISD`
567
- - **Counted Python operations:** `x == y`, `x != y`, `x <= y`, ... and `min(x,y)`, `max(x,y)` for `CountedFloat`
568
- - **Not counted:** Comparisons on non-CountedFloat, numpy comparisons
569
-
570
- ### FlopType.RND (`round`)
571
- - Relevant CPU instructions
572
- - **ARM:** `FRINT`
573
- - **x86:** `ROUNDSD`
574
- - **Counted Python operations:** `round(x, 0)` for `CountedFloat` (returns float)
575
- - **Not counted:** `numpy.round`, rounding with decimals, rounding on non-CountedFloat
576
-
577
- ### FlopType.F2I (`float->int`)
578
- - Relevant CPU instructions
579
- - **ARM:** `FCVTZS`
580
- - **x86:** `CVTSD2SI`
581
- - **Counted Python operations:** `int(x)`, `math.floor(x)`, `math.ceil(x)`, `math.trunc(x)`, `round(x)` for `CountedFloat` (returns int)
582
- - **Not counted:** Conversions on non-CountedFloat, numpy conversions
583
-
584
- ### FlopType.I2F (`int->float`)
585
- - Relevant CPU instructions
586
- - **ARM:** `SCVTF`
587
- - **x86:** `CVTSI2SD`
588
- - **Counted Python operations:** Construction of `CountedFloat` from int, any binary operation where one operand is an int and the other a `CountedFloat` (e.g., `x + 3`, `3 * x`, etc.)
589
- - **Not counted:** `float(n)`, unitary operations (e.g. `math.sqrt` on integers -> convert to `CountedFloat` first)
590
-
591
- ### FlopType.ADD (`x+y`)
592
- - Relevant CPU instructions
593
- - **ARM:** `FADD`
594
- - **x86:** `ADDSD`
595
- - **Counted Python operations:** `x + y` or `y + x` for `CountedFloat`
596
- - **Not counted:** Addition on non-CountedFloat, numpy addition
597
-
598
- ### FlopType.SUB (`x-y`)
599
- - Relevant CPU instructions
600
- - **ARM:** `FSUB`
601
- - **x86:** `SUBSD`
602
- - **Counted Python operations:** `x - y` or `y - x` for `CountedFloat`
603
- - **Not counted:** Subtraction on non-CountedFloat, numpy subtraction
604
-
605
- ### FlopType.MUL (`x*y`)
606
- - Relevant CPU instructions
607
- - **ARM:** `FMUL`
608
- - **x86:** `MULSD`
609
- - **Counted Python operations:** `x * y` or `y * x` for `CountedFloat`
610
- - **Not counted:** Multiplication on non-CountedFloat, numpy multiplication
611
-
612
- ### FlopType.DIV (`x/y`)
613
- - Relevant CPU instructions
614
- - **ARM:** `FDIV`
615
- - **x86:** `DIVSD`
616
- - **Counted Python operations:** `x / y` or `y / x` for `CountedFloat`
617
- - **Not counted:** Division on non-CountedFloat, numpy division
618
-
619
- ### FlopType.SQRT (`sqrt(x)`)
620
- - Relevant CPU instructions
621
- - **ARM:** `FSQRT`
622
- - **x86:** `SQRTSD`
623
- - **Counted Python operations:** `math.sqrt(x)` for `CountedFloat`
624
- - **Not counted:** `numpy.sqrt`, sqrt on non-CountedFloat
625
-
626
- ### FlopType.CBRT (`cbrt(x)`)
627
- - Relevant CPU instructions
628
- - **ARM:** (software)
629
- - **x86:** (software)
630
- - **Counted Python operations:** `math.cbrt(x)` for `CountedFloat`
631
- - **Not counted:** `numpy.cbrt`, cbrt on non-CountedFloat
632
-
633
- ### FlopType.EXP (`e^x`)
634
- - Relevant CPU instructions
635
- - **ARM:** (software)
636
- - **x86:** (software)
637
- - **Counted Python operations:** `math.exp(x)` for `CountedFloat`
638
- - **Not counted:** `math.exp(x)` on non-CountedFloat, `numpy.exp`, `math.expm1`, `math.e ** x`
639
-
640
- ### FlopType.EXP2 (`2^x`)
641
- - Relevant CPU instructions
642
- - **ARM:** (software)
643
- - **x86:** (software)
644
- - **Counted Python operations:** `2 ** x`, `pow(2, x)` or `math.exp2(x)` for `CountedFloat`
645
- - **Not counted:** `exp2` on non-CountedFloat, `numpy.exp2`
646
-
647
- ### FlopType.EXP10 (`10^x`)
648
- - Relevant CPU instructions
649
- - **ARM:** (software)
650
- - **x86:** (software)
651
- - **Counted Python operations:** `10 ** x`, `pow(10, x)` for `CountedFloat`
652
- - **Not counted:** `10 ** x` on non-CountedFloat
653
-
654
- ### FlopType.LOG (`log(x)`)
655
- - Relevant CPU instructions
656
- - **ARM:** (software)
657
- - **x86:** (software)
658
- - **Counted Python operations:** `math.log(x)` for `CountedFloat`; `math.log(x, base)` for `CountedFloat` decomposes per the constant-detection heuristic (int base 2/10 -> LOG2/LOG10; other int base -> LOG+MUL; float base -> LOG per counted operand + DIV)
659
- - **Not counted:** `numpy.log`, log on non-CountedFloat
660
-
661
- ### FlopType.LOG2 (`log2(x)`)
662
- - Relevant CPU instructions
663
- - **ARM:** (software)
664
- - **x86:** (software)
665
- - **Counted Python operations:** `math.log2(x)` for `CountedFloat`; `math.log(x, 2)` (int base) for `CountedFloat`
666
- - **Not counted:** `numpy.log2`, log2 on non-CountedFloat
667
-
668
- ### FlopType.LOG10 (`log10(x)`)
669
- - Relevant CPU instructions
670
- - **ARM:** (software)
671
- - **x86:** (software)
672
- - **Counted Python operations:** `math.log10(x)` for `CountedFloat`; `math.log(x, 10)` (int base) for `CountedFloat`
673
- - **Not counted:** `numpy.log10`, log10 on non-CountedFloat
674
-
675
- ### FlopType.POW (`x^y`)
676
- - Relevant CPU instructions
677
- - **ARM:** (software)
678
- - **x86:** (software)
679
- - **Counted Python operations:** `x ** y`, `pow(x, y)` for `CountedFloat`
680
- - **Not counted:** `pow` on non-CountedFloat, `numpy.pow`
681
-
682
- ### FlopType.SIN (`sin(x)`)
683
- - Relevant CPU instructions
684
- - **ARM:** (software)
685
- - **x86:** (software)
686
- - **Counted Python operations:** `math.sin(x)` for `CountedFloat`
687
- - **Not counted:** `sin` on non-CountedFloat, `numpy.sin`
688
-
689
- ### FlopType.COS (`cos(x)`)
690
- - Relevant CPU instructions
691
- - **ARM:** (software)
692
- - **x86:** (software)
693
- - **Counted Python operations:** `math.cos(x)` for `CountedFloat`
694
- - **Not counted:** `cos` on non-CountedFloat, `numpy.cos`
695
-
696
- ### FlopType.TAN (`tan(x)`)
697
- - Relevant CPU instructions
698
- - **ARM:** (software)
699
- - **x86:** (software)
700
- - **Counted Python operations:** `math.tan(x)` for `CountedFloat`
701
- - **Not counted:** `tan` on non-CountedFloat, `numpy.tan
File without changes
File without changes