# Programming parallel for C++ and Python application

**URL:** <https://community.unix.com/t/programming-parallel-for-c-and-python-application/325209>\
**Category:** High Performance Computing\
**Created:** [March 4, 2013, 5:47pm UTC](https://community.unix.com/t/programming-parallel-for-c-and-python-application/325209 "2013-03-04T17:47:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![figaro](https://community.unix.com/letter_avatar/figaro/32/6_449c533f586939b6e5f246632a46421f.png) [@figaro](https://community.unix.com/u/figaro)\
**Post date:** [March 4, 2013, 5:47pm UTC](https://community.unix.com/t/programming-parallel-for-c-and-python-application/325209/1 "2013-03-04T17:47:49Z")

</div>

I am looking to have a C++ and Python application developed using the processing power of at least one GPU.  
We are already using Boost, so [Boost.MPI](http://www.boost.org/doc/libs/1_53_0/doc/html/mpi.html) comes to mind.  
We already have some experience in developing C++ applications for multi-core CPUs by using threading.  
However, since we have not developed sufficient expertise in MPI, we were wondering if a Python solution would be more appropriate, because it will give the developers a better understanding of what the code does. In such a case something like [mpi4py](http://mpi4py.scipy.org/) would come to mind.

Of course having a GPU specifically for simulation purposes could mean that something like [PyOpenCL](http://mathema.tician.de/software/pyopencl) may be even better.  
I mention "simulation", because the machine will be calculating variations on what is largely the same problem, ie not be a general purpose machine.

So in summary:  
1- For raw processing speed with a multi-core CPU and a GPU, would a openCL solution or Boost.MPI solution be recommended?  
2- Should the Python solution be used only for high level functionality, such as handling data upon return, or does Python compromise speed too much?

---

<div class="post-metadata">

**Author:** ![jim\_mcnamara](https://community.unix.com/letter_avatar/jim_mcnamara/32/6_449c533f586939b6e5f246632a46421f.png) [@jim\_mcnamara](https://community.unix.com/u/jim_mcnamara)\
**Post date:** [March 5, 2013, 7:02pm UTC](https://community.unix.com/t/programming-parallel-for-c-and-python-application/325209/2 "2013-03-05T19:02:33Z")

</div>

What you have basically in both Boost and mpi4py is just embedded Openmpi.  
IMO since mpi is straightforward (mostly just pragmas) in C/C++ you can tweak things  
merely by either recompiling with -D to define some things or actually read in command line arguments.

See here for libraries and documentation:  
[Open MPI: Open Source High Performance Computing](http://www.open-mpi.org/)

---

<div class="post-metadata">

**Author:** ![figaro](https://community.unix.com/letter_avatar/figaro/32/6_449c533f586939b6e5f246632a46421f.png) [@figaro](https://community.unix.com/u/figaro)\
**Post date:** [March 6, 2013, 3:08am UTC](https://community.unix.com/t/programming-parallel-for-c-and-python-application/325209/3 "2013-03-06T03:08:38Z")

</div>

Thank you for your response. What this likely will come down to is setting up the core multi-core calculations in Boost and do some post-processing in Python. The post-processing will take place at a higher level (ie user) and is likely to be more prone to changes.

---

<div class="post-metadata">

**Author:** ![figaro](https://community.unix.com/letter_avatar/figaro/32/6_449c533f586939b6e5f246632a46421f.png) [@figaro](https://community.unix.com/u/figaro)\
**Post date:** [April 7, 2013, 4:42pm UTC](https://community.unix.com/t/programming-parallel-for-c-and-python-application/325209/4 "2013-04-07T16:42:51Z")

</div>

I am getting concerned that our compiled Boost-code is getting bloated. We will be experimenting with basic C++ functions as if there was only one core and no Boost, then add MPI pragmas to the C++ code and finally add user functionality (screens, post-processing etc) in Python.
