counted-float 0.9.3__tar.gz → 0.9.5__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 (86) hide show
  1. counted_float-0.9.5/PKG-INFO +608 -0
  2. counted_float-0.9.5/README.md +587 -0
  3. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/__init__.py +2 -2
  4. counted_float-0.9.5/counted_float/_core/benchmarking/__init__.py +11 -0
  5. counted_float-0.9.5/counted_float/_core/benchmarking/flops/__init__.py +3 -0
  6. counted_float-0.9.5/counted_float/_core/benchmarking/flops/_array_generator.py +76 -0
  7. counted_float-0.9.5/counted_float/_core/benchmarking/flops/_flops_benchmark_suite.py +375 -0
  8. counted_float-0.9.5/counted_float/_core/benchmarking/flops/_flops_micro_benchmark.py +67 -0
  9. counted_float-0.9.5/counted_float/_core/benchmarking/micro/__init__.py +1 -0
  10. {counted_float-0.9.3/counted_float/_core/benchmarking → counted_float-0.9.5/counted_float/_core/benchmarking/micro}/_micro_benchmark.py +23 -28
  11. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/compatibility/__init__.py +0 -1
  12. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/counting/_builtin_data.py +10 -4
  13. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/counting/_counted_float.py +150 -35
  14. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/counting/_global_counter.py +34 -13
  15. counted_float-0.9.5/counted_float/_core/counting/config/__init__.py +2 -0
  16. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/counting/config/_defaults.py +1 -32
  17. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/models/__init__.py +4 -2
  18. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/models/_flop_counts.py +12 -5
  19. counted_float-0.9.5/counted_float/_core/models/_flop_type.py +35 -0
  20. counted_float-0.9.5/counted_float/_core/models/_flops_benchmark_meta_data.py +128 -0
  21. counted_float-0.9.3/counted_float/_core/models/_flops_benchmark_result.py → counted_float-0.9.5/counted_float/_core/models/_flops_benchmark_result_v1.py +7 -27
  22. counted_float-0.9.5/counted_float/_core/models/_flops_benchmark_result_v2.py +26 -0
  23. counted_float-0.9.5/counted_float/_core/models/_flops_benchmark_type.py +32 -0
  24. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/models/_instruction_latencies.py +10 -10
  25. counted_float-0.9.5/counted_float/_core/models/_micro_benchmark_result.py +62 -0
  26. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/utils/__init__.py +1 -1
  27. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/utils/_formatting.py +6 -6
  28. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/utils/_latency.py +1 -1
  29. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/benchmarking/__init__.py +2 -2
  30. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/config/__init__.py +0 -4
  31. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/arm/v8_x/benchmarks/m3_max_macbook_pro_16.json +29 -26
  32. counted_float-0.9.5/counted_float/data/arm/v8_x/benchmarks/m3_max_macbook_pro_16_v2.json +196 -0
  33. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/arm/v8_x/specs/arm_v8_cortex_a76.json +5 -0
  34. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/arm/v8_x/specs/arm_v9_cortex_n1.json +5 -0
  35. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/arm/v8_x/specs/arm_v9_cortex_v1.json +5 -0
  36. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/arm/v8_x/specs/arm_v9_cortex_x1.json +5 -0
  37. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_n2.json +5 -0
  38. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_v2.json +5 -0
  39. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_x2.json +5 -0
  40. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_x3.json +5 -0
  41. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/arm/v9_2/specs/arm_v9_cortex_v3.json +5 -0
  42. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/arm/v9_2/specs/arm_v9_cortex_x4.json +5 -0
  43. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/arm/v9_2/specs/arm_v9_cortex_x925.json +5 -0
  44. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/amd/2017_zen1/analysis_uops_info_zen1+.json +5 -0
  45. counted_float-0.9.5/counted_float/data/x86/amd/2017_zen1/benchmark_ryzen_1700x.json +106 -0
  46. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/amd/2020_zen3/analysis_agner_fog_r7_5800x.json +5 -0
  47. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/amd/2020_zen3/analysis_uops_info_zen3.json +5 -0
  48. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/amd/2022_zen4/analysis_agner_fog_r9_7900x.json +5 -0
  49. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/amd/2022_zen4/analysis_uops_info_zen4.json +5 -0
  50. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/amd/2022_zen4/specs_amd.json +5 -0
  51. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/amd/2024_zen5/analysis_agner_fog_r7_9800x3d.json +5 -0
  52. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/amd/2024_zen5/specs_amd.json +5 -0
  53. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/intel/2017_coffee_lake_gen_8/analysis_agner_fog_coffee_lake.json +5 -0
  54. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/intel/2017_coffee_lake_gen_8/analysis_uops_info_coffee_lake.json +5 -0
  55. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/analysis_agner_fog_ice_lake.json +5 -0
  56. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/analysis_uops_info_ice_lake.json +5 -0
  57. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/analysis_uops_info_tiger_lake.json +5 -0
  58. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/intel/2021_golden_cove_gen_12/analysis_uops_info_alder_lake_p.json +5 -0
  59. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/intel/2021_golden_cove_gen_12/benchmark_core_i7_1265u.json +29 -26
  60. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/intel/2021_golden_cove_gen_12/specs_intel.json +5 -0
  61. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/intel/2022_raptor_cove_gen_13_14/specs_intel.json +5 -0
  62. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/data/x86/intel/2023_redwood_cove_ultra_1/specs_intel.json +5 -0
  63. {counted_float-0.9.3 → counted_float-0.9.5}/pyproject.toml +4 -4
  64. counted_float-0.9.3/PKG-INFO +0 -382
  65. counted_float-0.9.3/README.md +0 -361
  66. counted_float-0.9.3/counted_float/_core/benchmarking/__init__.py +0 -19
  67. counted_float-0.9.3/counted_float/_core/benchmarking/_flops_benchmark_suite.py +0 -193
  68. counted_float-0.9.3/counted_float/_core/benchmarking/_flops_micro_benchmark.py +0 -59
  69. counted_float-0.9.3/counted_float/_core/benchmarking/_time_utils.py +0 -1
  70. counted_float-0.9.3/counted_float/_core/compatibility/_strenum.py +0 -6
  71. counted_float-0.9.3/counted_float/_core/counting/config/__init__.py +0 -7
  72. counted_float-0.9.3/counted_float/_core/models/_flop_type.py +0 -47
  73. counted_float-0.9.3/counted_float/_core/models/_micro_benchmark_result.py +0 -41
  74. {counted_float-0.9.3 → counted_float-0.9.5}/.gitignore +0 -0
  75. {counted_float-0.9.3 → counted_float-0.9.5}/LICENSE +0 -0
  76. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/__init__.py +0 -0
  77. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/_cli.py +0 -0
  78. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/compatibility/_numba.py +0 -0
  79. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/counting/__init__.py +0 -0
  80. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/counting/_context_managers.py +0 -0
  81. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/counting/config/_config.py +0 -0
  82. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/models/_base.py +0 -0
  83. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/models/_flop_weights.py +0 -0
  84. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/utils/_geo_mean.py +0 -0
  85. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/utils/_missing_data.py +0 -0
  86. {counted_float-0.9.3 → counted_float-0.9.5}/counted_float/_core/utils/_timer.py +0 -0
@@ -0,0 +1,608 @@
1
+ Metadata-Version: 2.4
2
+ Name: counted-float
3
+ Version: 0.9.5
4
+ Summary: Count floating-point operations in Python code & benchmark relative flop costs.
5
+ Project-URL: Source, https://github.com/bertpl/counted-float
6
+ Project-URL: ChangeLog, https://github.com/bertpl/counted-float/blob/develop/CHANGELOG.md
7
+ Project-URL: Issues, https://github.com/bertpl/counted-float/issues
8
+ Project-URL: Roadmap, https://github.com/bertpl/counted-float/milestones
9
+ License-File: LICENSE
10
+ Requires-Python: >=3.11
11
+ Requires-Dist: numpy>=1.20
12
+ Requires-Dist: psutil>=5.0
13
+ Requires-Dist: py-cpuinfo>=9.0.0
14
+ Requires-Dist: pydantic>=2.0.0
15
+ Requires-Dist: rich>=13.0.0
16
+ Provides-Extra: cli
17
+ Requires-Dist: click>=8.0.0; extra == 'cli'
18
+ Provides-Extra: numba
19
+ Requires-Dist: numba>=0.50; extra == 'numba'
20
+ Description-Content-Type: text/markdown
21
+
22
+ <!--START_SECTION:images-->
23
+ ![shields.io-python-versions](https://img.shields.io/badge/python-3.11%20%7C%203.12%20%7C%203.13-blue)
24
+ ![genbadge-test-count](https://bertpl.github.io/counted-float/version_artifacts/v0.9.5/badge-test-count.svg)
25
+ ![genbadge-test-coverage](https://bertpl.github.io/counted-float/version_artifacts/v0.9.5/badge-coverage.svg)
26
+ ![counted_float logo](https://bertpl.github.io/counted-float/version_artifacts/v0.9.5/splash.webp)
27
+ <!--END_SECTION:images-->
28
+
29
+ # counted-float
30
+
31
+ This Python package provides functionality for...
32
+ - **counting floating point operations** (FLOPs) of numerical algorithms implemented in plain Python, optionally weighted by their relative cost of execution
33
+ - **running benchmarks** to estimate the relative cost of executing various floating-point operations (requires `numba` optional dependency for achieving accurate results)
34
+
35
+ The target application area is evaluation of research prototypes of numerical algorithms where (weighted) flop counting can be
36
+ useful for estimating total computational cost, in cases where benchmarking a compiled version (C, Rust, ...) is not
37
+ feasible or desirable.
38
+
39
+ # 1. Installation
40
+
41
+ Use you favorite package manager such as `uv` or `pip`:
42
+
43
+ ```
44
+ pip install counted-float # install without numba optional dependency
45
+ pip install counted-float[numba] # install with numba optional dependency
46
+ ```
47
+ Numba is optional due to its relatively large size (40-50MB, including llvmlite), but without it, benchmarks will
48
+ not be reliable (but will still run, but not in jit-compiled form).
49
+
50
+ NOTE: the `cli` optional dependency is only useful when installing the code as a tool using e.g. `uv` or `pipx` (see below)
51
+
52
+ # 2. Counting Flops
53
+
54
+ ## 2.1. CountedFloat class
55
+
56
+ In order to instrument all floating point operations with counting functionality,
57
+ the `CountedFloat` class was implemented, which is a drop-in replacement for the built-in `float` type.
58
+ The `CountedFloat` class is a subclass of `float` and is "contagious", meaning that it will automatically
59
+ ensure results of math operations where at least one operand is a `CountedFloat` will also be a `CountedFloat`.
60
+ This way we ensure flop counting is a 'closed system'.
61
+
62
+ On top of this, we monkey-patch the `math` module to ensure that all math operations
63
+ that require counting (`sqrt`, `log2`, `pow`, ...) are also instrumented.
64
+
65
+ **Example 1**:
66
+
67
+ ```python
68
+ from counted_float import CountedFloat
69
+
70
+ cf = CountedFloat(1.3)
71
+ f = 2.8
72
+
73
+ result = cf + f # result = CountedFloat(4.1)
74
+
75
+ is_float_1 = isinstance(cf, float) # True
76
+ is_float_2 = isinstance(result, float) # True
77
+ ```
78
+
79
+ **Example 2**:
80
+
81
+ ```python
82
+ import math
83
+ from counted_float import CountedFloat
84
+
85
+ cf1 = CountedFloat(0.81)
86
+
87
+ s = math.sqrt(cf1) # s = CountedFloat(0.9)
88
+ is_float = isinstance(s, float) # True
89
+ ```
90
+
91
+ ## 2.2. FLOP counting context managers
92
+
93
+ Once we use the `CountedFloat` class, we can use the available context managers to count the number of
94
+ flops performed by `CountedFloat` objects.
95
+
96
+ **Example 1**: _basic usage_
97
+ ```python
98
+ from counted_float import CountedFloat, FlopCountingContext
99
+
100
+ cf1 = CountedFloat(1.73)
101
+ cf2 = CountedFloat(2.94)
102
+
103
+ with FlopCountingContext() as ctx:
104
+ _ = cf1 * cf2
105
+ _ = cf1 + cf2
106
+
107
+ counts = ctx.flop_counts() # {FlopType.MUL: 1, FlopType.ADD: 1}
108
+ counts.total_count() # 2
109
+ ```
110
+
111
+ **Example 2**: _pause counting 1_
112
+
113
+ ```python
114
+ from counted_float import CountedFloat, FlopCountingContext
115
+
116
+ cf1 = CountedFloat(1.73)
117
+ cf2 = CountedFloat(2.94)
118
+
119
+ with FlopCountingContext() as ctx:
120
+ _ = cf1 * cf2
121
+ ctx.pause()
122
+ _ = cf1 + cf2 # will be executed but not counted
123
+ ctx.resume()
124
+ _ = cf1 - cf2
125
+
126
+ counts = ctx.flop_counts() # {FlopType.MUL: 1, FlopType.SUB: 1}
127
+ counts.total_count() # 2
128
+ ```
129
+
130
+ **Example 3**: _pause counting 2_
131
+
132
+ ```python
133
+ from counted_float import CountedFloat, FlopCountingContext, PauseFlopCounting
134
+
135
+ cf1 = CountedFloat(1.73)
136
+ cf2 = CountedFloat(2.94)
137
+
138
+ with FlopCountingContext() as ctx:
139
+ _ = cf1 * cf2
140
+ with PauseFlopCounting():
141
+ _ = cf1 + cf2 # will be executed but not counted
142
+ _ = cf1 - cf2
143
+
144
+ counts = ctx.flop_counts() # {FlopType.MUL: 1, FlopType.SUB: 1}
145
+ counts.total_count() # 2
146
+ ```
147
+
148
+ ## 2.3. Weighted FLOP counting
149
+
150
+ The `counted_float` package contains a set of default, built-in FLOP weights, based on both empirical measurements
151
+ and theoretical estimates of the relative cost of different floating point operations.
152
+
153
+ See [fpu_data_sources.md](https://github.com/bertpl/counted-float/tree/develop/docs/analysis_methodology.md) for
154
+ rationale behind choice of data sources and methodology.
155
+
156
+ ```
157
+ >>> from counted_float.config import get_active_flop_weights
158
+ >>> get_active_flop_weights().show()
159
+
160
+ {
161
+ FlopType.ABS [abs(x)] : 1
162
+ FlopType.MINUS [-x] : 1
163
+ FlopType.COMP [x<=y] : 1
164
+ FlopType.RND [round] : 2
165
+ FlopType.F2I [float->int] : 2
166
+ FlopType.I2F [int->float] : 2
167
+ FlopType.ADD [x+y] : 1
168
+ FlopType.SUB [x-y] : 1
169
+ FlopType.MUL [x*y] : 1
170
+ FlopType.DIV [x/y] : 5
171
+ FlopType.SQRT [sqrt(x)] : 6
172
+ FlopType.CBRT [cbrt(x)] : 42
173
+ FlopType.EXP [e^x] : 19
174
+ FlopType.EXP2 [2^x] : 29
175
+ FlopType.EXP10 [10^x] : 23
176
+ FlopType.LOG [log(x)] : 19
177
+ FlopType.LOG2 [log2(x)] : 24
178
+ FlopType.LOG10 [log10(x)] : 19
179
+ FlopType.POW [x^y] : 62
180
+ FlopType.SIN [sin(x)] : 32
181
+ FlopType.COS [cos(x)] : 31
182
+ FlopType.TAN [tan(x)] : 34
183
+ }
184
+ ```
185
+ These weights will be used by default when extracting total weighted flop costs:
186
+
187
+ ```python
188
+ import math
189
+ from counted_float import CountedFloat, FlopCountingContext
190
+
191
+
192
+ cf1 = CountedFloat(1.73)
193
+ cf2 = CountedFloat(2.94)
194
+
195
+ with FlopCountingContext() as ctx:
196
+ _ = cf1 + cf2
197
+ _ = cf1 ** cf2
198
+ _ = math.log2(cf2)
199
+
200
+ flop_counts = ctx.flop_counts()
201
+ total_cost = flop_counts.total_weighted_cost() # 1 + 62 + 24 = 87
202
+ ```
203
+ Note that the `total_weighted_cost` method will use the default flop weights as returned by `get_flop_weights()`. This can be
204
+ overridden by either configuring different flop weights (see next section) or by setting the `weights` argument of the `total_weighted_cost()` method.
205
+
206
+
207
+ ## 2.4. Configuring FLOP weights
208
+
209
+ We showed earlier that the `get_flop_weights()` function returns the default FLOP weights. We can change this by
210
+ using the `set_flop_weights()` function, which takes a `FlopWeights` object as an argument. This way we can configure
211
+ flop weights that might be obtained using benchmarks run on the target hardware (see later sections).
212
+
213
+ ```python
214
+ from counted_float.config import set_active_flop_weights
215
+ from counted_float import FlopWeights
216
+
217
+ set_active_flop_weights(weights=FlopWeights(...)) # insert own weights here
218
+ ```
219
+ ## 2.5. Inspecting built-in data
220
+
221
+ ### 2.5.1. Default, pre-aggregated flop weights
222
+
223
+ Built-in flop weights can be inspected using the following functions:
224
+
225
+ ```python
226
+ from counted_float.config import get_default_consensus_flop_weights
227
+
228
+ >>> get_default_consensus_flop_weights(rounded=False).show()
229
+
230
+ {
231
+ FlopType.ABS [abs(x)] : 0.63673
232
+ FlopType.MINUS [-x] : 0.64396
233
+ FlopType.COMP [x<=y] : 1.20756
234
+ FlopType.RND [round] : 1.54041
235
+ FlopType.F2I [float->int] : 1.99099
236
+ FlopType.I2F [int->float] : 1.84601
237
+ FlopType.ADD [x+y] : 1.00000
238
+ FlopType.SUB [x-y] : 1.00586
239
+ FlopType.MUL [x*y] : 1.37238
240
+ FlopType.DIV [x/y] : 5.07465
241
+ FlopType.SQRT [sqrt(x)] : 5.90559
242
+ FlopType.CBRT [cbrt(x)] : 42.39375
243
+ FlopType.EXP [e^x] : 18.58228
244
+ FlopType.EXP2 [2^x] : 28.88672
245
+ FlopType.EXP10 [10^x] : 22.86839
246
+ FlopType.LOG [log(x)] : 18.89135
247
+ FlopType.LOG2 [log2(x)] : 24.34792
248
+ FlopType.LOG10 [log10(x)] : 18.55085
249
+ FlopType.POW [x^y] : 61.79155
250
+ FlopType.SIN [sin(x)] : 31.91490
251
+ FlopType.COS [cos(x)] : 30.79295
252
+ FlopType.TAN [tan(x)] : 34.37970
253
+ }
254
+ ```
255
+
256
+ The default weights that are configured out-of-the-box in the package are the integer-rounded `consensus` weights.
257
+
258
+ ### 2.5.2. Custom-aggregated flop weights
259
+
260
+ We can retrieve built-in flop weights in a more fine-grained manner, by custom filtering and the aggregating them with
261
+ the geometric mean.
262
+
263
+ ```python
264
+ from counted_float.config import get_builtin_flop_weights
265
+
266
+ >>> get_builtin_flop_weights(key_filter="arm").show()
267
+
268
+ {
269
+ FlopType.ABS [abs(x)] : 0.97313
270
+ FlopType.MINUS [-x] : 0.99098
271
+ FlopType.COMP [x<=y] : 1.03987
272
+ FlopType.RND [round] : 1.35111
273
+ FlopType.F2I [float->int] : 1.52648
274
+ FlopType.I2F [int->float] : 1.63320
275
+ FlopType.ADD [x+y] : 1.00000
276
+ FlopType.SUB [x-y] : 1.00058
277
+ FlopType.MUL [x*y] : 1.44952
278
+ FlopType.DIV [x/y] : 5.00897
279
+ FlopType.SQRT [sqrt(x)] : 5.15597
280
+ FlopType.CBRT [cbrt(x)] : 39.30448
281
+ FlopType.EXP [e^x] : 17.22817
282
+ FlopType.EXP2 [2^x] : 15.82232
283
+ FlopType.EXP10 [10^x] : 21.20195
284
+ FlopType.LOG [log(x)] : 17.51472
285
+ FlopType.LOG2 [log2(x)] : 18.32529
286
+ FlopType.LOG10 [log10(x)] : 17.19903
287
+ FlopType.POW [x^y] : 47.63289
288
+ FlopType.SIN [sin(x)] : 29.58923
289
+ FlopType.COS [cos(x)] : 28.54904
290
+ FlopType.TAN [tan(x)] : 31.87442
291
+ }
292
+ ```
293
+
294
+ # 3. Benchmarking
295
+
296
+ If the package is installed with the optional `numba` dependency, it provides the ability to micro-benchmark
297
+ floating point operations as follows:
298
+
299
+ ```
300
+ >>> from counted_float.benchmarking import run_flops_benchmark
301
+ >>> results = run_flops_benchmark()
302
+
303
+ Running FLOPS benchmarks using counted-float 0.9.5 ...
304
+ (Expected duration: ~87.8 seconds)
305
+
306
+ baseline : wwwwwwwwwwwwwww......................... [ 74.43 ns ± 2.6% | 302 cpu cycles ± 2.6% ] / 1000 iterations
307
+ add : wwwwwwwwwwwwwww......................... [ 662.35 ns ± 0.2% | 2.69K cpu cycles ± 0.2% ] / 1000 iterations
308
+ add_minus : wwwwwwwwwwwwwww......................... [ 1.23 µs ± 0.2% | 4.98K cpu cycles ± 0.2% ] / 1000 iterations
309
+ add_abs : wwwwwwwwwwwwwww......................... [ 1.23 µs ± 0.4% | 4.99K cpu cycles ± 0.4% ] / 1000 iterations
310
+ add_add : wwwwwwwwwwwwwww......................... [ 1.29 µs ± 0.2% | 5.23K cpu cycles ± 0.2% ] / 1000 iterations
311
+ add_sub : wwwwwwwwwwwwwww......................... [ 1.29 µs ± 0.2% | 5.23K cpu cycles ± 0.2% ] / 1000 iterations
312
+ add_round : wwwwwwwwwwwwwww......................... [ 1.44 µs ± 0.1% | 5.84K cpu cycles ± 0.1% ] / 1000 iterations
313
+ add_sqrt : wwwwwwwwwwwwwww......................... [ 3.96 µs ± 0.2% | 16.1K cpu cycles ± 0.2% ] / 1000 iterations
314
+ add_cbrt : wwwwwwwwwwwwwww......................... [ 25.42 µs ± 0.2% | 103K cpu cycles ± 0.2% ] / 1000 iterations
315
+ add_log : wwwwwwwwwwwwwww......................... [ 11.69 µs ± 0.3% | 47.4K cpu cycles ± 0.3% ] / 1000 iterations
316
+ add_log_exp : wwwwwwwwwwwwwww......................... [ 22.57 µs ± 0.1% | 91.5K cpu cycles ± 0.1% ] / 1000 iterations
317
+ add_log2 : wwwwwwwwwwwwwww......................... [ 12.00 µs ± 0.2% | 48.7K cpu cycles ± 0.2% ] / 1000 iterations
318
+ add_log2_exp2 : wwwwwwwwwwwwwww......................... [ 22.48 µs ± 0.2% | 91.2K cpu cycles ± 0.2% ] / 1000 iterations
319
+ add_log10 : wwwwwwwwwwwwwww......................... [ 11.50 µs ± 0.2% | 46.6K cpu cycles ± 0.2% ] / 1000 iterations
320
+ add_log10_exp10 : wwwwwwwwwwwwwww......................... [ 24.68 µs ± 0.2% | 100K cpu cycles ± 0.2% ] / 1000 iterations
321
+ add_sin : wwwwwwwwwwwwwww......................... [ 18.64 µs ± 0.3% | 75.6K cpu cycles ± 0.3% ] / 1000 iterations
322
+ add_cos : wwwwwwwwwwwwwww......................... [ 18.92 µs ± 0.3% | 76.7K cpu cycles ± 0.3% ] / 1000 iterations
323
+ add_tan : wwwwwwwwwwwwwww......................... [ 20.91 µs ± 0.2% | 84.8K cpu cycles ± 0.2% ] / 1000 iterations
324
+ pow : wwwwwwwwwwwwwww......................... [ 24.12 µs ± 0.3% | 97.8K cpu cycles ± 0.3% ] / 1000 iterations
325
+ pow_pow : wwwwwwwwwwwwwww......................... [ 48.15 µs ± 0.2% | 195K cpu cycles ± 0.2% ] / 1000 iterations
326
+ sub : wwwwwwwwwwwwwww......................... [ 661.55 ns ± 0.2% | 2.68K cpu cycles ± 0.2% ] / 1000 iterations
327
+ sub_sub : wwwwwwwwwwwwwww......................... [ 1.29 µs ± 0.2% | 5.24K cpu cycles ± 0.2% ] / 1000 iterations
328
+ mul : wwwwwwwwwwwwwww......................... [ 961.78 ns ± 0.2% | 3.90K cpu cycles ± 0.2% ] / 1000 iterations
329
+ mul_mul : wwwwwwwwwwwwwww......................... [ 1.92 µs ± 0.2% | 7.78K cpu cycles ± 0.2% ] / 1000 iterations
330
+ div : wwwwwwwwwwwwwww......................... [ 2.45 µs ± 0.2% | 9.92K cpu cycles ± 0.2% ] / 1000 iterations
331
+ div_div : wwwwwwwwwwwwwww......................... [ 5.00 µs ± 0.2% | 20.3K cpu cycles ± 0.2% ] / 1000 iterations
332
+ lte_addsub : wwwwwwwwwwwwwww......................... [ 1.71 µs ± 0.2% | 6.94K cpu cycles ± 0.2% ] / 1000 iterations
333
+
334
+ >>> results.flop_weights.show()
335
+
336
+ {
337
+ FlopType.ABS [abs(x)] : 0.90556
338
+ FlopType.MINUS [-x] : 0.90089
339
+ FlopType.COMP [x<=y] : 1.67297
340
+ FlopType.RND [round] : 1.24118
341
+ FlopType.ADD [x+y] : 1.00000
342
+ FlopType.SUB [x-y] : 0.99928
343
+ FlopType.MUL [x*y] : 1.52656
344
+ FlopType.DIV [x/y] : 4.06589
345
+ FlopType.SQRT [sqrt(x)] : 5.26487
346
+ FlopType.CBRT [cbrt(x)] : 39.49190
347
+ FlopType.EXP [e^x] : 17.34508
348
+ FlopType.EXP2 [2^x] : 16.70475
349
+ FlopType.EXP10 [10^x] : 21.03351
350
+ FlopType.LOG [log(x)] : 17.59412
351
+ FlopType.LOG2 [log2(x)] : 18.08932
352
+ FlopType.LOG10 [log10(x)] : 17.27955
353
+ FlopType.POW [x^y] : 38.32044
354
+ FlopType.SIN [sin(x)] : 28.67006
355
+ FlopType.COS [cos(x)] : 29.11818
356
+ FlopType.TAN [tan(x)] : 32.28703
357
+ FlopType.F2I [float->int] : nan
358
+ FlopType.I2F [int->float] : nan
359
+ }
360
+ ```
361
+
362
+ ## 4. Installing the package as a command-line tool
363
+
364
+ An alternative way of using (parts) of the functionality is installing the package as a stand-alone command-line tool
365
+ using `uv` or `pipx`:
366
+
367
+ ```
368
+ uv tool install git+https://github.com/bertpl/counted-float@main[numba,cli] # latest official release
369
+ uv tool install git+https://github.com/bertpl/counted-float@develop[numba,cli] # or latest develop version
370
+ ```
371
+ This installs the `counted_float` command-line tool, which can be used to e.g. run flops benchmarks.
372
+
373
+ ## 4.1. Running benchmarks
374
+
375
+ ```
376
+ counted_float benchmark
377
+ ```
378
+ after which the results will be shown as .json.
379
+
380
+ ## 4.2. Show built-in data
381
+
382
+ ```
383
+ [~] counted_float show-data
384
+
385
+ ABS MINUS ADD SUB COMP MUL RND I2F F2I DIV SQRT LOG10 EXP LOG EXP10 LOG2 EXP2 COS SIN TAN CBRT POW
386
+ ALL 0.64 0.64 1.00 1.01 1.21 1.37 1.54 1.85 1.99 5.07 5.91 18.55 18.58 18.89 22.87 24.35 28.89 30.79 31.91 34.38 42.39 61.79
387
+ ├─arm 0.97 0.99 1.00 1.00 1.04 1.45 1.35 1.63 1.53 5.01 5.16 17.20 17.23 17.51 21.20 18.33 15.82 28.55 29.59 31.87 39.30 47.63
388
+ │ ├─v8_x 0.92 0.97 1.00 1.00 1.12 1.35 1.25 1.94 1.58 3.88 4.09 16.56 16.59 16.86 20.41 17.64 15.23 27.48 28.49 30.69 37.84 45.86
389
+ │ │ ├─benchmarks 0.85 0.95 1.00 1.00 1.26 1.22 1.05 / / 2.93 3.12 15.11 15.14 15.39 18.63 16.10 13.90 25.09 26.00 28.01 34.54 41.85
390
+ │ │ │ ├─m3_max_macbook_pro_16 0.80 1.00 1.00 1.01 1.01 1.01 0.89 / / 2.19 1.85 / / / / 14.40 11.59 / / / / 46.48
391
+ │ │ │ └─m3_max_macbook_pro_16_v2 0.90 0.90 1.00 1.00 1.58 1.47 1.24 / / 3.93 5.25 17.23 17.26 17.55 21.24 18.01 16.68 28.60 29.64 31.93 39.38 37.68
392
+ │ │ └─specs 1.00 1.00 1.00 1.00 1.00 1.50 1.50 2.12 1.73 5.12 5.37 / / / / / / / / / / /
393
+ │ │ ├─arm_v8_cortex_a76 1.00 1.00 1.00 1.00 1.00 1.50 1.50 3.00 2.00 5.12 5.45 / / / / / / / / / / /
394
+ │ │ ├─arm_v9_cortex_n1 1.00 1.00 1.00 1.00 1.00 1.50 1.50 3.00 2.00 5.12 5.45 / / / / / / / / / / /
395
+ │ │ ├─arm_v9_cortex_v1 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 5.12 5.29 / / / / / / / / / / /
396
+ │ │ └─arm_v9_cortex_x1 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 5.12 5.29 / / / / / / / / / / /
397
+ │ ├─v9_0 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 5.12 5.29 / / / / / / / / / / /
398
+ │ │ └─specs 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 5.12 5.29 / / / / / / / / / / /
399
+ │ │ ├─arm_v9_cortex_n2 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 5.12 5.29 / / / / / / / / / / /
400
+ │ │ ├─arm_v9_cortex_v2 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 5.12 5.29 / / / / / / / / / / /
401
+ │ │ ├─arm_v9_cortex_x2 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 5.12 5.29 / / / / / / / / / / /
402
+ │ │ └─arm_v9_cortex_x3 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 5.12 5.29 / / / / / / / / / / /
403
+ │ └─v9_2 1.00 1.00 1.00 1.00 1.00 1.50 1.31 1.50 1.50 6.33 6.33 / / / / / / / / / / /
404
+ │ └─specs 1.00 1.00 1.00 1.00 1.00 1.50 1.31 1.50 1.50 6.33 6.33 / / / / / / / / / / /
405
+ │ ├─arm_v9_cortex_v3 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 6.50 6.50 / / / / / / / / / / /
406
+ │ ├─arm_v9_cortex_x4 1.00 1.00 1.00 1.00 1.00 1.50 1.50 1.50 1.50 6.50 6.50 / / / / / / / / / / /
407
+ │ └─arm_v9_cortex_x925 1.00 1.00 1.00 1.00 1.00 1.50 1.00 1.50 1.50 6.00 6.00 / / / / / / / / / / /
408
+ └─x86 0.42 0.42 1.00 1.01 1.40 1.30 1.76 2.09 2.60 5.14 6.76 / / / / 32.35 52.74 / / / / 80.16
409
+ ├─amd 0.44 0.44 1.00 1.01 1.81 1.18 1.02 2.19 2.61 4.85 6.94 / / / / 32.91 173.48 / / / / 94.73
410
+ │ ├─2017_zen1 0.46 0.48 1.00 1.04 1.57 1.14 1.14 2.22 3.51 4.46 5.06 / / / / 32.94 173.63 / / / / 94.81
411
+ │ │ ├─analysis_uops_info_zen1+ 0.33 0.33 1.00 1.00 2.33 1.33 0.67 2.11 3.33 4.33 6.67 / / / / / / / / / / /
412
+ │ │ └─benchmark_ryzen_1700x 0.64 0.69 1.00 1.08 1.06 0.97 1.97 / / 4.58 3.83 / / / / 34.68 182.82 / / / / 99.82
413
+ │ ├─2020_zen3 0.33 0.33 1.00 1.00 1.97 1.01 0.76 2.01 2.45 4.42 6.67 / / / / / / / / / / /
414
+ │ │ ├─analysis_agner_fog_r7_5800x 0.33 0.33 1.00 1.00 1.67 / 1.00 2.33 2.00 4.50 6.67 / / / / / / / / / / /
415
+ │ │ └─analysis_uops_info_zen3 0.33 0.33 1.00 1.00 2.33 1.00 0.58 1.73 3.00 4.33 6.67 / / / / / / / / / / /
416
+ │ ├─2022_zen4 0.33 0.33 1.00 1.00 1.28 1.02 0.83 1.63 2.00 4.33 6.89 / / / / / / / / / / /
417
+ │ │ ├─analysis_agner_fog_r9_7900x 0.33 0.33 1.00 1.00 1.33 / 1.00 2.00 2.00 4.33 7.00 / / / / / / / / / / /
418
+ │ │ ├─analysis_uops_info_zen4 0.33 0.33 1.00 1.00 2.33 1.00 0.58 1.63 3.00 4.33 7.00 / / / / / / / / / / /
419
+ │ │ └─specs_amd 0.33 0.33 1.00 1.00 0.67 1.00 1.00 1.33 1.33 4.33 6.67 / / / / / / / / / / /
420
+ │ └─2024_zen5 0.71 0.71 1.00 1.00 2.72 1.66 1.50 3.17 2.72 6.50 10.00 / / / / / / / / / / /
421
+ │ ├─analysis_agner_fog_r7_9800x3d 1.00 1.00 1.00 1.00 3.00 / 1.50 3.50 3.00 6.50 10.00 / / / / / / / / / / /
422
+ │ └─specs_amd 0.50 0.50 1.00 1.00 / 1.50 1.50 / / 6.50 10.00 / / / / / / / / / / /
423
+ └─intel 0.40 0.40 1.00 1.01 1.09 1.43 3.02 1.99 2.58 5.45 6.59 / / / / 31.80 16.03 / / / / 67.83
424
+ ├─2017_coffee_lake_gen_8 0.25 0.25 1.00 1.00 0.74 1.00 2.00 1.41 1.62 3.56 4.29 / / / / / / / / / / /
425
+ │ ├─analysis_agner_fog_coffee_lake 0.25 0.25 1.00 1.00 / 1.00 2.00 1.50 1.50 3.37 3.87 / / / / / / / / / / /
426
+ │ └─analysis_uops_info_coffee_lake 0.25 0.25 1.00 1.00 0.75 1.00 2.00 1.32 1.75 3.75 4.75 / / / / / / / / / / /
427
+ ├─2019_sunny_cove_gen_10 0.25 0.25 1.00 1.00 0.66 0.98 2.00 1.38 1.66 3.62 4.44 / / / / / / / / / / /
428
+ │ ├─analysis_agner_fog_ice_lake 0.25 0.25 1.00 1.00 0.50 / 2.00 1.50 1.50 3.37 3.87 / / / / / / / / / / /
429
+ │ ├─analysis_uops_info_ice_lake 0.25 0.25 1.00 1.00 0.75 1.00 2.00 1.32 1.75 3.75 4.75 / / / / / / / / / / /
430
+ │ └─analysis_uops_info_tiger_lake 0.25 0.25 1.00 1.00 0.75 1.00 2.00 1.32 1.75 3.75 4.75 / / / / / / / / / / /
431
+ ├─2021_golden_cove_gen_12 0.64 0.64 1.00 1.07 1.39 1.53 3.93 2.54 3.46 7.61 8.07 / / / / 40.46 20.40 / / / / 86.31
432
+ │ ├─analysis_uops_info_alder_lake_p 0.41 0.41 1.00 1.00 1.22 1.63 3.27 2.16 2.86 6.12 7.76 / / / / / / / / / / /
433
+ │ ├─benchmark_core_i7_1265u 1.28 1.25 1.00 1.21 1.47 1.10 4.65 / / 10.27 7.54 / / / / 48.46 24.43 / / / / 103.37
434
+ │ └─specs_intel 0.50 0.50 1.00 1.00 1.50 2.00 4.00 2.50 3.50 7.00 9.00 / / / / / / / / / / /
435
+ ├─2022_raptor_cove_gen_13_14 0.50 0.50 1.00 1.00 1.50 2.00 4.00 2.50 3.50 7.00 9.00 / / / / / / / / / / /
436
+ │ └─specs_intel 0.50 0.50 1.00 1.00 1.50 2.00 4.00 2.50 3.50 7.00 9.00 / / / / / / / / / / /
437
+ └─2023_redwood_cove_ultra_1 0.50 0.50 1.00 1.00 1.50 2.00 4.00 2.50 3.50 7.00 9.00 / / / / / / / / / / /
438
+ └─specs_intel 0.50 0.50 1.00 1.00 1.50 2.00 4.00 2.50 3.50 7.00 9.00 / / / / / / / / / / /
439
+ ```
440
+
441
+ # 5. Known limitations
442
+
443
+ - currently any non-Python-built-in math operations are not counted (e.g. `numpy`)
444
+ - not all Python built-in math operations are counted (e.g. `log`, `log10`, `exp`, `exp10`)
445
+ - 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...
446
+
447
+ # Appendix A - Flop counting / analysis details
448
+
449
+ This appendix provides detailed information about how each floating-point operation (FLOP) type is counted and analyzed in the `counted-float` package. For each flop type, you will find:
450
+ - Relevant scalar instructions for ARM (v8+) and x86 (SSE2+)
451
+ - Python operations that are counted for this flop type
452
+ - Python operations that are *not* counted for this flop type
453
+
454
+ ## Flop Types
455
+
456
+ ### FlopType.ABS (`abs(x)`)
457
+ - Relevant CPU instructions
458
+ - **ARM:** `FABS`
459
+ - **x86:** `ANDPD`
460
+ - **Counted Python operations:** `abs(x)` where `x` is a `CountedFloat`
461
+ - **Not counted:** `numpy.abs`, complex abs, abs on non-CountedFloat
462
+
463
+ ### FlopType.MINUS (`-x`)
464
+ - Relevant CPU instructions
465
+ - **ARM:** `FNEG`
466
+ - **x86:** `XORPD`
467
+ - **Counted Python operations:** Unary minus (`-x`) for `CountedFloat`
468
+ - **Not counted:** Negation on non-CountedFloat, numpy negation
469
+
470
+ ### FlopType.COMP (`x<=y`, `x>y`, `x==y`, `x==0.0`, ...)
471
+ - Relevant CPU instructions
472
+ - **ARM:** `FCMP`
473
+ - **x86:** `(U)COMISD`
474
+ - **Counted Python operations:** `x == y`, `x != y`, `x <= y`, ... and `min(x,y)`, `max(x,y)` for `CountedFloat`
475
+ - **Not counted:** Comparisons on non-CountedFloat, numpy comparisons
476
+
477
+ ### FlopType.RND (`round`)
478
+ - Relevant CPU instructions
479
+ - **ARM:** `FRINT`
480
+ - **x86:** `ROUNDSD`
481
+ - **Counted Python operations:** `round(x, 0)` for `CountedFloat` (returns float)
482
+ - **Not counted:** `numpy.round`, rounding with decimals, rounding on non-CountedFloat
483
+
484
+ ### FlopType.F2I (`float->int`)
485
+ - Relevant CPU instructions
486
+ - **ARM:** `FCVTZS`
487
+ - **x86:** `CVTSD2SI`
488
+ - **Counted Python operations:** `int(x)`, `math.floor(x)`, `math.ceil(x)`, `math.trunc(x)`, `round(x)` for `CountedFloat` (returns int)
489
+ - **Not counted:** Conversions on non-CountedFloat, numpy conversions
490
+
491
+ ### FlopType.I2F (`int->float`)
492
+ - Relevant CPU instructions
493
+ - **ARM:** `SCVTF`
494
+ - **x86:** `CVTSI2SD`
495
+ - **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.)
496
+ - **Not counted:** `float(n)`, unitary operations (e.g. `math.sqrt` on integers -> convert to `CountedFloat` first)
497
+
498
+ ### FlopType.ADD (`x+y`)
499
+ - Relevant CPU instructions
500
+ - **ARM:** `FADD`
501
+ - **x86:** `ADDSD`
502
+ - **Counted Python operations:** `x + y` or `y + x` for `CountedFloat`
503
+ - **Not counted:** Addition on non-CountedFloat, numpy addition
504
+
505
+ ### FlopType.SUB (`x-y`)
506
+ - Relevant CPU instructions
507
+ - **ARM:** `FSUB`
508
+ - **x86:** `SUBSD`
509
+ - **Counted Python operations:** `x - y` or `y - x` for `CountedFloat`
510
+ - **Not counted:** Subtraction on non-CountedFloat, numpy subtraction
511
+
512
+ ### FlopType.MUL (`x*y`)
513
+ - Relevant CPU instructions
514
+ - **ARM:** `FMUL`
515
+ - **x86:** `MULSD`
516
+ - **Counted Python operations:** `x * y` or `y * x` for `CountedFloat`
517
+ - **Not counted:** Multiplication on non-CountedFloat, numpy multiplication
518
+
519
+ ### FlopType.DIV (`x/y`)
520
+ - Relevant CPU instructions
521
+ - **ARM:** `FDIV`
522
+ - **x86:** `DIVSD`
523
+ - **Counted Python operations:** `x / y` or `y / x` for `CountedFloat`
524
+ - **Not counted:** Division on non-CountedFloat, numpy division
525
+
526
+ ### FlopType.SQRT (`sqrt(x)`)
527
+ - Relevant CPU instructions
528
+ - **ARM:** `FSQRT`
529
+ - **x86:** `SQRTSD`
530
+ - **Counted Python operations:** `math.sqrt(x)` for `CountedFloat`
531
+ - **Not counted:** `numpy.sqrt`, sqrt on non-CountedFloat
532
+
533
+ ### FlopType.CBRT (`cbrt(x)`)
534
+ - Relevant CPU instructions
535
+ - **ARM:** (software)
536
+ - **x86:** (software)
537
+ - **Counted Python operations:** `math.cbrt(x)` for `CountedFloat`
538
+ - **Not counted:** `numpy.cbrt`, cbrt on non-CountedFloat
539
+
540
+ ### FlopType.EXP (`e^x`)
541
+ - Relevant CPU instructions
542
+ - **ARM:** (software)
543
+ - **x86:** (software)
544
+ - **Counted Python operations:** `math.exp(x)` for `CountedFloat`
545
+ - **Not counted:** `math.exp(x)` on non-CountedFloat, `numpy.exp`, `math.expm1`, `math.e ** x`
546
+
547
+ ### FlopType.EXP2 (`2^x`)
548
+ - Relevant CPU instructions
549
+ - **ARM:** (software)
550
+ - **x86:** (software)
551
+ - **Counted Python operations:** `2 ** x`, `pow(2, x)` or `math.exp2(x)` for `CountedFloat`
552
+ - **Not counted:** `exp2` on non-CountedFloat, `numpy.exp2`
553
+
554
+ ### FlopType.EXP10 (`10^x`)
555
+ - Relevant CPU instructions
556
+ - **ARM:** (software)
557
+ - **x86:** (software)
558
+ - **Counted Python operations:** `10 ** x`, `pow(10, x)` for `CountedFloat`
559
+ - **Not counted:** `10 ** x` on non-CountedFloat
560
+
561
+ ### FlopType.LOG (`log(x)`)
562
+ - Relevant CPU instructions
563
+ - **ARM:** (software)
564
+ - **x86:** (software)
565
+ - **Counted Python operations:** `math.log(x)` for `CountedFloat`
566
+ - **Not counted:** `numpy.log`, log on non-CountedFloat
567
+
568
+ ### FlopType.LOG2 (`log2(x)`)
569
+ - Relevant CPU instructions
570
+ - **ARM:** (software)
571
+ - **x86:** (software)
572
+ - **Counted Python operations:** `math.log2(x)` for `CountedFloat`
573
+ - **Not counted:** `numpy.log2`, log2 on non-CountedFloat
574
+
575
+ ### FlopType.LOG10 (`log10(x)`)
576
+ - Relevant CPU instructions
577
+ - **ARM:** (software)
578
+ - **x86:** (software)
579
+ - **Counted Python operations:** `math.log10(x)` for `CountedFloat`
580
+ - **Not counted:** `numpy.log10`, log10 on non-CountedFloat
581
+
582
+ ### FlopType.POW (`x^y`)
583
+ - Relevant CPU instructions
584
+ - **ARM:** (software)
585
+ - **x86:** (software)
586
+ - **Counted Python operations:** `x ** y`, `pow(x, y)` for `CountedFloat`
587
+ - **Not counted:** `pow` on non-CountedFloat, `numpy.pow`
588
+
589
+ ### FlopType.SIN (`sin(x)`)
590
+ - Relevant CPU instructions
591
+ - **ARM:** (software)
592
+ - **x86:** (software)
593
+ - **Counted Python operations:** `math.sin(x)` for `CountedFloat`
594
+ - **Not counted:** `sin` on non-CountedFloat, `numpy.sin`
595
+
596
+ ### FlopType.COS (`cos(x)`)
597
+ - Relevant CPU instructions
598
+ - **ARM:** (software)
599
+ - **x86:** (software)
600
+ - **Counted Python operations:** `math.cos(x)` for `CountedFloat`
601
+ - **Not counted:** `cos` on non-CountedFloat, `numpy.cos`
602
+
603
+ ### FlopType.TAN (`tan(x)`)
604
+ - Relevant CPU instructions
605
+ - **ARM:** (software)
606
+ - **x86:** (software)
607
+ - **Counted Python operations:** `math.tan(x)` for `CountedFloat`
608
+ - **Not counted:** `tan` on non-CountedFloat, `numpy.tan