Results 1 to 8 of 8

Thread: How to parallelize the following code by OpenMP?

  1. #1
    Join Date
    Jul 2010
    Posts
    57

    How to parallelize the following code by OpenMP?

    I am trying to parallelism a Fortran code using OpenMP which calculates a product of matrices of large dimensions: AxB = C. So I have a number of loops to initialize arrays and then to calculate the matrix product. After my main loops parallelized , I compared the execution time of my program and my sequential program parallelized using the time function of the shell. I get the non- parallelized program runs faster. The goal of parallelization is to reduce the computation time. The results I get are inconsistent. How to parallelize the following code by OpenMP?

  2. #2
    Join Date
    Apr 2008
    Posts
    4,642

    Re: How to parallelize the following code by OpenMP?

    The example that I think is relevant because it is a Fortran code for a fixed period provided online by IDRIS ( Institute of Development and Resources in Computer Science). As I said , this exercise makes a matrix product and thus is conducive to the use of OpenMP as there are several nested loops to initialize arrays . I have large arrays of sizes so that the computing time is substantial. For information , I use the Intel compiler ifort . I actually varies the number of threads and the option of OMP DO directive ( static , dynamic and guided ) but the results are poorer than the non- parallelized code.

  3. #3
    Join Date
    May 2008
    Posts
    4,570

    Re: How to parallelize the following code by OpenMP?

    This is exactly the example that I worked . After compilation, I specify the number of threads that I use : export OMP_NUM_THREADS = 4 and I also give OMP_SCHEDULE = "STATIC , 400 "for example (given that I do not really know what is best for the choice of these options. Logically, in this example , the parallelization must accelerate the computation time which is not my case . The number of threads I referred to is correct. To compile this sample, I only added the compiler option - openmp .

  4. #4
    Join Date
    May 2008
    Posts
    4,345

    Re: How to parallelize the following code by OpenMP?

    Using OpenMP in the C code generally requires to include the file omp.h : # include <omp.h>, then use the OpenMP library when editing links , and use an OpenMP compiler . In the case of a project VisualStudio mode " Win32 Console" it is necessary to clarify to take account OpenMP compiler directives and generate code "Release" and "Multithread, " by amending "Project Properties VisualStudio. In the case of gcc on Linux, it is necessary to compile with option "- fopenmp". In all cases it is also responsible to advise the compiler to optimize code generation speed !

  5. #5
    Join Date
    Apr 2009
    Posts
    1,107

    Re: How to parallelize the following code by OpenMP?

    Several solutions can parallelize the serial code provided with different efficiencies .
    1. What is it for loop the most interesting to parallelize ?
    2. Make a parallelization of grid 256x256 useful points for 50,000 cyclesFrom a Directive orphan. Run your code by imposing different numbers of threads and check the accuracy of the result (Potential displayed in the center of the grid relaxation ) . The correct results are summarized at the bottom of this page .
    3. Perform a parallel from an parallel region setting a variable and a variable IO NI -specific Thread and initialized in the parallel region. Insert the instructions for displaying the 'c ' at the beginning of the area parallel . Verify that the message " c " appears several times verify the accuracy of the result.

  6. #6
    Join Date
    Feb 2010
    Posts
    638

    Re: How to parallelize the following code by OpenMP?

    In the case shown, each subdomain is a rectangthe and thes interfaces are located the along its sides. For a given interface , each process located byt and the other sends and receives data, we then use the function MPI_SENDRECV. In the If data stored Discontiguous way it is bybe helpful to build a derived type to achieve thes communications. In our exemptionthes the spatial pattern is only intervene thes points directly adjacent to the node computing power. So for each sub - domain there is only one layer of ghost nodes .

  7. #7
    Join Date
    Nov 2009
    Posts
    351

    Re: How to parallelize the following code by OpenMP?

    The variables when the program began ( or sub -programs), it shows the visibility of variables when entering the region by OpenMP. For this we use the clause DEFAULT ( NONE) requiring the compiler to ensure that all thes variables have been mentioned purposes. A wrong choice can lead to erroneous results will vary from one execution to another by while the code sequence is correct . A private to each thread , as well as some variables scalar because it is cheaper to do a little calculation by all the threads rather than setting a sync after the calculation.

  8. #8
    Join Date
    May 2009
    Posts
    511

    Re: How to parallelize the following code by OpenMP?

    There is a single FORTRAN compiler on AIX , but the way to call will differ depending on the type of source code . Regarding the codes SMP ( thus making explicit or implicit appeal to threads ) , we call "xlf_r(Code fortran77 ), or "xlf90_r( Fortran90 code ) or "xlf95_r" ( Code fortran95 ).
    = self - qsmp : compiler option , automatic parallelization .
    Generally ineffective , only loops with iterations completely markers are independent and easily parallelized.
    - qreport [ smplist : hotlist ] : provides a listing of changes made.

Similar Threads

  1. Replies: 15
    Last Post: 02-05-2014, 03:00 PM
  2. Segmentation fault on MPI, runs properly on OpenMP
    By Tamali in forum Windows Software
    Replies: 6
    Last Post: 28-09-2010, 12:12 AM
  3. Tools for visualizing OPENMP
    By Aarav in forum Windows Software
    Replies: 7
    Last Post: 27-09-2010, 11:12 AM
  4. Intel ifort and OpenMP problem with XCode 3.2.2 update
    By Abhidi in forum Software Development
    Replies: 6
    Last Post: 25-09-2010, 09:05 PM
  5. Is Win32 Fibers used with OpenMp?
    By Moon Walker in forum Windows Software
    Replies: 6
    Last Post: 25-09-2010, 04:49 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,544,397.67158 seconds with 17 queries