A openMP question

A openMP question

Dear IVF users and developers,

I am learning OpenMP today. I followed a tutorial: http://www.openmp.org/presentations/miguel/F95_OpenMPv1_v2.pdf

But when I compile and run this:

    program OpenMPpractice
    implicit none
    ! Variables
    ! Body of OpenMPpractice

	    !$OMP PARALLEL

	        write(*,*) "Hello"

	        !$OMP PARALLEL

	            write(*,*) "Hi"

	        !$OMP END PARALLEL

	    !$OMP END PARALLEL

	    end program OpenMPpractice

The result is:

 Hello
 Hello
 Hello
 Hello
 Hi
 Hello
 Hello
 Hello
 Hi
 Hi
 Hello
 Hi
 Hi
 Hi
 Hi
 Hi

But according to the tutorial, I can see that there are 8 threads in the first level of parallel. But in the second level of parallel, the situation is different. I was thinking there should be 64 "Hi"s printed, but there are only 8.

Can anyone tell me what happened there?

 

Thanks,

 

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Hi,

I think you need nested parallelism enabled.  Can you try adding:

call omp_set_nested(.true.)

 

Roman

 

Hi Roman,

It works! Thanks.

I add use omp_lib. Everything compiles OK.

Leave a Comment

Please sign in to add a comment. Not a member? Join today