0
\$\begingroup\$

I'm planning to port an erosion algorithm from CPU to GPU, in theory, will it be faster or would it be better to multi-thread it on the CPU? The algorithm has quite a lot of if statements and loops with non-constant amount of iterations so it's going to be a lot of branching.

\$\endgroup\$
  • 3
    \$\begingroup\$ There's no reliable way to predict that. Is your algorithm highly parallelizable? If yes there's a good change perfomance will be much better on the GPU. But the only way to know for sure: Try it and profile both solutions. \$\endgroup\$ – LukeG Feb 16 '17 at 13:06
  • \$\begingroup\$ depends on the workload, to port it to the gpu you'll need to parallelize it so you may as well make a inbetween stop at cpu multithreading \$\endgroup\$ – ratchet freak Feb 16 '17 at 13:12
2
\$\begingroup\$

That depends on the algorithm.

Algorithms which perform the same operation on a large amount of data-points without any of these operations being dependent on the other data-points, or in other words, operations which are trivially parallelizable, are great for porting to GPUs.

But algorithms which have lots of branching and looping or which require to allocate large amounts of memory are usually more efficient to implement on the CPU.

Your algorithm sounds like something which would work better on CPU, but without actually seeing the algorithm in detail it is hard to tell.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.