Skip to content

Conversation

@Riga27527
Copy link

提示:请在 PR 描述中说明使用的 CPU 有多少核、多少线程哦 :)
如果不希望写 PR 描述,也可以直接在代码注释里写,没问题的~

完成了hw06的基本要求!

物理核心:4

逻辑核心:4

线程数:4

因为用的是轻薄本的虚拟机,所以性能会比较拉...

结果对比

----------------------------------Old result---------------------
fill: 2.09027s
fill: 2.13145s
saxpy: 0.0397575s
sqrtdot: 0.0888022s
5165.4
minvalue: 0.0843207s
-1.11803
magicfilter: 0.456461s
55924034
scanner: 0.105253s
5.28566e+07

----------------------------------Parallel result---------------------
fill: 0.517877s
fill: 0.520669s
saxpy: 0.0425261s
sqrtdot: 0.0366869s
5792.62
minvalue: 0.0220482s
-1.11803
magicfilter: 0.164679s
55924034
scanner: 0.0727342s
5.28613e+07

  • fill函数:parallel_for,加速比约4
  • saxpy函数:parallel_for,没有提升,反而还慢了点...
  • sqrtdot函数:parallel_reduce,加速比约2.4
  • minvalue函数:parallel_for + mutex or parallel_reduce,两个方法差不多,加速比约3.8
  • magicfilter函数:parallel_for + mutex,加速比2.7
  • scanner函数:parallel_scan,加速比1.4

看了一会下一节课,saxpy函数应该是因为计算简单,io成为了瓶颈导致并行效果不佳.

嗷还有就是由于用了tbb,原本std::reduce需要修改一下才能通过编译了,也不晓得为啥.....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant