Will multi threading provide any performance boost?

前端 未结 19 862
说谎
说谎 2021-02-05 13:49

I am new to programming in general so please keep that in mind when you answer my question.

I have a program that takes a large 3D array (1 billion elements) and sums up

19条回答
  •  名媛妹妹
    2021-02-05 14:07

    Multithreading will only make your code faster if the computations can be broken down into chunks that can be worked on independently and concurrently.


    EDIT

    I said the above (it's almost an automatic response) because I see many developers spend a lot of time on multithreading code for no performance increase at all. Of course, then they end up with the same (or even slower performance) and the extra complications of managing the multiple threads.

    Yes, it does appear after reading your question again and taking into account your specific case you would benefit from multithreading.

    RAM is very fast, so I think it would be very hard to saturate the memory bandwidth unless you have many, many threads.

提交回复
热议问题