0

I am trying to find a way to write a program to find the correct combination of numbers relating to a card game I used to play, but there are 30ish variables to loop through (between 1 up to 50 or so). I was advised that coding the program in a “parallel” way rather than nested loops would be better, especially if I was able to access a supercomputer or HPC multi-processing system to process the code.

I have checked some of the C++ editor/compilers on my home PC and they do not recognize “parfor” as a keyword. Would I have to download addons such as VTune Profiler/Parallel Studio/OpenMP and install them as plug-ins to those compilers? I have tried MS Visual Studio, and some others including CodeBlocks, Eclipse, CodeLite and Dev++ compilers.

Blastfurnace
  • 18,411
  • 56
  • 55
  • 70
  • 3
    Does this answer your question? [Parallel Loops in C++](https://stackoverflow.com/questions/36246300/parallel-loops-in-c) – dmedine Jul 20 '21 at 23:48
  • https://learn.microsoft.com/en-us/cpp/parallel/openmp/openmp-in-visual-cpp?view=msvc-160 – Retired Ninja Jul 20 '21 at 23:51
  • From the parfor tag description: `parfor is a Matlab command for executing the iterations of a for-loop in parallel`. – KamilCuk Jul 20 '21 at 23:55
  • c++17 already have a parallel algorithm: https://devblogs.microsoft.com/cppblog/using-c17-parallel-algorithms-for-better-performance/ – prehistoricpenguin Jul 21 '21 at 02:54
  • OpenMP is the way to go for the parallelization of any HPC code running on 1 node (ie. in shared memory). In most cases, there is no need to download anything more than a mainstream compiler. GCC, Clang, ICC and MSVC support it (although MSVC only support a very old version). Few annotations using pragma directives and compiler flags are needed to parallelize your code. In practice, OpenMP gives more flexibility than the parallel STL. [Here](https://riptutorial.com/openmp) is some examples. – Jérôme Richard Jul 21 '21 at 18:52

0 Answers0