Monday, November 23, 2009

OpenMP vs OpenMPI

For beginner "computationalist" like me, it's quite hard to understand the difference between OpenMP and OpenMPI. At first, I thought both of them tackles the same problem in the same way, namely parallel execution. However, after studying them both further, it's clear that OpenMPI uses a distributed-memory architecture while OpenMP uses shared-memory model. Both of the memory architecture can be explained as follows:

  • In a distributed-memory architecture, each process doesn't share the same address space as the other process (which very possibly run on different machine). This means each process cannot "see" the other process variable(s). The process must "send a message" to the other process to change variable in the other process. Hence, the "Massage Passing Interface (MPI)". The MPI library such as OpenMPI basically is a sort of "middleware" to facilitate the massage passing between the processes, the process migration, initialization and tear-down.
  • In a shared-memory architecture, there is usually one process which contains couple of threads which share the same memory address space, file handles and so on. Hence, the shared memory name. In this architecture, each threads can modify a "precess" global data. Therefore, a semaphore mechanism must be in use. OpenMP simplify the programming for shared memory architeture by providing compiler "extensions" in the form of various standardized "pragma"s. 

Upon reading both of the simplified explanation above, it's obvious that we can combine OpenMPI and OpenMP for paralel execution of code. Say, use OpenMP for "local execution within a machine" and use OpenMPI for inter-machine process communication. 


Post a Comment

5 comments:

creatine said...

The OpenMP Application Program Interface (API) supports multi-platform shared-memory parallel programming in C/C++ and Fortran on all architectures, including Unix platforms and Windows NT platforms. Jointly defined by a group of major computer hardware and software vendors, OpenMP is a portable, scalable model that gives shared-memory parallel programmers a simple and flexible interface for developing parallel applications for platforms ranging from the desktop to the supercomputer.

Darmawan Salihun said...

Ah yes, I forgot to mention about the Intel Cluster OpenMP which supports clusters of machines ;-)

Darmawan Salihun said...

@Praveen: I'm studying a bit about CFD and Computer Vision in my spare time ;-).

The AI bully said...

So, can someone use OpenMPI on the same PC?

Darmawan Salihun said...

OpenMP is meant to be used on the same machine at first. Before, the cluster support was added ;-).