counted-float 0.9.7__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {counted_float-0.9.7 → counted_float-1.0.0}/PKG-INFO +34 -6
- {counted_float-0.9.7 → counted_float-1.0.0}/README.md +33 -5
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/_cli.py +7 -1
- counted_float-1.0.0/counted_float/_core/benchmarking/__init__.py +37 -0
- counted_float-1.0.0/counted_float/_core/benchmarking/counted_float/__init__.py +1 -0
- counted_float-1.0.0/counted_float/_core/benchmarking/counted_float/_counted_float_benchmark.py +83 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/benchmarking/micro/_micro_benchmark.py +2 -2
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/utils/_missing_data.py +1 -5
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/benchmarking/__init__.py +2 -1
- {counted_float-0.9.7 → counted_float-1.0.0}/pyproject.toml +1 -1
- counted_float-0.9.7/counted_float/_core/benchmarking/__init__.py +0 -11
- {counted_float-0.9.7 → counted_float-1.0.0}/.gitignore +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/LICENSE +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/__init__.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/__init__.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/benchmarking/flops/__init__.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/benchmarking/flops/_array_generator.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/benchmarking/flops/_flops_benchmark_suite.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/benchmarking/flops/_flops_micro_benchmark.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/benchmarking/micro/__init__.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/compatibility/__init__.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/compatibility/_numba.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/counting/__init__.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/counting/_builtin_data.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/counting/_context_managers.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/counting/_counted_float.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/counting/_global_counter.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/counting/config/__init__.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/counting/config/_config.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/counting/config/_defaults.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/__init__.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_base.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_flop_counts.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_flop_type.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_flop_weights.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_flops_benchmark_meta_data.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_flops_benchmark_result.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_flops_benchmark_type.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_instruction_latencies.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_micro_benchmark_result.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/utils/__init__.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/utils/_cpu_freq.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/utils/_formatting.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/utils/_geo_mean.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/utils/_latency.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/utils/_rounding.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/utils/_timer.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/config/__init__.py +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v8_x/benchmarks/apple_m3_max_mbp16.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v8_x/benchmarks/apple_m3_mba15.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v8_x/benchmarks/ec2_m6g_xlarge_graviton_2_neoverse_n1.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v8_x/benchmarks/ec2_m7g_xlarge_graviton_3_neoverse_v1.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v8_x/benchmarks/gh_apple_m1.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v8_x/specs/arm_v8_cortex_a76.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v8_x/specs/arm_v9_cortex_x1.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v8_x/specs/arm_v9_neoverse_n1.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v8_x/specs/arm_v9_neoverse_v1.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v9_0/benchmarks/ec2_m8g_xlarge_graviton_4_neoverse_v2.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v9_0/benchmarks/gh_azure_cobalt_100_neoverse_n2.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_x2.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_x3.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v9_0/specs/arm_v9_neoverse_n2.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v9_0/specs/arm_v9_neoverse_v2.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v9_2/benchmarks/apple_m4_pro_mbp16.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v9_2/specs/arm_v9_cortex_x4.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v9_2/specs/arm_v9_cortex_x925.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v9_2/specs/arm_v9_neoverse_v3.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2017_zen1/analysis_uops_info_zen1+.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2017_zen1/benchmark_ryzen_1700x.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2020_zen3/analysis_agner_fog_r7_5800x.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2020_zen3/analysis_uops_info_zen3.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2020_zen3/benchmark_gh_amd_epyc_7763_linux.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2020_zen3/benchmark_gh_amd_epyc_7763_windows.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2022_zen4/analysis_agner_fog_r9_7900x.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2022_zen4/analysis_uops_info_zen4.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2022_zen4/benchmark_ec2_m7a_xlarge_zen4.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2022_zen4/specs_amd.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2024_zen5/analysis_agner_fog_r7_9800x3d.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2024_zen5/benchmark_ec2_m8a_xlarge_zen5.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2024_zen5/specs_amd.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2017_coffee_lake_gen_8/analysis_agner_fog_coffee_lake.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2017_coffee_lake_gen_8/analysis_uops_info_coffee_lake.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2017_coffee_lake_gen_8/benchmark_gh_intel_i7_8700B_macos.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2017_coffee_lake_gen_8/benchmark_intel_i7_8550U_windows.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/analysis_agner_fog_ice_lake.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/analysis_uops_info_ice_lake.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/analysis_uops_info_tiger_lake.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2019_sunny_cove_gen_10/benchmark_ec2_m6i_xlarge_ice_lake.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2021_golden_cove_gen_12/analysis_uops_info_alder_lake_p.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2021_golden_cove_gen_12/benchmark_ec2_m7i_xlarge_sapphire_rapids.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2021_golden_cove_gen_12/specs_intel.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2022_raptor_cove_gen_13_14/benchmark_ec2_i7i_xlarge_emerald_rapids.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2022_raptor_cove_gen_13_14/specs_intel.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2023_redwood_cove_ultra_1/benchmark_ec2_m8i_xlarge_granite_rapids.json +0 -0
- {counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/intel/2023_redwood_cove_ultra_1/specs_intel.json +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: counted-float
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 1.0.0
|
|
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
|
|
@@ -21,9 +21,9 @@ Description-Content-Type: text/markdown
|
|
|
21
21
|
|
|
22
22
|
<!--START_SECTION:images-->
|
|
23
23
|

|
|
24
|
-

|
|
25
|
+

|
|
26
|
+

|
|
27
27
|
<!--END_SECTION:images-->
|
|
28
28
|
|
|
29
29
|
# counted-float
|
|
@@ -467,10 +467,38 @@ ALL 0.47 0.70
|
|
|
467
467
|
|
|
468
468
|
```
|
|
469
469
|
|
|
470
|
-
|
|
470
|
+
## 4.2. Test performance of `CountedFloat` vs `float`
|
|
471
|
+
|
|
472
|
+
```
|
|
473
|
+
[~] counted_float benchmark-counted-float
|
|
474
|
+
```
|
|
475
|
+
See next section for results.
|
|
476
|
+
|
|
477
|
+
# 5. Performance impact
|
|
478
|
+
|
|
479
|
+
Obviously, using `CountedFloat` instead of regular `float` will have a performance impact due to the overhead of counting operations.
|
|
480
|
+
It is not advised to use `CountedFloat` for production code, but just for research code for which you want to estimate the floating-point operation count.
|
|
481
|
+
|
|
482
|
+
Micro-benchmarking of a bisection algorithm using `counted_float benchmark-counted-float` teaches us this:
|
|
483
|
+
```
|
|
484
|
+
------------------------------------------------------------------------------------------------------------------------
|
|
485
|
+
Running CountedFloat benchmark...
|
|
486
|
+
|
|
487
|
+
float : wwwwwwwwwwwwwww................................... [ 12.34 µs ± 1.2% | 50.1K cpu cycles ± 1.2% ] / execution
|
|
488
|
+
CountedFloat : wwwwwwwwwwwwwww................................... [ 459.95 µs ± 0.2% | 1.87M cpu cycles ± 0.2% ] / execution
|
|
489
|
+
------------------------------------------------------------------------------------------------------------------------
|
|
490
|
+
|
|
491
|
+
CountedFloat Benchmark Results:
|
|
492
|
+
Bisection using float : 12.34 µs / execution
|
|
493
|
+
Bisection using CountedFloat : 459.95 µs / execution
|
|
494
|
+
|
|
495
|
+
CountedFloat is 37.3x slower than float
|
|
496
|
+
```
|
|
497
|
+
|
|
498
|
+
# 6. Known limitations
|
|
471
499
|
|
|
472
500
|
- currently any non-Python-built-in math operations are not counted (e.g. `numpy`)
|
|
473
|
-
- not all Python built-in math operations are counted (e.g.
|
|
501
|
+
- not all Python built-in math operations are counted (e.g. hyperbolic functions)
|
|
474
502
|
- 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...
|
|
475
503
|
|
|
476
504
|
# Appendix A - Flop counting / analysis details
|
|
@@ -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
|
|
@@ -446,10 +446,38 @@ ALL 0.47 0.70
|
|
|
446
446
|
|
|
447
447
|
```
|
|
448
448
|
|
|
449
|
-
|
|
449
|
+
## 4.2. Test performance of `CountedFloat` vs `float`
|
|
450
|
+
|
|
451
|
+
```
|
|
452
|
+
[~] counted_float benchmark-counted-float
|
|
453
|
+
```
|
|
454
|
+
See next section for results.
|
|
455
|
+
|
|
456
|
+
# 5. Performance impact
|
|
457
|
+
|
|
458
|
+
Obviously, using `CountedFloat` instead of regular `float` will have a performance impact due to the overhead of counting operations.
|
|
459
|
+
It is not advised to use `CountedFloat` for production code, but just for research code for which you want to estimate the floating-point operation count.
|
|
460
|
+
|
|
461
|
+
Micro-benchmarking of a bisection algorithm using `counted_float benchmark-counted-float` teaches us this:
|
|
462
|
+
```
|
|
463
|
+
------------------------------------------------------------------------------------------------------------------------
|
|
464
|
+
Running CountedFloat benchmark...
|
|
465
|
+
|
|
466
|
+
float : wwwwwwwwwwwwwww................................... [ 12.34 µs ± 1.2% | 50.1K cpu cycles ± 1.2% ] / execution
|
|
467
|
+
CountedFloat : wwwwwwwwwwwwwww................................... [ 459.95 µs ± 0.2% | 1.87M cpu cycles ± 0.2% ] / execution
|
|
468
|
+
------------------------------------------------------------------------------------------------------------------------
|
|
469
|
+
|
|
470
|
+
CountedFloat Benchmark Results:
|
|
471
|
+
Bisection using float : 12.34 µs / execution
|
|
472
|
+
Bisection using CountedFloat : 459.95 µs / execution
|
|
473
|
+
|
|
474
|
+
CountedFloat is 37.3x slower than float
|
|
475
|
+
```
|
|
476
|
+
|
|
477
|
+
# 6. Known limitations
|
|
450
478
|
|
|
451
479
|
- currently any non-Python-built-in math operations are not counted (e.g. `numpy`)
|
|
452
|
-
- not all Python built-in math operations are counted (e.g.
|
|
480
|
+
- not all Python built-in math operations are counted (e.g. hyperbolic functions)
|
|
453
481
|
- 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...
|
|
454
482
|
|
|
455
483
|
# Appendix A - Flop counting / analysis details
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import click
|
|
2
2
|
|
|
3
3
|
from counted_float import BuiltInData
|
|
4
|
-
from counted_float.benchmarking import run_flops_benchmark
|
|
4
|
+
from counted_float._core.benchmarking import run_counted_float_benchmark, run_flops_benchmark
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
# -------------------------------------------------------------------------
|
|
@@ -22,3 +22,9 @@ def benchmark():
|
|
|
22
22
|
@click.option("--key_filter", default="", help="Optional key filter for built-in data")
|
|
23
23
|
def show_data(key_filter: str):
|
|
24
24
|
BuiltInData.show(key_filter=key_filter)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
@cli.command(short_help="run benchmark of float vs CountedFloat performance")
|
|
28
|
+
def benchmark_counted_float():
|
|
29
|
+
result = run_counted_float_benchmark()
|
|
30
|
+
result.show()
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
from .counted_float import BenchmarkCountedFloat, BenchmarkFloat, CountedFloatBenchmarkResults
|
|
2
|
+
from .flops import FlopsBenchmarkResults, FlopsBenchmarkSuite
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def run_flops_benchmark(n_seconds_per_run_target: float = 0.1) -> FlopsBenchmarkResults:
|
|
6
|
+
"""Run the flops benchmark suite with default settings returns a FlopsBenchmarkResults object."""
|
|
7
|
+
|
|
8
|
+
benchmark_results = FlopsBenchmarkSuite().run(n_seconds_per_run_target=n_seconds_per_run_target)
|
|
9
|
+
|
|
10
|
+
print()
|
|
11
|
+
|
|
12
|
+
return benchmark_results
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
def run_counted_float_benchmark(t_target_sec: float = 0.1) -> CountedFloatBenchmarkResults:
|
|
16
|
+
"""Run benchmark to compare performance of float vs CountedFloat."""
|
|
17
|
+
print("-" * 120)
|
|
18
|
+
print("Running CountedFloat benchmark...")
|
|
19
|
+
print()
|
|
20
|
+
|
|
21
|
+
result_float = BenchmarkFloat().run_many(
|
|
22
|
+
n_runs_total=50,
|
|
23
|
+
n_runs_warmup=15,
|
|
24
|
+
n_seconds_per_run_target=t_target_sec,
|
|
25
|
+
)
|
|
26
|
+
result_counted_float = BenchmarkCountedFloat().run_many(
|
|
27
|
+
n_runs_total=50,
|
|
28
|
+
n_runs_warmup=15,
|
|
29
|
+
n_seconds_per_run_target=t_target_sec,
|
|
30
|
+
)
|
|
31
|
+
print("-" * 120)
|
|
32
|
+
print()
|
|
33
|
+
|
|
34
|
+
return CountedFloatBenchmarkResults(
|
|
35
|
+
float_time_nsec=result_float.summary_stats_nsecs_per_exec().q50,
|
|
36
|
+
counted_float_time_nsec=result_counted_float.summary_stats_nsecs_per_exec().q50,
|
|
37
|
+
)
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from ._counted_float_benchmark import BenchmarkCountedFloat, BenchmarkFloat, CountedFloatBenchmarkResults
|
counted_float-1.0.0/counted_float/_core/benchmarking/counted_float/_counted_float_benchmark.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
from counted_float._core.benchmarking.micro import MicroBenchmark
|
|
2
|
+
from counted_float._core.counting import CountedFloat
|
|
3
|
+
from counted_float._core.models import MyBaseModel
|
|
4
|
+
from counted_float._core.utils import format_time_duration
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
# =================================================================================================
|
|
8
|
+
# Result class
|
|
9
|
+
# =================================================================================================
|
|
10
|
+
class CountedFloatBenchmarkResults(MyBaseModel):
|
|
11
|
+
float_time_nsec: float
|
|
12
|
+
counted_float_time_nsec: float
|
|
13
|
+
|
|
14
|
+
def show(self):
|
|
15
|
+
print("CountedFloat Benchmark Results:")
|
|
16
|
+
print(f" Bisection using float : {format_time_duration(self.float_time_nsec)} / execution")
|
|
17
|
+
print(f" Bisection using CountedFloat : {format_time_duration(self.counted_float_time_nsec)} / execution")
|
|
18
|
+
ratio = self.counted_float_time_nsec / self.float_time_nsec
|
|
19
|
+
print()
|
|
20
|
+
print(f"CountedFloat is {ratio:.1f}x slower than float")
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
# =================================================================================================
|
|
24
|
+
# MicroBenchmarks
|
|
25
|
+
# =================================================================================================
|
|
26
|
+
def _zero_function(x: float) -> float:
|
|
27
|
+
# function for which we want to find a root
|
|
28
|
+
return (x * x * x) - 7.0
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class BenchmarkFloat(MicroBenchmark):
|
|
32
|
+
def __init__(self):
|
|
33
|
+
super().__init__(name="float")
|
|
34
|
+
self._n_executions = 1
|
|
35
|
+
|
|
36
|
+
def _prepare_benchmark(self, n_executions: int):
|
|
37
|
+
self._n_executions = n_executions
|
|
38
|
+
|
|
39
|
+
def _run_benchmark(self):
|
|
40
|
+
for _ in range(self._n_executions):
|
|
41
|
+
# Execute bisection to find root of _zero_function in interval [-1e50,1e50],
|
|
42
|
+
# using standard float() arithmetic
|
|
43
|
+
a = -1e50
|
|
44
|
+
b = 1e50
|
|
45
|
+
fa = _zero_function(a)
|
|
46
|
+
fb = _zero_function(b)
|
|
47
|
+
while b - a > 1e-15:
|
|
48
|
+
mid = 0.5 * (a + b)
|
|
49
|
+
fmid = _zero_function(mid)
|
|
50
|
+
if fmid < 0:
|
|
51
|
+
a = mid
|
|
52
|
+
fa = fmid
|
|
53
|
+
else:
|
|
54
|
+
b = mid
|
|
55
|
+
fb = fmid
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class BenchmarkCountedFloat(MicroBenchmark):
|
|
59
|
+
def __init__(self):
|
|
60
|
+
super().__init__(name="CountedFloat")
|
|
61
|
+
self._n_executions = 1
|
|
62
|
+
|
|
63
|
+
def _prepare_benchmark(self, n_executions: int):
|
|
64
|
+
self._n_executions = n_executions
|
|
65
|
+
|
|
66
|
+
def _run_benchmark(self):
|
|
67
|
+
for _ in range(self._n_executions):
|
|
68
|
+
# Execute bisection to find root of _zero_function in interval [-1e50,1e50],
|
|
69
|
+
# with identical implementation as BenchmarkFloat, except that we initialize a,b as CountedFloats,
|
|
70
|
+
# which will make sure all the remaining operations are also executed using CountedFloat arithmetic
|
|
71
|
+
a = CountedFloat(-1e50)
|
|
72
|
+
b = CountedFloat(1e50)
|
|
73
|
+
fa = _zero_function(a)
|
|
74
|
+
fb = _zero_function(b)
|
|
75
|
+
while b - a > 1e-15:
|
|
76
|
+
mid = 0.5 * (a + b)
|
|
77
|
+
fmid = _zero_function(mid)
|
|
78
|
+
if fmid < 0:
|
|
79
|
+
a = mid
|
|
80
|
+
fa = fmid
|
|
81
|
+
else:
|
|
82
|
+
b = mid
|
|
83
|
+
fb = fmid
|
|
@@ -115,9 +115,9 @@ class MicroBenchmark(ABC):
|
|
|
115
115
|
run by the MicroBenchmarkRunner class to ensure that the benchmark_runs runs for a reasonable amount of time
|
|
116
116
|
(e.g. 1 second per run).
|
|
117
117
|
"""
|
|
118
|
-
|
|
118
|
+
...
|
|
119
119
|
|
|
120
120
|
@abstractmethod
|
|
121
121
|
def _run_benchmark(self):
|
|
122
122
|
"""Run benchmark_runs. This method is called multiple times and the time spent here is measured."""
|
|
123
|
-
|
|
123
|
+
...
|
|
@@ -35,11 +35,7 @@ def impute_missing_data(data: np.ndarray) -> np.ndarray:
|
|
|
35
35
|
]
|
|
36
36
|
|
|
37
37
|
# overall exact correction is geo_mean of these factors, which we'll apply with step e_step
|
|
38
|
-
|
|
39
|
-
c_row_correct[i_row] = geo_mean(factors) ** e_step if factors else np.nan
|
|
40
|
-
except TypeError as e:
|
|
41
|
-
print(e)
|
|
42
|
-
pass
|
|
38
|
+
c_row_correct[i_row] = geo_mean(factors) ** e_step if factors else np.nan
|
|
43
39
|
|
|
44
40
|
# compute correction factors for c_cols
|
|
45
41
|
c_col_correct = np.zeros(n_cols)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
from counted_float._core.benchmarking import FlopsBenchmarkResults, run_flops_benchmark
|
|
1
|
+
from counted_float._core.benchmarking import FlopsBenchmarkResults, run_counted_float_benchmark, run_flops_benchmark
|
|
2
2
|
|
|
3
3
|
__all__ = [
|
|
4
4
|
"FlopsBenchmarkResults",
|
|
5
|
+
"run_counted_float_benchmark",
|
|
5
6
|
"run_flops_benchmark",
|
|
6
7
|
]
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
from .flops import FlopsBenchmarkResults, FlopsBenchmarkSuite
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def run_flops_benchmark() -> FlopsBenchmarkResults:
|
|
5
|
-
"""Run the flops benchmark suite with default settings returns a FlopsBenchmarkResults object."""
|
|
6
|
-
|
|
7
|
-
benchmark_results = FlopsBenchmarkSuite().run()
|
|
8
|
-
|
|
9
|
-
print()
|
|
10
|
-
|
|
11
|
-
return benchmark_results
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/benchmarking/flops/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/benchmarking/micro/__init__.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/counting/_context_managers.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/counting/config/_defaults.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_flops_benchmark_meta_data.py
RENAMED
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_flops_benchmark_result.py
RENAMED
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_flops_benchmark_type.py
RENAMED
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_instruction_latencies.py
RENAMED
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/_core/models/_micro_benchmark_result.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v8_x/benchmarks/gh_apple_m1.json
RENAMED
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v8_x/specs/arm_v8_cortex_a76.json
RENAMED
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v8_x/specs/arm_v9_cortex_x1.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_x2.json
RENAMED
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v9_0/specs/arm_v9_cortex_x3.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/arm/v9_2/specs/arm_v9_cortex_x4.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2022_zen4/specs_amd.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
{counted_float-0.9.7 → counted_float-1.0.0}/counted_float/data/x86/amd/2024_zen5/specs_amd.json
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|