Parallelize for-loop by MPI?

This is a discussion on Parallelize for-loop by MPI? within the C Programming forums, part of the General Programming Boards category; I am wondering how I can speed up the time-consuming computation in the loop of my code below using MPI? ...

  1. #1
    Registered User
    Join Date
    Jan 2009
    Posts
    159

    Parallelize for-loop by MPI?

    I am wondering how I can speed up the time-consuming computation in the loop of my code below using MPI?
    Code:
         int main(int argc, char ** argv)   
         {   
         // some operations           
         f(size);           
         // some operations         
         return 0;   
         }   
            
         void f(int size)   
         {   
         // some operations          
         int i;           
         double * array =  new double [size];           
         for (i = 0; i < size; i++) // how can I use MPI to speed up this loop to compute all elements in the array?   
         {   
         array[i] = complicated_computation(); // time comsuming computation. Elements are computed independently of each other.  
         }           
         // some operations using all elements in array           
         delete [] array;  
         }
    As shown in the code, I want to do some operations before and after the part to be paralleled with MPI, but I don't know how to specify where the parallel part begins and ends.

  2. #2
    Registered User
    Join Date
    Feb 2009
    Posts
    12

    OpenMP

    I am not sure, but you can look for OpenMP

    OpenMP is for multi-processor systems support.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. MPI, which way will be best?
    By maverick_starst in forum C++ Programming
    Replies: 5
    Last Post: 06-30-2009, 03:17 PM
  2. MPI in C
    By ltee in forum C Programming
    Replies: 5
    Last Post: 03-26-2009, 07:10 AM
  3. Sorting whit MPI
    By isato in forum C Programming
    Replies: 0
    Last Post: 03-03-2009, 10:38 AM
  4. Malloc and MPI
    By moddinati in forum C Programming
    Replies: 17
    Last Post: 03-07-2008, 07:55 PM
  5. MPI programming
    By kris.c in forum Tech Board
    Replies: 1
    Last Post: 12-08-2006, 12:25 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21