Skip to content

Conversation

GeLee-Q
Copy link

@GeLee-Q GeLee-Q commented Mar 14, 2022

hw10

未开启openMP

134.008686s

开启openMP

49.100373s        加速:2.72x

03/00.cpp 指针数组来表示

OpenMp  29.86s 	  加速:4,48x
tbb 	17.48s    加速:7.66x

04/04.cpp 指针数组加上spin_mutex

 openMP 33.47s    加速:4.06x
 tbb    17.76s	  加速:7.54x

实现方法

封装稀疏网格的 Grid 类的?

  • 参考03/00.cpp 使用了指针的数组封装稀疏的Grid表格
  • 参考04/04.cpp 在上一个的基础上使用了spin_mutex自旋锁
  • 如果使用hash().pointer().dense的话,在WSL上回出现 out of memory

有无位运算量化减轻内存带宽?

  • & 替代 %, >> 替代 /, | 替代 +

Grid 是否可以并行访问?OpenMP 还是 TBB?

  • 使用OpenMP进行并行访问。

有没有用访问者模式缓存坐标,避免重复上锁?

  • 没有使用, 在WSL里使用这个,会莫名出现segment fault

对于 step() 中这种插桩你是如何优化的?用了老师的什么知识点?

  • 将step()改造成了tbb并行。

@GeLee-Q GeLee-Q changed the title 1 hw10 Gelee Mar 14, 2022
auto &block = m_data[(x >> Bshift) & B1mask][(y >> Bshift) & B1mask];
if (!block)
return 0;
return block->m_block[x & Bmask][y & Bmask];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

我觉得还可以做一下8bit合成一个char的那个优化。

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.

2 participants