- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I am using ivf 11.1 to parallize my code with openmp. Before the work, I want to try the openmp function first and to investigate whether it works fine on my CPU Q6600. I am surprised to see that the program generate 4 threads indeed. However, when I am checking the usage of the CPU cores, I found only one core is using (25%) (tried few times). Then I turned to my colleague's computer with i7 720q. The program creates 8 threads and also uses one core (13%). I think maybe something setting is wrong. Here is the code:
I want to know which option I have missed resulting the low usage of the multi-core resource.
[fortran]program openmp_testThe program is compiler with the option /Qopenmp.
use omp_lib
implicit none
real*8:: r_double
integer:: i
!$omp parallel do private(i)
do i=1,900000
write(40,*) 'Thread ID',omp_get_thread_num(),'calculated DO no.',i,' = ',dble(i)**3
end do
!$omp end parallel do
end[/fortran]
I want to know which option I have missed resulting the low usage of the multi-core resource.
Link Copied
5 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You don't leave significant opportunity for parallel work, considering that the write to a single output stream must be serialized implicitly.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I tried it on my Core 2 Duo and saw two threads.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
How about the usage of your CPU? 50%?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Do you mean that if I replace the I/O code with some function/subroutine doing 'real' work, the usage of CPU will increase?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Yes, if you actually do computational work in the loop, you should see more cores active. As Tim says, all you have is a WRITE to a common unit, so that gets serialized. But if you look at the output, you'll see different thread numbers indicating that they are indeed running in separate threads.
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page