Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Port signed integer math to modern QDK #1841

Merged
merged 16 commits into from
Aug 22, 2024
Merged

Port signed integer math to modern QDK #1841

merged 16 commits into from
Aug 22, 2024

Conversation

sezna
Copy link
Contributor

@sezna sezna commented Aug 14, 2024

This PR ports the classic QDK's signed int math functionality to the modern QDK.

It is not intended to provide the perfect API -- it is just a port, that other libraries will build upon, primarily the fixed point library.

Copy link

Benchmark for 9bf065e

Click to view benchmark
Test Base PR %
Array append evaluation 336.9±7.50µs 335.1±2.94µs -0.53%
Array literal evaluation 186.2±0.81µs 186.3±1.07µs +0.05%
Array update evaluation 414.6±6.11µs 413.6±1.25µs -0.24%
Core + Standard library compilation 22.0±0.25ms 21.9±0.33ms -0.45%
Deutsch-Jozsa evaluation 4.9±0.06ms 4.9±0.10ms 0.00%
Large file parity evaluation 34.5±0.26ms 34.5±0.27ms 0.00%
Large input file compilation 13.8±0.27ms 13.8±0.23ms 0.00%
Large input file compilation (interpreter) 51.5±1.69ms 51.4±1.50ms -0.19%
Large nested iteration 33.0±0.30ms 32.8±0.31ms -0.61%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1552.6±32.53µs 1551.9±33.59µs -0.05%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.7±0.07ms 7.7±0.37ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1420.6±49.01µs 1417.9±40.44µs -0.19%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.5±0.37ms 27.4±0.13ms -0.36%
Teleport evaluation 92.9±3.57µs 94.0±3.42µs +1.18%

Copy link

Benchmark for e9ecf1c

Click to view benchmark
Test Base PR %
Array append evaluation 336.3±14.67µs 333.1±1.68µs -0.95%
Array literal evaluation 208.1±1.96µs 224.3±1.14µs +7.78%
Array update evaluation 415.4±1.52µs 412.1±2.79µs -0.79%
Core + Standard library compilation 21.8±0.26ms 22.5±0.82ms +3.21%
Deutsch-Jozsa evaluation 4.9±0.06ms 4.9±0.06ms 0.00%
Large file parity evaluation 34.5±0.27ms 34.6±0.48ms +0.29%
Large input file compilation 13.7±0.22ms 13.7±0.50ms 0.00%
Large input file compilation (interpreter) 51.9±2.08ms 56.7±1.86ms +9.25%
Large nested iteration 32.8±0.18ms 32.9±0.28ms +0.30%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1563.2±32.61µs 1560.7±25.89µs -0.16%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.12ms 7.8±0.13ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1423.3±37.19µs 1442.8±101.89µs +1.37%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.6±0.34ms 27.8±0.71ms +0.72%
Teleport evaluation 92.4±3.49µs 93.8±4.26µs +1.52%

Copy link

Benchmark for 45e2c36

Click to view benchmark
Test Base PR %
Array append evaluation 334.0±1.79µs 336.8±1.94µs +0.84%
Array literal evaluation 192.4±1.14µs 197.4±5.17µs +2.60%
Array update evaluation 412.6±2.00µs 416.3±2.18µs +0.90%
Core + Standard library compilation 25.6±1.50ms 25.9±1.02ms +1.17%
Deutsch-Jozsa evaluation 5.0±0.06ms 5.0±0.06ms 0.00%
Large file parity evaluation 35.0±0.27ms 34.9±0.34ms -0.29%
Large input file compilation 15.4±0.49ms 15.3±0.48ms -0.65%
Large input file compilation (interpreter) 59.8±2.55ms 59.2±2.23ms -1.00%
Large nested iteration 32.7±0.18ms 33.1±0.21ms +1.22%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1598.8±105.78µs 1606.2±119.65µs +0.46%
Perform Runtime Capabilities Analysis (RCA) on large file sample 8.3±0.16ms 8.4±0.19ms +1.20%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1457.8±103.24µs 1469.4±112.59µs +0.80%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.4±0.27ms 28.6±0.23ms +0.70%
Teleport evaluation 94.5±3.73µs 94.4±4.22µs -0.11%

Copy link

Benchmark for 170b917

Click to view benchmark
Test Base PR %
Array append evaluation 336.6±2.55µs 335.0±3.20µs -0.48%
Array literal evaluation 178.3±4.53µs 192.4±2.34µs +7.91%
Array update evaluation 417.1±3.25µs 412.9±1.55µs -1.01%
Core + Standard library compilation 24.2±0.65ms 26.7±1.27ms +10.33%
Deutsch-Jozsa evaluation 5.0±0.20ms 5.0±0.18ms 0.00%
Large file parity evaluation 34.9±0.51ms 34.8±0.49ms -0.29%
Large input file compilation 14.4±0.40ms 14.0±0.42ms -2.78%
Large input file compilation (interpreter) 56.7±1.86ms 59.8±2.99ms +5.47%
Large nested iteration 33.1±0.33ms 32.9±0.43ms -0.60%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1627.4±193.03µs 1572.4±56.68µs -3.38%
Perform Runtime Capabilities Analysis (RCA) on large file sample 8.1±0.14ms 7.9±0.16ms -2.47%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1452.3±83.16µs 1427.2±59.05µs -1.73%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.4±1.48ms 28.0±0.46ms -1.41%
Teleport evaluation 94.9±6.41µs 94.0±3.90µs -0.95%

Copy link

Benchmark for 75a9a1b

Click to view benchmark
Test Base PR %
Array append evaluation 333.3±3.34µs 336.0±5.99µs +0.81%
Array literal evaluation 192.8±2.93µs 175.4±2.59µs -9.02%
Array update evaluation 413.8±5.42µs 417.8±5.29µs +0.97%
Core + Standard library compilation 23.1±0.60ms 23.1±0.71ms 0.00%
Deutsch-Jozsa evaluation 5.0±0.06ms 5.0±0.06ms 0.00%
Large file parity evaluation 34.8±0.27ms 34.8±0.37ms 0.00%
Large input file compilation 14.4±0.32ms 14.3±0.37ms -0.69%
Large input file compilation (interpreter) 56.2±2.31ms 55.8±2.20ms -0.71%
Large nested iteration 32.7±0.34ms 32.8±0.27ms +0.31%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1586.5±138.96µs 1580.2±64.80µs -0.40%
Perform Runtime Capabilities Analysis (RCA) on large file sample 8.0±0.13ms 8.0±0.12ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1441.6±63.84µs 1445.3±102.89µs +0.26%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.9±0.28ms 28.0±0.29ms +0.36%
Teleport evaluation 93.5±3.58µs 94.1±3.84µs +0.64%

Copy link

Benchmark for 03a5d55

Click to view benchmark
Test Base PR %
Array append evaluation 338.7±9.24µs 338.5±2.32µs -0.06%
Array literal evaluation 168.9±2.19µs 186.2±0.84µs +10.24%
Array update evaluation 417.5±7.21µs 415.8±2.93µs -0.41%
Core + Standard library compilation 25.0±0.80ms 24.2±0.89ms -3.20%
Deutsch-Jozsa evaluation 5.0±0.06ms 4.9±0.06ms -2.00%
Large file parity evaluation 34.2±0.11ms 34.2±0.16ms 0.00%
Large input file compilation 15.0±0.59ms 14.7±0.51ms -2.00%
Large input file compilation (interpreter) 56.2±1.83ms 56.6±2.08ms +0.71%
Large nested iteration 33.3±1.72ms 32.8±0.36ms -1.50%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1585.3±68.07µs 1594.2±105.62µs +0.56%
Perform Runtime Capabilities Analysis (RCA) on large file sample 8.2±0.17ms 8.1±0.14ms -1.22%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1452.4±82.27µs 1451.1±137.74µs -0.09%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.3±0.25ms 28.2±0.45ms -0.35%
Teleport evaluation 93.9±3.67µs 93.7±4.72µs -0.21%

Copy link

Benchmark for 072b2fe

Click to view benchmark
Test Base PR %
Array append evaluation 339.1±3.88µs 336.8±8.86µs -0.68%
Array literal evaluation 169.8±6.47µs 185.6±0.73µs +9.31%
Array update evaluation 419.4±21.64µs 413.7±3.18µs -1.36%
Core + Standard library compilation 22.6±0.74ms 22.2±0.73ms -1.77%
Deutsch-Jozsa evaluation 4.9±0.14ms 5.0±0.07ms +2.04%
Large file parity evaluation 34.2±0.08ms 34.2±0.10ms 0.00%
Large input file compilation 14.2±0.67ms 13.7±0.23ms -3.52%
Large input file compilation (interpreter) 51.5±1.52ms 53.5±1.94ms +3.88%
Large nested iteration 32.7±0.33ms 32.7±0.39ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1558.8±35.97µs 1559.3±30.30µs +0.03%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.09ms 7.9±0.11ms +1.28%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1428.1±46.30µs 1443.3±139.48µs +1.06%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.3±1.08ms 27.8±0.32ms -1.77%
Teleport evaluation 93.6±3.49µs 93.4±5.91µs -0.21%

Copy link
Contributor

@cesarzc cesarzc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a few minor comments.

sezna and others added 2 commits August 21, 2024 19:14
Copy link

Benchmark for 36e7798

Click to view benchmark
Test Base PR %
Array append evaluation 339.8±4.61µs 338.2±2.55µs -0.47%
Array literal evaluation 168.9±1.17µs 170.0±8.99µs +0.65%
Array update evaluation 417.7±5.07µs 415.2±1.68µs -0.60%
Core + Standard library compilation 21.7±0.10ms 21.7±0.41ms 0.00%
Deutsch-Jozsa evaluation 4.9±0.07ms 4.9±0.06ms 0.00%
Large file parity evaluation 34.2±0.09ms 34.2±0.10ms 0.00%
Large input file compilation 13.5±0.12ms 13.6±0.24ms +0.74%
Large input file compilation (interpreter) 50.6±1.53ms 50.7±0.94ms +0.20%
Large nested iteration 34.1±2.30ms 32.8±0.77ms -3.81%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1555.0±27.65µs 1554.2±27.03µs -0.05%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.8±0.15ms 7.8±0.09ms 0.00%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1420.5±34.77µs 1419.6±41.41µs -0.06%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.7±0.60ms 27.6±0.28ms -0.36%
Teleport evaluation 93.2±3.36µs 93.0±4.35µs -0.21%

Copy link

Benchmark for b38992a

Click to view benchmark
Test Base PR %
Array append evaluation 338.2±4.01µs 339.4±2.80µs +0.35%
Array literal evaluation 186.3±1.06µs 186.7±4.26µs +0.21%
Array update evaluation 415.1±3.93µs 416.8±5.90µs +0.41%
Core + Standard library compilation 25.0±1.02ms 24.7±0.73ms -1.20%
Deutsch-Jozsa evaluation 5.0±0.06ms 5.0±0.06ms 0.00%
Large file parity evaluation 34.5±0.64ms 34.4±0.61ms -0.29%
Large input file compilation 14.8±0.34ms 15.0±0.61ms +1.35%
Large input file compilation (interpreter) 57.3±1.94ms 57.8±2.48ms +0.87%
Large nested iteration 32.9±0.84ms 32.8±0.15ms -0.30%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1608.4±114.85µs 1603.2±93.14µs -0.32%
Perform Runtime Capabilities Analysis (RCA) on large file sample 8.1±0.16ms 8.2±0.16ms +1.23%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1473.4±137.92µs 1470.6±121.52µs -0.19%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.5±0.38ms 28.3±0.26ms -0.70%
Teleport evaluation 94.4±3.70µs 94.1±3.75µs -0.32%

@DmitryVasilevsky
Copy link
Contributor

DmitryVasilevsky commented Aug 22, 2024

@sezna , Feel free to postpone all my comments for later time if you need. We can always improve code :)

Copy link

Benchmark for 5bbb91a

Click to view benchmark
Test Base PR %
Array append evaluation 337.8±6.12µs 339.0±1.75µs +0.36%
Array literal evaluation 186.5±0.83µs 169.1±1.25µs -9.33%
Array update evaluation 415.7±2.67µs 415.6±2.63µs -0.02%
Core + Standard library compilation 22.5±0.49ms 22.6±0.59ms +0.44%
Deutsch-Jozsa evaluation 5.0±0.06ms 4.9±0.06ms -2.00%
Large file parity evaluation 34.4±0.92ms 34.2±0.11ms -0.58%
Large input file compilation 14.1±0.27ms 14.2±0.56ms +0.71%
Large input file compilation (interpreter) 53.6±1.89ms 54.0±1.93ms +0.75%
Large nested iteration 32.6±0.11ms 33.7±1.22ms +3.37%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1566.3±36.82µs 1566.5±39.48µs +0.01%
Perform Runtime Capabilities Analysis (RCA) on large file sample 7.9±0.11ms 8.0±0.14ms +1.27%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1428.8±38.35µs 1438.2±83.07µs +0.66%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 27.8±0.18ms 27.8±0.22ms 0.00%
Teleport evaluation 93.6±3.63µs 92.9±3.76µs -0.75%

Copy link

Benchmark for 91aeb81

Click to view benchmark
Test Base PR %
Array append evaluation 338.9±3.41µs 343.1±10.11µs +1.24%
Array literal evaluation 168.6±1.50µs 169.6±6.15µs +0.59%
Array update evaluation 415.7±2.27µs 415.7±1.97µs 0.00%
Core + Standard library compilation 25.8±1.55ms 22.8±0.86ms -11.63%
Deutsch-Jozsa evaluation 5.0±0.06ms 5.0±0.08ms 0.00%
Large file parity evaluation 34.3±0.11ms 34.3±0.47ms 0.00%
Large input file compilation 14.3±0.51ms 14.5±0.70ms +1.40%
Large input file compilation (interpreter) 57.1±2.36ms 54.9±2.80ms -3.85%
Large nested iteration 32.8±0.32ms 32.7±0.60ms -0.30%
Perform Runtime Capabilities Analysis (RCA) on Deutsch-Jozsa sample 1580.9±43.76µs 1609.9±188.18µs +1.83%
Perform Runtime Capabilities Analysis (RCA) on large file sample 8.1±0.19ms 8.2±0.23ms +1.23%
Perform Runtime Capabilities Analysis (RCA) on teleport sample 1443.3±82.96µs 1440.2±67.44µs -0.21%
Perform Runtime Capabilities Analysis (RCA) on the core and std libraries 28.1±0.45ms 28.1±0.41ms 0.00%
Teleport evaluation 93.7±3.44µs 94.3±7.97µs +0.64%

@sezna sezna added this pull request to the merge queue Aug 22, 2024
Merged via the queue into main with commit e7f02d6 Aug 22, 2024
18 checks passed
@sezna sezna deleted the alex/signed-math branch August 22, 2024 21:46
github-merge-queue bot pushed a commit that referenced this pull request Aug 26, 2024
I forgot to export this as a part of the API in the initial PR (#1841).
This is needed in the Fixed Point library (#1838).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants