salesforce / p4-fusion

A fast Perforce to Git conversion tool written in C++ using Perforce Helix Core C++ API and Libgit2
BSD 3-Clause "New" or "Revised" License
78 stars 15 forks source link

Using openMP #1

Closed bensuperpc closed 2 years ago

bensuperpc commented 2 years ago

You can use OpenMP for multi-threaded calculations

It is supported by most C ++ compilers (GCC, Clang and MSVC), this easily applies to a for loop for example, You can even use another machine or the graphics card to perform some part of the calculations.

More info: https://bisqwit.iki.fi/story/howto/openmp/ https://medium.com/swlh/introduction-to-the-openmp-with-c-and-some-integrals-approximation-a7f03e9ebb65

Exemple my brute-force project: https://github.com/bensuperpc/GTA_SA_cheat_finder/blob/196dcedf30e81317148d025961b65f7213aa47e1/source/main.cpp#L89

twarit-waikar commented 2 years ago

Thanks @bensuperpc!

One of the reasons why we went ahead to use a thread pool was that we required a way to multithreaded the network I/O calls which are serial in nature in terms of a single Helix Core C++ API library context. I believe OpenMP helps in multithreading computationally heavy tasks that occur on the CPU, however, most of the time our CPU usage is pretty low because we spend most of our time waiting for the network I/O to finish, rather than doing computationally heavy tasks for which OpenMP or other threading libraries would be trying to cater to.

bensuperpc commented 2 years ago

Okey ^^