# SIMD or Algorithm - 0100

igame2000

## Intrinsics，SIMD，再加上OpenMP

``````#paragm omp parallel for
for(int h = 0; h < 1024; h++) {
.......

#paragm omp parallel for
for(int w = 0; w < 1024; w++)

......
}``````

You see，现在就剩下比较结果了。

``````int _tmain(int argc, _TCHAR* argv[]) {

INIT_PERF() // 初始化性能计数器

float perf0 = 0.0, perf1 = 0.0, perf2 = 0.0, perf3 = 0.0; // 分别用来统计4种方法的结果
const int loop = 1000; // 进行1000测试

for ( int i = 0; i < loop; i++ ) perf0 += test_Normal_Filter(); // 传统方法
for ( int i = 0; i < loop; i++ ) perf1 += test_Normal_OMP_Filter(); // 传统方法+OMP
for ( int i = 0; i < loop; i++ ) perf2 += test_SIMD_Filter(); // SIMD方法
for ( int i = 0; i < loop; i++ ) perf3 += test_SIMD_OMP_Filter(); // SIMD方法+OMP

cout<<"Counter Freq:"<<m_CounterFreq<<endl; // 计数频率
cout<<"Perf0:"<<endl<<"Total:"<<perf0<<" "<<perf0/loop<<"/per proc"<<endl; // 传统方法的结果
cout<<"Perf1:"<<endl<<"Total:"<<perf1<<" "<<perf1/loop<<"/per proc"<<endl; // 传统方法_OMP
cout<<"Perf2:"<<endl<<"Total:"<<perf2<<" "<<perf2/loop<<"/per proc"<<endl; //SIMD
cout<<"Perf3:"<<endl<<"Total:"<<perf3<<" "<<perf3/loop<<"/per proc"<<endl; // SIMD + OMP

return 0;
}``````

``````如果处理比较简单，像例子中这样没有复杂计算，数据相关性小，适合于流水线发挥作用的情况，注意算法的优化可能带来更好的性能提升。

``````

good lucky!

A babysitter.

6 声望
2 粉丝