Parallelization: pthreads or OpenMP?

前端 未结 6 1912
天涯浪人
天涯浪人 2020-12-23 02:00

Most people in scientific computing use OpenMP as a quasi-standard when it comes to shared memory parallelization.

Is there any reason (other than readability) to u

6条回答
  •  半阙折子戏
    2020-12-23 02:42

    One other reason: the OpenMP is task-based, Pthreads is thread based. It means that OpenMP will allocate the same number of threads as number of cores. So you will get scalable solution. It is not so easy task to do it using raw threads.

    The second opinion: OpenMP provides reduction features: when you need to compute partial results in threads and combine them. You can implement it just using single line of code. But using raw threads you should do more job.

    Just think about your requirements and try to understand: is OpenMP enough for you? You will save lots of time.

提交回复
热议问题