Discussion: Python and OpenMP

Carl J. Van Arsdall cvanarsdall at mvista.com
Fri May 12 13:52:13 EDT 2006

Hey everyone,

I know I've posted several questions regarding python and python's 
parallel capabilities so bear with me as I've never attempted to incite 
discussion.  However, today I'm interested in sparking discussion over 
having an OpenMP style of interface in python.

For those of you familiar with OpenMP, its a pragmatic api for 
parallelizing software.  For more information I invite anyone to do some 
google searches, there's a plethora of information available. Just to 
give a simple example of what i'm talking about, in OpenMP you would 
insert a pragma above a section of code you want to parallelize.

In C it might look something like:

int main(int argc, char* argv[])
  #pragma omp parallel  
  printf("Hello, world.\n");
  return 0;

In which case threads are spawn and handled.  OpenMP of course has more 
than this available for developers, but I'm just trying to paint a 
picture before I start asking questions. 

Anyhow, onto the meat of the discussion.  Would the python community be 
interested in parallel programming this way?  Although I understand 
python already supports threading I thought that this was a real 
interesting (and easy) way of writing parallel code. 

For example, new keywords could be added to the python interpreter, such 
as parallel:


  print "I am a thread"


Taking this a step further, OpenMP or an OpenMP style implementation 
could be added to python.  In addition easy to use/read, one possible 
benefit I could see of writing parallel python code this way would be 
providing a layer of abstraction between parallel code and threading 
constructs.  For example, as a developer or community standards change 
threading in python code would not have to be re-written.  Developers 
would create an interface between python's OpenMP style code and 
whatever their new threading libraries may be (this is one of many ways 
it could happen).  Ultimately providing more code portability between 
people using different threading standards (should they ever become 
available).  I see other use cases as well, but I just wanted to throw a 
couple ideas to see if this was worth thinking about further.

Thanks for reading this one, I know it was long but I'd really 
appreciate your comments!



Carl J. Van Arsdall
cvanarsdall at mvista.com
Build and Release
MontaVista Software

More information about the Python-list mailing list