STREAM Benchmark及其操作性能分析

STREAM 是业界广为流行的综合性内存带宽实际性能 测量 工具之一。随着处理器处理核心数量的增多,内存带宽对于提升整个系统性能越发重要,如果某个系统不能够足够迅速地将内存中的数据传输到处理器当中,若干处理核心就会处于等待数据的闲置状态,而这其中所产生的闲置时间不仅会降低系统的效率还会抵消多核心和高主频所带来的性能提升因素。 STREAM 具有良好的空间局部性,是对 TLB 友好、Cache友好的一款测试。STREAM支持Copy 、Scale 、 Add、 Triad四种操作,下面分别介绍四种操作的含义:

void tuned_STREAM_Copy()
{
    int j;
        for (j=0; j<N; j++)
            c[j] = a[j];
}
void tuned_STREAM_Scale(double scalar)
{
    int j;
    for (j=0; j<N; j++)
        b[j] = scalar*c[j];
}
void tuned_STREAM_Add()
{
    int j;
    for (j=0; j<N; j++)
        c[j] = a[j]+b[j];
}
void tuned_STREAM_Triad(double scalar)
{
    int j;
    for (j=0; j<N; j++)
        a[j] = b[j]+scalar*c[j];
}

Copy操作最为简单,它先访问一个内存单元读出其中的值,再将值写入到另一个内存单元。
Scale操作先从内存单元读出其中的值,作一个乘法运算,再将结果写入到另一个内存单元。
Add操作先从内存单元读出两个值,做加法运算, 再将结果写入到另一个内存单元。
Triad的中文含义是将三个组合起来,在本测试中表示的意思是将Copy、Scale、Add三种操作组合起来进行测试。具体操作方式是:先从内存单元中中读两个值a、b,对其进行乘加混合运算(a + 因子 * b ) ,将运算结果写入到另一个内存单元。

延伸内容:
以上分析基于STREAM1.0,现在已经推出了STREAM2.0测试,总体思想一致,四种操作进行了少许修改:

STREAM2 is an attempt to extend the functionality of the STREAM benchmark in two important ways:

      STREAM2 measures sustained bandwidth at all levels of the cache hierarchy, and
      STREAM2 more clearly exposes the performance differences between reads and writes

STREAM2 is based on the same ideas as STREAM, but uses a different set of vector kernels:

      FILL:        similar to bzero(), but fills with a constant instead of zero
      COPY:        similar to bcopy(), and the same as STREAM Copy
      DAXPY:    similar to STREAM Triad, but overwrites one of the input vectors instead of writing results to a third vector
      SUM:        sum reduction on a single vector -- reads only, no writes
---------------------
作者:maray
来源:CSDN
原文:https://blog.csdn.net/maray/article/details/6230912
版权声明:本文为博主原创文章,转载请附上博文链接!

原文地址:https://www.cnblogs.com/idyllcheung/p/11278339.html