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.
Files changed (82) hide show
  1. {counted_float-0.9.3 → counted_float-0.9.4}/PKG-INFO +42 -41
  2. {counted_float-0.9.3 → counted_float-0.9.4}/README.md +40 -40
  3. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/__init__.py +2 -2
  4. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/benchmarking/__init__.py +2 -4
  5. counted_float-0.9.4/counted_float/_core/benchmarking/flops/__init__.py +3 -0
  6. counted_float-0.9.4/counted_float/_core/benchmarking/flops/_array_generator.py +76 -0
  7. counted_float-0.9.4/counted_float/_core/benchmarking/flops/_flops_benchmark_suite.py +290 -0
  8. counted_float-0.9.4/counted_float/_core/benchmarking/flops/_flops_micro_benchmark.py +67 -0
  9. counted_float-0.9.4/counted_float/_core/benchmarking/micro/__init__.py +1 -0
  10. {counted_float-0.9.3/counted_float/_core/benchmarking → counted_float-0.9.4/counted_float/_core/benchmarking/micro}/_micro_benchmark.py +23 -28
  11. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/_builtin_data.py +10 -4
  12. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/_counted_float.py +60 -9
  13. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/_global_counter.py +6 -0
  14. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/models/__init__.py +4 -2
  15. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/models/_flop_counts.py +2 -0
  16. counted_float-0.9.4/counted_float/_core/models/_flop_type.py +30 -0
  17. counted_float-0.9.4/counted_float/_core/models/_flops_benchmark_meta_data.py +128 -0
  18. 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
  19. counted_float-0.9.4/counted_float/_core/models/_flops_benchmark_result_v2.py +26 -0
  20. counted_float-0.9.4/counted_float/_core/models/_flops_benchmark_type.py +24 -0
  21. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/models/_instruction_latencies.py +8 -2
  22. counted_float-0.9.4/counted_float/_core/models/_micro_benchmark_result.py +62 -0
  23. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/utils/__init__.py +1 -1
  24. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/utils/_latency.py +1 -1
  25. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/benchmarking/__init__.py +2 -2
  26. {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
  27. counted_float-0.9.4/counted_float/data/arm/v8_x/benchmarks/m3_max_macbook_pro_16_v2.json +151 -0
  28. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v8_x/specs/arm_v8_cortex_a76.json +5 -0
  29. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v8_x/specs/arm_v9_cortex_n1.json +5 -0
  30. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v8_x/specs/arm_v9_cortex_v1.json +5 -0
  31. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v8_x/specs/arm_v9_cortex_x1.json +5 -0
  32. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_n2.json +5 -0
  33. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_v2.json +5 -0
  34. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_x2.json +5 -0
  35. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_x3.json +5 -0
  36. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_2/specs/arm_v9_cortex_v3.json +5 -0
  37. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_2/specs/arm_v9_cortex_x4.json +5 -0
  38. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/arm/v9_2/specs/arm_v9_cortex_x925.json +5 -0
  39. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/amd/2017_zen1/analysis_uops_info_zen1+.json +5 -0
  40. counted_float-0.9.4/counted_float/data/x86/amd/2017_zen1/benchmark_ryzen_1700x.json +121 -0
  41. {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
  42. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/amd/2020_zen3/analysis_uops_info_zen3.json +5 -0
  43. {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
  44. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/amd/2022_zen4/analysis_uops_info_zen4.json +5 -0
  45. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/amd/2022_zen4/specs_amd.json +5 -0
  46. {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
  47. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/data/x86/amd/2024_zen5/specs_amd.json +5 -0
  48. {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
  49. {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
  50. {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
  51. {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
  52. {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
  53. {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
  54. {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
  55. {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
  56. {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
  57. {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
  58. {counted_float-0.9.3 → counted_float-0.9.4}/pyproject.toml +2 -1
  59. counted_float-0.9.3/counted_float/_core/benchmarking/_flops_benchmark_suite.py +0 -193
  60. counted_float-0.9.3/counted_float/_core/benchmarking/_flops_micro_benchmark.py +0 -59
  61. counted_float-0.9.3/counted_float/_core/benchmarking/_time_utils.py +0 -1
  62. counted_float-0.9.3/counted_float/_core/models/_flop_type.py +0 -47
  63. counted_float-0.9.3/counted_float/_core/models/_micro_benchmark_result.py +0 -41
  64. {counted_float-0.9.3 → counted_float-0.9.4}/.gitignore +0 -0
  65. {counted_float-0.9.3 → counted_float-0.9.4}/LICENSE +0 -0
  66. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/__init__.py +0 -0
  67. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/_cli.py +0 -0
  68. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/compatibility/__init__.py +0 -0
  69. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/compatibility/_numba.py +0 -0
  70. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/compatibility/_strenum.py +0 -0
  71. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/__init__.py +0 -0
  72. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/_context_managers.py +0 -0
  73. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/config/__init__.py +0 -0
  74. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/config/_config.py +0 -0
  75. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/counting/config/_defaults.py +0 -0
  76. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/models/_base.py +0 -0
  77. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/models/_flop_weights.py +0 -0
  78. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/utils/_formatting.py +0 -0
  79. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/utils/_geo_mean.py +0 -0
  80. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/utils/_missing_data.py +0 -0
  81. {counted_float-0.9.3 → counted_float-0.9.4}/counted_float/_core/utils/_timer.py +0 -0
  82. {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
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
  ![shields.io-python-versions](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)
24
- ![genbadge-test-count](https://bertpl.github.io/counted-float/version_artifacts/v0.9.3/badge-test-count.svg)
25
- ![genbadge-test-coverage](https://bertpl.github.io/counted-float/version_artifacts/v0.9.3/badge-coverage.svg)
26
- ![counted_float logo](https://bertpl.github.io/counted-float/version_artifacts/v0.9.3/splash.webp)
25
+ ![genbadge-test-count](https://bertpl.github.io/counted-float/version_artifacts/v0.9.4/badge-test-count.svg)
26
+ ![genbadge-test-coverage](https://bertpl.github.io/counted-float/version_artifacts/v0.9.4/badge-coverage.svg)
27
+ ![counted_float logo](https://bertpl.github.io/counted-float/version_artifacts/v0.9.4/splash.webp)
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)] : 1
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)] : 0.96944
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)] : 2.63592
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.2 ...
288
-
289
- baseline : wwwwwwwwww.................... ( 187.03 ns = 759 cpu cycles) ± 0.6% / 1000 iterations
290
- FlopType.ABS [abs(x)] : wwwwwwwwww.................... ( 303.31 ns = 1.23K cpu cycles) ± 1.7% / 1000 iterations
291
- FlopType.CMP_ZERO [x>=0] : wwwwwwwwww.................... ( 302.19 ns = 1.23K cpu cycles) ± 3.0% / 1000 iterations
292
- FlopType.RND [round(x)] : wwwwwwwwww.................... ( 305.95 ns = 1.24K cpu cycles) ± 4.8% / 1000 iterations
293
- FlopType.MINUS [-x] : wwwwwwwwww.................... ( 306.31 ns = 1.24K cpu cycles) ± 2.6% / 1000 iterations
294
- FlopType.EQUALS [x==y] : wwwwwwwwww.................... ( 320.59 ns = 1.30K cpu cycles) ± 3.9% / 1000 iterations
295
- FlopType.GTE [x>=y] : wwwwwwwwww.................... ( 331.51 ns = 1.34K cpu cycles) ± 2.9% / 1000 iterations
296
- FlopType.LTE [x<=y] : wwwwwwwwww.................... ( 333.81 ns = 1.35K cpu cycles) ± 1.0% / 1000 iterations
297
- FlopType.ADD [x+y] : wwwwwwwwww.................... ( 315.84 ns = 1.28K cpu cycles) ± 3.2% / 1000 iterations
298
- FlopType.SUB [x-y] : wwwwwwwwww.................... ( 335.49 ns = 1.36K cpu cycles) ± 3.8% / 1000 iterations
299
- FlopType.MUL [x*y] : wwwwwwwwww.................... ( 325.65 ns = 1.32K cpu cycles) ± 3.0% / 1000 iterations
300
- FlopType.SQRT [sqrt(x)] : wwwwwwwwww.................... ( 443.30 ns = 1.80K cpu cycles) ± 2.6% / 1000 iterations
301
- FlopType.DIV [x/y] : wwwwwwwwww.................... ( 491.51 ns = 1.99K cpu cycles) ± 1.1% / 1000 iterations
302
- FlopType.POW2 [2^x] : wwwwwwwwww.................... ( 1.79 µs = 7.28K cpu cycles) ± 0.3% / 1000 iterations
303
- FlopType.LOG2 [log2(x)] : wwwwwwwwww.................... ( 2.17 µs = 8.80K cpu cycles) ± 0.8% / 1000 iterations
304
- FlopType.POW [x^y] : wwwwwwwwww.................... ( 6.32 µs = 25.6K cpu cycles) ± 0.7% / 1000 iterations
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.84769
310
- FlopType.MINUS [-x] : 0.86954
311
- FlopType.EQUALS [x==y] : 0.97369
312
- FlopType.GTE [x>=y] : 1.05327
313
- FlopType.LTE [x<=y] : 1.07007
314
- FlopType.CMP_ZERO [x>=0] : 0.83957
315
- FlopType.RND [round(x)] : 0.86695
316
- FlopType.ADD [x+y] : 0.93905
317
- FlopType.SUB [x-y] : 1.08227
318
- FlopType.MUL [x*y] : 1.01055
319
- FlopType.DIV [x/y] : 2.21970
320
- FlopType.SQRT [sqrt(x)] : 1.86822
321
- FlopType.POW2 [2^x] : 11.72183
322
- FlopType.LOG2 [log2(x)] : 14.45542
323
- FlopType.POW [x^y] : 44.68266
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
  ![shields.io-python-versions](https://img.shields.io/badge/python-3.10%20%7C%203.11%20%7C%203.12%20%7C%203.13-blue)
3
- ![genbadge-test-count](https://bertpl.github.io/counted-float/version_artifacts/v0.9.3/badge-test-count.svg)
4
- ![genbadge-test-coverage](https://bertpl.github.io/counted-float/version_artifacts/v0.9.3/badge-coverage.svg)
5
- ![counted_float logo](https://bertpl.github.io/counted-float/version_artifacts/v0.9.3/splash.webp)
3
+ ![genbadge-test-count](https://bertpl.github.io/counted-float/version_artifacts/v0.9.4/badge-test-count.svg)
4
+ ![genbadge-test-coverage](https://bertpl.github.io/counted-float/version_artifacts/v0.9.4/badge-coverage.svg)
5
+ ![counted_float logo](https://bertpl.github.io/counted-float/version_artifacts/v0.9.4/splash.webp)
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)] : 1
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)] : 0.96944
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)] : 2.63592
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.2 ...
267
-
268
- baseline : wwwwwwwwww.................... ( 187.03 ns = 759 cpu cycles) ± 0.6% / 1000 iterations
269
- FlopType.ABS [abs(x)] : wwwwwwwwww.................... ( 303.31 ns = 1.23K cpu cycles) ± 1.7% / 1000 iterations
270
- FlopType.CMP_ZERO [x>=0] : wwwwwwwwww.................... ( 302.19 ns = 1.23K cpu cycles) ± 3.0% / 1000 iterations
271
- FlopType.RND [round(x)] : wwwwwwwwww.................... ( 305.95 ns = 1.24K cpu cycles) ± 4.8% / 1000 iterations
272
- FlopType.MINUS [-x] : wwwwwwwwww.................... ( 306.31 ns = 1.24K cpu cycles) ± 2.6% / 1000 iterations
273
- FlopType.EQUALS [x==y] : wwwwwwwwww.................... ( 320.59 ns = 1.30K cpu cycles) ± 3.9% / 1000 iterations
274
- FlopType.GTE [x>=y] : wwwwwwwwww.................... ( 331.51 ns = 1.34K cpu cycles) ± 2.9% / 1000 iterations
275
- FlopType.LTE [x<=y] : wwwwwwwwww.................... ( 333.81 ns = 1.35K cpu cycles) ± 1.0% / 1000 iterations
276
- FlopType.ADD [x+y] : wwwwwwwwww.................... ( 315.84 ns = 1.28K cpu cycles) ± 3.2% / 1000 iterations
277
- FlopType.SUB [x-y] : wwwwwwwwww.................... ( 335.49 ns = 1.36K cpu cycles) ± 3.8% / 1000 iterations
278
- FlopType.MUL [x*y] : wwwwwwwwww.................... ( 325.65 ns = 1.32K cpu cycles) ± 3.0% / 1000 iterations
279
- FlopType.SQRT [sqrt(x)] : wwwwwwwwww.................... ( 443.30 ns = 1.80K cpu cycles) ± 2.6% / 1000 iterations
280
- FlopType.DIV [x/y] : wwwwwwwwww.................... ( 491.51 ns = 1.99K cpu cycles) ± 1.1% / 1000 iterations
281
- FlopType.POW2 [2^x] : wwwwwwwwww.................... ( 1.79 µs = 7.28K cpu cycles) ± 0.3% / 1000 iterations
282
- FlopType.LOG2 [log2(x)] : wwwwwwwwww.................... ( 2.17 µs = 8.80K cpu cycles) ± 0.8% / 1000 iterations
283
- FlopType.POW [x^y] : wwwwwwwwww.................... ( 6.32 µs = 25.6K cpu cycles) ± 0.7% / 1000 iterations
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.84769
289
- FlopType.MINUS [-x] : 0.86954
290
- FlopType.EQUALS [x==y] : 0.97369
291
- FlopType.GTE [x>=y] : 1.05327
292
- FlopType.LTE [x<=y] : 1.07007
293
- FlopType.CMP_ZERO [x>=0] : 0.83957
294
- FlopType.RND [round(x)] : 0.86695
295
- FlopType.ADD [x+y] : 0.93905
296
- FlopType.SUB [x-y] : 1.08227
297
- FlopType.MUL [x*y] : 1.01055
298
- FlopType.DIV [x/y] : 2.21970
299
- FlopType.SQRT [sqrt(x)] : 1.86822
300
- FlopType.POW2 [2^x] : 11.72183
301
- FlopType.LOG2 [log2(x)] : 14.45542
302
- FlopType.POW [x^y] : 44.68266
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
- FlopsBenchmarkResults,
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
- "FlopsBenchmarkResults",
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 counted_float._core.models import FlopsBenchmarkResults
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,3 @@
1
+ from ._array_generator import ArrayGenerator
2
+ from ._flops_benchmark_suite import FlopsBenchmarkResults_V2, FlopsBenchmarkSuite
3
+ from ._flops_micro_benchmark import FlopsMicroBenchmark
@@ -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)