1

I have a task that can be easily broken down to parallel tasks. And I have a PC with multiple processors which will run the task. I'm planning to use c++ and boost library.

I'm familliar with multithreading using multiple cores, but it's my first time with multiprocessor system. I'm not sure if boost::threads will be sufficient for efficient usage of all processors.

Should I use boost::threads or build a solution upon multiple processes? Also, I'm not familiar with MPI, but I feel it may be useful for my task.

CodingFeles
  • 374
  • 5
  • 18
  • As far as I understand your setup, you need multiprocessing not multithreading. The most immediate way I know to play with multiprocessing is OpenMP, you'll just need to read a couple examples and minimal changes to your code to learn how to run - f.ex. - a loop in parallel. I don't know boost::threads but in general threads share memory, while processes don't. When you do multithreading, threads use the same CPU. Processes don't necessarily use the same CPU. – L.C. Nov 16 '18 at 10:40
  • I can't use OpenMP(for some reasons). "When you do multithreading, threads use the same CPU" - that's interesting point that I'm gonna research. Thanks! – CodingFeles Nov 16 '18 at 10:43
  • You can start here: https://stackoverflow.com/questions/200469/what-is-the-difference-between-a-process-and-a-thread/200473#200473 – L.C. Nov 16 '18 at 10:46
  • 1
    "_When you do multithreading, threads use the same CPU_" it's wrong statement, one multithreaded process can uses multiples CPU. Ex. [for Windows](https://learn.microsoft.com/en-us/cpp/parallel/multithread-programs) "_On multiprocessor machines, the scheduler can move individual threads to different processors to balance the CPU load_" – serge Nov 16 '18 at 10:50
  • Bisqwit did an amazing series on [parallelisation in C++](https://www.youtube.com/watch?v=Pc8DfEyAxzg&list=PLzLzYGEbdY5lrUYSssHfk5ahwZERojgid). If I remember correctly, he introduced both multithreading and multiprocessing, but I am not sure (can't watch it right now) It's definitely worth checking though. – Fureeish Nov 16 '18 at 10:51
  • @JohnZwinck I think I don't understand very well toolset for multiprocessor solutions. Hence the question. I do understand how this all will lay out in multithreading solution. – CodingFeles Nov 16 '18 at 11:38
  • Oh, so are you specifically asking, "I know how to do multithreading programming, but I have always used computers with a single socket, i.e. one physical processor die. Now I am going to write code for a NUMA system with multiple physical processor dies. What concerns do I need to keep in mind?" Is that it? – John Zwinck Nov 16 '18 at 11:56
  • @JohnZwinck yeah, I think you put it very well. – CodingFeles Nov 16 '18 at 11:59
  • In this case, your question is too broad for this site. We can't possible answer such a wide-ranging question in this format. I suggest you try writing your multithreaded code as you normally would, and ask specific questions if they come up. – John Zwinck Nov 16 '18 at 12:11

0 Answers0