counted-float 0.9.3__tar.gz → 0.9.4__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.
- {counted_float-0.9.3 → counted_float-0.9.4}/PKG-INFO +42 -41
- {counted_float-0.9.3 → counted_float-0.9.4}/README.md +40 -40
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/__init__.py +2 -2
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/benchmarking/__init__.py +2 -4
- counted_float-0.9.4/counted_float/_core/benchmarking/flops/__init__.py +3 -0
- counted_float-0.9.4/counted_float/_core/benchmarking/flops/_array_generator.py +76 -0
- counted_float-0.9.4/counted_float/_core/benchmarking/flops/_flops_benchmark_suite.py +290 -0
- counted_float-0.9.4/counted_float/_core/benchmarking/flops/_flops_micro_benchmark.py +67 -0
- counted_float-0.9.4/counted_float/_core/benchmarking/micro/__init__.py +1 -0
- {counted_float-0.9.3/counted_float/_core/benchmarking → counted_float-0.9.4/counted_float/_core/benchmarking/micro}/_micro_benchmark.py +23 -28
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/_builtin_data.py +10 -4
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/_counted_float.py +60 -9
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/_global_counter.py +6 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/models/__init__.py +4 -2
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/models/_flop_counts.py +2 -0
- counted_float-0.9.4/counted_float/_core/models/_flop_type.py +30 -0
- counted_float-0.9.4/counted_float/_core/models/_flops_benchmark_meta_data.py +128 -0
- counted_float-0.9.3/counted_float/_core/models/_flops_benchmark_result.py → counted_float-0.9.4/counted_float/_core/models/_flops_benchmark_result_v1.py +7 -27
- counted_float-0.9.4/counted_float/_core/models/_flops_benchmark_result_v2.py +26 -0
- counted_float-0.9.4/counted_float/_core/models/_flops_benchmark_type.py +24 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/models/_instruction_latencies.py +8 -2
- counted_float-0.9.4/counted_float/_core/models/_micro_benchmark_result.py +62 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/utils/__init__.py +1 -1
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/utils/_latency.py +1 -1
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/benchmarking/__init__.py +2 -2
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v8_x/benchmarks/m3_max_macbook_pro_16.json +29 -11
- counted_float-0.9.4/counted_float/data/arm/v8_x/benchmarks/m3_max_macbook_pro_16_v2.json +151 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v8_x/specs/arm_v8_cortex_a76.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v8_x/specs/arm_v9_cortex_n1.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v8_x/specs/arm_v9_cortex_v1.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v8_x/specs/arm_v9_cortex_x1.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_n2.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_v2.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_x2.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_x3.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_2/specs/arm_v9_cortex_v3.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_2/specs/arm_v9_cortex_x4.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_2/specs/arm_v9_cortex_x925.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/amd/2017_zen1/analysis_uops_info_zen1+.json +5 -0
- counted_float-0.9.4/counted_float/data/x86/amd/2017_zen1/benchmark_ryzen_1700x.json +121 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/amd/2020_zen3/analysis_agner_fog_r7_5800x.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/amd/2020_zen3/analysis_uops_info_zen3.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/amd/2022_zen4/analysis_agner_fog_r9_7900x.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/amd/2022_zen4/analysis_uops_info_zen4.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/amd/2022_zen4/specs_amd.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/amd/2024_zen5/analysis_agner_fog_r7_9800x3d.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/amd/2024_zen5/specs_amd.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/intel/2017_coffee_lake_gen_8/analysis_agner_fog_coffee_lake.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/intel/2017_coffee_lake_gen_8/analysis_uops_info_coffee_lake.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/analysis_agner_fog_ice_lake.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/analysis_uops_info_ice_lake.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/analysis_uops_info_tiger_lake.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/intel/2021_golden_cove_gen_12/analysis_uops_info_alder_lake_p.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/intel/2021_golden_cove_gen_12/benchmark_core_i7_1265u.json +29 -11
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/intel/2021_golden_cove_gen_12/specs_intel.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/intel/2022_raptor_cove_gen_13_14/specs_intel.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/intel/2023_redwood_cove_ultra_1/specs_intel.json +5 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/pyproject.toml +2 -1
- counted_float-0.9.3/counted_float/_core/benchmarking/_flops_benchmark_suite.py +0 -193
- counted_float-0.9.3/counted_float/_core/benchmarking/_flops_micro_benchmark.py +0 -59
- counted_float-0.9.3/counted_float/_core/benchmarking/_time_utils.py +0 -1
- counted_float-0.9.3/counted_float/_core/models/_flop_type.py +0 -47
- counted_float-0.9.3/counted_float/_core/models/_micro_benchmark_result.py +0 -41
- {counted_float-0.9.3 → counted_float-0.9.4}/.gitignore +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/LICENSE +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/__init__.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/_cli.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/compatibility/__init__.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/compatibility/_numba.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/compatibility/_strenum.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/__init__.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/_context_managers.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/config/__init__.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/config/_config.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/config/_defaults.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/models/_base.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/models/_flop_weights.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/utils/_formatting.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/utils/_geo_mean.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/utils/_missing_data.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/utils/_timer.py +0 -0
- {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/config/__init__.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: counted-float
|
|
3
|
-
Version: 0.9.
|
|
3
|
+
Version: 0.9.4
|
|
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/develop/CHANGELOG.md
|
|
@@ -11,6 +11,7 @@ Requires-Python: >=3.10
|
|
|
11
11
|
Requires-Dist: backports-strenum>=1.3.1
|
|
12
12
|
Requires-Dist: numpy>=1.20
|
|
13
13
|
Requires-Dist: psutil>=5.0
|
|
14
|
+
Requires-Dist: py-cpuinfo>=9.0.0
|
|
14
15
|
Requires-Dist: pydantic>=2.0.0
|
|
15
16
|
Requires-Dist: rich>=13.0.0
|
|
16
17
|
Provides-Extra: cli
|
|
@@ -21,9 +22,9 @@ Description-Content-Type: text/markdown
|
|
|
21
22
|
|
|
22
23
|
<!--START_SECTION:images-->
|
|
23
24
|

|
|
24
|
-

|
|
26
|
+

|
|
27
|
+

|
|
27
28
|
<!--END_SECTION:images-->
|
|
28
29
|
|
|
29
30
|
# counted-float
|
|
@@ -164,7 +165,7 @@ rationale behind choice of data sources and methodology.
|
|
|
164
165
|
FlopType.GTE [x>=y] : 1
|
|
165
166
|
FlopType.LTE [x<=y] : 1
|
|
166
167
|
FlopType.CMP_ZERO [x>=0] : 1
|
|
167
|
-
FlopType.RND [round(x)]
|
|
168
|
+
FlopType.RND [round(x,0)] : 1
|
|
168
169
|
FlopType.ADD [x+y] : 1
|
|
169
170
|
FlopType.SUB [x-y] : 1
|
|
170
171
|
FlopType.MUL [x*y] : 1
|
|
@@ -227,7 +228,7 @@ from counted_float.config import get_default_empirical_flop_weights, get_default
|
|
|
227
228
|
FlopType.GTE [x>=y] : 0.94684
|
|
228
229
|
FlopType.LTE [x<=y] : 0.93101
|
|
229
230
|
FlopType.CMP_ZERO [x>=0] : 0.82204
|
|
230
|
-
FlopType.RND [round(x)]
|
|
231
|
+
FlopType.RND [round(x,0)] : 0.96944
|
|
231
232
|
FlopType.ADD [x+y] : 0.89296
|
|
232
233
|
FlopType.SUB [x-y] : 1.14383
|
|
233
234
|
FlopType.MUL [x*y] : 1.04677
|
|
@@ -258,7 +259,7 @@ from counted_float.config import get_builtin_flop_weights
|
|
|
258
259
|
FlopType.GTE [x>=y] : 0.89744
|
|
259
260
|
FlopType.LTE [x<=y] : 0.89744
|
|
260
261
|
FlopType.CMP_ZERO [x>=0] : 0.84762
|
|
261
|
-
FlopType.RND [round(x)]
|
|
262
|
+
FlopType.RND [round(x,0)] : 2.63592
|
|
262
263
|
FlopType.ADD [x+y] : 0.86616
|
|
263
264
|
FlopType.SUB [x-y] : 1.10411
|
|
264
265
|
FlopType.MUL [x*y] : 1.16515
|
|
@@ -284,43 +285,43 @@ floating point operations as follows:
|
|
|
284
285
|
>>> from counted_float.benchmarking import run_flops_benchmark
|
|
285
286
|
>>> results = run_flops_benchmark()
|
|
286
287
|
|
|
287
|
-
Running FLOPS benchmarks using counted-float 0.9.
|
|
288
|
-
|
|
289
|
-
baseline : wwwwwwwwww....................
|
|
290
|
-
FlopType.ABS [abs(x)] : wwwwwwwwww....................
|
|
291
|
-
FlopType.CMP_ZERO [x>=0] : wwwwwwwwww....................
|
|
292
|
-
FlopType.RND [round(x)]
|
|
293
|
-
FlopType.MINUS [-x] : wwwwwwwwww....................
|
|
294
|
-
FlopType.EQUALS [x==y] : wwwwwwwwww....................
|
|
295
|
-
FlopType.GTE [x>=y] : wwwwwwwwww....................
|
|
296
|
-
FlopType.LTE [x<=y] : wwwwwwwwww....................
|
|
297
|
-
FlopType.ADD [x+y] : wwwwwwwwww....................
|
|
298
|
-
FlopType.SUB [x-y] : wwwwwwwwww....................
|
|
299
|
-
FlopType.MUL [x*y] : wwwwwwwwww....................
|
|
300
|
-
FlopType.SQRT [sqrt(x)] : wwwwwwwwww....................
|
|
301
|
-
FlopType.DIV [x/y] : wwwwwwwwww....................
|
|
302
|
-
FlopType.POW2 [2^x] : wwwwwwwwww....................
|
|
303
|
-
FlopType.LOG2 [log2(x)] : wwwwwwwwww....................
|
|
304
|
-
FlopType.POW [x^y] : wwwwwwwwww....................
|
|
288
|
+
Running FLOPS benchmarks using counted-float 0.9.4 ...
|
|
289
|
+
|
|
290
|
+
baseline : wwwwwwwwww.................... [ 177.53 ns ± 2.0% | 720 cpu cycles ± 2.0% ] / 1000 iterations
|
|
291
|
+
FlopType.ABS [abs(x)] : wwwwwwwwww.................... [ 286.71 ns ± 5.7% | 1.16K cpu cycles ± 5.7% ] / 1000 iterations
|
|
292
|
+
FlopType.CMP_ZERO [x>=0] : wwwwwwwwww.................... [ 294.71 ns ± 3.6% | 1.20K cpu cycles ± 3.6% ] / 1000 iterations
|
|
293
|
+
FlopType.RND [round(x,0)] : wwwwwwwwww.................... [ 291.74 ns ± 6.1% | 1.18K cpu cycles ± 6.1% ] / 1000 iterations
|
|
294
|
+
FlopType.MINUS [-x] : wwwwwwwwww.................... [ 291.81 ns ± 5.8% | 1.18K cpu cycles ± 5.8% ] / 1000 iterations
|
|
295
|
+
FlopType.EQUALS [x==y] : wwwwwwwwww.................... [ 297.70 ns ± 4.2% | 1.21K cpu cycles ± 4.2% ] / 1000 iterations
|
|
296
|
+
FlopType.GTE [x>=y] : wwwwwwwwww.................... [ 301.59 ns ± 3.2% | 1.22K cpu cycles ± 3.2% ] / 1000 iterations
|
|
297
|
+
FlopType.LTE [x<=y] : wwwwwwwwww.................... [ 295.77 ns ± 2.2% | 1.20K cpu cycles ± 2.2% ] / 1000 iterations
|
|
298
|
+
FlopType.ADD [x+y] : wwwwwwwwww.................... [ 289.49 ns ± 2.6% | 1.17K cpu cycles ± 2.6% ] / 1000 iterations
|
|
299
|
+
FlopType.SUB [x-y] : wwwwwwwwww.................... [ 289.85 ns ± 1.7% | 1.18K cpu cycles ± 1.7% ] / 1000 iterations
|
|
300
|
+
FlopType.MUL [x*y] : wwwwwwwwww.................... [ 305.46 ns ± 2.8% | 1.24K cpu cycles ± 2.8% ] / 1000 iterations
|
|
301
|
+
FlopType.SQRT [sqrt(x)] : wwwwwwwwww.................... [ 435.30 ns ± 0.5% | 1.77K cpu cycles ± 0.5% ] / 1000 iterations
|
|
302
|
+
FlopType.DIV [x/y] : wwwwwwwwww.................... [ 479.90 ns ± 1.2% | 1.95K cpu cycles ± 1.2% ] / 1000 iterations
|
|
303
|
+
FlopType.POW2 [2^x] : wwwwwwwwww.................... [ 1.78 µs ± 0.1% | 7.22K cpu cycles ± 0.1% ] / 1000 iterations
|
|
304
|
+
FlopType.LOG2 [log2(x)] : wwwwwwwwww.................... [ 2.17 µs ± 0.6% | 8.80K cpu cycles ± 0.6% ] / 1000 iterations
|
|
305
|
+
FlopType.POW [x^y] : wwwwwwwwww.................... [ 6.14 µs ± 0.4% | 24.9K cpu cycles ± 0.4% ] / 1000 iterations
|
|
305
306
|
|
|
306
307
|
>>> results.flop_weights.show()
|
|
307
308
|
|
|
308
309
|
{
|
|
309
|
-
FlopType.ABS [abs(x)] : 0.
|
|
310
|
-
FlopType.MINUS [-x] :
|
|
311
|
-
FlopType.EQUALS [x==y] :
|
|
312
|
-
FlopType.GTE [x>=y] : 1.
|
|
313
|
-
FlopType.LTE [x<=y] : 1.
|
|
314
|
-
FlopType.CMP_ZERO [x>=0] :
|
|
315
|
-
FlopType.RND [round(x)]
|
|
316
|
-
FlopType.ADD [x+y] :
|
|
317
|
-
FlopType.SUB [x-y] : 1.
|
|
318
|
-
FlopType.MUL [x*y] : 1.
|
|
319
|
-
FlopType.DIV [x/y] : 2.
|
|
320
|
-
FlopType.SQRT [sqrt(x)] :
|
|
321
|
-
FlopType.POW2 [2^x] :
|
|
322
|
-
FlopType.LOG2 [log2(x)] :
|
|
323
|
-
FlopType.POW [x^y] :
|
|
310
|
+
FlopType.ABS [abs(x)] : 0.97517
|
|
311
|
+
FlopType.MINUS [-x] : 1.02074
|
|
312
|
+
FlopType.EQUALS [x==y] : 1.07339
|
|
313
|
+
FlopType.GTE [x>=y] : 1.10812
|
|
314
|
+
FlopType.LTE [x<=y] : 1.05609
|
|
315
|
+
FlopType.CMP_ZERO [x>=0] : 1.04665
|
|
316
|
+
FlopType.RND [round(x,0)] : 1.02017
|
|
317
|
+
FlopType.ADD [x+y] : 1.00000
|
|
318
|
+
FlopType.SUB [x-y] : 1.00328
|
|
319
|
+
FlopType.MUL [x*y] : 1.14268
|
|
320
|
+
FlopType.DIV [x/y] : 2.70079
|
|
321
|
+
FlopType.SQRT [sqrt(x)] : 2.30238
|
|
322
|
+
FlopType.POW2 [2^x] : 14.30722
|
|
323
|
+
FlopType.LOG2 [log2(x)] : 17.79592
|
|
324
|
+
FlopType.POW [x^y] : 53.26393
|
|
324
325
|
}
|
|
325
326
|
```
|
|
326
327
|
|
|
@@ -335,7 +336,7 @@ uv tool install git+https://github.com/bertpl/counted-float@develop[numba,cli]
|
|
|
335
336
|
```
|
|
336
337
|
This installs the `counted_float` command-line tool, which can be used to e.g. run flops benchmarks.
|
|
337
338
|
|
|
338
|
-
## 4.1 Running benchmarks
|
|
339
|
+
## 4.1. Running benchmarks
|
|
339
340
|
|
|
340
341
|
```
|
|
341
342
|
counted_float benchmark
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
<!--START_SECTION:images-->
|
|
2
2
|

|
|
3
|
-

|
|
4
|
+

|
|
5
|
+

|
|
6
6
|
<!--END_SECTION:images-->
|
|
7
7
|
|
|
8
8
|
# counted-float
|
|
@@ -143,7 +143,7 @@ rationale behind choice of data sources and methodology.
|
|
|
143
143
|
FlopType.GTE [x>=y] : 1
|
|
144
144
|
FlopType.LTE [x<=y] : 1
|
|
145
145
|
FlopType.CMP_ZERO [x>=0] : 1
|
|
146
|
-
FlopType.RND [round(x)]
|
|
146
|
+
FlopType.RND [round(x,0)] : 1
|
|
147
147
|
FlopType.ADD [x+y] : 1
|
|
148
148
|
FlopType.SUB [x-y] : 1
|
|
149
149
|
FlopType.MUL [x*y] : 1
|
|
@@ -206,7 +206,7 @@ from counted_float.config import get_default_empirical_flop_weights, get_default
|
|
|
206
206
|
FlopType.GTE [x>=y] : 0.94684
|
|
207
207
|
FlopType.LTE [x<=y] : 0.93101
|
|
208
208
|
FlopType.CMP_ZERO [x>=0] : 0.82204
|
|
209
|
-
FlopType.RND [round(x)]
|
|
209
|
+
FlopType.RND [round(x,0)] : 0.96944
|
|
210
210
|
FlopType.ADD [x+y] : 0.89296
|
|
211
211
|
FlopType.SUB [x-y] : 1.14383
|
|
212
212
|
FlopType.MUL [x*y] : 1.04677
|
|
@@ -237,7 +237,7 @@ from counted_float.config import get_builtin_flop_weights
|
|
|
237
237
|
FlopType.GTE [x>=y] : 0.89744
|
|
238
238
|
FlopType.LTE [x<=y] : 0.89744
|
|
239
239
|
FlopType.CMP_ZERO [x>=0] : 0.84762
|
|
240
|
-
FlopType.RND [round(x)]
|
|
240
|
+
FlopType.RND [round(x,0)] : 2.63592
|
|
241
241
|
FlopType.ADD [x+y] : 0.86616
|
|
242
242
|
FlopType.SUB [x-y] : 1.10411
|
|
243
243
|
FlopType.MUL [x*y] : 1.16515
|
|
@@ -263,43 +263,43 @@ floating point operations as follows:
|
|
|
263
263
|
>>> from counted_float.benchmarking import run_flops_benchmark
|
|
264
264
|
>>> results = run_flops_benchmark()
|
|
265
265
|
|
|
266
|
-
Running FLOPS benchmarks using counted-float 0.9.
|
|
267
|
-
|
|
268
|
-
baseline : wwwwwwwwww....................
|
|
269
|
-
FlopType.ABS [abs(x)] : wwwwwwwwww....................
|
|
270
|
-
FlopType.CMP_ZERO [x>=0] : wwwwwwwwww....................
|
|
271
|
-
FlopType.RND [round(x)]
|
|
272
|
-
FlopType.MINUS [-x] : wwwwwwwwww....................
|
|
273
|
-
FlopType.EQUALS [x==y] : wwwwwwwwww....................
|
|
274
|
-
FlopType.GTE [x>=y] : wwwwwwwwww....................
|
|
275
|
-
FlopType.LTE [x<=y] : wwwwwwwwww....................
|
|
276
|
-
FlopType.ADD [x+y] : wwwwwwwwww....................
|
|
277
|
-
FlopType.SUB [x-y] : wwwwwwwwww....................
|
|
278
|
-
FlopType.MUL [x*y] : wwwwwwwwww....................
|
|
279
|
-
FlopType.SQRT [sqrt(x)] : wwwwwwwwww....................
|
|
280
|
-
FlopType.DIV [x/y] : wwwwwwwwww....................
|
|
281
|
-
FlopType.POW2 [2^x] : wwwwwwwwww....................
|
|
282
|
-
FlopType.LOG2 [log2(x)] : wwwwwwwwww....................
|
|
283
|
-
FlopType.POW [x^y] : wwwwwwwwww....................
|
|
266
|
+
Running FLOPS benchmarks using counted-float 0.9.4 ...
|
|
267
|
+
|
|
268
|
+
baseline : wwwwwwwwww.................... [ 177.53 ns ± 2.0% | 720 cpu cycles ± 2.0% ] / 1000 iterations
|
|
269
|
+
FlopType.ABS [abs(x)] : wwwwwwwwww.................... [ 286.71 ns ± 5.7% | 1.16K cpu cycles ± 5.7% ] / 1000 iterations
|
|
270
|
+
FlopType.CMP_ZERO [x>=0] : wwwwwwwwww.................... [ 294.71 ns ± 3.6% | 1.20K cpu cycles ± 3.6% ] / 1000 iterations
|
|
271
|
+
FlopType.RND [round(x,0)] : wwwwwwwwww.................... [ 291.74 ns ± 6.1% | 1.18K cpu cycles ± 6.1% ] / 1000 iterations
|
|
272
|
+
FlopType.MINUS [-x] : wwwwwwwwww.................... [ 291.81 ns ± 5.8% | 1.18K cpu cycles ± 5.8% ] / 1000 iterations
|
|
273
|
+
FlopType.EQUALS [x==y] : wwwwwwwwww.................... [ 297.70 ns ± 4.2% | 1.21K cpu cycles ± 4.2% ] / 1000 iterations
|
|
274
|
+
FlopType.GTE [x>=y] : wwwwwwwwww.................... [ 301.59 ns ± 3.2% | 1.22K cpu cycles ± 3.2% ] / 1000 iterations
|
|
275
|
+
FlopType.LTE [x<=y] : wwwwwwwwww.................... [ 295.77 ns ± 2.2% | 1.20K cpu cycles ± 2.2% ] / 1000 iterations
|
|
276
|
+
FlopType.ADD [x+y] : wwwwwwwwww.................... [ 289.49 ns ± 2.6% | 1.17K cpu cycles ± 2.6% ] / 1000 iterations
|
|
277
|
+
FlopType.SUB [x-y] : wwwwwwwwww.................... [ 289.85 ns ± 1.7% | 1.18K cpu cycles ± 1.7% ] / 1000 iterations
|
|
278
|
+
FlopType.MUL [x*y] : wwwwwwwwww.................... [ 305.46 ns ± 2.8% | 1.24K cpu cycles ± 2.8% ] / 1000 iterations
|
|
279
|
+
FlopType.SQRT [sqrt(x)] : wwwwwwwwww.................... [ 435.30 ns ± 0.5% | 1.77K cpu cycles ± 0.5% ] / 1000 iterations
|
|
280
|
+
FlopType.DIV [x/y] : wwwwwwwwww.................... [ 479.90 ns ± 1.2% | 1.95K cpu cycles ± 1.2% ] / 1000 iterations
|
|
281
|
+
FlopType.POW2 [2^x] : wwwwwwwwww.................... [ 1.78 µs ± 0.1% | 7.22K cpu cycles ± 0.1% ] / 1000 iterations
|
|
282
|
+
FlopType.LOG2 [log2(x)] : wwwwwwwwww.................... [ 2.17 µs ± 0.6% | 8.80K cpu cycles ± 0.6% ] / 1000 iterations
|
|
283
|
+
FlopType.POW [x^y] : wwwwwwwwww.................... [ 6.14 µs ± 0.4% | 24.9K cpu cycles ± 0.4% ] / 1000 iterations
|
|
284
284
|
|
|
285
285
|
>>> results.flop_weights.show()
|
|
286
286
|
|
|
287
287
|
{
|
|
288
|
-
FlopType.ABS [abs(x)] : 0.
|
|
289
|
-
FlopType.MINUS [-x] :
|
|
290
|
-
FlopType.EQUALS [x==y] :
|
|
291
|
-
FlopType.GTE [x>=y] : 1.
|
|
292
|
-
FlopType.LTE [x<=y] : 1.
|
|
293
|
-
FlopType.CMP_ZERO [x>=0] :
|
|
294
|
-
FlopType.RND [round(x)]
|
|
295
|
-
FlopType.ADD [x+y] :
|
|
296
|
-
FlopType.SUB [x-y] : 1.
|
|
297
|
-
FlopType.MUL [x*y] : 1.
|
|
298
|
-
FlopType.DIV [x/y] : 2.
|
|
299
|
-
FlopType.SQRT [sqrt(x)] :
|
|
300
|
-
FlopType.POW2 [2^x] :
|
|
301
|
-
FlopType.LOG2 [log2(x)] :
|
|
302
|
-
FlopType.POW [x^y] :
|
|
288
|
+
FlopType.ABS [abs(x)] : 0.97517
|
|
289
|
+
FlopType.MINUS [-x] : 1.02074
|
|
290
|
+
FlopType.EQUALS [x==y] : 1.07339
|
|
291
|
+
FlopType.GTE [x>=y] : 1.10812
|
|
292
|
+
FlopType.LTE [x<=y] : 1.05609
|
|
293
|
+
FlopType.CMP_ZERO [x>=0] : 1.04665
|
|
294
|
+
FlopType.RND [round(x,0)] : 1.02017
|
|
295
|
+
FlopType.ADD [x+y] : 1.00000
|
|
296
|
+
FlopType.SUB [x-y] : 1.00328
|
|
297
|
+
FlopType.MUL [x*y] : 1.14268
|
|
298
|
+
FlopType.DIV [x/y] : 2.70079
|
|
299
|
+
FlopType.SQRT [sqrt(x)] : 2.30238
|
|
300
|
+
FlopType.POW2 [2^x] : 14.30722
|
|
301
|
+
FlopType.LOG2 [log2(x)] : 17.79592
|
|
302
|
+
FlopType.POW [x^y] : 53.26393
|
|
303
303
|
}
|
|
304
304
|
```
|
|
305
305
|
|
|
@@ -314,7 +314,7 @@ uv tool install git+https://github.com/bertpl/counted-float@develop[numba,cli]
|
|
|
314
314
|
```
|
|
315
315
|
This installs the `counted_float` command-line tool, which can be used to e.g. run flops benchmarks.
|
|
316
316
|
|
|
317
|
-
## 4.1 Running benchmarks
|
|
317
|
+
## 4.1. Running benchmarks
|
|
318
318
|
|
|
319
319
|
```
|
|
320
320
|
counted_float benchmark
|
|
@@ -5,7 +5,7 @@ from ._core.counting import BuiltInData, CountedFloat, FlopCountingContext, Paus
|
|
|
5
5
|
from ._core.models import (
|
|
6
6
|
FlopCounts,
|
|
7
7
|
FlopsBenchmarkDurations,
|
|
8
|
-
|
|
8
|
+
FlopsBenchmarkResults_V1,
|
|
9
9
|
FlopType,
|
|
10
10
|
FlopWeights,
|
|
11
11
|
Quantiles,
|
|
@@ -19,7 +19,7 @@ __all__ = [
|
|
|
19
19
|
"FlopCountingContext",
|
|
20
20
|
"FlopCounts",
|
|
21
21
|
"FlopsBenchmarkDurations",
|
|
22
|
-
"
|
|
22
|
+
"FlopsBenchmarkResults_V1",
|
|
23
23
|
"FlopType",
|
|
24
24
|
"FlopWeights",
|
|
25
25
|
"PauseFlopCounting",
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
from importlib.metadata import version
|
|
2
2
|
|
|
3
|
-
from
|
|
3
|
+
from .flops import FlopsBenchmarkResults_V2, FlopsBenchmarkSuite
|
|
4
4
|
|
|
5
|
-
from ._flops_benchmark_suite import FlopsBenchmarkSuite
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
def run_flops_benchmark() -> FlopsBenchmarkResults:
|
|
6
|
+
def run_flops_benchmark() -> FlopsBenchmarkResults_V2:
|
|
9
7
|
"""Run the flops benchmark suite with default settings returns a FlopsBenchmarkResults object."""
|
|
10
8
|
|
|
11
9
|
print()
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import random
|
|
4
|
+
from abc import ABC, abstractmethod
|
|
5
|
+
|
|
6
|
+
import numpy as np
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
# =================================================================================================
|
|
10
|
+
# Base class
|
|
11
|
+
# =================================================================================================
|
|
12
|
+
class ArrayGenerator(ABC):
|
|
13
|
+
# -------------------------------------------------------------------------
|
|
14
|
+
# API
|
|
15
|
+
# -------------------------------------------------------------------------
|
|
16
|
+
@abstractmethod
|
|
17
|
+
def new_array(self, size: int) -> np.ndarray:
|
|
18
|
+
"""Generates random 1D numpy array of requested size"""
|
|
19
|
+
raise NotImplementedError
|
|
20
|
+
|
|
21
|
+
# -------------------------------------------------------------------------
|
|
22
|
+
# Factory Methods
|
|
23
|
+
# -------------------------------------------------------------------------
|
|
24
|
+
@classmethod
|
|
25
|
+
def lin_range(cls, min_value: float, max_value: float) -> ArrayGenerator:
|
|
26
|
+
return ArrayGeneratorLinear(min_value, max_value)
|
|
27
|
+
|
|
28
|
+
@classmethod
|
|
29
|
+
def log_range(cls, min_value: float, max_value: float) -> ArrayGenerator:
|
|
30
|
+
return ArrayGeneratorLog(min_value, max_value)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
# =================================================================================================
|
|
34
|
+
# Implementations
|
|
35
|
+
# =================================================================================================
|
|
36
|
+
class ArrayGeneratorLinear(ArrayGenerator):
|
|
37
|
+
def __init__(self, min_value: float, max_value: float):
|
|
38
|
+
"""Array generator, where values are in interval [min_value, max_value] with avg. equal to mid-point."""
|
|
39
|
+
self.min_value = min_value
|
|
40
|
+
self.max_value = max_value
|
|
41
|
+
|
|
42
|
+
def new_array(self, size: int) -> np.ndarray:
|
|
43
|
+
uniform_values = 0.5 * (1.0 + _random_balanced_values(size)) # uniform random values in [0,1]
|
|
44
|
+
return self.min_value + uniform_values * (self.max_value - self.min_value)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
class ArrayGeneratorLog(ArrayGenerator):
|
|
48
|
+
def __init__(self, min_value: float, max_value: float):
|
|
49
|
+
"""Array generator, where values are in interval [min_value, max_value] with geomean of values eq. to geo-mid"""
|
|
50
|
+
self.min_value = min_value
|
|
51
|
+
self.max_value = max_value
|
|
52
|
+
|
|
53
|
+
def new_array(self, size: int) -> np.ndarray:
|
|
54
|
+
uniform_values = 0.5 * (1.0 + _random_balanced_values(size)) # uniform random values in [0,1]
|
|
55
|
+
return self.min_value * (self.max_value / self.min_value) ** uniform_values
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
# =================================================================================================
|
|
59
|
+
# Helpers
|
|
60
|
+
# =================================================================================================
|
|
61
|
+
def _random_balanced_values(size: int) -> np.ndarray:
|
|
62
|
+
"""
|
|
63
|
+
Returns random values in [-1,1], such that...
|
|
64
|
+
- mean value == 0.0
|
|
65
|
+
- cumulative sum of any arbitrary first n values also lies within [-1,1]
|
|
66
|
+
"""
|
|
67
|
+
cumsum = 0.0
|
|
68
|
+
lst = []
|
|
69
|
+
for i in range(size - 1):
|
|
70
|
+
next_min_value = max(-1.0, -1.0 - cumsum)
|
|
71
|
+
next_max_value = min(1.0, 1.0 - cumsum)
|
|
72
|
+
next_value = random.uniform(next_min_value, next_max_value)
|
|
73
|
+
lst.append(next_value)
|
|
74
|
+
cumsum += next_value
|
|
75
|
+
lst.append(-cumsum)
|
|
76
|
+
return np.array(lst)
|