用superpi、tinypi、tpi等工具计算圆周率的比较

无意中发现,测试CPU性能的super pi程序开源了。

https://github.com/Fibonacci43/SuperPI/archive/refs/heads/main.zip

在windows中用mingw64 gcc编译

复制代码
C:\d>set path=C:\WINDOWS\system32;C:\WINDOWS;C:\d\mingw64\bin;C:\d\pypy

C:\d>cd SuperPI-main

C:\d\SuperPI-main>gcc -O -funroll-loops -fomit-frame-pointer pi_fftcs.c fftsg_h.c -lm -o pi_css5



C:\d\SuperPI-main>pi_css5
Calculation of PI using FFT and AGM, ver. LG1.1.2-MP1.5.2a.memsave

Usage: pi_css5 digits

Number of digits of pi to calculate?
1
initializing...
nfft= 2
radix= 10000
error_margin= 1.0747e-07
calculating 8 digits of PI...
AGM iteration
precision= 48: 0.00 sec
writing pi8.txt...
0.00 sec. (real time)
Hit RETURN to exit.


C:\d\SuperPI-main>pi_css5
Calculation of PI using FFT and AGM, ver. LG1.1.2-MP1.5.2a.memsave

Usage: pi_css5 digits

Number of digits of pi to calculate?
1000000
initializing...
nfft= 262144
radix= 10000
error_margin= 0.00611182
calculating 1048576 digits of PI...
AGM iteration
precision= 48: 0.06 sec
precision= 80: 0.06 sec
precision= 176: 0.06 sec
precision= 352: 0.06 sec
precision= 688: 0.06 sec
precision= 1392: 0.06 sec
precision= 2784: 0.06 sec
precision= 5584: 0.06 sec
precision= 11168: 0.06 sec
precision= 22336: 0.06 sec
precision= 44688: 0.06 sec
precision= 89408: 0.06 sec
precision= 178816: 0.06 sec
precision= 357648: 0.06 sec
precision= 715312: 0.06 sec
precision= 1430640: 0.06 sec
writing pi1048576.txt...
1.05 sec. (real time)
Hit RETURN to exit.


C:\d\SuperPI-main>pi_css5
Calculation of PI using FFT and AGM, ver. LG1.1.2-MP1.5.2a.memsave

Usage: pi_css5 digits

Number of digits of pi to calculate?
10000000
initializing...
nfft= 4194304
radix= 10000
error_margin= 0.136439
calculating 16777216 digits of PI...
AGM iteration
precision= 48: 1.02 sec
precision= 80: 1.02 sec
precision= 176: 1.02 sec
precision= 352: 1.02 sec
precision= 688: 1.02 sec
precision= 1392: 1.02 sec
precision= 2784: 1.02 sec
precision= 5584: 1.02 sec
precision= 11168: 1.02 sec
precision= 22336: 1.02 sec
precision= 44688: 1.02 sec
precision= 89408: 1.02 sec
precision= 178816: 1.02 sec
precision= 357648: 1.02 sec
precision= 715312: 1.02 sec
precision= 1430640: 1.02 sec
precision= 2861280: 1.02 sec
precision= 5722592: 1.02 sec
precision= 11445200: 1.02 sec
precision= 22890416: 1.03 sec
writing pi16777216.txt...
23.32 sec. (real time)
Hit RETURN to exit.

100万和1600万的执行结果比tinycc作者的tinypi还要快。

复制代码
C:\d\SuperPI-main>

https://bellard.org/pi/tinypi/

https://bellard.org/pi/tinypi/tinypi-2024-11-04.tar.gz

C:\d\SuperPI-main>gcc -O2 tinypi.c -o tinypi

C:\d\SuperPI-main>..\timer64 tinypi 1e6 pi_1e6.txt


Kernel  Time =     0.046 =    3%
User    Time =     1.328 =   93%
Process Time =     1.375 =   97%    Virtual  Memory =     10 MB
Global  Time =     1.415 =  100%    Physical Memory =     13 MB

C:\d\SuperPI-main>..\timer64 tinypi 1e7 pi_1e7.txt


Kernel  Time =     0.453 =    1%
User    Time =    24.000 =   97%
Process Time =    24.453 =   99%    Virtual  Memory =    100 MB
Global  Time =    24.503 =  100%    Physical Memory =    103 MB

但是不如bellard没有开源,只提供二进制文件的tpi快。

https://bellard.org/pi/pi2700e9/tpi-0.9.3-win.zip

https://bellard.org/pi/pi2700e9/tpi-0.9-linux.tar.gz

复制代码
C:\d\SuperPI-main>..\timer64 tpi -o pi.txt 10M
Using 12.6GiB of RAM
Computation to 10000000 digits, formula=Chudnovsky
Output file=pi.txt, format=txt, binary result size=4.15MB
Binary Splitting
Depth=20
  mem   max  disk   max operation                       compl lv
55.5M 55.5M     0     0 completed                      100.0%  0
  time = 1.955 s
Compute P, Q
43.5M 55.5M     0     0 completed
  time = 0.028 s
Division
61.5M 61.5M     0     0 completed
  time = 0.187 s
Sqrt
54.4M 61.5M     0     0 completed
  time = 0.120 s
Final multiplication
85.3M 85.3M     0     0 completed
  time = 0.088 s
Total time (binary result) = 2.378 s
Base conversion
56.4M 85.3M     0     0 completed
  time = 0.336 s
Total time (base 10 result) = 2.714 s
Writing result to 'pi.txt'


Kernel  Time =     0.328 =   11%
User    Time =     2.453 =   86%
Process Time =     2.781 =   98%    Virtual  Memory =     87 MB
Global  Time =     2.836 =  100%    Physical Memory =     91 MB


C:\d\SuperPI-main>..\timer64 tpi -T 4 -o pi4.txt 10M
Using 12.6GiB of RAM
Computation to 10000000 digits, formula=Chudnovsky
Output file=pi4.txt, format=txt, binary result size=4.15MB
Binary Splitting
Depth=20, thread_level=0
  mem   max  disk   max operation                       compl lv
55.8M 55.8M     0     0 completed                        0.0%  0
  time = 0.641 s
Compute P, Q
43.2M 55.8M     0     0 completed
  time = 0.015 s
Division
61.7M 61.7M     0     0 completed
  time = 0.097 s
Sqrt
54.7M 61.7M     0     0 completed
  time = 0.065 s
Final multiplication
85.8M 85.8M     0     0 completed
  time = 0.038 s
Total time (binary result) = 0.857 s
Base conversion
56.7M 85.8M     0     0 completed
  time = 0.281 s
Total time (base 10 result) = 1.138 s
Writing result to 'pi4.txt'


Kernel  Time =     0.234 =   19%
User    Time =     2.484 =  201%
Process Time =     2.718 =  220%    Virtual  Memory =     90 MB
Global  Time =     1.230 =  100%    Physical Memory =     94 MB

tpi还支持并行计算。

相关推荐
学逆向的7 分钟前
C 多文件开发
c语言·开发语言·网络安全
企业数字化笔记17 分钟前
AI视频增强后画质怎么验收?插值基线、伪细节与帧间闪烁的检查方法
人工智能·算法·音视频
学逆向的41 分钟前
C 内存属性
c语言·开发语言·算法·网络安全
Zwawa1 小时前
一盏 LED 不够用了:让同一盏灯说出不同的话
c语言·单片机·嵌入式
lengxuenong1 小时前
树状数组 · 信息学学习手册1-求和3个模板
c++·学习·算法·青少年编程
ComputerInBook1 小时前
泛函分析概观
人工智能·算法·机器学习·泛函分析
Nuanyt2 小时前
LeetCode Hot100 刷题笔记 · 普通数组专题
java·笔记·算法·leetcode
q27551300422 小时前
AS8132 DP转HDMI 4K60(420)被动式 国产性价比AS方案
linux·算法·硬件架构·dash
安全指北针2 小时前
密态计算:数据 “可用不可见” 的底层技术解析
人工智能·算法