Viewing 2 reply threads
  • Author
    Posts
    • #6103 Score: 1
      V_V
      Participant
      1 pt

      请问作业7的多线程结果比较暗是什么原因?

      我的实现是见图1.
      图2,3中,亮的是没用多线程的结果,暗的是多线程的结果。
      我电脑应该最多有8个线程,使用了8个线程,时间快了4倍,这正常么?

      请大佬帮忙指点,多谢!

      This post has received 1 vote up.
      Attachments:
      You must be logged in to view attached files.
    • #6105 Score: 0
      V_V
      Participant
      1 pt

      这是结果图,转成jpg了

      Attachments:
      You must be logged in to view attached files.
    • #6108 Score: 0
      arc
      Participant
      5 pts

      int id = n_threads * tid + i 改成 int id = n_loops * tid + i 看看?

      • #6109 Score: 0
        V_V
        Participant
        1 pt

        我傻了,应该是int id = n_loops * tid + i,谢谢!

        不过加速效果不是很明显,用了8个线程,速度才快了2倍

        • #6110 Score: 1
          arc
          Participant
          5 pts

          因为这样写的话计算每个像素都需要创建 num_threads 个线程,开销比较大。
          最好是将每个线程的任务量尽可能多分配些。

          This post has received 1 vote up.
          • #6111 Score: 0
            V_V
            Participant
            1 pt

            哦哦,那我试试将图片分块处理。
            谢谢你的帮助!

Viewing 2 reply threads
  • You must be logged in to reply to this topic.