Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,4 @@
*.app

*.DS_Store
build/
Binary file added doc/img/i128_graphs/linux/ARM32_benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/i128_graphs/linux/ARM64_benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/i128_graphs/linux/ppc64le_benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/i128_graphs/linux/s390x_benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/i128_graphs/linux/x64_benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/i128_graphs/linux/x86_benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/i128_graphs/macos/ARM64_benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/i128_graphs/macos/x64_benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/i128_graphs/windows/ARM64_benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/i128_graphs/windows/x64_benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added doc/img/i128_graphs/windows/x86_benchmarks.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions doc/int128.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ https://www.boost.org/LICENSE_1_0.txt
:source-language: c++

:leveloffset: +1
:imagesdir: ../img

= Int128: Portable and Performant 128-bit integers
Matt Borland
Expand All @@ -39,6 +40,8 @@ include::int128/saturating.adoc[]

include::int128/u128_benchmarks.adoc[]

include::int128/i128_benchmarks.adoc[]

include::int128/reference.adoc[]

include::int128/copyright.adoc[]
Expand Down
244 changes: 244 additions & 0 deletions doc/int128/i128_benchmarks.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
////
Copyright 2025 Matt Borland
Distributed under the Boost Software License, Version 1.0.
https://www.boost.org/LICENSE_1_0.txt
////

[#i128_benchmarks]
= `int128_t` Benchmarks
:idprefix: i128_benchmarks_

== Methodology

The benchmarks below represent the time in microseconds it takes to perform 20'000'000 operations between two values of random width (e.g. 2x1 words, 1x2 words, etc.).
On most platforms we use the builtin `\__int128` as the reference benchmark.
When this is unavailable (such as on 32-bit architectures) we us `boost::multiprecision::int128_t` (abbreviated as `boost::mp::int128_t`) as it is widely used, and known to be portable.
On MSVC platforms we use as reference `std::_Signed128` from the header `<__msvc_int128.hpp>` since this is bundled with their compiler.

== Linux

=== x86_64

[cols="1,1,1,1"]
|===
| Operation | `__int128` | `int128_t` | `boost::mp::int128_t`

| Comparisons | 2086545 | 1807917 | 6119951
| Addition | 229772 | 249644 | 620566
| Subtraction | 245300 | 172252 | 1522422
| Multiplication | 403481 | 246659 | 898345
| Division | 4315016 | 4369512 | 4767180
| Modulo | 4303454 | 4686920 | 4855786
|===

////
image::i128_graphs/linux/x64_benchmarks.png[x64 Benchmark Results, width=100%]
////

image::i128_graphs/linux/x64_relative_performance.png[x64 Relative Performance, width=100%]

=== ARM64

[cols="1,1,1,1"]
|===
| Operation | `__int128` | `int128_t` | `boost::mp::int128_t`

| Comparisons | 3524205 | 2191692 | 5559916
| Addition | 109691 | 126544 | 553814
| Subtraction | 195129 | 196092 | 1024231
| Multiplication | 286623 | 192214 | 924637
| Division | 2350225 | 2163053 | 2718340
| Modulo | 2345191 | 2167260 | 2380277
|===

////
image::i128_graphs/linux/ARM64_benchmarks.png[ARM64 Benchmark Results, width=100%]
////

image::i128_graphs/linux/ARM64_relative_performance.png[x64 Relative Performance, width=100%]

=== S390x

[cols="1,1,1,1"]
|===
| Operation | `__int128` | `int128_t` | `boost::mp::int128_t`

| Comparisons | 7033705 | 6231386 | 10322828
| Addition | 558950 | 689575 | 1673032
| Subtraction | 534362 | 329127 | 2149206
| Multiplication | 911317 | 946090 | 1362947
| Division | 4371582 | 3574992 | 3669927
| Modulo | 4375939 | 3727994 | 4419901
|===

////
image::i128_graphs/linux/s390x_benchmarks.png[s390x Benchmark Results, width=100%]
////

image::i128_graphs/linux/s390x_relative_performance.png[s390x Relative Performance, width=100%]

=== PPC64LE

[cols="1,1,1,1"]
|===
| Operation | `__int128` | `int128_t` | `boost::mp::int128_t`

| Comparisons | 4538094 | 5796198 | 13907323
| Addition | 221708 | 191841 | 1177034
| Subtraction | 222629 | 174273 | 1861166
| Multiplication | 193315 | 191785 | 878393
| Division | 5607581 | 4669820 | 5616217
| Modulo | 5623562 | 4750314 | 5641480
|===

////
image::i128_graphs/linux/ppc64le_benchmarks.png[ppc64le Benchmark Results, width=100%]
////

image::i128_graphs/linux/ppc64le_relative_performance.png[ppc64le Relative Performance, width=100%]


=== x86_32

NOTE: This platform has no hardware type so we compare relative to `boost::mp::int128_t`

[cols="1,1,1"]
|===
| Operation | `int128_t` | `boost::mp::int128_t`

| Comparisons | 9530060 | 12168353
| Addition | 785799 | 7777469
| Subtraction | 778881 | 8214089
| Multiplication | 1148024 | 9477355
| Division | 10337258 | 22857709
| Modulo | 10438037 | 14848256
|===

////
image::i128_graphs/linux/x86_benchmarks.png[x86 Benchmark Results, width=100%]
////

image::i128_graphs/linux/x86_relative_performance.png[x86 Relative Performance, width=100%]

=== ARM32

NOTE: This platform has no hardware type so we compare relative to `boost::mp::int128_t`

[cols="1,1,1"]
|===
| Operation | `int128_t` | `boost::mp::int128_t`

| Comparisons | 6149439 | 6432579
| Addition | 457850 | 5669571
| Subtraction | 488321 | 7464427
| Multiplication | 1793874 | 11410321
| Division | 17738614 | 38956122
| Modulo | 18064819 | 30144743
|===

////
image::i128_graphs/linux/ARM32_benchmarks.png[ARM32 Benchmark Results, width=100%]
////

image::i128_graphs/linux/ARM32_relative_performance.png[ARM32 Relative Performance, width=100%]

== Windows

=== x86_64

[cols="1,1,1,1"]
|===
| Operation | `std::_Signed128` | `int128_t` | `boost::mp::int128_t`

| Comparisons | 2186843 | 2142626 | 4854983
| Addition | 186771 | 184598 | 2645943
| Subtraction | 193660 | 186335 | 2925784
| Multiplication | 402806 | 117413 | 3887479
| Division | 1612873 | 2369701 | 6437280
| Modulo | 1637135 | 2218627 | 6236026
|===
////
image::i128_graphs/windows/x64_benchmarks.png[x64 Benchmark Results, width=100%]
////

image::i128_graphs/windows/x64_relative_performance.png[x64 Relative Performance, width=100%]

=== ARM64

[cols="1,1,1,1"]
|===
| Operation | `std::_Signed128` | `int128_t` | `boost::mp::int128_t`

| Comparisons | 911829 | 368104 | 2376802
| Addition | 33233 | 34001 | 121700
| Subtraction | 33411 | 34130 | 1488822
| Multiplication | 117586 | 56324 | 1564799
| Division | 1127267 | 1500725 | 2808293
| Modulo | 1287100 | 1548073 | 2997474
|===
////
image::i128_graphs/windows/ARM64_benchmarks.png[ARM64 Benchmark Results, width=100%]
////

image::i128_graphs/windows/ARM64_relative_performance.png[ARM64 Relative Performance, width=100%]

=== x86_32

[cols="1,1,1,1"]
|===
| Operation | `std::_Signed128` | `int128_t` | `boost::mp::int128_t`

| Comparisons | 3187340 | 3046252 | 4269507
| Addition | 185960 | 189165 | 2488618
| Subtraction | 979025 | 192609 | 2783600
| Multiplication | 1896082 | 3569921 | 4908622
| Division | 5566403 | 4348306 | 6835035
| Modulo | 4697289 | 4793845 | 6476032
|===
////
image::i128_graphs/windows/x86_benchmarks.png[x86_32 Benchmark Results, width=100%]
////

image::i128_graphs/windows/x86_relative_performance.png[x86_32 Relative Performance, width=100%]

== macOS

=== ARM64 (Apple Silicon)

[cols="1,1,1,1"]
|===
| Operation | `__int128` | `int128_t` | `boost::mp::int128_t`

| Comparisons | 134803 | 144313 | 338665
| Addition | 20133 | 17820 | 168326
| Subtraction | 20156 | 17864 | 169666
| Multiplication | 19974 | 18572 | 77514
| Division | 649380 | 666749 | 962183
| Modulo | 708247 | 681991 | 1014055
|===

////
image::i128_graphs/macos/ARM64_benchmarks.png[ARM64 Benchmark Results, width=100%]
////

image::i128_graphs/macos/ARM64_relative_performance.png[ARM64 Relative Performance, width=100%]

=== x86_64

[cols="1,1,1,1"]
|===
| Operation | `__int128` | `int128_t` | `boost::mp::int128_t`

| Comparisons | 1628142 | 1748005 | 4318109
| Addition | 224648 | 180393 | 925013
| Subtraction | 212849 | 131062 | 1876834
| Multiplication | 432205 | 407829 | 651209
| Division | 3924951 | 2409106 | 3719183
| Modulo | 3042060 | 2423738 | 4443402
|===

////
image::i128_graphs/macos/x64_benchmarks.png[x64 Benchmark Results, width=100%]
////

image::i128_graphs/macos/x64_relative_performance.png[x64 Relative Performance, width=100%]
3 changes: 2 additions & 1 deletion doc/int128/overview.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ https://www.boost.org/LICENSE_1_0.txt
== Description

Boost.Int128 is a portable implementation of a signed, and an unsigned 128-bit integer and related functionality (e.g. bit counting).
Importantly, on all platforms, the `sizeof` the types provided in this library are 128-bits.

The library is header-only, has no dependencies, and requires only C++14.

Expand All @@ -26,7 +27,7 @@ Anywhere 128-bits are needed.
== Supported Compilers

Boost.Int128 is tested natively on Ubuntu (x86_64, s390x, and aarch64), macOS (x86_64, and Apple Silicon), and Windows (x32 and x64);
as well as emulated PPC64LE and STM32 using QEMU with the following compilers:
as well as emulated PPC64LE using QEMU with the following compilers:

* GCC 5 and later
* Clang 5 and later
Expand Down
50 changes: 25 additions & 25 deletions doc/int128/u128_benchmarks.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ On MSVC platforms we use as reference `std::_Unsigned128` from the header `<__ms

[cols="1,1,1,1"]
|===
| Operation | `std::_Unsigned128` | `uint128_t` | `boost::mp::uint128_t`
| Operation | `unsigned __int128` | `uint128_t` | `boost::mp::uint128_t`

| Comparisons | 2068491 | 2416378 | 3191439
| Addition | 383258 | 180522 | 545521
Expand All @@ -41,7 +41,7 @@ image::u128_graphs/linux/x64_relative_performance.png[x64 Relative Performance,

[cols="1,1,1,1"]
|===
| Operation | `std::_Unsigned128` | `uint128_t` | `boost::mp::uint128_t`
| Operation | `unsigned __int128` | `uint128_t` | `boost::mp::uint128_t`

| Comparisons | 2068491 | 2416378 | 3191439
| Addition | 383258 | 180522 | 545521
Expand All @@ -61,7 +61,7 @@ image::u128_graphs/linux/ARM64_relative_performance.png[x64 Relative Performance

[cols="1,1,1,1"]
|===
| Operation | `std::_Unsigned128` | `uint128_t` | `boost::mp::uint128_t`
| Operation | `unsigned __int128` | `uint128_t` | `boost::mp::uint128_t`

| Comparisons | 14415854 | 12658246 | 16561079
| Addition | 1232397 | 1423451 | 2909066
Expand All @@ -81,7 +81,7 @@ image::u128_graphs/linux/s390x_relative_performance.png[s390x Relative Performan

[cols="1,1,1,1"]
|===
| Operation | `std::_Unsigned128` | `uint128_t` | `boost::mp::uint128_t`
| Operation | `unsigned __int128` | `uint128_t` | `boost::mp::uint128_t`

| Comparisons | 5242604 | 4450958 | 5704848
| Addition | 221776 | 193063 | 847504
Expand Down Expand Up @@ -144,6 +144,25 @@ image::u128_graphs/linux/ARM32_relative_performance.png[ARM32 Relative Performan

== Windows

=== x86_64

[cols="1,1,1,1"]
|===
| Operation | `std::_Unsigned128` | `uint128_t` | `boost::mp::uint128_t`

| Comparisons | 2060556 | 1921174 | 3009890
| Addition | 261475 | 106545 | 2710279
| Subtraction | 178724 | 124181 | 3059187
| Multiplication | 146063 | 136115 | 3495634
| Division | 1332838 | 1360295 | 4852899
| Modulo | 1465138 | 1471169 | 3926336
|===
////
image::u128_graphs/windows/x64_benchmarks.png[x64 Benchmark Results, width=100%]
////

image::u128_graphs/windows/x64_relative_performance.png[x64 Relative Performance, width=100%]

=== ARM64

[cols="1,1,1,1"]
Expand Down Expand Up @@ -182,32 +201,13 @@ image::u128_graphs/windows/x86_benchmarks.png[x86_32 Benchmark Results, width=10

image::u128_graphs/windows/x86_relative_performance.png[x86_32 Relative Performance, width=100%]

=== x86_64

[cols="1,1,1,1"]
|===
| Operation | `std::_Unsigned128` | `uint128_t` | `boost::mp::uint128_t`

| Comparisons | 2060556 | 1921174 | 3009890
| Addition | 261475 | 106545 | 2710279
| Subtraction | 178724 | 124181 | 3059187
| Multiplication | 146063 | 136115 | 3495634
| Division | 1332838 | 1360295 | 4852899
| Modulo | 1465138 | 1471169 | 3926336
|===
////
image::u128_graphs/windows/x64_benchmarks.png[x64 Benchmark Results, width=100%]
////

image::u128_graphs/windows/x64_relative_performance.png[x64 Relative Performance, width=100%]

== macOS

=== ARM64 (Apple Silicon)

[cols="1,1,1,1"]
|===
| Operation | `unsigned __in128` | `uint128_t` | `boost::mp::uint128_t`
| Operation | `unsigned __int128` | `uint128_t` | `boost::mp::uint128_t`

| Comparisons | 131902 | 133564 | 134182
| Addition | 20613 | 17912 | 40176
Expand All @@ -227,7 +227,7 @@ image::u128_graphs/macos/ARM64_relative_performance.png[ARM64 Relative Performan

[cols="1,1,1,1"]
|===
| Operation | `unsigned __in128` | `uint128_t` | `boost::mp::uint128_t`
| Operation | `unsigned __int128` | `uint128_t` | `boost::mp::uint128_t`

| Comparisons | 131902 | 133564 | 134182
| Addition | 20613 | 17912 | 40176
Expand Down
Loading