Will multi threading provide any performance boost?

前端 未结 19 828
说谎
说谎 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:20

    I think that even if multithreading can produce a performance boost it's the wrong way to approach optimization. Multiple cores are all the rage because they are the only way for CPU manufacturers to provide faster CPU speeds at a marketable rate -- not necessarily because they're an amazing programming tool (there's still a lot of maturing that needs to happen).

    Always look at the algorithm you're using above all else. You say your program is very RAM intensive -- what can you do to improve cache hits? Is there a way to sort your array so that the computations can be applied linearly? What programming language are you using and would it benefit you to optimize in a lower level language? Is there a way that you can use dynamic programming to store your results?

    In general, spend all your resources working toward a more efficient algorithm, mathematically and as compiler optimizations, then worry about multi-core. Of course, you may already be at that stage, in which case this comment isn't very useful ;p

提交回复
热议问题