Thread-safety of read-only memory access

前端 未结 2 1061
囚心锁ツ
囚心锁ツ 2021-01-06 04:11

I\'ve implemented the Barnes-Hut gravity algorithm in C as follows:

  1. Build a tree of clustered stars.
  2. For each star, traverse the tree and apply the gr
2条回答
  •  南方客
    南方客 (楼主)
    2021-01-06 05:08

    If your data is read-only, then no, you do not need to make a private copy of the tree for each thread. This is the biggest advantage that a shared memory threading model offers!

    I'm not aware of any performance problems with such a model. If anything, it should be faster depending on if your CPUs can share some of their cache.

提交回复
热议问题