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\$
2
  • 4
    \$\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
    Commented Feb 16, 2017 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\$ Commented Feb 16, 2017 at 13:12

1 Answer 1

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\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .