Stream使用教程

本文详细介绍了如何使用Streambenchmark进行内存带宽和内核向量计算速度的基准测试,包括安装步骤、测试过程及结果解读。通过四个不同测试项(copy、scale、add、triad)的比较,展示了程序性能受内存带宽限制的现象。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

        现在,计算机CPU运行速度的快速发展已经远远超过了内存的访问速度。越来越多的程序性能被内存带宽所限制,而不是计算机的CPU运行速率。

        Stream benchmark是一个简单的合成基准测试程序,衡量内存带宽(MB /秒)和相应的内核向量的计算速度。

 Each of the four tests adds independent information to the results:

        1. “copy”:在没有算术的衡量传输速率;

        2. “Scale

  • ``Copy'' measures transfer rates in the absence of arithmetic.
  • ``Scale'' adds a simple arithmetic operation.
  • ``Sum'' adds a third operand to allow multiple load/store ports on vector machines to be tested.
  • ``Triad'' allows chained/overlapped/fused multiply/add operations.

1. 安装

[root@RedHat stream]# make
gcc -O2 stream.c -o stream
[root@RedHat stream]# ls
Makefile  stream  stream.c  stream.f

2. 测试

[root@RedHat stream]# ./stream
-------------------------------------------------------------
STREAM version $Revision: 5.9 $
-------------------------------------------------------------
This system uses 8 bytes per DOUBLE PRECISION word.
-------------------------------------------------------------
Array size = 2000000, Offset = 0
Total memory required = 45.8 MB.
Each test is run 10 times, but only
the *best* time for each is used.
-------------------------------------------------------------
Printing one line per active thread....
-------------------------------------------------------------
Your clock granularity/precision appears to be 6 microseconds.
Each test below will take on the order of 17340 microseconds.
   (= 2890 clock ticks)
Increase the size of the arrays if this shows that
you are not getting at least 20 clock ticks per test.
-------------------------------------------------------------
WARNING -- The above is only a rough guideline.
For best results, please be sure you know the
precision of your system timer.
-------------------------------------------------------------
Function      Rate (MB/s)   Avg time     Min time     Max time
Copy:        2264.0171       0.0154       0.0141       0.0169
Scale:       2212.8422       0.0154       0.0145       0.0164
Add:         2936.3309       0.0196       0.0163       0.0214
Triad:       2673.8123       0.0199       0.0180       0.0216
-------------------------------------------------------------
Solution Validates
-------------------------------------------------------------
[root@RedHat stream]#

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YoungerChina

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值