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
版權聲明:本文為博主原創文章,轉載請附上博文鏈接!